You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_plugins
|
||||
*
|
||||
* @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('JPATH_BASE') or die;
|
||||
|
||||
/**
|
||||
* Supports an HTML select list of plugins
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_plugins
|
||||
* @since 1.6
|
||||
*/
|
||||
class JFormFieldOrdering extends JFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $type = 'Ordering';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$html = array();
|
||||
$attr = '';
|
||||
|
||||
// Initialize some field attributes.
|
||||
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
|
||||
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
|
||||
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
|
||||
|
||||
// Initialize JavaScript field attributes.
|
||||
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
|
||||
|
||||
// Get some field values from the form.
|
||||
$pluginId = (int) $this->form->getValue('extension_id');
|
||||
$folder = $this->form->getValue('folder');
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Build the query for the ordering list.
|
||||
$query = 'SELECT ordering AS value, name AS text, type AS type, folder AS folder, extension_id AS extension_id' .
|
||||
' FROM #__extensions' .
|
||||
' WHERE (type =' .$db->quote('plugin'). 'AND folder='. $db->quote($folder) . ')'.
|
||||
' ORDER BY ordering';
|
||||
|
||||
// Create a read-only list (no name) with a hidden input to store the value.
|
||||
if ((string) $this->element['readonly'] == 'true')
|
||||
{
|
||||
$html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $pluginId ? 0 : 1);
|
||||
$html[] = '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'"/>';
|
||||
}
|
||||
// Create a regular list.
|
||||
else {
|
||||
$html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $pluginId ? 0 : 1);
|
||||
}
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
65
administrator/components/com_plugins/models/forms/plugin.xml
Normal file
65
administrator/components/com_plugins/models/forms/plugin.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="extension_id"
|
||||
label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC"
|
||||
type="text"
|
||||
default="0"
|
||||
readonly="true"
|
||||
class="readonly" />
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="hidden"
|
||||
label="COM_PLUGINS_FIELD_NAME_LABEL"
|
||||
description="COM_PLUGINS_FIELD_NAME_DESC" />
|
||||
|
||||
<field
|
||||
name="enabled"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
label="JSTATUS"
|
||||
description="COM_PLUGINS_FIELD_ENABLED_DESC"
|
||||
size="1"
|
||||
default="1">
|
||||
<option value="1">JENABLED</option>
|
||||
<option value="0">JDISABLED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="folder"
|
||||
type="text"
|
||||
class="readonly"
|
||||
size="20"
|
||||
label="COM_PLUGINS_FIELD_FOLDER_LABEL"
|
||||
description="COM_PLUGINS_FIELD_FOLDER_DESC"
|
||||
readonly="true" />
|
||||
|
||||
<field
|
||||
name="element"
|
||||
type="text"
|
||||
class="readonly"
|
||||
size="20"
|
||||
label="COM_PLUGINS_FIELD_ELEMENT_LABEL"
|
||||
description="COM_PLUGINS_FIELD_ELEMENT_DESC"
|
||||
readonly="true" />
|
||||
|
||||
<field
|
||||
name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
description="JFIELD_ACCESS_DESC"
|
||||
class="inputbox"
|
||||
size="1" />
|
||||
|
||||
<field
|
||||
name="ordering"
|
||||
type="ordering"
|
||||
class="inputbox"
|
||||
label="JFIELD_ORDERING_LABEL"
|
||||
description="JFIELD_ORDERING_DESC" />
|
||||
|
||||
</fieldset>
|
||||
</form>
|
1
administrator/components/com_plugins/models/index.html
Normal file
1
administrator/components/com_plugins/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
334
administrator/components/com_plugins/models/plugin.php
Normal file
334
administrator/components/com_plugins/models/plugin.php
Normal file
@ -0,0 +1,334 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_plugins
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Plugin model.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_plugins
|
||||
* @since 1.6
|
||||
*/
|
||||
class PluginsModelPlugin extends JModelAdmin
|
||||
{
|
||||
/**
|
||||
* @var string The help screen key for the module.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $helpKey = 'JHELP_EXTENSIONS_PLUGIN_MANAGER_EDIT';
|
||||
|
||||
/**
|
||||
* @var string The help screen base URL for the module.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $helpURL;
|
||||
|
||||
protected $_cache;
|
||||
|
||||
/**
|
||||
* @var string The event to trigger after saving the data.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $event_after_save = 'onExtensionAfterSave';
|
||||
|
||||
/**
|
||||
* @var string The event to trigger after before the data.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $event_before_save = 'onExtensionBeforeSave';
|
||||
|
||||
/**
|
||||
* 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();
|
||||
$folder = $item->folder;
|
||||
$element = $item->element;
|
||||
}
|
||||
else
|
||||
{
|
||||
$folder = JArrayHelper::getValue($data, 'folder', '', 'cmd');
|
||||
$element = JArrayHelper::getValue($data, 'element', '', 'cmd');
|
||||
}
|
||||
|
||||
// These variables are used to add data from the plugin XML files.
|
||||
$this->setState('item.folder', $folder);
|
||||
$this->setState('item.element', $element);
|
||||
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_plugins.plugin', 'plugin', array('control' => 'jform', 'load_data' => $loadData));
|
||||
if (empty($form))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Modify the form based on access controls.
|
||||
if (!$this->canEditState((object) $data))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
$form->setFieldAttribute('enabled', '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('enabled', '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()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$data = JFactory::getApplication()->getUserState('com_plugins.edit.plugin.data', array());
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
$this->preprocessData('com_plugins.plugin', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a single record.
|
||||
*
|
||||
* @param integer The id of the primary key.
|
||||
*
|
||||
* @return mixed Object on success, false on failure.
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('plugin.id');
|
||||
|
||||
if (!isset($this->_cache[$pk]))
|
||||
{
|
||||
$false = false;
|
||||
|
||||
// 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 && $table->getError())
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return $false;
|
||||
}
|
||||
|
||||
// Convert to the JObject before adding other data.
|
||||
$properties = $table->getProperties(1);
|
||||
$this->_cache[$pk] = JArrayHelper::toObject($properties, 'JObject');
|
||||
|
||||
// Convert the params field to an array.
|
||||
$registry = new JRegistry;
|
||||
$registry->loadString($table->params);
|
||||
$this->_cache[$pk]->params = $registry->toArray();
|
||||
|
||||
// Get the plugin XML.
|
||||
$path = JPath::clean(JPATH_PLUGINS.'/'.$table->folder.'/'.$table->element.'/'.$table->element.'.xml');
|
||||
|
||||
if (file_exists($path))
|
||||
{
|
||||
$this->_cache[$pk]->xml = simplexml_load_file($path);
|
||||
} else {
|
||||
$this->_cache[$pk]->xml = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_cache[$pk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the a Table object, always creating it.
|
||||
*
|
||||
* @param type The table type to instantiate
|
||||
* @param string A prefix for the table class name. Optional.
|
||||
* @param array Configuration array for model. Optional.
|
||||
* @return JTable A database object
|
||||
*/
|
||||
public function getTable($type = 'Extension', $prefix = 'JTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
// Execute the parent method.
|
||||
parent::populateState();
|
||||
|
||||
$app = JFactory::getApplication('administrator');
|
||||
|
||||
// Load the User state.
|
||||
$pk = $app->input->getInt('extension_id');
|
||||
$this->setState('plugin.id', $pk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object A form object.
|
||||
* @param mixed The data expected for the form.
|
||||
* @return mixed True if successful.
|
||||
* @throws Exception if there is an error in the form event.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function preprocessForm(JForm $form, $data, $group = 'content')
|
||||
{
|
||||
jimport('joomla.filesystem.path');
|
||||
|
||||
$folder = $this->getState('item.folder');
|
||||
$element = $this->getState('item.element');
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
// Load the core and/or local language sys file(s) for the ordering field.
|
||||
$db = JFactory::getDbo();
|
||||
$query = 'SELECT element' .
|
||||
' FROM #__extensions' .
|
||||
' WHERE (type =' .$db->quote('plugin'). 'AND folder='. $db->quote($folder) . ')';
|
||||
$db->setQuery($query);
|
||||
$elements = $db->loadColumn();
|
||||
|
||||
foreach ($elements as $elementa)
|
||||
{
|
||||
$lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_ADMINISTRATOR, null, false, false)
|
||||
|| $lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_PLUGINS.'/'.$folder.'/'.$elementa, null, false, false)
|
||||
|| $lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|
||||
|| $lang->load('plg_'.$folder.'_'.$elementa.'.sys', JPATH_PLUGINS.'/'.$folder.'/'.$elementa, $lang->getDefault(), false, false);
|
||||
}
|
||||
|
||||
if (empty($folder) || empty($element))
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$app->redirect(JRoute::_('index.php?option=com_plugins&view=plugins', false));
|
||||
}
|
||||
|
||||
$formFile = JPath::clean(JPATH_PLUGINS . '/' . $folder . '/' . $element . '/' . $element . '.xml');
|
||||
if (!file_exists($formFile))
|
||||
{
|
||||
throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $element . '.xml'));
|
||||
}
|
||||
|
||||
// Load the core and/or local language file(s).
|
||||
$lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, null, false, false)
|
||||
|| $lang->load('plg_'.$folder.'_'.$element, JPATH_PLUGINS.'/'.$folder.'/'.$element, null, false, false)
|
||||
|| $lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|
||||
|| $lang->load('plg_'.$folder.'_'.$element, JPATH_PLUGINS.'/'.$folder.'/'.$element, $lang->getDefault(), false, false);
|
||||
|
||||
if (file_exists($formFile))
|
||||
{
|
||||
// Get the plugin 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 ? $helpKey : $this->helpKey;
|
||||
$this->helpURL = $helpURL ? $helpURL : $this->helpURL;
|
||||
}
|
||||
|
||||
// Trigger the default form events.
|
||||
parent::preprocessForm($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* A protected method to get a set of ordering conditions.
|
||||
*
|
||||
* @param object 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[] = 'type = '. $this->_db->quote($table->type);
|
||||
$condition[] = 'folder = '. $this->_db->quote($table->folder);
|
||||
return $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override method to save the form data.
|
||||
*
|
||||
* @param array The form data.
|
||||
* @return boolean True on success.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
// Load the extension plugin group.
|
||||
JPluginHelper::importPlugin('extension');
|
||||
|
||||
// Setup type
|
||||
$data['type'] = 'plugin';
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom clean cache method, plugins are cached in 2 places for different clients
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function cleanCache($group = null, $client_id = 0)
|
||||
{
|
||||
parent::cleanCache('com_plugins');
|
||||
}
|
||||
}
|
260
administrator/components/com_plugins/models/plugins.php
Normal file
260
administrator/components/com_plugins/models/plugins.php
Normal file
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_plugins
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Methods supporting a list of plugin records.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_plugins
|
||||
* @since 1.6
|
||||
*/
|
||||
class PluginsModelPlugins 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(
|
||||
'extension_id', 'a.extension_id',
|
||||
'name', 'a.name',
|
||||
'folder', 'a.folder',
|
||||
'element', 'a.element',
|
||||
'checked_out', 'a.checked_out',
|
||||
'checked_out_time', 'a.checked_out_time',
|
||||
'state', 'a.state',
|
||||
'enabled', 'a.enabled',
|
||||
'access', 'a.access', 'access_level',
|
||||
'ordering', 'a.ordering',
|
||||
'client_id', 'a.client_id',
|
||||
);
|
||||
}
|
||||
|
||||
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 = null, $direction = null)
|
||||
{
|
||||
// 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.enabled', 'filter_enabled', '', 'string');
|
||||
$this->setState('filter.enabled', $state);
|
||||
|
||||
$folder = $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', null, 'cmd');
|
||||
$this->setState('filter.folder', $folder);
|
||||
|
||||
$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
|
||||
$this->setState('filter.language', $language);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_plugins');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('folder', '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.folder');
|
||||
$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)
|
||||
{
|
||||
$search = $this->getState('filter.search');
|
||||
$ordering = $this->getState('list.ordering', 'ordering');
|
||||
if ($ordering == 'name' || (!empty($search) && stripos($search, 'id:') !== 0))
|
||||
{
|
||||
$this->_db->setQuery($query);
|
||||
$result = $this->_db->loadObjectList();
|
||||
$this->translate($result);
|
||||
if (!empty($search))
|
||||
{
|
||||
foreach ($result as $i => $item)
|
||||
{
|
||||
if (!preg_match("/$search/i", $item->name))
|
||||
{
|
||||
unset($result[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$direction = ($this->getState('list.direction') == 'desc') ? -1 : 1;
|
||||
JArrayHelper::sortObjects($result, $ordering, $direction, 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.folder ASC');
|
||||
$ordering = 'a.ordering';
|
||||
}
|
||||
$query->order($this->_db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
|
||||
|
||||
if ($ordering == 'folder')
|
||||
{
|
||||
$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();
|
||||
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
$source = JPATH_PLUGINS . '/' . $item->folder . '/' . $item->element;
|
||||
$extension = 'plg_' . $item->folder . '_' . $item->element;
|
||||
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false)
|
||||
|| $lang->load($extension . '.sys', $source, null, false, false)
|
||||
|| $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|
||||
|| $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false);
|
||||
$item->name = JText::_($item->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, a.folder, a.checked_out, a.checked_out_time,' .
|
||||
' a.enabled, a.access, a.ordering'
|
||||
)
|
||||
)
|
||||
->from($db->quoteName('#__extensions') . ' AS a')
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
|
||||
|
||||
// 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');
|
||||
|
||||
// Filter by access level.
|
||||
if ($access = $this->getState('filter.access'))
|
||||
{
|
||||
$query->where('a.access = ' . (int) $access);
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$published = $this->getState('filter.enabled');
|
||||
if (is_numeric($published))
|
||||
{
|
||||
$query->where('a.enabled = ' . (int) $published);
|
||||
}
|
||||
elseif ($published === '')
|
||||
{
|
||||
$query->where('(a.enabled IN (0, 1))');
|
||||
}
|
||||
|
||||
// Filter by state
|
||||
$query->where('a.state >= 0');
|
||||
|
||||
// Filter by folder.
|
||||
if ($folder = $this->getState('filter.folder'))
|
||||
{
|
||||
$query->where('a.folder = ' . $db->quote($folder));
|
||||
}
|
||||
|
||||
// Filter by search in name or id
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search))
|
||||
{
|
||||
if (stripos($search, 'id:') === 0)
|
||||
{
|
||||
$query->where('a.extension_id = ' . (int) substr($search, 3));
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user