| Current Path : /home/digilove/public_html/41423/ |
| Current File : //home/digilove/public_html/41423/com_modules.tar |
models/forms/filter_modules.xml 0000644 00000005323 15234424504 0012722 0 ustar 00 <?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_modules/models/fields" />
<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="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>
</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>
controller.php 0000644 00000002175 15234424504 0007450 0 ustar 00 <?php
/**
* @package Joomla.Site
* @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;
/**
* Modules manager master display controller.
*
* @since 3.5
*/
class ModulesController extends JControllerLegacy
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
*
* @since 3.5
*/
public function __construct($config = array())
{
$this->input = JFactory::getApplication()->input;
// Modules frontpage Editor Module proxying:
if ($this->input->get('view') === 'modules' && $this->input->get('layout') === 'modal')
{
JHtml::_('stylesheet', 'system/adminlist.css', array('version' => 'auto', 'relative' => true));
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
}
parent::__construct($config);
}
}
modules.php 0000644 00000001707 15234424504 0006735 0 ustar 00 <?php
/**
* @package Joomla.Site
* @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;
// Load the required admin language files
$lang = JFactory::getLanguage();
$app = JFactory::getApplication();
$config = array();
$lang->load('com_modules', JPATH_ADMINISTRATOR);
if ($app->input->get('view') === 'modules' && $app->input->get('layout') === 'modal')
{
if (!JFactory::getUser()->authorise('core.create', 'com_modules'))
{
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');
return;
}
}
if ($app->input->get('task') === 'module.orderPosition')
{
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
}
// Trigger the controller
$controller = JControllerLegacy::getInstance('Modules', $config);
$controller->execute($app->input->get('task'));
$controller->redirect();
js/admin-modules-modal.js 0000644 00000003561 15234430060 0011350 0 ustar 00 /**
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
document.addEventListener('DOMContentLoaded', function() {
"use strict";
/** Get the elements **/
var modulesLinks = document.querySelectorAll('.js-module-insert'), i,
positionsLinks = document.querySelectorAll('.js-position-insert');
/** Assign listener for click event (for single module id insertion) **/
for (i= 0; modulesLinks.length > i; i++) {
modulesLinks[i].addEventListener('click', function(event) {
event.preventDefault();
var modid = event.target.getAttribute('data-module'),
editor = event.target.getAttribute('data-editor');
/** Use the API, if editor supports it **/
if (window.parent.Joomla && window.parent.Joomla.editors && window.parent.Joomla.editors.instances && window.parent.Joomla.editors.instances.hasOwnProperty(editor)) {
window.parent.Joomla.editors.instances[editor].replaceSelection("{loadmoduleid " + modid + "}")
} else {
window.parent.jInsertEditorText("{loadmoduleid " + modid + "}", editor);
}
window.parent.jModalClose();
});
}
/** Assign listener for click event (for position insertion) **/
for (i= 0; positionsLinks.length > i; i++) {
positionsLinks[i].addEventListener('click', function(event) {
event.preventDefault();
var position = event.target.getAttribute('data-position'),
editor = event.target.getAttribute('data-editor');
/** Use the API, if editor supports it **/
if (window.Joomla && window.Joomla.editors && Joomla.editors.instances && Joomla.editors.instances.hasOwnProperty(editor)) {
Joomla.editors.instances[editor].replaceSelection("{loadposition " + position + "}")
} else {
window.parent.jInsertEditorText("{loadposition " + position + "}", editor);
}
window.parent.jModalClose();
});
}
});
js/admin-modules-modal.min.js 0000644 00000002110 15234430060 0012117 0 ustar 00 document.addEventListener('DOMContentLoaded',function(){'use strict';var b,a=document.querySelectorAll('.js-module-insert'),c=document.querySelectorAll('.js-position-insert');for(b=0;a.length>b;b++)a[b].addEventListener('click',function(d){d.preventDefault();var e=d.target.getAttribute('data-module'),f=d.target.getAttribute('data-editor');window.parent.Joomla&&window.parent.Joomla.editors&&window.parent.Joomla.editors.instances&&window.parent.Joomla.editors.instances.hasOwnProperty(f)?window.parent.Joomla.editors.instances[f].replaceSelection('{loadmoduleid '+e+'}'):window.parent.jInsertEditorText('{loadmoduleid '+e+'}',f),window.parent.jModalClose()});for(b=0;c.length>b;b++)c[b].addEventListener('click',function(d){d.preventDefault();var e=d.target.getAttribute('data-position'),f=d.target.getAttribute('data-editor');window.Joomla&&window.Joomla.editors&&Joomla.editors.instances&&Joomla.editors.instances.hasOwnProperty(f)?Joomla.editors.instances[f].replaceSelection('{loadposition '+e+'}'):window.parent.jInsertEditorText('{loadposition '+e+'}',f),window.parent.jModalClose()})});
controllers/index.html 0000644 00000000037 15234574225 0011120 0 ustar 00 <!DOCTYPE html><title></title>
controllers/module.php 0000644 00000017235 15234574225 0011131 0 ustar 00 <?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;
/**
* Module controller class.
*
* @since 1.6
*/
class ModulesControllerModule extends JControllerForm
{
/**
* Override parent add method.
*
* @return mixed True if the record can be added, a JError object if not.
*
* @since 1.6
*/
public function add()
{
$app = JFactory::getApplication();
// Get the result of the parent method. If an error, just return it.
$result = parent::add();
if ($result instanceof Exception)
{
return $result;
}
// Look for the Extension ID.
$extensionId = $app->input->get('eid', 0, 'int');
if (empty($extensionId))
{
$redirectUrl = 'index.php?option=' . $this->option . '&view=' . $this->view_item . '&layout=edit';
$this->setRedirect(JRoute::_($redirectUrl, false));
return JError::raiseWarning(500, JText::_('COM_MODULES_ERROR_INVALID_EXTENSION'));
}
$app->setUserState('com_modules.add.module.extension_id', $extensionId);
$app->setUserState('com_modules.add.module.params', null);
// Parameters could be coming in for a new item, so let's set them.
$params = $app->input->get('params', array(), 'array');
$app->setUserState('com_modules.add.module.params', $params);
}
/**
* Override parent cancel method to reset the add module state.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return boolean True if access level checks pass, false otherwise.
*
* @since 1.6
*/
public function cancel($key = null)
{
$app = JFactory::getApplication();
$result = parent::cancel();
$app->setUserState('com_modules.add.module.extension_id', null);
$app->setUserState('com_modules.add.module.params', null);
return $result;
}
/**
* Override parent allowSave method.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowSave($data, $key = 'id')
{
// Use custom position if selected
if (isset($data['custom_position']))
{
if (empty($data['position']))
{
$data['position'] = $data['custom_position'];
}
unset($data['custom_position']);
}
return parent::allowSave($data, $key);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 3.2
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Initialise variables.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
// Zero record (id:0), return component edit permission by calling parent controller method
if (!$recordId)
{
return parent::allowEdit($data, $key);
}
// Check edit on the record asset (explicit or inherited)
if ($user->authorise('core.edit', 'com_modules.module.' . $recordId))
{
return true;
}
return false;
}
/**
* Method to run batch operations.
*
* @param string $model The model
*
* @return boolean True on success.
*
* @since 1.7
*/
public function batch($model = null)
{
$this->checkToken();
// Set the model
$model = $this->getModel('Module', '', array());
// Preset the redirect
$redirectUrl = 'index.php?option=com_modules&view=modules' . $this->getRedirectToListAppend();
$this->setRedirect(JRoute::_($redirectUrl, false));
return parent::batch($model);
}
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$app = JFactory::getApplication();
$task = $this->getTask();
switch ($task)
{
case 'save2new':
$app->setUserState('com_modules.add.module.extension_id', $model->getState('module.extension_id'));
break;
default:
$app->setUserState('com_modules.add.module.extension_id', null);
break;
}
$app->setUserState('com_modules.add.module.params', null);
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key
*
* @return boolean True if successful, false otherwise.
*/
public function save($key = null, $urlVar = null)
{
$this->checkToken();
if (JFactory::getDocument()->getType() == 'json')
{
$model = $this->getModel();
$data = $this->input->post->get('jform', array(), 'array');
$item = $model->getItem($this->input->get('id'));
$properties = $item->getProperties();
if (isset($data['params']))
{
unset($properties['params']);
}
// Replace changed properties
$data = array_replace_recursive($properties, $data);
if (!empty($data['assigned']))
{
$data['assigned'] = array_map('abs', $data['assigned']);
}
// Add new data to input before process by parent save()
$this->input->post->set('jform', $data);
// Add path of forms directory
JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/models/forms');
}
parent::save($key, $urlVar);
}
/**
* Method to get the other modules in the same position
*
* @return string The data for the Ajax request.
*
* @since 3.6.3
*/
public function orderPosition()
{
$app = JFactory::getApplication();
// Send json mime type.
$app->mimeType = 'application/json';
$app->setHeader('Content-Type', $app->mimeType . '; charset=' . $app->charSet);
$app->sendHeaders();
// Check if user token is valid.
if (!JSession::checkToken('get'))
{
$app->enqueueMessage(JText::_('JINVALID_TOKEN_NOTICE'), 'error');
echo new JResponseJson;
$app->close();
}
$jinput = $app->input;
$clientId = $jinput->getValue('client_id');
$position = $jinput->getValue('position');
$moduleId = $jinput->getValue('module_id');
// Access check.
if (!JFactory::getUser()->authorise('core.create', 'com_modules')
&& !JFactory::getUser()->authorise('core.edit.state', 'com_modules')
&& ($moduleId && !JFactory::getUser()->authorise('core.edit.state', 'com_modules.module.' . $moduleId)))
{
$app->enqueueMessage(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 'error');
echo new JResponseJson;
$app->close();
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('position, ordering, title')
->from('#__modules')
->where('client_id = ' . (int) $clientId . ' AND position = ' . $db->q($position))
->order('ordering');
$db->setQuery($query);
try
{
$orders = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return '';
}
$orders2 = array();
$n = count($orders);
if ($n > 0)
{
for ($i = 0, $n; $i < $n; $i++)
{
if (!isset($orders2[$orders[$i]->position]))
{
$orders2[$orders[$i]->position] = 0;
}
$orders2[$orders[$i]->position]++;
$ord = $orders2[$orders[$i]->position];
$title = JText::sprintf('COM_MODULES_OPTION_ORDER_POSITION', $ord, htmlspecialchars($orders[$i]->title, ENT_QUOTES, 'UTF-8'));
$html[] = $orders[$i]->position . ',' . $ord . ',' . $title;
}
}
else
{
$html[] = $position . ',' . 1 . ',' . JText::_('JNONE');
}
echo new JResponseJson($html);
$app->close();
}
}
controllers/modules.php 0000644 00000003121 15234574225 0011301 0 ustar 00 <?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;
/**
* Modules list controller class.
*
* @since 1.6
*/
class ModulesControllerModules extends JControllerAdmin
{
/**
* Method to clone an existing module.
*
* @return void
*
* @since 1.6
*/
public function duplicate()
{
// Check for request forgeries
$this->checkToken();
$pks = (array) $this->input->post->get('cid', array(), 'int');
// Remove zero values resulting from input filter
$pks = array_filter($pks);
try
{
if (empty($pks))
{
throw new Exception(JText::_('COM_MODULES_ERROR_NO_MODULES_SELECTED'));
}
$model = $this->getModel();
$model->duplicate($pks);
$this->setMessage(JText::plural('COM_MODULES_N_MODULES_DUPLICATED', count($pks)));
}
catch (Exception $e)
{
JError::raiseWarning(500, $e->getMessage());
}
$this->setRedirect('index.php?option=com_modules&view=modules');
}
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Module', $prefix = 'ModulesModel', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
}
helpers/html/index.html 0000644 00000000037 15234574225 0011160 0 ustar 00 <!DOCTYPE html><title></title>
helpers/html/modules.php 0000644 00000014162 15234574225 0011350 0 ustar 00 <?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;
use Joomla\Utilities\ArrayHelper;
/**
* JHtml module helper class.
*
* @since 1.6
*/
abstract class JHtmlModules
{
/**
* Builds an array of template options
*
* @param integer $clientId The client id.
* @param string $state The state of the template.
*
* @return array
*/
public static function templates($clientId = 0, $state = '')
{
$options = array();
$templates = ModulesHelper::getTemplates($clientId, $state);
foreach ($templates as $template)
{
$options[] = JHtml::_('select.option', $template->element, $template->name);
}
return $options;
}
/**
* Builds an array of template type options
*
* @return array
*/
public static function types()
{
$options = array();
$options[] = JHtml::_('select.option', 'user', 'COM_MODULES_OPTION_POSITION_USER_DEFINED');
$options[] = JHtml::_('select.option', 'template', 'COM_MODULES_OPTION_POSITION_TEMPLATE_DEFINED');
return $options;
}
/**
* Builds an array of template state options
*
* @return array
*/
public static function templateStates()
{
$options = array();
$options[] = JHtml::_('select.option', '1', 'JENABLED');
$options[] = JHtml::_('select.option', '0', 'JDISABLED');
return $options;
}
/**
* Returns a published state on a grid
*
* @param integer $value The state value.
* @param integer $i The row index
* @param boolean $enabled An optional setting for access control on the action.
* @param string $checkbox An optional prefix for checkboxes.
*
* @return string The Html code
*
* @see JHtmlJGrid::state
* @since 1.7.1
*/
public static function state($value, $i, $enabled = true, $checkbox = 'cb')
{
$states = array(
1 => array(
'unpublish',
'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
'COM_MODULES_HTML_UNPUBLISH_ENABLED',
'COM_MODULES_EXTENSION_PUBLISHED_ENABLED',
true,
'publish',
'publish',
),
0 => array(
'publish',
'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
'COM_MODULES_HTML_PUBLISH_ENABLED',
'COM_MODULES_EXTENSION_UNPUBLISHED_ENABLED',
true,
'unpublish',
'unpublish',
),
-1 => array(
'unpublish',
'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
'COM_MODULES_HTML_UNPUBLISH_DISABLED',
'COM_MODULES_EXTENSION_PUBLISHED_DISABLED',
true,
'warning',
'warning',
),
-2 => array(
'publish',
'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
'COM_MODULES_HTML_PUBLISH_DISABLED',
'COM_MODULES_EXTENSION_UNPUBLISHED_DISABLED',
true,
'unpublish',
'unpublish',
),
);
return JHtml::_('jgrid.state', $states, $value, $i, 'modules.', $enabled, true, $checkbox);
}
/**
* Display a batch widget for the module position selector.
*
* @param integer $clientId The client ID.
* @param integer $state The state of the module (enabled, unenabled, trashed).
* @param string $selectedPosition The currently selected position for the module.
*
* @return string The necessary positions for the widget.
*
* @since 2.5
*/
public static function positions($clientId, $state = 1, $selectedPosition = '')
{
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');
$templates = array_keys(ModulesHelper::getTemplates($clientId, $state));
$templateGroups = array();
// Add an empty value to be able to deselect a module position
$option = ModulesHelper::createOption();
$templateGroups[''] = ModulesHelper::createOptionGroup('', array($option));
// Add positions from templates
$isTemplatePosition = false;
foreach ($templates as $template)
{
$options = array();
$positions = TemplatesHelper::getPositions($clientId, $template);
if (is_array($positions))
{
foreach ($positions as $position)
{
$text = ModulesHelper::getTranslatedModulePosition($clientId, $template, $position) . ' [' . $position . ']';
$options[] = ModulesHelper::createOption($position, $text);
if (!$isTemplatePosition && $selectedPosition === $position)
{
$isTemplatePosition = true;
}
}
$options = ArrayHelper::sortObjects($options, 'text');
}
$templateGroups[$template] = ModulesHelper::createOptionGroup(ucfirst($template), $options);
}
// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');
$editPositions = true;
$customPositions = ModulesHelper::getPositions($clientId, $editPositions);
$templateGroups[$customGroupText] = ModulesHelper::createOptionGroup($customGroupText, $customPositions);
return $templateGroups;
}
/**
* Get a select with the batch action options
*
* @return void
*/
public static function batchOptions()
{
// Create the copy/move options.
$options = array(
JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')),
JHtml::_('select.option', 'm', JText::_('JLIB_HTML_BATCH_MOVE'))
);
echo JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm');
}
/**
* Method to get the field options.
*
* @param integer $clientId The client ID
*
* @return array The field option objects.
*
* @since 2.5
*/
public static function positionList($clientId = 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(position) as value')
->select('position as text')
->from($db->quoteName('#__modules'))
->where($db->quoteName('client_id') . ' = ' . (int) $clientId)
->order('position');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
// Pop the first item off the array if it's blank
if (count($options))
{
if (strlen($options[0]->text) < 1)
{
array_shift($options);
}
}
return $options;
}
}
helpers/index.html 0000644 00000000037 15234574225 0010214 0 ustar 00 <!DOCTYPE html><title></title>
helpers/modules.php 0000644 00000021446 15234574225 0010407 0 ustar 00 <?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;
/**
* Modules component helper.
*
* @since 1.6
*/
abstract class ModulesHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*/
public static function addSubmenu($vName)
{
// Not used in this component.
}
/**
* Gets a list of the actions that can be performed.
*
* @param integer $moduleId The module ID.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions($moduleId = 0)
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
if (empty($moduleId))
{
$result = JHelperContent::getActions('com_modules');
}
else
{
$result = JHelperContent::getActions('com_modules', 'module', $moduleId);
}
return $result;
}
/**
* Get a list of filter options for the state of a module.
*
* @return array An array of JHtmlOption elements.
*/
public static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '1', JText::_('JPUBLISHED'));
$options[] = JHtml::_('select.option', '0', JText::_('JUNPUBLISHED'));
$options[] = JHtml::_('select.option', '-2', JText::_('JTRASHED'));
$options[] = JHtml::_('select.option', '*', JText::_('JALL'));
return $options;
}
/**
* Get a list of filter options for the application clients.
*
* @return array An array of JHtmlOption elements.
*/
public static function getClientOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('JSITE'));
$options[] = JHtml::_('select.option', '1', JText::_('JADMINISTRATOR'));
return $options;
}
/**
* Get a list of modules positions
*
* @param integer $clientId Client ID
* @param boolean $editPositions Allow to edit the positions
*
* @return array A list of positions
*/
public static function getPositions($clientId, $editPositions = false)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(position)')
->from('#__modules')
->where($db->quoteName('client_id') . ' = ' . (int) $clientId)
->order('position');
$db->setQuery($query);
try
{
$positions = $db->loadColumn();
$positions = is_array($positions) ? $positions : array();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return;
}
// Build the list
$options = array();
foreach ($positions as $position)
{
if (!$position && !$editPositions)
{
$options[] = JHtml::_('select.option', 'none', JText::_('COM_MODULES_NONE'));
}
else
{
$options[] = JHtml::_('select.option', $position, $position);
}
}
return $options;
}
/**
* Return a list of templates
*
* @param integer $clientId Client ID
* @param string $state State
* @param string $template Template name
*
* @return array List of templates
*/
public static function getTemplates($clientId = 0, $state = '', $template = '')
{
$db = JFactory::getDbo();
// Get the database object and a new query object.
$query = $db->getQuery(true);
// Build the query.
$query->select('element, name, enabled')
->from('#__extensions')
->where('client_id = ' . (int) $clientId)
->where('type = ' . $db->quote('template'));
if ($state != '')
{
$query->where('enabled = ' . $db->quote($state));
}
if ($template != '')
{
$query->where('element = ' . $db->quote($template));
}
// Set the query and load the templates.
$db->setQuery($query);
$templates = $db->loadObjectList('element');
return $templates;
}
/**
* Get a list of the unique modules installed in the client application.
*
* @param int $clientId The client id.
*
* @return array Array of unique modules
*/
public static function getModules($clientId)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('element AS value, name AS text')
->from('#__extensions as e')
->where('e.client_id = ' . (int) $clientId)
->where('type = ' . $db->quote('module'))
->join('LEFT', '#__modules as m ON m.module=e.element AND m.client_id=e.client_id')
->where('m.module IS NOT NULL')
->group('element,name');
$db->setQuery($query);
$modules = $db->loadObjectList();
$lang = JFactory::getLanguage();
foreach ($modules as $i => $module)
{
$extension = $module->value;
$path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
$source = $path . "/modules/$extension";
$lang->load("$extension.sys", $path, null, false, true)
|| $lang->load("$extension.sys", $source, null, false, true);
$modules[$i]->text = JText::_($module->text);
}
$modules = ArrayHelper::sortObjects($modules, 'text', 1, true, true);
return $modules;
}
/**
* Get a list of the assignment options for modules to menus.
*
* @param int $clientId The client id.
*
* @return array
*/
public static function getAssignmentOptions($clientId)
{
$options = array();
$options[] = JHtml::_('select.option', '0', 'COM_MODULES_OPTION_MENU_ALL');
$options[] = JHtml::_('select.option', '-', 'COM_MODULES_OPTION_MENU_NONE');
if ($clientId == 0)
{
$options[] = JHtml::_('select.option', '1', 'COM_MODULES_OPTION_MENU_INCLUDE');
$options[] = JHtml::_('select.option', '-1', 'COM_MODULES_OPTION_MENU_EXCLUDE');
}
return $options;
}
/**
* Return a translated module position name
*
* @param integer $clientId Application client id 0: site | 1: admin
* @param string $template Template name
* @param string $position Position name
*
* @return string Return a translated position name
*
* @since 3.0
*/
public static function getTranslatedModulePosition($clientId, $template, $position)
{
// Template translation
$lang = JFactory::getLanguage();
$path = $clientId ? JPATH_ADMINISTRATOR : JPATH_SITE;
$loaded = $lang->getPaths('tpl_' . $template . '.sys');
// Only load the template's language file if it hasn't been already
if (!$loaded)
{
$lang->load('tpl_' . $template . '.sys', $path, null, false, false)
|| $lang->load('tpl_' . $template . '.sys', $path . '/templates/' . $template, null, false, false)
|| $lang->load('tpl_' . $template . '.sys', $path, $lang->getDefault(), false, false)
|| $lang->load('tpl_' . $template . '.sys', $path . '/templates/' . $template, $lang->getDefault(), false, false);
}
$langKey = strtoupper('TPL_' . $template . '_POSITION_' . $position);
$text = JText::_($langKey);
// Avoid untranslated strings
if (!self::isTranslatedText($langKey, $text))
{
// Modules component translation
$langKey = strtoupper('COM_MODULES_POSITION_' . $position);
$text = JText::_($langKey);
// Avoid untranslated strings
if (!self::isTranslatedText($langKey, $text))
{
// Try to humanize the position name
$text = ucfirst(preg_replace('/^' . $template . '\-/', '', $position));
$text = ucwords(str_replace(array('-', '_'), ' ', $text));
}
}
return $text;
}
/**
* Check if the string was translated
*
* @param string $langKey Language file text key
* @param string $text The "translated" text to be checked
*
* @return boolean Return true for translated text
*
* @since 3.0
*/
public static function isTranslatedText($langKey, $text)
{
return $text !== $langKey;
}
/**
* Create and return a new Option
*
* @param string $value The option value [optional]
* @param string $text The option text [optional]
*
* @return object The option as an object (stdClass instance)
*
* @since 3.0
*/
public static function createOption($value = '', $text = '')
{
if (empty($text))
{
$text = $value;
}
$option = new stdClass;
$option->value = $value;
$option->text = $text;
return $option;
}
/**
* Create and return a new Option Group
*
* @param string $label Value and label for group [optional]
* @param array $options Array of options to insert into group [optional]
*
* @return array Return the new group as an array
*
* @since 3.0
*/
public static function createOptionGroup($label = '', $options = array())
{
$group = array();
$group['value'] = $label;
$group['text'] = $label;
$group['items'] = $options;
return $group;
}
}
helpers/xml.php 0000644 00000002324 15234574225 0007531 0 ustar 00 <?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;
try
{
JLog::add('ModulesHelperXML is deprecated. Do not use.', JLog::WARNING, 'deprecated');
}
catch (RuntimeException $exception)
{
// Informational log only
}
/**
* Helper for parse XML module files
*
* @since 1.5
* @deprecated 3.2 Do not use.
*/
class ModulesHelperXML
{
/**
* Parse the module XML file
*
* @param array &$rows XML rows
*
* @return void
*
* @since 1.5
*
* @deprecated 3.2 Do not use.
*/
public function parseXMLModuleFile(&$rows)
{
foreach ($rows as $i => $row)
{
if ($row->module == '')
{
$rows[$i]->name = 'custom';
$rows[$i]->module = 'custom';
$rows[$i]->descrip = 'Custom created module, using Module Manager New function';
}
else
{
$data = JInstaller::parseXMLInstallFile($row->path . '/' . $row->file);
if ($data['type'] == 'module')
{
$rows[$i]->name = $data['name'];
$rows[$i]->descrip = $data['description'];
}
}
}
}
}
layouts/toolbar/cancelselect.php 0000644 00000000757 15234574225 0013066 0 ustar 00 <?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>
layouts/toolbar/index.html 0000644 00000000037 15234574225 0011714 0 ustar 00 <!DOCTYPE html><title></title>
layouts/toolbar/newmodule.php 0000644 00000001034 15234574225 0012425 0 ustar 00 <?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>
layouts/index.html 0000644 00000000037 15234574225 0010252 0 ustar 00 <!DOCTYPE html><title></title>
models/fields/modulesmodule.php 0000644 00000001701 15234574225 0012674 0 ustar 00 <?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);
}
}
models/fields/modulesposition.php 0000644 00000001711 15234574225 0013254 0 ustar 00 <?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);
}
}
models/forms/advanced.xml 0000644 00000002050 15234574225 0011452 0 ustar 00 <?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>
models/forms/filter_modulesadmin.xml 0000644 00000006601 15234574225 0013741 0 ustar 00 <?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>
models/forms/index.html 0000644 00000000037 15234574225 0011163 0 ustar 00 <!DOCTYPE html><title></title>
models/forms/module.xml 0000644 00000006371 15234574225 0011204 0 ustar 00 <?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>
models/forms/moduleadmin.xml 0000644 00000006375 15234574225 0012221 0 ustar 00 <?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>
models/index.html 0000644 00000000037 15234574225 0010035 0 ustar 00 <!DOCTYPE html><title></title>
models/module.php 0000644 00000066721 15234574225 0010052 0 ustar 00 <?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());
}
}
models/modules.php 0000644 00000032241 15234574225 0010223 0 ustar 00 <?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;
}
}
models/positions.php 0000644 00000014256 15234574225 0010610 0 ustar 00 <?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;
}
}
models/select.php 0000644 00000007674 15234574225 0010046 0 ustar 00 <?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;
}
}
views/module/tmpl/edit.php 0000644 00000025414 15234574225 0011617 0 ustar 00 <?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>
views/module/tmpl/edit_assignment.php 0000644 00000015315 15234574225 0014046 0 ustar 00 <?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>
views/module/tmpl/edit_options.php 0000644 00000002461 15234574225 0013367 0 ustar 00 <?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;
?>
<?php
echo JHtml::_('bootstrap.startAccordion', 'moduleOptions', array('active' => 'collapse0'));
$fieldSets = $this->form->getFieldsets('params');
$i = 0;
foreach ($fieldSets as $name => $fieldSet) :
$label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MODULES_' . $name . '_FIELDSET_LABEL';
$class = isset($fieldSet->class) && !empty($fieldSet->class) ? $fieldSet->class : '';
echo JHtml::_('bootstrap.addSlide', 'moduleOptions', JText::_($label), 'collapse' . ($i++), $class);
if (isset($fieldSet->description) && trim($fieldSet->description)) :
echo '<p class="tip">' . $this->escape(JText::_($fieldSet->description)) . '</p>';
endif;
?>
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach;
echo JHtml::_('bootstrap.endSlide');
endforeach;
echo JHtml::_('bootstrap.endAccordion');
views/module/tmpl/edit_positions.php 0000644 00000002223 15234574225 0013717 0 ustar 00 <?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);
views/module/tmpl/index.html 0000644 00000000037 15234574225 0012150 0 ustar 00 <!DOCTYPE html><title></title>
views/module/tmpl/modal.php 0000644 00000001415 15234574225 0011761 0 ustar 00 <?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>
views/module/index.html 0000644 00000000037 15234574225 0011174 0 ustar 00 <!DOCTYPE html><title></title>
views/module/view.html.php 0000644 00000005445 15234574225 0011635 0 ustar 00 <?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);
}
}
views/module/view.json.php 0000644 00000002030 15234574225 0011625 0 ustar 00 <?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;
}
}
views/modules/tmpl/default.php 0000644 00000022105 15234574225 0012473 0 ustar 00 <?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::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$clientId = (int) $this->state->get('client_id', 0);
$user = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = ($listOrder == 'a.ordering');
if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_modules&task=modules.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'moduleList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
$colSpan = $clientId === 1 ? 8 : 10;
?>
<form action="<?php echo JRoute::_('index.php?option=com_modules'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if ($this->total > 0) : ?>
<table class="table table-striped" id="moduleList">
<thead>
<tr>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="1%" class="nowrap center" style="min-width:55px">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="15%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'COM_MODULES_HEADING_POSITION', 'a.position', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_MODULES_HEADING_MODULE', 'name', $listDirn, $listOrder); ?>
</th>
<?php if ($clientId === 0) : ?>
<th width="10%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_MODULES_HEADING_PAGES', 'pages', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'ag.title', $listDirn, $listOrder); ?>
</th>
<?php if ($clientId === 0) : ?>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'l.title', $listDirn, $listOrder); ?>
</th>
<?php elseif ($clientId === 1 && JModuleHelper::isAdminMultilang()) : ?>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'a.language', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="<?php echo $colSpan; ?>">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$ordering = ($listOrder == 'a.ordering');
$canCreate = $user->authorise('core.create', 'com_modules');
$canEdit = $user->authorise('core.edit', 'com_modules.module.' . $item->id);
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id')|| $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_modules.module.' . $item->id) && $canCheckin;
?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->position ?: 'none'; ?>">
<td class="order nowrap center hidden-phone">
<?php
$iconClass = '';
if (!$canChange)
{
$iconClass = ' inactive';
}
elseif (!$saveOrder)
{
$iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::_('tooltipText', 'JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass; ?>">
<span class="icon-menu"></span>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order" />
<?php endif; ?>
</td>
<td class="center">
<?php if ($item->enabled > 0) : ?>
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
<?php endif; ?>
</td>
<td class="center">
<div class="btn-group">
<?php // Check if extension is enabled ?>
<?php if ($item->enabled > 0) : ?>
<?php echo JHtml::_('jgrid.published', $item->published, $i, 'modules.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
<?php // Create dropdown items and render the dropdown list.
if ($canCreate)
{
JHtml::_('actionsdropdown.duplicate', 'cb' . $i, 'modules');
}
if ($canChange)
{
JHtml::_('actionsdropdown.' . ((int) $item->published === -2 ? 'un' : '') . 'trash', 'cb' . $i, 'modules');
}
if ($canCreate || $canChange)
{
echo JHtml::_('actionsdropdown.render', $this->escape($item->title));
}
?>
<?php else : ?>
<?php // Extension is not enabled, show a message that indicates this. ?>
<button class="btn btn-micro hasTooltip" title="<?php echo JText::_('COM_MODULES_MSG_MANAGE_EXTENSION_DISABLED'); ?>">
<span class="icon-ban-circle" aria-hidden="true"></span>
</button>
<?php endif; ?>
</div>
</td>
<td class="has-context">
<div class="pull-left">
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'modules.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a class="hasTooltip" href="<?php echo JRoute::_('index.php?option=com_modules&task=module.edit&id=' . (int) $item->id); ?>" title="<?php echo JText::_('JACTION_EDIT'); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<?php if (!empty($item->note)) : ?>
<div class="small">
<?php echo JText::sprintf('JGLOBAL_LIST_NOTE', $this->escape($item->note)); ?>
</div>
<?php endif; ?>
</div>
</td>
<td class="small hidden-phone">
<?php if ($item->position) : ?>
<span class="label label-info">
<?php echo $item->position; ?>
</span>
<?php else : ?>
<span class="label">
<?php echo JText::_('JNONE'); ?>
</span>
<?php endif; ?>
</td>
<td class="small hidden-phone hidden-tablet">
<?php echo $item->name; ?>
</td>
<?php if ($clientId === 0) : ?>
<td class="small hidden-phone hidden-tablet">
<?php echo $item->pages; ?>
</td>
<?php endif; ?>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?>
</td>
<?php if ($clientId === 0) : ?>
<td class="small hidden-phone">
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td>
<?php elseif ($clientId === 1 && JModuleHelper::isAdminMultilang()) : ?>
<td class="small hidden-phone">
<?php if ($item->language == ''):?>
<?php echo JText::_('JUNDEFINED'); ?>
<?php elseif ($item->language == '*'):?>
<?php echo JText::alt('JALL', 'language'); ?>
<?php else:?>
<?php echo $this->escape($item->language); ?>
<?php endif; ?>
</td>
<?php endif; ?>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php // Load the batch processing form. ?>
<?php if ($user->authorise('core.create', 'com_modules')
&& $user->authorise('core.edit', 'com_modules')
&& $user->authorise('core.edit.state', 'com_modules')) : ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'collapseModal',
array(
'title' => JText::_('COM_MODULES_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer'),
),
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
views/modules/tmpl/default.xml 0000644 00000000320 15234574225 0012477 0 ustar 00 <?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_MODULES_MODULES_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_MODULES_MODULES_VIEW_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
views/modules/tmpl/default_batch_body.php 0000644 00000004616 15234574225 0014660 0 ustar 00 <?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;
$clientId = $this->state->get('client_id');
// Show only Module Positions of published Templates
$published = 1;
$positions = JHtml::_('modules.positions', $clientId, $published);
$positions['']['items'][] = ModulesHelper::createOption('nochange', JText::_('COM_MODULES_BATCH_POSITION_NOCHANGE'));
$positions['']['items'][] = ModulesHelper::createOption('noposition', JText::_('COM_MODULES_BATCH_POSITION_NOPOSITION'));
// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');
// Build field
$attr = array(
'id' => 'batch-position-id',
'list.attr' => 'class="chzn-custom-value input-xlarge" '
. 'data-custom_group_text="' . $customGroupText . '" '
. 'data-no_results_text="' . JText::_('COM_MODULES_ADD_CUSTOM_POSITION') . '" '
. 'data-placeholder="' . JText::_('COM_MODULES_TYPE_OR_SELECT_POSITION') . '" '
);
?>
<div class="container-fluid">
<p><?php echo JText::_('COM_MODULES_BATCH_TIP'); ?></p>
<div class="row-fluid">
<?php if ($clientId != 1) : ?>
<div class="control-group span6">
<div class="controls">
<?php echo JLayoutHelper::render('joomla.html.batch.language', array()); ?>
</div>
</div>
<?php elseif ($clientId == 1 && JModuleHelper::isAdminMultilang()) : ?>
<div class="control-group span6">
<div class="controls">
<?php echo JLayoutHelper::render('joomla.html.batch.adminlanguage', array()); ?>
</div>
</div>
<?php endif; ?>
<div class="control-group span6">
<div class="controls">
<?php echo JHtml::_('batch.access'); ?>
</div>
</div>
</div>
<div class="row-fluid">
<?php if ($published >= 0) : ?>
<div class="span6">
<div class="controls">
<label id="batch-choose-action-lbl" for="batch-choose-action">
<?php echo JText::_('COM_MODULES_BATCH_POSITION_LABEL'); ?>
</label>
<div id="batch-choose-action" class="control-group">
<?php echo JHtml::_('select.groupedlist', $positions, 'batch[position_id]', $attr); ?>
<div id="batch-copy-move" class="control-group radio">
<?php echo JHtml::_('modules.batchOptions'); ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
views/modules/tmpl/default_batch_footer.php 0000644 00000001277 15234574225 0015221 0 ustar 00 <?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;
?>
<button type="button" class="btn" onclick="document.getElementById('batch-position-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo JText::_('JCANCEL'); ?>
</button>
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('module.batch');return false;">
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
views/modules/tmpl/index.html 0000644 00000000037 15234574225 0012333 0 ustar 00 <!DOCTYPE html><title></title>
views/modules/tmpl/modal.php 0000644 00000012302 15234574225 0012141 0 ustar 00 <?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;
if (JFactory::getApplication()->isClient('site'))
{
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
}
// Load needed scripts
JHtml::_('behavior.core');
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
JHtml::_('bootstrap.popover', '.hasPopover', array('placement' => 'bottom'));
JHtml::_('formbehavior.chosen', 'select');
// Scripts for the modules xtd-button
JHtml::_('behavior.polyfill', array('event'), 'lt IE 9');
JHtml::_('script', 'com_modules/admin-modules-modal.min.js', array('version' => 'auto', 'relative' => true));
// Special case for the search field tooltip.
$searchFilterDesc = $this->filterForm->getFieldAttribute('search', 'description', null, 'filter');
JHtml::_('bootstrap.tooltip', '#filter_search', array('title' => JText::_($searchFilterDesc), 'placement' => 'bottom'));
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$editor = JFactory::getApplication()->input->get('editor', '', 'cmd');
$link = 'index.php?option=com_modules&view=modules&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
if (!empty($editor))
{
$link = 'index.php?option=com_modules&view=modules&layout=modal&tmpl=component&editor=' . $editor . '&' . JSession::getFormToken() . '=1';
}
?>
<div class="container-popup">
<form action="<?php echo JRoute::_($link); ?>" method="post" name="adminForm" id="adminForm">
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php if ($this->total > 0) : ?>
<table class="table table-striped" id="moduleList">
<thead>
<tr>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
</th>
<th class="title">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="15%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'COM_MODULES_HEADING_POSITION', 'a.position', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'COM_MODULES_HEADING_MODULE', 'name', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone hidden-tablet">
<?php echo JHtml::_('searchtools.sort', 'COM_MODULES_HEADING_PAGES', 'pages', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'ag.title', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'l.title', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="8">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$iconStates = array(
-2 => 'icon-trash',
0 => 'icon-unpublish',
1 => 'icon-publish',
2 => 'icon-archive',
);
foreach ($this->items as $i => $item) :
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<span class="<?php echo $iconStates[$this->escape($item->published)]; ?>" aria-hidden="true"></span>
</td>
<td class="has-context">
<a class="js-module-insert btn btn-small btn-block btn-success" href="#" data-module="<?php echo $item->id; ?>" data-editor="<?php echo $this->escape($editor); ?>">
<?php echo $this->escape($item->title); ?>
</a>
</td>
<td class="small hidden-phone">
<?php if ($item->position) : ?>
<a class="js-position-insert btn btn-small btn-block btn-warning" href="#" data-position="<?php echo $this->escape($item->position); ?>" data-editor="<?php echo $this->escape($editor); ?>"><?php echo $this->escape($item->position); ?></a>
<?php else : ?>
<span class="label"><?php echo JText::_('JNONE'); ?></span>
<?php endif; ?>
</td>
<td class="small hidden-phone">
<?php echo $item->name; ?>
</td>
<td class="small hidden-phone hidden-tablet">
<?php echo $item->pages; ?>
</td>
<td class="small hidden-phone">
<?php echo $this->escape($item->access_level); ?>
</td>
<td class="small hidden-phone">
<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="editor" value="<?php echo $editor; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>
views/modules/index.html 0000644 00000000037 15234574225 0011357 0 ustar 00 <!DOCTYPE html><title></title>
views/modules/view.html.php 0000644 00000015044 15234574225 0012014 0 ustar 00 <?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 class for a list of modules.
*
* @since 1.6
*/
class ModulesViewModules extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->total = $this->get('Total');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->clientId = $this->state->get('client_id');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// We do not need the Language filter when modules are not filtered
if ($this->clientId == 1 && !JModuleHelper::isAdminMultilang())
{
unset($this->activeFilters['language']);
$this->filterForm->removeField('language', 'filter');
}
// We don't need the toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
$this->addToolbar();
}
// If in modal layout.
else
{
// Client id selector should not exist.
$this->filterForm->removeField('client_id', '');
// If in the frontend state and language should not activate the search tools.
if (JFactory::getApplication()->isClient('site'))
{
unset($this->activeFilters['state']);
unset($this->activeFilters['language']);
}
}
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
return parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = JHelperContent::getActions('com_modules');
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolbar::getInstance('toolbar');
if ($state->get('client_id') == 1)
{
JToolbarHelper::title(JText::_('COM_MODULES_MANAGER_MODULES_ADMIN'), 'cube module');
}
else
{
JToolbarHelper::title(JText::_('COM_MODULES_MANAGER_MODULES_SITE'), 'cube module');
}
if ($canDo->get('core.create'))
{
// Instantiate a new JLayoutFile instance and render the layout
$layout = new JLayoutFile('toolbar.newmodule');
$bar->appendButton('Custom', $layout->render(array()), 'new');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('module.edit');
}
if ($canDo->get('core.create'))
{
JToolbarHelper::custom('modules.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true);
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::publish('modules.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('modules.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::checkin('modules.checkin');
}
// Add a batch button
if ($user->authorise('core.create', 'com_modules') && $user->authorise('core.edit', 'com_modules')
&& $user->authorise('core.edit.state', 'com_modules'))
{
JHtml::_('bootstrap.renderModal', 'collapseModal');
$title = JText::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button
$layout = new JLayoutFile('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'modules.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('modules.trash');
}
if ($canDo->get('core.admin'))
{
JToolbarHelper::preferences('com_modules');
}
JToolbarHelper::help('JHELP_EXTENSIONS_MODULE_MANAGER');
if (JHtmlSidebar::getEntries())
{
$this->sidebar = JHtmlSidebar::render();
}
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
$this->state = $this->get('State');
if ($this->state->get('client_id') == 0)
{
if ($this->getLayout() == 'default')
{
return array(
'ordering' => JText::_('JGRID_HEADING_ORDERING'),
'a.published' => JText::_('JSTATUS'),
'a.title' => JText::_('JGLOBAL_TITLE'),
'position' => JText::_('COM_MODULES_HEADING_POSITION'),
'name' => JText::_('COM_MODULES_HEADING_MODULE'),
'pages' => JText::_('COM_MODULES_HEADING_PAGES'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'language_title' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
return array(
'a.title' => JText::_('JGLOBAL_TITLE'),
'position' => JText::_('COM_MODULES_HEADING_POSITION'),
'name' => JText::_('COM_MODULES_HEADING_MODULE'),
'pages' => JText::_('COM_MODULES_HEADING_PAGES'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'language_title' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
else
{
if ($this->getLayout() == 'default')
{
return array(
'ordering' => JText::_('JGRID_HEADING_ORDERING'),
'a.published' => JText::_('JSTATUS'),
'a.title' => JText::_('JGLOBAL_TITLE'),
'position' => JText::_('COM_MODULES_HEADING_POSITION'),
'name' => JText::_('COM_MODULES_HEADING_MODULE'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
return array(
'a.title' => JText::_('JGLOBAL_TITLE'),
'position' => JText::_('COM_MODULES_HEADING_POSITION'),
'name' => JText::_('COM_MODULES_HEADING_MODULE'),
'a.access' => JText::_('JGRID_HEADING_ACCESS'),
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}
}
views/positions/tmpl/index.html 0000644 00000000037 15234574225 0012712 0 ustar 00 <!DOCTYPE html><title></title>
views/positions/tmpl/modal.php 0000644 00000010167 15234574225 0012527 0 ustar 00 <?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
*/
// @deprecated 4.0 without replacement only used in hathor
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('formbehavior.chosen', 'select');
$function = JFactory::getApplication()->input->getCmd('function', 'jSelectPosition');
$lang = JFactory::getLanguage();
$ordering = $this->escape($this->state->get('list.ordering'));
$direction = $this->escape($this->state->get('list.direction'));
$clientId = $this->state->get('client_id');
$state = $this->state->get('filter.state');
$template = $this->state->get('filter.template');
$type = $this->state->get('filter.type');
?>
<form action="<?php echo JRoute::_('index.php?option=com_modules&view=positions&layout=modal&tmpl=component&function=' . $function . '&client_id=' . $clientId); ?>" method="post" name="adminForm" id="adminForm">
<fieldset class="filter clearfix">
<div class="left">
<label for="filter_search">
<?php echo JText::_('JSEARCH_FILTER_LABEL'); ?>
</label>
<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" size="30" title="<?php echo JText::_('COM_MODULES_FILTER_SEARCH_DESC'); ?>" />
<button type="submit">
<?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
<button type="button" onclick="document.getElementById('filter_search').value='';this.form.submit();">
<?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
</div>
<div class="right">
<select name="filter_state" onchange="this.form.submit()">
<option value=""><?php echo JText::_('JOPTION_SELECT_PUBLISHED'); ?></option>
<?php echo JHtml::_('select.options', JHtml::_('modules.templateStates'), 'value', 'text', $state, true); ?>
</select>
<select name="filter_type" onchange="this.form.submit()">
<option value=""><?php echo JText::_('COM_MODULES_OPTION_SELECT_TYPE'); ?></option>
<?php echo JHtml::_('select.options', JHtml::_('modules.types'), 'value', 'text', $type, true); ?>
</select>
<select name="filter_template" onchange="this.form.submit()">
<option value=""><?php echo JText::_('JOPTION_SELECT_TEMPLATE'); ?></option>
<?php echo JHtml::_('select.options', JHtml::_('modules.templates', $clientId), 'value', 'text', $template, true); ?>
</select>
</div>
</fieldset>
<table class="adminlist">
<thead>
<tr>
<th class="title" width="20%">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'value', $direction, $ordering); ?>
</th>
<th>
<?php echo JHtml::_('grid.sort', 'COM_MODULES_HEADING_TEMPLATES', 'templates', $direction, $ordering); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php $i = 1; foreach ($this->items as $value => $templates) : ?>
<tr class="row<?php echo $i = 1 - $i; ?>">
<td>
<a class="pointer" onclick="if (window.parent) window.parent.<?php echo $function; ?>('<?php echo $value; ?>');"><?php echo $this->escape($value); ?></a>
</td>
<td>
<?php if (!empty($templates)) : ?>
<a class="pointer" onclick="if (window.parent) window.parent.<?php echo $function; ?>('<?php echo $value; ?>');">
<ul>
<?php foreach ($templates as $template => $label) : ?>
<li><?php echo $lang->hasKey($label) ? JText::sprintf('COM_MODULES_MODULE_TEMPLATE_POSITION', JText::_($template), JText::_($label)) : JText::_($template); ?></li>
<?php endforeach; ?>
</ul>
</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $ordering; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $direction; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
views/positions/index.html 0000644 00000000037 15234574225 0011736 0 ustar 00 <!DOCTYPE html><title></title>
views/positions/view.html.php 0000644 00000001761 15234574225 0012374 0 ustar 00 <?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
*/
// @deprecated 4.0 without replacement only used in hathor
defined('_JEXEC') or die;
/**
* View Module positions class.
*
* @since 1.6
*/
class ModulesViewPositions extends JViewLegacy
{
protected $items;
protected $pagination;
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->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
parent::display($tpl);
}
}
views/preview/tmpl/default.php 0000644 00000001534 15234574225 0012507 0 ustar 00 <?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
*/
// @deprecated 4.0 not used for a long time
defined('_JEXEC') or die;
JFactory::getDocument()->addScriptDeclaration(
'
var form = window.top.document.adminForm
var title = form.title.value;
var alltext = window.top.' . $this->editor->getContent('text') . ';
jQuery(document).ready(function() {
document.getElementById("td-title").innerHTML = title;
document.getElementById("td-text").innerHTML = alltext;
});'
);
?>
<table class="center" width="90%">
<tr>
<td class="contentheading" colspan="2" id="td-title"></td>
</tr>
<tr>
<td valign="top" height="90%" colspan="2" id="td-text"></td>
</tr>
</table>
views/preview/tmpl/index.html 0000644 00000000037 15234574225 0012344 0 ustar 00 <!DOCTYPE html><title></title>
views/preview/index.html 0000644 00000000037 15234574225 0011370 0 ustar 00 <!DOCTYPE html><title></title>
views/preview/view.html.php 0000644 00000001410 15234574225 0012015 0 ustar 00 <?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// @deprecated 4.0 not used for a long time
defined('_JEXEC') or die;
/**
* HTML View class for the Modules component
*
* @since 1.6
*/
class ModulesViewPreview extends JViewLegacy
{
/**
* 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)
{
$editor = JFactory::getConfig()->get('editor');
$this->editor = JEditor::getInstance($editor);
parent::display($tpl);
}
}
views/select/tmpl/default.php 0000644 00000002341 15234574225 0012302 0 ustar 00 <?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::_('bootstrap.popover');
$document = JFactory::getDocument();
?>
<h2><?php echo JText::_('COM_MODULES_TYPE_CHOOSE'); ?></h2>
<ul id="new-modules-list" class="list list-striped">
<?php foreach ($this->items as &$item) : ?>
<?php // Prepare variables for the link. ?>
<?php $link = 'index.php?option=com_modules&task=module.add&eid=' . $item->extension_id; ?>
<?php $name = $this->escape($item->name); ?>
<?php $desc = JHtml::_('string.truncate', $this->escape(strip_tags($item->desc)), 200); ?>
<?php $short_desc = JHtml::_('string.truncate', $this->escape(strip_tags($item->desc)), 90); ?>
<li>
<a href="<?php echo JRoute::_($link); ?>">
<strong><?php echo $name; ?></strong></a>
<small class="hasPopover" data-placement="right" title="<?php echo $name; ?>" data-content="<?php echo $desc; ?>"><?php echo $short_desc; ?></small>
</li>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
views/select/tmpl/index.html 0000644 00000000037 15234574225 0012142 0 ustar 00 <!DOCTYPE html><title></title>
views/select/index.html 0000644 00000000037 15234574225 0011166 0 ustar 00 <!DOCTYPE html><title></title>
views/select/view.html.php 0000644 00000003127 15234574225 0011622 0 ustar 00 <?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;
/**
* HTML View class for the Modules component
*
* @since 1.6
*/
class ModulesViewSelect extends JViewLegacy
{
protected $state;
protected $items;
/**
* 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)
{
$state = $this->get('State');
$items = $this->get('Items');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->state = &$state;
$this->items = &$items;
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$state = $this->get('State');
// Add page title
if ($state->get('client_id') == 1)
{
JToolbarHelper::title(JText::_('COM_MODULES_MANAGER_MODULES_ADMIN'), 'cube module');
}
else
{
JToolbarHelper::title(JText::_('COM_MODULES_MANAGER_MODULES_SITE'), 'cube module');
}
// Get the toolbar object instance
$bar = JToolbar::getInstance('toolbar');
// Instantiate a new JLayoutFile instance and render the layout
$layout = new JLayoutFile('toolbar.cancelselect');
$bar->appendButton('Custom', $layout->render(array()), 'new');
}
}
views/index.html 0000644 00000000037 15234574225 0007707 0 ustar 00 <!DOCTYPE html><title></title>
access.xml 0000644 00000002473 15234574225 0006546 0 ustar 00 <?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>