Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/com_modules.zip
Назад
PK �|!]��w layouts/toolbar/newmodule.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; $text = JText::_('JTOOLBAR_NEW'); ?> <button onclick="location.href='index.php?option=com_modules&view=select'" class="btn btn-small btn-success" title="<?php echo $text; ?>"> <span class="icon-plus icon-white" aria-hidden="true"></span> <?php echo $text; ?> </button> PK �|!]:M�m� � layouts/toolbar/cancelselect.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; $text = JText::_('JTOOLBAR_CANCEL'); ?> <button onclick="location.href='index.php?option=com_modules'" class="btn" title="<?php echo $text; ?>"> <span class="icon-remove" aria-hidden="true"></span> <?php echo $text; ?> </button> PK �|!]�b��� � modules.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <extension type="component" version="3.1" method="upgrade"> <name>com_modules</name> <author>Joomla! Project</author> <creationDate>April 2006</creationDate> <copyright>(C) 2006 Open Source Matters, Inc.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <version>3.0.0</version> <description>COM_MODULES_XML_DESCRIPTION</description> <administration> <files folder="admin"> <filename>config.xml</filename> <filename>controller.php</filename> <filename>modules.php</filename> <folder>controllers</folder> <folder>helpers</folder> <folder>models</folder> <folder>views</folder> </files> <languages folder="admin"> <language tag="en-GB">language/en-GB.com_modules.ini</language> <language tag="en-GB">language/en-GB.com_modules.sys.ini</language> </languages> </administration> </extension> PK �|!]����� � controller.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Modules manager master display controller. * * @since 1.6 */ class ModulesController extends JControllerLegacy { /** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array|boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()} * * @return JController This object to support chaining. * * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $id = $this->input->getInt('id'); $document = JFactory::getDocument(); // For JSON requests if ($document->getType() == 'json') { $view = new ModulesViewModule; // Get/Create the model if ($model = new ModulesModelModule) { // Checkin table entry if (!$model->checkout($id)) { JFactory::getApplication()->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), 'error'); return false; } // Push the model into the view (as default) $view->setModel($model, true); } $view->document = $document; return $view->display(); } JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php'); $layout = $this->input->get('layout', 'edit'); $id = $this->input->getInt('id'); // Check for edit form. if ($layout == 'edit' && !$this->checkEditId('com_modules.edit.module', $id)) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_modules&view=modules', false)); return false; } // Load the submenu. ModulesHelper::addSubmenu($this->input->get('view', 'modules')); // Check custom administrator menu modules if (JModuleHelper::isAdminMultilang()) { $languages = JLanguageHelper::getInstalledLanguages(1, true); $langCodes = array(); foreach ($languages as $language) { if (isset($language->metadata['nativeName'])) { $languageName = $language->metadata['nativeName']; } else { $languageName = $language->metadata['name']; } $langCodes[$language->metadata['tag']] = $languageName; } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->qn('m.language')) ->from($db->qn('#__modules', 'm')) ->where($db->qn('m.module') . ' = ' . $db->quote('mod_menu')) ->where($db->qn('m.published') . ' = 1') ->where($db->qn('m.client_id') . ' = 1') ->group($db->qn('m.language')); $mLanguages = $db->setQuery($query)->loadColumn(); // Check if we have a mod_menu module set to All languages or a mod_menu module for each admin language. if (!in_array('*', $mLanguages) && count($langMissing = array_diff(array_keys($langCodes), $mLanguages))) { $app = JFactory::getApplication(); $langMissing = array_intersect_key($langCodes, array_flip($langMissing)); $app->enqueueMessage(JText::sprintf('JMENU_MULTILANG_WARNING_MISSING_MODULES', implode(', ', $langMissing)), 'warning'); } } return parent::display(); } } PK �|!]4��z� � modules.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::_('behavior.tabstate'); $user = JFactory::getUser(); $input = JFactory::getApplication()->input; if (($input->get('layout') !== 'modal' && $input->get('view') !== 'modules') && !$user->authorise('core.manage', 'com_modules')) { throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Modules'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect(); PK �|!]�.x� � models/forms/filter_modules.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <form> <fieldset addfieldpath="/administrator/components/com_modules/models/fields" /> <field name="client_id" type="list" label="" filtermode="selector" layout="default" onchange="jQuery('#filter_position, #filter_module, #filter_language, #filter_menuitem').val('');this.form.submit();" > <option value="0">JSITE</option> <option value="1">JADMINISTRATOR</option> </field> <fields name="filter"> <field name="search" type="text" inputmode="search" label="COM_MODULES_MODULES_FILTER_SEARCH_LABEL" description="COM_MODULES_MODULES_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" noresults="COM_MODULES_MSG_MANAGE_NO_MODULES" /> <field name="state" type="status" label="JSTATUS" filter="*,-2,0,1" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="position" type="modulesposition" label="COM_MODULES_FIELD_POSITION_LABEL" onchange="this.form.submit();" > <option value="">COM_MODULES_OPTION_SELECT_POSITION</option> </field> <field name="module" type="ModulesModule" label="COM_MODULES_OPTION_SELECT_MODULE" onchange="this.form.submit();" > <option value="">COM_MODULES_OPTION_SELECT_MODULE</option> </field> <field name="menuitem" type="menuitem" label="COM_MODULES_OPTION_SELECT_MENU_ITEM" disable="separator,alias,heading,url" onchange="this.form.submit();" > <option value="">COM_MODULES_OPTION_SELECT_MENU_ITEM</option> <option value="-1">COM_MODULES_NONE</option> </field> <field name="access" type="accesslevel" label="JOPTION_FILTER_ACCESS" description="JOPTION_FILTER_ACCESS_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_ACCESS</option> </field> <field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_LANGUAGE</option> <option value="*">JALL</option> </field> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" description="JGLOBAL_SORT_BY" statuses="*,0,1,-2" onchange="this.form.submit();" default="a.position ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option> <option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option> <option value="a.published ASC">JSTATUS_ASC</option> <option value="a.published DESC">JSTATUS_DESC</option> <option value="a.title ASC">JGLOBAL_TITLE_ASC</option> <option value="a.title DESC">JGLOBAL_TITLE_DESC</option> <option value="a.position ASC">COM_MODULES_HEADING_POSITION_ASC</option> <option value="a.position DESC">COM_MODULES_HEADING_POSITION_DESC</option> <option value="name ASC">COM_MODULES_HEADING_MODULE_ASC</option> <option value="name DESC">COM_MODULES_HEADING_MODULE_DESC</option> <option value="pages ASC">COM_MODULES_HEADING_PAGES_ASC</option> <option value="pages DESC">COM_MODULES_HEADING_PAGES_DESC</option> <option value="ag.title ASC">JGRID_HEADING_ACCESS_ASC</option> <option value="ag.title DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="l.title ASC">JGRID_HEADING_LANGUAGE_ASC</option> <option value="l.title DESC">JGRID_HEADING_LANGUAGE_DESC</option> <option value="a.id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.id DESC">JGRID_HEADING_ID_DESC</option> </field> <field name="limit" type="limitbox" label="COM_MODULES_LIST_LIMIT" description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" /> </fields> </form> PK �|!]$�y�( ( models/forms/advanced.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <form> <fields name="params"> <fieldset name="advanced"> <field name="module_tag" type="moduletag" label="COM_MODULES_FIELD_MODULE_TAG_LABEL" description="COM_MODULES_FIELD_MODULE_TAG_DESC" default="div" validate="options" /> <field name="bootstrap_size" type="integer" label="COM_MODULES_FIELD_BOOTSTRAP_SIZE_LABEL" description="COM_MODULES_FIELD_BOOTSTRAP_SIZE_DESC" first="0" last="12" step="1" /> <field name="header_tag" type="headertag" label="COM_MODULES_FIELD_HEADER_TAG_LABEL" description="COM_MODULES_FIELD_HEADER_TAG_DESC" default="h3" validate="options" /> <field name="header_class" type="text" label="COM_MODULES_FIELD_HEADER_CLASS_LABEL" description="COM_MODULES_FIELD_HEADER_CLASS_DESC" /> <field name="style" type="chromestyle" label="COM_MODULES_FIELD_MODULE_STYLE_LABEL" description="COM_MODULES_FIELD_MODULE_STYLE_DESC" /> </fieldset> </fields> </form> PK �|!]�#W� � models/forms/module.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <form> <fieldset> <field name="id" type="number" label="JGLOBAL_FIELD_ID_LABEL" description="JGLOBAL_FIELD_ID_DESC" default="0" readonly="true" /> <field name="title" type="text" label="JGLOBAL_TITLE" description="COM_MODULES_FIELD_TITLE_DESC" class="input-xxlarge input-large-text" size="40" maxlength="100" required="true" /> <field name="note" type="text" label="COM_MODULES_FIELD_NOTE_LABEL" description="COM_MODULES_FIELD_NOTE_DESC" maxlength="255" size="40" class="span12" /> <field name="module" type="hidden" label="COM_MODULES_FIELD_MODULE_LABEL" description="COM_MODULES_FIELD_MODULE_DESC" readonly="readonly" size="20" /> <field name="showtitle" type="radio" label="COM_MODULES_FIELD_SHOWTITLE_LABEL" description="COM_MODULES_FIELD_SHOWTITLE_DESC" class="btn-group btn-group-yesno" default="1" size="1" > <option value="1">JSHOW</option> <option value="0">JHIDE</option> </field> <field name="published" type="list" label="JSTATUS" description="COM_MODULES_FIELD_PUBLISHED_DESC" class="chzn-color-state" default="1" size="1" > <option value="1">JPUBLISHED</option> <option value="0">JUNPUBLISHED</option> <option value="-2">JTRASHED</option> </field> <field name="publish_up" type="calendar" label="COM_MODULES_FIELD_PUBLISH_UP_LABEL" description="COM_MODULES_FIELD_PUBLISH_UP_DESC" filter="user_utc" translateformat="true" showtime="true" size="22" /> <field name="publish_down" type="calendar" label="COM_MODULES_FIELD_PUBLISH_DOWN_LABEL" description="COM_MODULES_FIELD_PUBLISH_DOWN_DESC" filter="user_utc" translateformat="true" showtime="true" size="22" /> <field name="client_id" type="hidden" label="COM_MODULES_FIELD_CLIENT_ID_LABEL" description="COM_MODULES_FIELD_CLIENT_ID_DESC" readonly="true" size="1" /> <field name="position" type="moduleposition" label="COM_MODULES_FIELD_POSITION_LABEL" description="COM_MODULES_FIELD_POSITION_DESC" default="" maxlength="50" /> <field name="access" type="accesslevel" label="JFIELD_ACCESS_LABEL" description="JFIELD_ACCESS_DESC" size="1" /> <field name="ordering" type="moduleorder" label="JFIELD_ORDERING_LABEL" description="JFIELD_ORDERING_DESC" linked="position" /> <field name="content" type="editor" label="COM_MODULES_FIELD_CONTENT_LABEL" description="COM_MODULES_FIELD_CONTENT_DESC" buttons="true" filter="JComponentHelper::filterText" hide="readmore,pagebreak,module" /> <field name="language" type="contentlanguage" label="JFIELD_LANGUAGE_LABEL" description="JFIELD_MODULE_LANGUAGE_DESC" > <option value="*">JALL</option> </field> <field name="assignment" type="hidden" /> <field name="assigned" type="hidden" /> <field name="asset_id" type="hidden" filter="unset" /> <field name="rules" type="rules" label="JFIELD_RULES_LABEL" translate_label="false" filter="rules" component="com_modules" section="module" validate="rules" /> </fieldset> </form> PK �|!]Ff� � models/forms/moduleadmin.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <form> <fieldset> <field name="id" type="number" label="JGLOBAL_FIELD_ID_LABEL" description="JGLOBAL_FIELD_ID_DESC" default="0" readonly="true" /> <field name="title" type="text" label="JGLOBAL_TITLE" description="COM_MODULES_FIELD_TITLE_DESC" class="input-xxlarge input-large-text" size="40" maxlength="100" required="true" /> <field name="note" type="text" label="COM_MODULES_FIELD_NOTE_LABEL" description="COM_MODULES_FIELD_NOTE_DESC" maxlength="255" size="40" class="span12" /> <field name="module" type="hidden" label="COM_MODULES_FIELD_MODULE_LABEL" description="COM_MODULES_FIELD_MODULE_DESC" readonly="readonly" size="20" /> <field name="showtitle" type="radio" label="COM_MODULES_FIELD_SHOWTITLE_LABEL" description="COM_MODULES_FIELD_SHOWTITLE_DESC" class="btn-group btn-group-yesno" default="1" size="1" > <option value="1">JSHOW</option> <option value="0">JHIDE</option> </field> <field name="published" type="list" label="JSTATUS" description="COM_MODULES_FIELD_PUBLISHED_DESC" class="chzn-color-state" default="1" size="1" > <option value="1">JPUBLISHED</option> <option value="0">JUNPUBLISHED</option> <option value="-2">JTRASHED</option> </field> <field name="publish_up" type="calendar" label="COM_MODULES_FIELD_PUBLISH_UP_LABEL" description="COM_MODULES_FIELD_PUBLISH_UP_DESC" filter="user_utc" translateformat="true" showtime="true" size="22" /> <field name="publish_down" type="calendar" label="COM_MODULES_FIELD_PUBLISH_DOWN_LABEL" description="COM_MODULES_FIELD_PUBLISH_DOWN_DESC" filter="user_utc" translateformat="true" showtime="true" size="22" /> <field name="client_id" type="hidden" label="COM_MODULES_FIELD_CLIENT_ID_LABEL" description="COM_MODULES_FIELD_CLIENT_ID_DESC" readonly="true" size="1" /> <field name="position" type="moduleposition" label="COM_MODULES_FIELD_POSITION_LABEL" description="COM_MODULES_FIELD_POSITION_DESC" default="" maxlength="50" /> <field name="access" type="accesslevel" label="JFIELD_ACCESS_LABEL" description="JFIELD_ACCESS_DESC" size="1" /> <field name="ordering" type="moduleorder" label="JFIELD_ORDERING_LABEL" description="JFIELD_ORDERING_DESC" linked="position" /> <field name="language" type="language" label="JFIELD_LANGUAGE_LABEL" description="JFIELD_MODULE_LANGUAGE_DESC" default="*" client="administrator" > <option value="*">JALL</option> </field> <field name="content" type="editor" label="COM_MODULES_FIELD_CONTENT_LABEL" description="COM_MODULES_FIELD_CONTENT_DESC" buttons="true" filter="JComponentHelper::filterText" hide="readmore,pagebreak,module" /> <field name="assignment" type="hidden" /> <field name="assigned" type="hidden" /> <field name="asset_id" type="hidden" filter="unset" /> <field name="rules" type="rules" label="JFIELD_RULES_LABEL" translate_label="false" filter="rules" component="com_modules" section="module" validate="rules" /> </fieldset> </form> PK �|!]��K� � $ models/forms/filter_modulesadmin.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <form> <fieldset addfieldpath="/administrator/components/com_modules/models/fields" /> <field name="client_id" type="list" label="" filtermode="selector" layout="default" onchange="jQuery('#filter_position, #filter_module, #filter_language').val('');this.form.submit();" > <option value="0">JSITE</option> <option value="1">JADMINISTRATOR</option> </field> <fields name="filter"> <field name="search" type="text" inputmode="search" label="COM_MODULES_MODULES_FILTER_SEARCH_LABEL" description="COM_MODULES_MODULES_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" noresults="COM_MODULES_MSG_MANAGE_NO_MODULES" /> <field name="state" type="status" label="JSTATUS" filter="*,-2,0,1" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="position" type="modulesposition" label="COM_MODULES_FIELD_POSITION_LABEL" onchange="this.form.submit();" > <option value="">COM_MODULES_OPTION_SELECT_POSITION</option> </field> <field name="module" type="ModulesModule" label="COM_MODULES_OPTION_SELECT_MODULE" onchange="this.form.submit();" > <option value="">COM_MODULES_OPTION_SELECT_MODULE</option> </field> <field name="access" type="accesslevel" label="JOPTION_FILTER_ACCESS" description="JOPTION_FILTER_ACCESS_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_ACCESS</option> </field> <field name="language" type="language" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" client="administrator" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_LANGUAGE</option> <option value="*">JALL</option> </field> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" description="JGLOBAL_SORT_BY" statuses="*,0,1,-2" onchange="this.form.submit();" default="a.position ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option> <option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option> <option value="a.published ASC">JSTATUS_ASC</option> <option value="a.published DESC">JSTATUS_DESC</option> <option value="a.title ASC">JGLOBAL_TITLE_ASC</option> <option value="a.title DESC">JGLOBAL_TITLE_DESC</option> <option value="a.position ASC">COM_MODULES_HEADING_POSITION_ASC</option> <option value="a.position DESC">COM_MODULES_HEADING_POSITION_DESC</option> <option value="name ASC">COM_MODULES_HEADING_MODULE_ASC</option> <option value="name DESC">COM_MODULES_HEADING_MODULE_DESC</option> <option value="ag.title ASC">JGRID_HEADING_ACCESS_ASC</option> <option value="ag.title DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="a.language ASC" requires="adminlanguage">JGRID_HEADING_LANGUAGE_ASC</option> <option value="a.language DESC" requires="adminlanguage">JGRID_HEADING_LANGUAGE_DESC</option> <option value="a.id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.id DESC">JGRID_HEADING_ID_DESC</option> </field> <field name="limit" type="limitbox" label="COM_MODULES_LIST_LIMIT" description="JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" /> </fields> </form> PK �|!]��Y�m �m models/module.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; /** * Module model. * * @since 1.6 */ class ModulesModelModule extends JModelAdmin { /** * The type alias for this content type. * * @var string * @since 3.4 */ public $typeAlias = 'com_modules.module'; /** * @var string The prefix to use with controller messages. * @since 1.6 */ protected $text_prefix = 'COM_MODULES'; /** * @var string The help screen key for the module. * @since 1.6 */ protected $helpKey = 'JHELP_EXTENSIONS_MODULE_MANAGER_EDIT'; /** * @var string The help screen base URL for the module. * @since 1.6 */ protected $helpURL; /** * Batch copy/move command. If set to false, * the batch copy/move command is not supported * * @var string */ protected $batch_copymove = 'position_id'; /** * Allowed batch commands * * @var array */ protected $batch_commands = array( 'assetgroup_id' => 'batchAccess', 'language_id' => 'batchLanguage', ); /** * Constructor. * * @param array $config An optional associative array of configuration settings. */ public function __construct($config = array()) { $config = array_merge( array( 'event_after_delete' => 'onExtensionAfterDelete', 'event_after_save' => 'onExtensionAfterSave', 'event_before_delete' => 'onExtensionBeforeDelete', 'event_before_save' => 'onExtensionBeforeSave', 'events_map' => array( 'save' => 'extension', 'delete' => 'extension' ) ), $config ); parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 1.6 */ protected function populateState() { $app = JFactory::getApplication('administrator'); // Load the User state. $pk = $app->input->getInt('id'); if (!$pk) { if ($extensionId = (int) $app->getUserState('com_modules.add.module.extension_id')) { $this->setState('extension.id', $extensionId); } } $this->setState('module.id', $pk); // Load the parameters. $params = JComponentHelper::getParams('com_modules'); $this->setState('params', $params); } /** * Batch copy modules to a new position or current. * * @param integer $value The new value matching a module position. * @param array $pks An array of row IDs. * @param array $contexts An array of item contexts. * * @return boolean True if successful, false otherwise and internal error is set. * * @since 2.5 */ protected function batchCopy($value, $pks, $contexts) { // Set the variables $user = JFactory::getUser(); $table = $this->getTable(); $newIds = array(); foreach ($pks as $pk) { if ($user->authorise('core.create', 'com_modules')) { $table->reset(); $table->load($pk); // Set the new position if ($value == 'noposition') { $position = ''; } elseif ($value == 'nochange') { $position = $table->position; } else { $position = $value; } $table->position = $position; // Copy of the Asset ID $oldAssetId = $table->asset_id; // Alter the title if necessary $data = $this->generateNewTitle(0, $table->title, $table->position); $table->title = $data['0']; // Reset the ID because we are making a copy $table->id = 0; // Unpublish the new module $table->published = 0; if (!$table->store()) { $this->setError($table->getError()); return false; } // Get the new item ID $newId = $table->get('id'); // Add the new ID to the array $newIds[$pk] = $newId; // Now we need to handle the module assignments $db = $this->getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('menuid')) ->from($db->quoteName('#__modules_menu')) ->where($db->quoteName('moduleid') . ' = ' . $pk); $db->setQuery($query); $menus = $db->loadColumn(); // Insert the new records into the table foreach ($menus as $menu) { $query->clear() ->insert($db->quoteName('#__modules_menu')) ->columns(array($db->quoteName('moduleid'), $db->quoteName('menuid'))) ->values($newId . ', ' . $menu); $db->setQuery($query); $db->execute(); } // Copy rules $query->clear() ->update($db->quoteName('#__assets', 't')) ->join('INNER', $db->quoteName('#__assets', 's') . ' ON ' . $db->quoteName('s.id') . ' = ' . $oldAssetId ) ->set($db->quoteName('t.rules') . ' = ' . $db->quoteName('s.rules')) ->where($db->quoteName('t.id') . ' = ' . $table->asset_id); $db->setQuery($query)->execute(); } else { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); return false; } } // Clean the cache $this->cleanCache(); return $newIds; } /** * Batch move modules to a new position or current. * * @param integer $value The new value matching a module position. * @param array $pks An array of row IDs. * @param array $contexts An array of item contexts. * * @return boolean True if successful, false otherwise and internal error is set. * * @since 2.5 */ protected function batchMove($value, $pks, $contexts) { // Set the variables $user = JFactory::getUser(); $table = $this->getTable(); foreach ($pks as $pk) { if ($user->authorise('core.edit', 'com_modules')) { $table->reset(); $table->load($pk); // Set the new position if ($value == 'noposition') { $position = ''; } elseif ($value == 'nochange') { $position = $table->position; } else { $position = $value; } $table->position = $position; if (!$table->store()) { $this->setError($table->getError()); return false; } } else { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); return false; } } // Clean the cache $this->cleanCache(); return true; } /** * Method to test whether a record can have its state edited. * * @param object $record A record object. * * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. * * @since 3.2 */ protected function canEditState($record) { // Check for existing module. if (!empty($record->id)) { return JFactory::getUser()->authorise('core.edit.state', 'com_modules.module.' . (int) $record->id); } // Default to component settings if module not known. return parent::canEditState($record); } /** * Method to delete rows. * * @param array &$pks An array of item ids. * * @return boolean Returns true on success, false on failure. * * @since 1.6 * @throws Exception */ public function delete(&$pks) { $dispatcher = JEventDispatcher::getInstance(); $pks = (array) $pks; $user = JFactory::getUser(); $table = $this->getTable(); $context = $this->option . '.' . $this->name; // Include the plugins for the on delete events. JPluginHelper::importPlugin($this->events_map['delete']); // Iterate the items to delete each one. foreach ($pks as $pk) { if ($table->load($pk)) { // Access checks. if (!$user->authorise('core.delete', 'com_modules.module.' . (int) $pk) || $table->published != -2) { JError::raiseWarning(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED')); return; } // Trigger the before delete event. $result = $dispatcher->trigger($this->event_before_delete, array($context, $table)); if (in_array(false, $result, true) || !$table->delete($pk)) { throw new Exception($table->getError()); } else { // Delete the menu assignments $db = $this->getDbo(); $query = $db->getQuery(true) ->delete('#__modules_menu') ->where('moduleid=' . (int) $pk); $db->setQuery($query); $db->execute(); // Trigger the after delete event. $dispatcher->trigger($this->event_after_delete, array($context, $table)); } // Clear module cache parent::cleanCache($table->module, $table->client_id); } else { throw new Exception($table->getError()); } } // Clear modules cache $this->cleanCache(); return true; } /** * Method to duplicate modules. * * @param array &$pks An array of primary key IDs. * * @return boolean|JException Boolean true on success, JException instance on error * * @since 1.6 * @throws Exception */ public function duplicate(&$pks) { $user = JFactory::getUser(); $db = $this->getDbo(); // Access checks. if (!$user->authorise('core.create', 'com_modules')) { throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED')); } $table = $this->getTable(); foreach ($pks as $pk) { if ($table->load($pk, true)) { // Reset the id to create a new record. $table->id = 0; // Alter the title. $m = null; if (preg_match('#\((\d+)\)$#', $table->title, $m)) { $table->title = preg_replace('#\(\d+\)$#', '(' . ($m[1] + 1) . ')', $table->title); } $data = $this->generateNewTitle(0, $table->title, $table->position); $table->title = $data[0]; // Unpublish duplicate module $table->published = 0; if (!$table->check() || !$table->store()) { throw new Exception($table->getError()); } $query = $db->getQuery(true) ->select($db->quoteName('menuid')) ->from($db->quoteName('#__modules_menu')) ->where($db->quoteName('moduleid') . ' = ' . (int) $pk); $db->setQuery($query); $rows = $db->loadColumn(); foreach ($rows as $menuid) { $tuples[] = (int) $table->id . ',' . (int) $menuid; } } else { throw new Exception($table->getError()); } } if (!empty($tuples)) { // Module-Menu Mapping: Do it in one query $query = $db->getQuery(true) ->insert($db->quoteName('#__modules_menu')) ->columns($db->quoteName(array('moduleid', 'menuid'))) ->values($tuples); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { return JError::raiseWarning(500, $e->getMessage()); } } // Clear modules cache $this->cleanCache(); return true; } /** * Method to change the title. * * @param integer $categoryId The id of the category. Not used here. * @param string $title The title. * @param string $position The position. * * @return array Contains the modified title. * * @since 2.5 */ protected function generateNewTitle($categoryId, $title, $position) { // Alter the title & alias $table = $this->getTable(); while ($table->load(array('position' => $position, 'title' => $title))) { $title = StringHelper::increment($title); } return array($title); } /** * Method to get the client object * * @return void * * @since 1.6 */ public function &getClient() { return $this->_client; } /** * Method to get the record form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return JForm A JForm object on success, false on failure * * @since 1.6 */ public function getForm($data = array(), $loadData = true) { // The folder and element vars are passed when saving the form. if (empty($data)) { $item = $this->getItem(); $clientId = $item->client_id; $module = $item->module; $id = $item->id; } else { $clientId = ArrayHelper::getValue($data, 'client_id'); $module = ArrayHelper::getValue($data, 'module'); $id = ArrayHelper::getValue($data, 'id'); } // Add the default fields directory $baseFolder = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE; JForm::addFieldPath($baseFolder . '/modules' . '/' . $module . '/field'); // These variables are used to add data from the plugin XML files. $this->setState('item.client_id', $clientId); $this->setState('item.module', $module); // Get the form. if ($clientId == 1) { $form = $this->loadForm('com_modules.module.admin', 'moduleadmin', array('control' => 'jform', 'load_data' => $loadData), true); // Display language field to filter admin custom menus per language if (!JModuleHelper::isAdminMultilang()) { $form->setFieldAttribute('language', 'type', 'hidden'); } } else { $form = $this->loadForm('com_modules.module', 'module', array('control' => 'jform', 'load_data' => $loadData), true); } if (empty($form)) { return false; } $form->setFieldAttribute('position', 'client', $this->getState('item.client_id') == 0 ? 'site' : 'administrator'); $user = JFactory::getUser(); /** * Check for existing module * Modify the form based on Edit State access controls. */ if ($id != 0 && (!$user->authorise('core.edit.state', 'com_modules.module.' . (int) $id)) || ($id == 0 && !$user->authorise('core.edit.state', 'com_modules')) ) { // Disable fields for display. $form->setFieldAttribute('ordering', 'disabled', 'true'); $form->setFieldAttribute('published', 'disabled', 'true'); $form->setFieldAttribute('publish_up', 'disabled', 'true'); $form->setFieldAttribute('publish_down', 'disabled', 'true'); // Disable fields while saving. // The controller has already verified this is a record you can edit. $form->setFieldAttribute('ordering', 'filter', 'unset'); $form->setFieldAttribute('published', 'filter', 'unset'); $form->setFieldAttribute('publish_up', 'filter', 'unset'); $form->setFieldAttribute('publish_down', 'filter', 'unset'); } return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * * @since 1.6 */ protected function loadFormData() { $app = JFactory::getApplication(); // Check the session for previously entered form data. $data = $app->getUserState('com_modules.edit.module.data', array()); if (empty($data)) { $data = $this->getItem(); // Pre-select some filters (Status, Module Position, Language, Access Level) in edit form if those have been selected in Module Manager if (!$data->id) { $filters = (array) $app->getUserState('com_modules.modules.filter'); $data->set('published', $app->input->getInt('published', ((isset($filters['state']) && $filters['state'] !== '') ? $filters['state'] : null))); $data->set('position', $app->input->getInt('position', (!empty($filters['position']) ? $filters['position'] : null))); $data->set('language', $app->input->getString('language', (!empty($filters['language']) ? $filters['language'] : null))); $data->set('access', $app->input->getInt('access', (!empty($filters['access']) ? $filters['access'] : JFactory::getConfig()->get('access')))); } // Avoid to delete params of a second module opened in a new browser tab while new one is not saved yet. if (empty($data->params)) { // This allows us to inject parameter settings into a new module. $params = $app->getUserState('com_modules.add.module.params'); if (is_array($params)) { $data->set('params', $params); } } } $this->preprocessData('com_modules.module', $data); return $data; } /** * Method to get a single record. * * @param integer $pk The id of the primary key. * * @return mixed Object on success, false on failure. * * @since 1.6 */ public function getItem($pk = null) { $pk = (!empty($pk)) ? (int) $pk : (int) $this->getState('module.id'); $db = $this->getDbo(); if (!isset($this->_cache[$pk])) { // Get a row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $error = $table->getError()) { $this->setError($error); return false; } // Check if we are creating a new extension. if (empty($pk)) { if ($extensionId = (int) $this->getState('extension.id')) { $query = $db->getQuery(true) ->select('element, client_id') ->from('#__extensions') ->where('extension_id = ' . $extensionId) ->where('type = ' . $db->quote('module')); $db->setQuery($query); try { $extension = $db->loadObject(); } catch (RuntimeException $e) { $this->setError($e->getMessage()); return false; } if (empty($extension)) { $this->setError('COM_MODULES_ERROR_CANNOT_FIND_MODULE'); return false; } // Extension found, prime some module values. $table->module = $extension->element; $table->client_id = $extension->client_id; } else { JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_modules&view=modules', false)); return false; } } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $this->_cache[$pk] = ArrayHelper::toObject($properties, 'JObject'); // Convert the params field to an array. $registry = new Registry($table->params); $this->_cache[$pk]->params = $registry->toArray(); // Determine the page assignment mode. $query = $db->getQuery(true) ->select($db->quoteName('menuid')) ->from($db->quoteName('#__modules_menu')) ->where($db->quoteName('moduleid') . ' = ' . (int) $pk); $db->setQuery($query); $assigned = $db->loadColumn(); if (empty($pk)) { // If this is a new module, assign to all pages. $assignment = 0; } elseif (empty($assigned)) { // For an existing module it is assigned to none. $assignment = '-'; } else { if ($assigned[0] > 0) { $assignment = 1; } elseif ($assigned[0] < 0) { $assignment = -1; } else { $assignment = 0; } } $this->_cache[$pk]->assigned = $assigned; $this->_cache[$pk]->assignment = $assignment; // Get the module XML. $client = JApplicationHelper::getClientInfo($table->client_id); $path = JPath::clean($client->path . '/modules/' . $table->module . '/' . $table->module . '.xml'); if (file_exists($path)) { $this->_cache[$pk]->xml = simplexml_load_file($path); } else { $this->_cache[$pk]->xml = null; } } return $this->_cache[$pk]; } /** * Get the necessary data to load an item help screen. * * @return object An object with key, url, and local properties for loading the item help screen. * * @since 1.6 */ public function getHelp() { return (object) array('key' => $this->helpKey, 'url' => $this->helpURL); } /** * Returns a reference to the a Table object, always creating it. * * @param string $type The table type to instantiate * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * * @return JTable A database object * * @since 1.6 */ public function getTable($type = 'Module', $prefix = 'JTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } /** * Prepare and sanitise the table prior to saving. * * @param JTable $table The database object * * @return void * * @since 1.6 */ protected function prepareTable($table) { $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->position = trim($table->position); } /** * Method to preprocess the form * * @param JForm $form A form object. * @param mixed $data The data expected for the form. * @param string $group The name of the plugin group to import (defaults to "content"). * * @return void * * @since 1.6 * @throws Exception if there is an error loading the form. */ protected function preprocessForm(JForm $form, $data, $group = 'content') { jimport('joomla.filesystem.path'); $lang = JFactory::getLanguage(); $clientId = $this->getState('item.client_id'); $module = $this->getState('item.module'); $client = JApplicationHelper::getClientInfo($clientId); $formFile = JPath::clean($client->path . '/modules/' . $module . '/' . $module . '.xml'); // Load the core and/or local language file(s). $lang->load($module, $client->path, null, false, true) || $lang->load($module, $client->path . '/modules/' . $module, null, false, true); if (file_exists($formFile)) { // Get the module form. if (!$form->loadFile($formFile, false, '//config')) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Attempt to load the xml file. if (!$xml = simplexml_load_file($formFile)) { throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. $help = $xml->xpath('/extension/help'); if (!empty($help)) { $helpKey = trim((string) $help[0]['key']); $helpURL = trim((string) $help[0]['url']); $this->helpKey = $helpKey ?: $this->helpKey; $this->helpURL = $helpURL ?: $this->helpURL; } } // Load the default advanced params JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/models/forms'); $form->loadFile('advanced', false); // Trigger the default form events. parent::preprocessForm($form, $data, $group); } /** * Loads ContentHelper for filters before validating data. * * @param object $form The form to validate against. * @param array $data The data to validate. * @param string $group The name of the group(defaults to null). * * @return mixed Array of filtered data if valid, false otherwise. * * @since 1.1 */ public function validate($form, $data, $group = null) { JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php'); if (!JFactory::getUser()->authorise('core.admin', 'com_modules')) { if (isset($data['rules'])) { unset($data['rules']); } } return parent::validate($form, $data, $group); } /** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $dispatcher = JEventDispatcher::getInstance(); $input = JFactory::getApplication()->input; $table = $this->getTable(); $pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('module.id'); $isNew = true; $context = $this->option . '.' . $this->name; // Include the plugins for the save event. JPluginHelper::importPlugin($this->events_map['save']); // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } // Alter the title and published state for Save as Copy if ($input->get('task') == 'save2copy') { $orig_table = clone $this->getTable(); $orig_table->load((int) $input->getInt('id')); $data['published'] = 0; if ($data['title'] == $orig_table->title) { $data['title'] = StringHelper::increment($data['title']); } } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the before save event. $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, $isNew)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Process the menu link mappings. $assignment = isset($data['assignment']) ? $data['assignment'] : 0; // Delete old module to menu item associations $db = $this->getDbo(); $query = $db->getQuery(true) ->delete('#__modules_menu') ->where('moduleid = ' . (int) $table->id); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { $this->setError($e->getMessage()); return false; } // If the assignment is numeric, then something is selected (otherwise it's none). if (is_numeric($assignment)) { // Variable is numeric, but could be a string. $assignment = (int) $assignment; // Logic check: if no module excluded then convert to display on all. if ($assignment == -1 && empty($data['assigned'])) { $assignment = 0; } // Check needed to stop a module being assigned to `All` // and other menu items resulting in a module being displayed twice. if ($assignment === 0) { // Assign new module to `all` menu item associations. $query->clear() ->insert('#__modules_menu') ->columns(array($db->quoteName('moduleid'), $db->quoteName('menuid'))) ->values((int) $table->id . ', 0'); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { $this->setError($e->getMessage()); return false; } } elseif (!empty($data['assigned'])) { // Get the sign of the number. $sign = $assignment < 0 ? -1 : 1; $query->clear() ->insert($db->quoteName('#__modules_menu')) ->columns($db->quoteName(array('moduleid', 'menuid'))); foreach ($data['assigned'] as &$pk) { $query->values((int) $table->id . ',' . (int) $pk * $sign); } $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { $this->setError($e->getMessage()); return false; } } } // Trigger the after save event. $dispatcher->trigger($this->event_after_save, array($context, &$table, $isNew)); // Compute the extension id of this module in case the controller wants it. $query->clear() ->select($db->quoteName('extension_id')) ->from($db->quoteName('#__extensions', 'e')) ->join( 'LEFT', $db->quoteName('#__modules', 'm') . ' ON ' . $db->quoteName('e.client_id') . ' = ' . (int) $table->client_id . ' AND ' . $db->quoteName('e.element') . ' = ' . $db->quoteName('m.module') ) ->where($db->quoteName('m.id') . ' = ' . (int) $table->id); $db->setQuery($query); try { $extensionId = $db->loadResult(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } $this->setState('module.extension_id', $extensionId); $this->setState('module.id', $table->id); // Clear modules cache $this->cleanCache(); // Clean module cache parent::cleanCache($table->module, $table->client_id); return true; } /** * A protected method to get a set of ordering conditions. * * @param object $table A record object. * * @return array An array of conditions to add to add to ordering queries. * * @since 1.6 */ protected function getReorderConditions($table) { $condition = array(); $condition[] = 'client_id = ' . (int) $table->client_id; $condition[] = 'position = ' . $this->_db->quote($table->position); return $condition; } /** * Custom clean cache method for different clients * * @param string $group The name of the plugin group to import (defaults to null). * @param integer $clientId The client ID. [optional] * * @return void * * @since 1.6 */ protected function cleanCache($group = null, $clientId = 0) { parent::cleanCache('com_modules', $this->getClient()); } } PK �|!]�{�4 �4 models/modules.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; /** * Modules Component Module Model * * @since 1.5 */ class ModulesModelModules extends JModelList { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'published', 'a.published', 'state', 'access', 'a.access', 'ag.title', 'access_level', 'ordering', 'a.ordering', 'module', 'a.module', 'language', 'a.language', 'l.title', 'language_title', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'client_id', 'a.client_id', 'position', 'a.position', 'pages', 'name', 'e.name', 'menuitem', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = 'a.position', $direction = 'asc') { $app = JFactory::getApplication(); $layout = $app->input->get('layout', '', 'cmd'); // Adjust the context to support modal layouts. if ($layout) { $this->context .= '.' . $layout; } // Load the filter state. $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string')); $this->setState('filter.position', $this->getUserStateFromRequest($this->context . '.filter.position', 'filter_position', '', 'string')); $this->setState('filter.module', $this->getUserStateFromRequest($this->context . '.filter.module', 'filter_module', '', 'string')); $this->setState('filter.menuitem', $this->getUserStateFromRequest($this->context . '.filter.menuitem', 'filter_menuitem', '', 'cmd')); $this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'cmd')); // If in modal layout on the frontend, state and language are always forced. if ($app->isClient('site') && $layout === 'modal') { $this->setState('filter.language', 'current'); $this->setState('filter.state', 1); } // If in backend (modal or not) we get the same fields from the user request. else { $this->setState('filter.language', $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '', 'string')); $this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string')); } // Special case for the client id. if ($app->isClient('site') || $layout === 'modal') { $this->setState('client_id', 0); $clientId = 0; } else { $clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int'); $clientId = (!in_array($clientId, array (0, 1))) ? 0 : $clientId; $this->setState('client_id', $clientId); } // Use a different filter file when client is administrator if ($clientId == 1) { $this->filterFormName = 'filter_modulesadmin'; } // Load the parameters. $params = JComponentHelper::getParams('com_modules'); $this->setState('params', $params); // List state information. parent::populateState($ordering, $direction); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('client_id'); $id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.state'); $id .= ':' . $this->getState('filter.position'); $id .= ':' . $this->getState('filter.module'); $id .= ':' . $this->getState('filter.menuitem'); $id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.language'); return parent::getStoreId($id); } /** * Returns an object list * * @param string $query The query * @param int $limitstart Offset * @param int $limit The number of records * * @return array */ protected function _getList($query, $limitstart = 0, $limit = 0) { $listOrder = $this->getState('list.ordering', 'a.position'); $listDirn = $this->getState('list.direction', 'asc'); // If ordering by fields that need translate we need to sort the array of objects after translating them. if (in_array($listOrder, array('pages', 'name'))) { // Fetch the results. $this->_db->setQuery($query); $result = $this->_db->loadObjectList(); // Translate the results. $this->translate($result); // Sort the array of translated objects. $result = ArrayHelper::sortObjects($result, $listOrder, strtolower($listDirn) == 'desc' ? -1 : 1, true, true); // Process pagination. $total = count($result); $this->cache[$this->getStoreId('getTotal')] = $total; if ($total < $limitstart) { $limitstart = 0; $this->setState('list.start', 0); } return array_slice($result, $limitstart, $limit ?: null); } // If ordering by fields that doesn't need translate just order the query. if ($listOrder === 'a.ordering') { $query->order($this->_db->quoteName('a.position') . ' ASC') ->order($this->_db->quoteName($listOrder) . ' ' . $this->_db->escape($listDirn)); } elseif ($listOrder === 'a.position') { $query->order($this->_db->quoteName($listOrder) . ' ' . $this->_db->escape($listDirn)) ->order($this->_db->quoteName('a.ordering') . ' ASC'); } else { $query->order($this->_db->quoteName($listOrder) . ' ' . $this->_db->escape($listDirn)); } // Process pagination. $result = parent::_getList($query, $limitstart, $limit); // Translate the results. $this->translate($result); return $result; } /** * Translate a list of objects * * @param array &$items The array of objects * * @return array The array of translated objects */ protected function translate(&$items) { $lang = JFactory::getLanguage(); $clientPath = $this->getState('client_id') ? JPATH_ADMINISTRATOR : JPATH_SITE; foreach ($items as $item) { $extension = $item->module; $source = $clientPath . "/modules/$extension"; $lang->load("$extension.sys", $clientPath, null, false, true) || $lang->load("$extension.sys", $source, null, false, true); $item->name = JText::_($item->name); if (is_null($item->pages)) { $item->pages = JText::_('JNONE'); } elseif ($item->pages < 0) { $item->pages = JText::_('COM_MODULES_ASSIGNED_VARIES_EXCEPT'); } elseif ($item->pages > 0) { $item->pages = JText::_('COM_MODULES_ASSIGNED_VARIES_ONLY'); } else { $item->pages = JText::_('JALL'); } } } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery */ protected function getListQuery() { $app = JFactory::getApplication(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.note, a.position, a.module, a.language,' . 'a.checked_out, a.checked_out_time, a.published AS published, e.enabled AS enabled, a.access, a.ordering, a.publish_up, a.publish_down' ) ); // From modules table. $query->from($db->quoteName('#__modules', 'a')); // Join over the language $query->select($db->quoteName('l.title', 'language_title')) ->select($db->quoteName('l.image', 'language_image')) ->join('LEFT', $db->quoteName('#__languages', 'l') . ' ON ' . $db->quoteName('l.lang_code') . ' = ' . $db->quoteName('a.language')); // Join over the users for the checked out user. $query->select($db->quoteName('uc.name', 'editor')) ->join('LEFT', $db->quoteName('#__users', 'uc') . ' ON ' . $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out')); // Join over the asset groups. $query->select($db->quoteName('ag.title', 'access_level')) ->join('LEFT', $db->quoteName('#__viewlevels', 'ag') . ' ON ' . $db->quoteName('ag.id') . ' = ' . $db->quoteName('a.access')); // Join over the module menus $query->select('MIN(mm.menuid) AS pages') ->join('LEFT', $db->quoteName('#__modules_menu', 'mm') . ' ON ' . $db->quoteName('mm.moduleid') . ' = ' . $db->quoteName('a.id')); // Join over the extensions $query->select($db->quoteName('e.name', 'name')) ->join('LEFT', $db->quoteName('#__extensions', 'e') . ' ON ' . $db->quoteName('e.element') . ' = ' . $db->quoteName('a.module')); // Group (careful with PostgreSQL) $query->group( 'a.id, a.title, a.note, a.position, a.module, a.language, a.checked_out, ' . 'a.checked_out_time, a.published, a.access, a.ordering, l.title, l.image, uc.name, ag.title, e.name, ' . 'l.lang_code, uc.id, ag.id, mm.moduleid, e.element, a.publish_up, a.publish_down, e.enabled' ); // Filter by client. $clientId = $this->getState('client_id'); $query->where($db->quoteName('a.client_id') . ' = ' . (int) $clientId . ' AND ' . $db->quoteName('e.client_id') . ' = ' . (int) $clientId); // Filter by current user access level. $user = JFactory::getUser(); // Get the current user for authorisation checks if ($user->authorise('core.admin') !== true) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ')'); } // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where($db->quoteName('a.access') . ' = ' . (int) $access); } // Filter by published state. $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where($db->quoteName('a.published') . ' = ' . (int) $state); } elseif ($state === '') { $query->where($db->quoteName('a.published') . ' IN (0, 1)'); } // Filter by position. if ($position = $this->getState('filter.position')) { $query->where($db->quoteName('a.position') . ' = ' . $db->quote(($position === 'none') ? '' : $position)); } // Filter by module. if ($module = $this->getState('filter.module')) { $query->where($db->quoteName('a.module') . ' = ' . $db->quote($module)); } // Filter by menuitem id (only for site client). if ((int) $clientId === 0 && $menuItemId = $this->getState('filter.menuitem')) { // If user selected the modules not assigned to any page (menu item). if ((int) $menuItemId === -1) { $query->having('MIN(' . $db->quoteName('mm.menuid') . ') IS NULL'); } // If user selected the modules assigned to some particular page (menu item). else { // Modules in "All" pages. $subQuery1 = $db->getQuery(true); $subQuery1->select('MIN(' . $db->quoteName('menuid') . ')') ->from($db->quoteName('#__modules_menu')) ->where($db->quoteName('moduleid') . ' = ' . $db->quoteName('a.id')); // Modules in "Selected" pages that have the chosen menu item id. $subQuery2 = $db->getQuery(true); $subQuery2->select($db->quoteName('moduleid')) ->from($db->quoteName('#__modules_menu')) ->where($db->quoteName('menuid') . ' = ' . (int) $menuItemId); // Modules in "All except selected" pages that doesn't have the chosen menu item id. $subQuery3 = $db->getQuery(true); $subQuery3->select($db->quoteName('moduleid')) ->from($db->quoteName('#__modules_menu')) ->where($db->quoteName('menuid') . ' = -' . (int) $menuItemId); // Filter by modules assigned to the selected menu item. $query->where('( (' . $subQuery1 . ') = 0 OR ((' . $subQuery1 . ') > 0 AND ' . $db->quoteName('a.id') . ' IN (' . $subQuery2 . ')) OR ((' . $subQuery1 . ') < 0 AND ' . $db->quoteName('a.id') . ' NOT IN (' . $subQuery3 . ')) )' ); } } // Filter by search in title or note or id:. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where($db->quoteName('a.id') . ' = ' . (int) substr($search, 3)); } else { $search = $db->quote('%' . StringHelper::strtolower($search) . '%'); $query->where('(LOWER(a.title) LIKE ' . $search . ' OR LOWER(a.note) LIKE ' . $search . ')'); } } // Filter on the language. if ($language = $this->getState('filter.language')) { if ($language === 'current') { $query->where($db->quoteName('a.language') . ' IN (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } else { $query->where($db->quoteName('a.language') . ' = ' . $db->quote($language)); } } return $query; } } PK �|!]6���� � ! models/fields/modulesposition.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php'); JFormHelper::loadFieldClass('list'); /** * Modules Position field. * * @since 3.4.2 */ class JFormFieldModulesPosition extends JFormFieldList { /** * The form field type. * * @var string * @since 3.4.2 */ protected $type = 'ModulesPosition'; /** * Method to get the field options. * * @return array The field option objects. * * @since 3.4.2 */ public function getOptions() { $options = ModulesHelper::getPositions(JFactory::getApplication()->getUserState('com_modules.modules.client_id', 0)); return array_merge(parent::getOptions(), $options); } } PK �|!]��d�� � models/fields/modulesmodule.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JLoader::register('ModulesHelper', JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php'); JFormHelper::loadFieldClass('list'); /** * Modules Module field. * * @since 3.4.2 */ class JFormFieldModulesModule extends JFormFieldList { /** * The form field type. * * @var string * @since 3.4.2 */ protected $type = 'ModulesModule'; /** * Method to get the field options. * * @return array The field option objects. * * @since 3.4.2 */ public function getOptions() { $options = ModulesHelper::getModules(JFactory::getApplication()->getUserState('com_modules.modules.client_id', 0)); return array_merge(parent::getOptions(), $options); } } PK �|!]��o&� � models/positions.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Modules Component Positions Model * * @since 1.6 */ class ModulesModelPositions extends JModelList { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'value', 'templates', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = 'value', $direction = 'asc') { $app = JFactory::getApplication('administrator'); // Load the filter state. $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string'); $this->setState('filter.state', $state); $template = $this->getUserStateFromRequest($this->context . '.filter.template', 'filter_template', '', 'string'); $this->setState('filter.template', $template); $type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'); $this->setState('filter.type', $type); // Special case for the client id. $clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int'); $clientId = (!in_array((int) $clientId, array (0, 1))) ? 0 : (int) $clientId; $this->setState('client_id', $clientId); // Load the parameters. $params = JComponentHelper::getParams('com_modules'); $this->setState('params', $params); // List state information. parent::populateState($ordering, $direction); } /** * Method to get an array of data items. * * @return mixed An array of data items on success, false on failure. * * @since 1.6 */ public function getItems() { if (!isset($this->items)) { $lang = JFactory::getLanguage(); $search = $this->getState('filter.search'); $state = $this->getState('filter.state'); $clientId = $this->getState('client_id'); $filter_template = $this->getState('filter.template'); $type = $this->getState('filter.type'); $ordering = $this->getState('list.ordering'); $direction = $this->getState('list.direction'); $limitstart = $this->getState('list.start'); $limit = $this->getState('list.limit'); $client = JApplicationHelper::getClientInfo($clientId); if ($type != 'template') { // Get the database object and a new query object. $query = $this->_db->getQuery(true) ->select('DISTINCT(position) as value') ->from('#__modules') ->where($this->_db->quoteName('client_id') . ' = ' . (int) $clientId); if ($search) { $search = $this->_db->quote('%' . str_replace(' ', '%', $this->_db->escape(trim($search), true) . '%')); $query->where('position LIKE ' . $search); } $this->_db->setQuery($query); try { $positions = $this->_db->loadObjectList('value'); } catch (RuntimeException $e) { $this->setError($e->getMessage()); return false; } foreach ($positions as $value => $position) { $positions[$value] = array(); } } else { $positions = array(); } // Load the positions from the installed templates. foreach (ModulesHelper::getTemplates($clientId) as $template) { $path = JPath::clean($client->path . '/templates/' . $template->element . '/templateDetails.xml'); if (file_exists($path)) { $xml = simplexml_load_file($path); if (isset($xml->positions[0])) { $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true); foreach ($xml->positions[0] as $position) { $value = (string) $position['value']; $label = (string) $position; if (!$value) { $value = $label; $label = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_' . $template->element . '_POSITION_' . $value); $altlabel = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'COM_MODULES_POSITION_' . $value); if (!$lang->hasKey($label) && $lang->hasKey($altlabel)) { $label = $altlabel; } } if ($type == 'user' || ($state != '' && $state != $template->enabled)) { unset($positions[$value]); } elseif (preg_match(chr(1) . $search . chr(1) . 'i', $value) && ($filter_template == '' || $filter_template == $template->element)) { if (!isset($positions[$value])) { $positions[$value] = array(); } $positions[$value][$template->name] = $label; } } } } } $this->total = count($positions); if ($limitstart >= $this->total) { $limitstart = $limitstart < $limit ? 0 : $limitstart - $limit; $this->setState('list.start', $limitstart); } if ($ordering == 'value') { if ($direction == 'asc') { ksort($positions); } else { krsort($positions); } } else { if ($direction == 'asc') { asort($positions); } else { arsort($positions); } } $this->items = array_slice($positions, $limitstart, $limit ?: null); } return $this->items; } /** * Method to get the total number of items. * * @return integer The total number of items. * * @since 1.6 */ public function getTotal() { if (!isset($this->total)) { $this->getItems(); } return $this->total; } } PK �|!]�T-� � models/select.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Utilities\ArrayHelper; /** * Module model. * * @since 1.6 */ class ModulesModelSelect extends JModelList { /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication('administrator'); // Load the filter state. $clientId = $app->getUserState('com_modules.modules.client_id', 0); $this->setState('client_id', (int) $clientId); // Load the parameters. $params = JComponentHelper::getParams('com_modules'); $this->setState('params', $params); // Manually set limits to get all modules. $this->setState('list.limit', 0); $this->setState('list.start', 0); $this->setState('list.ordering', 'a.name'); $this->setState('list.direction', 'ASC'); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('client_id'); return parent::getStoreId($id); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.extension_id, a.name, a.element AS module' ) ); $query->from($db->quoteName('#__extensions') . ' AS a'); // Filter by module $query->where('a.type = ' . $db->quote('module')); // Filter by client. $clientId = $this->getState('client_id'); $query->where('a.client_id = ' . (int) $clientId); // Filter by enabled $query->where('a.enabled = 1'); // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to get a list of items. * * @return mixed An array of objects on success, false on failure. */ public function getItems() { // Get the list of items from the database. $items = parent::getItems(); $client = JApplicationHelper::getClientInfo($this->getState('client_id', 0)); $lang = JFactory::getLanguage(); // Loop through the results to add the XML metadata, // and load language support. foreach ($items as &$item) { $path = JPath::clean($client->path . '/modules/' . $item->module . '/' . $item->module . '.xml'); if (file_exists($path)) { $item->xml = simplexml_load_file($path); } else { $item->xml = null; } // 1.5 Format; Core files or language packs then // 1.6 3PD Extension Support $lang->load($item->module . '.sys', $client->path, null, false, true) || $lang->load($item->module . '.sys', $client->path . '/modules/' . $item->module, null, false, true); $item->name = JText::_($item->name); if (isset($item->xml) && $text = trim($item->xml->description)) { $item->desc = JText::_($text); } else { $item->desc = JText::_('COM_MODULES_NODESCRIPTION'); } } $items = ArrayHelper::sortObjects($items, 'name', 1, true, true); // TODO: Use the cached XML from the extensions table? return $items; } } PK �|!]���� � config.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <config> <fieldset name="modules" label="COM_MODULES_GENERAL" description="COM_MODULES_GENERAL_FIELDSET_DESC" > <field name="redirect_edit" type="list" class="advancedSelect" default="site" label="COM_MODULES_REDIRECT_EDIT_LABEL" description="COM_MODULES_REDIRECT_EDIT_DESC" > <option value="admin">JADMINISTRATOR</option> <option value="site">JSITE</option> </field> </fieldset> <fieldset name="admin_modules" label="COM_MODULES_ADMIN_LANG_FILTER_FIELDSET_LABEL" > <field name="adminlangfilter" type="radio" label="COM_MODULES_ADMIN_LANG_FILTER_LABEL" description="COM_MODULES_ADMIN_LANG_FILTER_DESC" class="btn-group btn-group-yesno" default="0" filter="integer" > <option value="1">JYES</option> <option value="0">JNO</option> </field> </fieldset> <fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC" > <field name="rules" type="rules" label="JCONFIG_PERMISSIONS_LABEL" filter="rules" validate="rules" component="com_modules" section="component" /> </fieldset> </config> PK �|!]�>�b; ; access.xmlnu &1i� <?xml version="1.0" encoding="utf-8" ?> <access component="com_modules"> <section name="component"> <action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" /> <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" /> <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" /> <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" /> <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" /> <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" /> <action name="module.edit.frontend" title="COM_MODULES_ACTION_EDITFRONTEND" description="COM_MODULES_ACTION_EDITFRONTEND_COMPONENT_DESC" /> </section> <section name="module"> <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" /> <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" /> <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" /> <action name="module.edit.frontend" title="COM_MODULES_ACTION_EDITFRONTEND" description="COM_MODULES_ACTION_EDITFRONTEND_COMPONENT_DESC" /> </section> </access>PK �|!]� � % % views/module/view.html.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * View to edit a module. * * @since 1.6 */ class ModulesViewModule extends JViewLegacy { protected $form; protected $item; protected $state; /** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->canDo = JHelperContent::getActions('com_modules', 'module', $this->item->id); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors), 500); } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = ($this->item->id == 0); $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); $canDo = $this->canDo; JToolbarHelper::title(JText::sprintf('COM_MODULES_MANAGER_MODULE', JText::_($this->item->module)), 'cube module'); // For new records, check the create permission. if ($isNew && $canDo->get('core.create')) { JToolbarHelper::apply('module.apply'); JToolbarHelper::save('module.save'); JToolbarHelper::save2new('module.save2new'); JToolbarHelper::cancel('module.cancel'); } else { // Can't save the record if it's checked out. if (!$checkedOut) { // Since it's an existing record, check the edit permission. if ($canDo->get('core.edit')) { JToolbarHelper::apply('module.apply'); JToolbarHelper::save('module.save'); // We can save this record, but check the create permission to see if we can return to make a new one. if ($canDo->get('core.create')) { JToolbarHelper::save2new('module.save2new'); } } } // If checked out, we can still save if ($canDo->get('core.create')) { JToolbarHelper::save2copy('module.save2copy'); } JToolbarHelper::cancel('module.cancel', 'JTOOLBAR_CLOSE'); } // Get the help information for the menu item. $lang = JFactory::getLanguage(); $help = $this->get('Help'); if ($lang->hasKey($help->url)) { $debug = $lang->setDebug(false); $url = JText::_($help->url); $lang->setDebug($debug); } else { $url = null; } JToolbarHelper::help($help->key, false, $url); } } PK �|!]��qG views/module/view.json.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * View to edit a module. * * @package Joomla.Administrator * @subpackage com_templates * @since 3.2 */ class ModulesViewModule extends JViewLegacy { protected $item; protected $form; protected $state; /** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $app = JFactory::getApplication(); try { $this->item = $this->get('Item'); } catch (Exception $e) { $app->enqueueMessage($e->getMessage(), 'error'); return false; } $paramsList = $this->item->getProperties(); unset($paramsList['xml']); $paramsList = json_encode($paramsList); return $paramsList; } } PK �|!]DD��+ + views/module/tmpl/edit.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('behavior.formvalidator'); JHtml::_('behavior.combobox'); JHtml::_('behavior.keepalive'); JHtml::_('formbehavior.chosen', '#jform_position', null, array('disable_search_threshold' => 0 )); JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY'))); JHtml::_('formbehavior.chosen', '.multipleTags', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_TAG'))); JHtml::_('formbehavior.chosen', '.multipleAuthors', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_AUTHOR'))); JHtml::_('formbehavior.chosen', '.multipleAuthorAliases', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_AUTHOR_ALIAS'))); JHtml::_('formbehavior.chosen', 'select'); $hasContent = isset($this->item->xml->customContent); $hasContentFieldName = 'content'; // For a later improvement if ($hasContent) { $hasContentFieldName = 'content'; } // Get Params Fieldsets $this->fieldsets = $this->form->getFieldsets('params'); $script = " Joomla.submitbutton = function(task) { if (task == 'module.cancel' || document.formvalidator.isValid(document.getElementById('module-form'))) { "; if ($hasContent) { $script .= $this->form->getField($hasContentFieldName)->save(); } $script .= " Joomla.submitform(task, document.getElementById('module-form')); jQuery('#permissions-sliders select').attr('disabled', 'disabled'); if (self != top) { if (parent.viewLevels) { var updPosition = jQuery('#jform_position').chosen().val(), updTitle = jQuery('#jform_title').val(), updMenus = jQuery('#jform_assignment').chosen().val(), updStatus = jQuery('#jform_published').chosen().val(), updAccess = jQuery('#jform_access').chosen().val(), tmpMenu = jQuery('#menus-" . $this->item->id . "', parent.document), tmpRow = jQuery('#tr-" . $this->item->id . "', parent.document); tmpStatus = jQuery('#status-" . $this->item->id . "', parent.document); window.parent.inMenus = new Array(); window.parent.numMenus = jQuery(':input[name=\"jform[assigned][]\"]').length; jQuery('input[name=\"jform[assigned][]\"]').each(function(){ if (updMenus > 0 ) { if (jQuery(this).is(':checked')) { window.parent.inMenus.push(parseInt(jQuery(this).val())); } } if (updMenus < 0 ) { if (!jQuery(this).is(':checked')) { window.parent.inMenus.push(parseInt(jQuery(this).val())); } } }); if (updMenus == 0) { tmpMenu.html('<span class=\"label label-info\">" . JText::_('JALL') . "</span>'); if (tmpRow.hasClass('no')) { tmpRow.removeClass('no '); } } if (updMenus == '-') { tmpMenu.html('<span class=\"label label-important\">" . JText::_('JNO') . "</span>'); if (!tmpRow.hasClass('no') || tmpRow.hasClass('')) { tmpRow.addClass('no '); } } if (updMenus > 0) { if (window.parent.inMenus.indexOf(parent.menuId) >= 0) { if (window.parent.numMenus == window.parent.inMenus.length) { tmpMenu.html('<span class=\"label label-info\">" . JText::_('JALL') . "</span>'); if (tmpRow.hasClass('no') || tmpRow.hasClass('')) { tmpRow.removeClass('no'); } } else { tmpMenu.html('<span class=\"label label-success\">" . JText::_('JYES') . "</span>'); if (tmpRow.hasClass('no')) { tmpRow.removeClass('no'); } } } if (window.parent.inMenus.indexOf(parent.menuId) < 0) { tmpMenu.html('<span class=\"label label-important\">" . JText::_('JNO') . "</span>'); if (!tmpRow.hasClass('no')) { tmpRow.addClass('no'); } } } if (updMenus < 0) { if (window.parent.inMenus.indexOf(parent.menuId) >= 0) { if (window.parent.numMenus == window.parent.inMenus.length) { tmpMenu.html('<span class=\"label label-info\">" . JText::_('JALL') . "</span>'); if (tmpRow.hasClass('no')) { tmpRow.removeClass('no'); } } else { tmpMenu.html('<span class=\"label label-success\">" . JText::_('JYES') . "</span>'); if (tmpRow.hasClass('no')) { tmpRow.removeClass('no'); } } } if (window.parent.inMenus.indexOf(parent.menuId) < 0) { tmpMenu.html('<span class=\"label label-important\">" . JText::_('JNO') . "</span>'); if (!tmpRow.hasClass('no') || tmpRow.hasClass('')) { tmpRow.addClass('no'); } } } if (updStatus == 1) { tmpStatus.html('<span class=\"label label-success\">" . JText::_('JYES') . "</span>'); if (tmpRow.hasClass('unpublished')) { tmpRow.removeClass('unpublished '); } } if (updStatus == 0) { tmpStatus.html('<span class=\"label label-important\">" . JText::_('JNO') . "</span>'); if (!tmpRow.hasClass('unpublished') || tmpRow.hasClass('')) { tmpRow.addClass('unpublished'); } } if (updStatus == -2) { tmpStatus.html('<span class=\"label label-default\">" . JText::_('JTRASHED') . "</span>'); if (!tmpRow.hasClass('unpublished') || tmpRow.hasClass('')) { tmpRow.addClass('unpublished'); } } if (document.formvalidator.isValid(document.getElementById('module-form'))) { jQuery('#title-" . $this->item->id . "', parent.document).text(updTitle); jQuery('#position-" . $this->item->id . "', parent.document).text(updPosition); jQuery('#access-" . $this->item->id . "', parent.document).html(parent.viewLevels[updAccess]); } } } if (task !== 'module.apply') { window.parent.jQuery('#module" . ((int) $this->item->id == 0 ? 'Add' : 'Edit' . (int) $this->item->id) . "Modal').modal('hide'); } } };"; JFactory::getDocument()->addScriptDeclaration($script); $input = JFactory::getApplication()->input; // In case of modal $isModal = $input->get('layout') == 'modal' ? true : false; $layout = $isModal ? 'modal' : 'edit'; $tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : ''; ?> <form action="<?php echo JRoute::_('index.php?option=com_modules&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="module-form" class="form-validate"> <?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?> <div class="form-horizontal"> <?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'general')); ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'general', JText::_('COM_MODULES_MODULE')); ?> <div class="row-fluid"> <div class="span9"> <?php if ($this->item->xml) : ?> <?php if ($this->item->xml->description) : ?> <h2> <?php if ($this->item->xml) { echo ($text = (string) $this->item->xml->name) ? JText::_($text) : $this->item->module; } else { echo JText::_('COM_MODULES_ERR_XML'); } ?> </h2> <div class="info-labels"> <span class="label hasTooltip" title="<?php echo JHtml::_('tooltipText', 'COM_MODULES_FIELD_CLIENT_ID_LABEL'); ?>"> <?php echo $this->item->client_id == 0 ? JText::_('JSITE') : JText::_('JADMINISTRATOR'); ?> </span> </div> <div> <?php $short_description = JText::_($this->item->xml->description); $this->fieldset = 'description'; $long_description = JLayoutHelper::render('joomla.edit.fieldset', $this); if (!$long_description) { $truncated = JHtml::_('string.truncate', $short_description, 550, true, false); if (strlen($truncated) > 500) { $long_description = $short_description; $short_description = JHtml::_('string.truncate', $truncated, 250); if ($short_description == $long_description) { $long_description = ''; } } } ?> <p><?php echo $short_description; ?></p> <?php if ($long_description) : ?> <p class="readmore"> <a href="#" onclick="jQuery('.nav-tabs a[href=\'#description\']').tab('show');"> <?php echo JText::_('JGLOBAL_SHOW_FULL_DESCRIPTION'); ?> </a> </p> <?php endif; ?> </div> <?php endif; ?> <?php else : ?> <div class="alert alert-error"><?php echo JText::_('COM_MODULES_ERR_XML'); ?></div> <?php endif; ?> <?php if ($hasContent) { echo $this->form->getInput($hasContentFieldName); } $this->fieldset = 'basic'; $html = JLayoutHelper::render('joomla.edit.fieldset', $this); echo $html ? '<hr />' . $html : ''; ?> </div> <div class="span3"> <fieldset class="form-vertical"> <?php echo $this->form->renderField('showtitle'); ?> <div class="control-group"> <div class="control-label"> <?php echo $this->form->getLabel('position'); ?> </div> <div class="controls"> <?php echo $this->loadTemplate('positions'); ?> </div> </div> </fieldset> <?php // Set main fields. $this->fields = array( 'published', 'publish_up', 'publish_down', 'access', 'ordering', 'language', 'note' ); ?> <?php echo JLayoutHelper::render('joomla.edit.global', $this); ?> </div> </div> <?php echo JHtml::_('bootstrap.endTab'); ?> <?php if (isset($long_description) && $long_description != '') : ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'description', JText::_('JGLOBAL_FIELDSET_DESCRIPTION')); ?> <?php echo $long_description; ?> <?php echo JHtml::_('bootstrap.endTab'); ?> <?php endif; ?> <?php if ($this->item->client_id == 0) : ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'assignment', JText::_('COM_MODULES_MENU_ASSIGNMENT')); ?> <?php echo $this->loadTemplate('assignment'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?> <?php endif; ?> <?php $this->fieldsets = array(); $this->ignore_fieldsets = array('basic', 'description'); echo JLayoutHelper::render('joomla.edit.params', $this); ?> <?php if ($this->canDo->get('core.admin')) : ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'permissions', JText::_('COM_MODULES_FIELDSET_RULES')); ?> <?php echo $this->form->getInput('rules'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?> <?php endif; ?> <?php echo JHtml::_('bootstrap.endTabSet'); ?> <input type="hidden" name="task" value="" /> <?php echo JHtml::_('form.token'); ?> <?php echo $this->form->getInput('module'); ?> <?php echo $this->form->getInput('client_id'); ?> </div> </form> PK �|!]�J}�� � % views/module/tmpl/edit_assignment.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Initialise related data. JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); $menuTypes = MenusHelper::getMenuLinks(); JHtml::_('script', 'jui/treeselectmenu.jquery.min.js', array('version' => 'auto', 'relative' => true)); $script = " jQuery(document).ready(function() { menuHide(jQuery('#jform_assignment').val()); jQuery('#jform_assignment').change(function() { menuHide(jQuery(this).val()); }) }); function menuHide(val) { if (val == 0 || val == '-') { jQuery('#menuselect-group').hide(); } else { jQuery('#menuselect-group').show(); } } "; // Add the script to the document head JFactory::getDocument()->addScriptDeclaration($script); ?> <div class="control-group"> <label id="jform_menus-lbl" class="control-label" for="jform_menus"><?php echo JText::_('COM_MODULES_MODULE_ASSIGN'); ?></label> <div id="jform_menus" class="controls"> <select name="jform[assignment]" id="jform_assignment"> <?php echo JHtml::_('select.options', ModulesHelper::getAssignmentOptions($this->item->client_id), 'value', 'text', $this->item->assignment, true); ?> </select> </div> </div> <div id="menuselect-group" class="control-group"> <label id="jform_menuselect-lbl" class="control-label" for="jform_menuselect"><?php echo JText::_('JGLOBAL_MENU_SELECTION'); ?></label> <div id="jform_menuselect" class="controls"> <?php if (!empty($menuTypes)) : ?> <?php $id = 'jform_menuselect'; ?> <div class="well well-small"> <div class="form-inline"> <span class="small"><?php echo JText::_('JSELECT'); ?>: <a id="treeCheckAll" href="javascript://"><?php echo JText::_('JALL'); ?></a>, <a id="treeUncheckAll" href="javascript://"><?php echo JText::_('JNONE'); ?></a> </span> <span class="width-20">|</span> <span class="small"><?php echo JText::_('COM_MODULES_EXPAND'); ?>: <a id="treeExpandAll" href="javascript://"><?php echo JText::_('JALL'); ?></a>, <a id="treeCollapseAll" href="javascript://"><?php echo JText::_('JNONE'); ?></a> </span> <input type="text" id="treeselectfilter" name="treeselectfilter" class="input-medium search-query pull-right" size="16" autocomplete="off" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" aria-invalid="false" tabindex="-1"> </div> <div class="clearfix"></div> <hr class="hr-condensed" /> <ul class="treeselect"> <?php foreach ($menuTypes as &$type) : ?> <?php if (count($type->links)) : ?> <?php $prevlevel = 0; ?> <li> <div class="treeselect-item pull-left"> <label class="pull-left nav-header"><?php echo $type->title; ?></label></div> <?php foreach ($type->links as $i => $link) : ?> <?php if ($prevlevel < $link->level) { echo '<ul class="treeselect-sub">'; } elseif ($prevlevel > $link->level) { echo str_repeat('</li></ul>', $prevlevel - $link->level); } else { echo '</li>'; } $selected = 0; if ($this->item->assignment == 0) { $selected = 1; } elseif ($this->item->assignment < 0) { $selected = in_array(-$link->value, $this->item->assigned); } elseif ($this->item->assignment > 0) { $selected = in_array($link->value, $this->item->assigned); } ?> <li> <div class="treeselect-item pull-left"> <?php $uselessMenuItem = in_array($link->type, array('separator', 'heading', 'alias', 'url')); ?> <input type="checkbox" class="pull-left novalidate" name="jform[assigned][]" id="<?php echo $id . $link->value; ?>" value="<?php echo (int) $link->value; ?>"<?php echo $selected ? ' checked="checked"' : ''; echo $uselessMenuItem ? ' disabled="disabled"' : ''; ?> /> <label for="<?php echo $id . $link->value; ?>" class="pull-left"> <?php echo $link->text; ?> <span class="small"><?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($link->alias)); ?></span> <?php if (JLanguageMultilang::isEnabled() && $link->language != '' && $link->language != '*') : ?> <?php if ($link->language_image) : ?> <?php echo JHtml::_('image', 'mod_languages/' . $link->language_image . '.gif', $link->language_title, array('title' => $link->language_title), true); ?> <?php else : ?> <?php echo '<span class="label" title="' . $link->language_title . '">' . $link->language_sef . '</span>'; ?> <?php endif; ?> <?php endif; ?> <?php if ($link->published == 0) : ?> <?php echo ' <span class="label">' . JText::_('JUNPUBLISHED') . '</span>'; ?> <?php endif; ?> <?php if ($uselessMenuItem) : ?> <?php echo ' <span class="label">' . JText::_('COM_MODULES_MENU_ITEM_' . strtoupper($link->type)) . '</span>'; ?> <?php endif; ?> </label> </div> <?php if (!isset($type->links[$i + 1])) { echo str_repeat('</li></ul>', $link->level); } $prevlevel = $link->level; ?> <?php endforeach; ?> </li> <?php endif; ?> <?php endforeach; ?> </ul> <div id="noresultsfound" style="display:none;" class="alert alert-no-items"> <?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> </div> <div style="display:none;" id="treeselectmenu"> <div class="pull-left nav-hover treeselect-menu"> <div class="btn-group"> <a href="#" data-toggle="dropdown" class="dropdown-toggle btn btn-micro"> <span class="caret"></span> </a> <ul class="dropdown-menu"> <li class="nav-header"><?php echo JText::_('COM_MODULES_SUBITEMS'); ?></li> <li class="divider"></li> <li class=""><a class="checkall" href="javascript://"><span class="icon-checkbox" aria-hidden="true"></span> <?php echo JText::_('JSELECT'); ?></a> </li> <li><a class="uncheckall" href="javascript://"><span class="icon-checkbox-unchecked" aria-hidden="true"></span> <?php echo JText::_('COM_MODULES_DESELECT'); ?></a> </li> <div class="treeselect-menu-expand"> <li class="divider"></li> <li><a class="expandall" href="javascript://"><span class="icon-plus" aria-hidden="true"></span> <?php echo JText::_('COM_MODULES_EXPAND'); ?></a></li> <li><a class="collapseall" href="javascript://"><span class="icon-minus" aria-hidden="true"></span> <?php echo JText::_('COM_MODULES_COLLAPSE'); ?></a></li> </div> </ul> </div> </div> </div> </div> <?php endif; ?> </div> </div> PK �|!]G�XH views/module/tmpl/modal.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom')); ?> <button id="applyBtn" type="button" class="hidden" onclick="Joomla.submitbutton('module.apply');"></button> <button id="saveBtn" type="button" class="hidden" onclick="Joomla.submitbutton('module.save');"></button> <button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('module.cancel');"></button> <div class="container-popup"> <?php $this->setLayout('edit'); ?> <?php echo $this->loadTemplate(); ?> </div> PK �|!]X�q� � $ views/module/tmpl/edit_positions.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_modules * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php'); JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); $clientId = $this->item->client_id; $state = 1; $selectedPosition = $this->item->position; $positions = JHtml::_('modules.positions', $clientId, $state, $selectedPosition); // Add custom position to options $customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION'); // Build field $attr = array( 'id' => 'jform_position', 'list.select' => $this->item->position, 'list.attr' => 'class="chzn-custom-value" ' . 'data-custom_group_text="' . $customGroupText . '" ' . 'data-no_results_text="' . JText::_('COM_MODULES_ADD_CUSTOM_POSITION') . '" ' . 'data-placeholder="' . JText::_('COM_MODULES_TYPE_OR_SELECT_POSITION') . '" ' ); echo JHtml::_('select.groupedlist', $positions, 'jform[position]', $attr); PK �|!]��3�1 1 "