You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
<?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"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="bootstrap_size"
|
||||
type="integer"
|
||||
first="0"
|
||||
last="12"
|
||||
step="1"
|
||||
label="COM_MODULES_FIELD_BOOTSTRAP_SIZE_LABEL"
|
||||
description="COM_MODULES_FIELD_BOOTSTRAP_SIZE_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="header_tag"
|
||||
type="headertag"
|
||||
default="h3"
|
||||
label="COM_MODULES_FIELD_HEADER_TAG_LABEL"
|
||||
description="COM_MODULES_FIELD_HEADER_TAG_DESC"
|
||||
/>
|
||||
|
||||
<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>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
119
administrator/components/com_modules/models/forms/module.xml
Normal file
119
administrator/components/com_modules/models/forms/module.xml
Normal file
@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field name="id" type="text"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description="JGLOBAL_FIELD_ID_DESC"
|
||||
default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
|
||||
<field name="title" type="text"
|
||||
description="COM_MODULES_FIELD_TITLE_DESC"
|
||||
label="JGLOBAL_TITLE"
|
||||
maxlength="100"
|
||||
required="true"
|
||||
size="35"
|
||||
/>
|
||||
|
||||
<field name="note" type="text"
|
||||
description="COM_MODULES_FIELD_NOTE_DESC"
|
||||
label="COM_MODULES_FIELD_NOTE_LABEL"
|
||||
maxlength="100"
|
||||
size="35"
|
||||
/>
|
||||
|
||||
<field name="module" type="hidden"
|
||||
description="COM_MODULES_FIELD_MODULE_DESC"
|
||||
label="COM_MODULES_FIELD_MODULE_LABEL"
|
||||
readonly="readonly"
|
||||
size="20"
|
||||
/>
|
||||
|
||||
<field name="showtitle" type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="COM_MODULES_FIELD_SHOWTITLE_DESC"
|
||||
label="COM_MODULES_FIELD_SHOWTITLE_LABEL"
|
||||
size="1"
|
||||
>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
</field>
|
||||
|
||||
<field name="published" type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="COM_MODULES_FIELD_PUBLISHED_DESC"
|
||||
label="JSTATUS"
|
||||
size="1"
|
||||
>
|
||||
<option value="1">JPUBLISHED</option>
|
||||
<option value="0">JUNPUBLISHED</option>
|
||||
<option value="-2">JTRASHED</option>
|
||||
</field>
|
||||
|
||||
<field name="publish_up" type="calendar"
|
||||
description="COM_MODULES_FIELD_PUBLISH_UP_DESC"
|
||||
filter="user_utc"
|
||||
class="input-medium"
|
||||
format="%Y-%m-%d %H:%M:%S"
|
||||
label="COM_MODULES_FIELD_PUBLISH_UP_LABEL"
|
||||
size="22"
|
||||
/>
|
||||
|
||||
<field name="publish_down" type="calendar"
|
||||
description="COM_MODULES_FIELD_PUBLISH_DOWN_DESC"
|
||||
filter="user_utc"
|
||||
class="input-medium"
|
||||
format="%Y-%m-%d %H:%M:%S"
|
||||
label="COM_MODULES_FIELD_PUBLISH_DOWN_LABEL"
|
||||
size="22"
|
||||
/>
|
||||
|
||||
<field name="client_id" type="hidden"
|
||||
description="COM_MODULES_FIELD_CLIENT_ID_DESC"
|
||||
label="COM_MODULES_FIELD_CLIENT_ID_LABEL"
|
||||
readonly="true"
|
||||
size="1"
|
||||
/>
|
||||
|
||||
<field name="position" type="moduleposition"
|
||||
default=""
|
||||
description="COM_MODULES_FIELD_POSITION_DESC"
|
||||
label="COM_MODULES_FIELD_POSITION_LABEL"
|
||||
maxlength="50"
|
||||
/>
|
||||
|
||||
<field name="access" type="accesslevel"
|
||||
description="JFIELD_ACCESS_DESC"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
size="1"
|
||||
/>
|
||||
|
||||
<field name="ordering" type="moduleorder"
|
||||
description="JFIELD_ORDERING_DESC"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
/>
|
||||
|
||||
<field name="content" type="editor"
|
||||
buttons="true"
|
||||
class="inputbox"
|
||||
description="COM_MODULES_FIELD_CONTENT_DESC"
|
||||
filter="JComponentHelper::filterText"
|
||||
label="COM_MODULES_FIELD_CONTENT_LABEL"
|
||||
hide="readmore,pagebreak"
|
||||
/>
|
||||
|
||||
<field name="language" type="contentlanguage"
|
||||
description="JFIELD_MODULE_LANGUAGE_DESC"
|
||||
label="JFIELD_LANGUAGE_LABEL"
|
||||
>
|
||||
<option value="*">JALL</option>
|
||||
</field>
|
||||
|
||||
<field name="assignment" type="hidden" />
|
||||
|
||||
<field name="assigned" type="hidden" />
|
||||
</fieldset>
|
||||
</form>
|
1
administrator/components/com_modules/models/index.html
Normal file
1
administrator/components/com_modules/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1085
administrator/components/com_modules/models/module.php
Normal file
1085
administrator/components/com_modules/models/module.php
Normal file
File diff suppressed because it is too large
Load Diff
326
administrator/components/com_modules/models/modules.php
Normal file
326
administrator/components/com_modules/models/modules.php
Normal file
@ -0,0 +1,326 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Modules Component Module Model
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
* @since 1.5
|
||||
*/
|
||||
class ModulesModelModules extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array 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',
|
||||
'access', 'a.access', 'access_level',
|
||||
'ordering', 'a.ordering',
|
||||
'module', 'a.module',
|
||||
'language', 'a.language', 'language_title',
|
||||
'publish_up', 'a.publish_up',
|
||||
'publish_down', 'a.publish_down',
|
||||
'client_id', 'a.client_id',
|
||||
'position', 'a.position',
|
||||
'pages',
|
||||
'name', 'e.name',
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = JFactory::getApplication('administrator');
|
||||
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$accessId = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', null, 'int');
|
||||
$this->setState('filter.access', $accessId);
|
||||
|
||||
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
|
||||
$this->setState('filter.state', $state);
|
||||
|
||||
$position = $this->getUserStateFromRequest($this->context . '.filter.position', 'filter_position', '', 'string');
|
||||
$this->setState('filter.position', $position);
|
||||
|
||||
$module = $this->getUserStateFromRequest($this->context . '.filter.module', 'filter_module', '', 'string');
|
||||
$this->setState('filter.module', $module);
|
||||
|
||||
$clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', 0, 'int', false);
|
||||
$previousId = $app->getUserState($this->context . '.filter.client_id_previous', null);
|
||||
if ($previousId != $clientId || $previousId === null)
|
||||
{
|
||||
$this->getUserStateFromRequest($this->context . '.filter.client_id_previous', 'filter_client_id_previous', 0, 'int', true);
|
||||
$app->setUserState($this->context . '.filter.client_id_previous', $clientId);
|
||||
}
|
||||
$this->setState('filter.client_id', $clientId);
|
||||
|
||||
$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
|
||||
$this->setState('filter.language', $language);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_modules');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('position', '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 A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.access');
|
||||
$id .= ':' . $this->getState('filter.state');
|
||||
$id .= ':' . $this->getState('filter.position');
|
||||
$id .= ':' . $this->getState('filter.module');
|
||||
$id .= ':' . $this->getState('filter.client_id');
|
||||
$id .= ':' . $this->getState('filter.language');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object list
|
||||
*
|
||||
* @param string The query
|
||||
* @param int Offset
|
||||
* @param int The number of records
|
||||
* @return array
|
||||
*/
|
||||
protected function _getList($query, $limitstart = 0, $limit = 0)
|
||||
{
|
||||
$ordering = $this->getState('list.ordering', 'ordering');
|
||||
if (in_array($ordering, array('pages', 'name')))
|
||||
{
|
||||
$this->_db->setQuery($query);
|
||||
$result = $this->_db->loadObjectList();
|
||||
$this->translate($result);
|
||||
JArrayHelper::sortObjects($result, $ordering, $this->getState('list.direction') == 'desc' ? -1 : 1, true, true);
|
||||
$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 ? $limit : null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($ordering == 'ordering')
|
||||
{
|
||||
$query->order('a.position ASC');
|
||||
$ordering = 'a.ordering';
|
||||
}
|
||||
if ($ordering == 'language_title')
|
||||
{
|
||||
$ordering = 'l.title';
|
||||
}
|
||||
$query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
|
||||
if ($ordering == 'position')
|
||||
{
|
||||
$query->order('a.ordering ASC');
|
||||
}
|
||||
$result = parent::_getList($query, $limitstart, $limit);
|
||||
$this->translate($result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a list of objects
|
||||
*
|
||||
* @param array The array of objects
|
||||
* @return array The array of translated objects
|
||||
*/
|
||||
protected function translate(&$items)
|
||||
{
|
||||
$lang = JFactory::getLanguage();
|
||||
$client = $this->getState('filter.client_id') ? 'administrator' : 'site';
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$extension = $item->module;
|
||||
$source = constant('JPATH_' . strtoupper($client)) . "/modules/$extension";
|
||||
$lang->load("$extension.sys", constant('JPATH_' . strtoupper($client)), null, false, false)
|
||||
|| $lang->load("$extension.sys", $source, null, false, false)
|
||||
|| $lang->load("$extension.sys", constant('JPATH_' . strtoupper($client)), $lang->getDefault(), false, false)
|
||||
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
|
||||
$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()
|
||||
{
|
||||
// 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.id, a.title, a.note, a.position, a.module, a.language,' .
|
||||
'a.checked_out, a.checked_out_time, a.published+2*(e.enabled-1) as published, a.access, a.ordering, a.publish_up, a.publish_down'
|
||||
)
|
||||
);
|
||||
$query->from($db->quoteName('#__modules') . ' AS a');
|
||||
|
||||
// Join over the language
|
||||
$query->select('l.title AS language_title')
|
||||
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
|
||||
|
||||
// Join over the users for the checked out user.
|
||||
$query->select('uc.name AS editor')
|
||||
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
|
||||
|
||||
// Join over the asset groups.
|
||||
$query->select('ag.title AS access_level')
|
||||
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
|
||||
|
||||
// Join over the module menus
|
||||
$query->select('MIN(mm.menuid) AS pages')
|
||||
->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = a.id');
|
||||
|
||||
// Join over the extensions
|
||||
$query->select('e.name AS name')
|
||||
->join('LEFT', '#__extensions AS e ON e.element = a.module')
|
||||
->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, 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 access level.
|
||||
if ($access = $this->getState('filter.access'))
|
||||
{
|
||||
$query->where('a.access = ' . (int) $access);
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$state = $this->getState('filter.state');
|
||||
if (is_numeric($state))
|
||||
{
|
||||
$query->where('a.published = ' . (int) $state);
|
||||
}
|
||||
elseif ($state === '')
|
||||
{
|
||||
$query->where('(a.published IN (0, 1))');
|
||||
}
|
||||
|
||||
// Filter by position
|
||||
$position = $this->getState('filter.position');
|
||||
if ($position && $position != 'none')
|
||||
{
|
||||
$query->where('a.position = ' . $db->quote($position));
|
||||
}
|
||||
|
||||
elseif ($position == 'none')
|
||||
{
|
||||
$query->where('a.position = ' . $db->quote(''));
|
||||
}
|
||||
|
||||
// Filter by module
|
||||
$module = $this->getState('filter.module');
|
||||
if ($module)
|
||||
{
|
||||
$query->where('a.module = ' . $db->quote($module));
|
||||
}
|
||||
|
||||
// Filter by client.
|
||||
$clientId = $this->getState('filter.client_id');
|
||||
if (is_numeric($clientId))
|
||||
{
|
||||
$query->where('a.client_id = ' . (int) $clientId . ' AND e.client_id =' . (int) $clientId);
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search))
|
||||
{
|
||||
if (stripos($search, 'id:') === 0)
|
||||
{
|
||||
$query->where('a.id = ' . (int) substr($search, 3));
|
||||
}
|
||||
else
|
||||
{
|
||||
$search = $db->quote('%' . $db->escape($search, true) . '%');
|
||||
$query->where('(' . 'a.title LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
|
||||
}
|
||||
}
|
||||
|
||||
// Filter on the language.
|
||||
if ($language = $this->getState('filter.language'))
|
||||
{
|
||||
$query->where('a.language = ' . $db->quote($language));
|
||||
}
|
||||
|
||||
//echo nl2br(str_replace('#__','jos_',$query));
|
||||
return $query;
|
||||
}
|
||||
}
|
219
administrator/components/com_modules/models/positions.php
Normal file
219
administrator/components/com_modules/models/positions.php
Normal file
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Modules Component Positions Model
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
* @since 1.6
|
||||
*/
|
||||
class ModulesModelPositions extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array 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.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$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);
|
||||
|
||||
$clientId = $app->input->getInt('client_id', 0);
|
||||
$this->setState('filter.client_id', $clientId);
|
||||
|
||||
$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);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_modules');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('value', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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('filter.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)
|
||||
{
|
||||
$query->where('position LIKE '.$this->_db->quote('%'.$this->_db->escape($search, true).'%'));
|
||||
}
|
||||
|
||||
$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, false)
|
||||
|| $lang->load('tpl_'.$template->element.'.sys', $client->path.'/templates/'.$template->element, null, false, false)
|
||||
|| $lang->load('tpl_'.$template->element.'.sys', $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load('tpl_'.$template->element.'.sys', $client->path.'/templates/'.$template->element, $lang->getDefault(), false, false);
|
||||
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 ? $limit : null);
|
||||
}
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the total number of items.
|
||||
*
|
||||
* @return int The total number of items.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTotal()
|
||||
{
|
||||
if (!isset($this->total))
|
||||
{
|
||||
$this->getItems();
|
||||
}
|
||||
return $this->total;
|
||||
}
|
||||
}
|
153
administrator/components/com_modules/models/select.php
Normal file
153
administrator/components/com_modules/models/select.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Module model.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_modules
|
||||
* @since 1.6
|
||||
*/
|
||||
class ModulesModelSelect extends JModelList
|
||||
{
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = JFactory::getApplication('administrator');
|
||||
|
||||
// Load the filter state.
|
||||
$clientId = $app->getUserState('com_modules.modules.filter.client_id', 0);
|
||||
$this->setState('filter.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 A prefix for the store id.
|
||||
*
|
||||
* @return string A store id.
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.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('filter.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')));
|
||||
|
||||
//echo nl2br(str_replace('#__','jos_',$query));
|
||||
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('filter.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, false)
|
||||
|| $lang->load($item->module . '.sys', $client->path . '/modules/' . $item->module, null, false, false)
|
||||
|| $lang->load($item->module . '.sys', $client->path, $lang->getDefault(), false, false)
|
||||
|| $lang->load($item->module . '.sys', $client->path . '/modules/' . $item->module, $lang->getDefault(), false, false);
|
||||
$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 = JArrayHelper::sortObjects($items, 'name', 1, true, true);
|
||||
|
||||
// TODO: Use the cached XML from the extensions table?
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user