Source for file plugin.php
Documentation is available at plugin.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
* @package Joomla.Administrator
* @subpackage com_plugins
* @var string The help screen key for the module.
protected $helpKey =
'JHELP_EXTENSIONS_PLUGIN_MANAGER_EDIT';
* @var string The help screen base URL for the module.
* @var string The event to trigger after saving the data.
* @var string The event to trigger after before the data.
* 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
public function getForm($data =
array(), $loadData =
true)
// The folder and element vars are passed when saving the form.
$element =
$item->element;
// These variables are used to add data from the plugin XML files.
$this->setState('item.folder', $folder);
$this->setState('item.element', $element);
$form =
$this->loadForm('com_plugins.plugin', 'plugin', array('control' =>
'jform', 'load_data' =>
$loadData));
// Modify the form based on access controls.
// 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');
* Method to get the data that should be injected in the form.
* @return mixed The data for the form.
// Check the session for previously entered form 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]))
// Attempt to load the row.
$return =
$table->load($pk);
// Check for a table object error.
if ($return ===
false &&
$table->getError())
// Convert to the JObject before adding other data.
$properties =
$table->getProperties(1);
// Convert the params field to an array.
$registry->loadString($table->params);
$this->_cache[$pk]->params =
$registry->toArray();
$this->_cache[$pk]->xml =
null;
* 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())
* Auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
// Execute the parent method.
$pk =
$app->input->getInt('extension_id');
* @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.
protected function preprocessForm(JForm $form, $data, $group =
'content')
$folder =
$this->getState('item.folder');
$element =
$this->getState('item.element');
// Load the core and/or local language sys file(s) for the ordering field.
$query =
'SELECT element' .
' WHERE (type =' .
$db->quote('plugin').
'AND folder='.
$db->quote($folder) .
')';
$elements =
$db->loadColumn();
foreach ($elements as $elementa)
||
$lang->load('plg_'.
$folder.
'_'.
$elementa.
'.sys', JPATH_PLUGINS.
'/'.
$folder.
'/'.
$elementa, null, false, true);
if (empty($folder) ||
empty($element))
$app->redirect(JRoute::_('index.php?option=com_plugins&view=plugins', false));
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_PLUGINS.
'/'.
$folder.
'/'.
$element, null, false, true);
if (!$form->loadFile($formFile, false, '//config'))
throw
new Exception(JText::_('JERROR_LOADFILE_FAILED'));
// Attempt to load the xml file.
throw
new Exception(JText::_('JERROR_LOADFILE_FAILED'));
// Get the help data from the XML file if present.
$help =
$xml->xpath('/extension/help');
$helpKey =
trim((string)
$help[0]['key']);
$helpURL =
trim((string)
$help[0]['url']);
// 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.
$condition[] =
'type = '.
$this->_db->quote($table->type);
$condition[] =
'folder = '.
$this->_db->quote($table->folder);
* Override method to save the form data.
* @param array The form data.
* @return boolean True on success.
public function save($data)
// Load the extension plugin group.
$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.
return (object)
array('key' =>
$this->helpKey, 'url' =>
$this->helpURL);
* Custom clean cache method, plugins are cached in 2 places for different clients
protected function cleanCache($group =
null, $client_id =
0)
parent::cleanCache('com_plugins');
Documentation generated on Tue, 19 Nov 2013 15:10:44 +0100 by phpDocumentor 1.4.3