Skip to content

Commit

Permalink
Fix the plugins component to load config form from config.xml, if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Dec 10, 2013
1 parent 7c91a44 commit 87c6f3a
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions administrator/components/com_plugins/models/plugin.php
Expand Up @@ -153,14 +153,12 @@ public function getItem($pk = null)
$this->_cache[$pk]->params = $registry->toArray();

// Get the plugin XML.
$path = JPath::clean(JPATH_PLUGINS.'/'.$table->folder.'/'.$table->element.'/'.$table->element.'.xml');
$path = JPATH_PLUGINS.'/'.$table->folder.'/'.$table->element;
$installer = JInstaller::getInstance();
$installer->setPath('source', $path);

if (file_exists($path))
{
$this->_cache[$pk]->xml = simplexml_load_file($path);
} else {
$this->_cache[$pk]->xml = null;
}

$this->_cache[$pk]->xml = $installer->getManifest();
}

return $this->_cache[$pk];
Expand Down Expand Up @@ -234,29 +232,36 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
$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'));
}
$manifestPath = JPATH_PLUGINS . '/' . $folder . '/' . $element;
$installer = JInstaller::getInstance();
$installer->setPath('source', $manifestPath);

// Load the core and/or local language file(s).
$lang->load('plg_'.$folder.'_'.$element, JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load('plg_'.$folder.'_'.$element, JPATH_PLUGINS.'/'.$folder.'/'.$element, null, false, true);


if (!$xml = $installer->getManifest())
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}

// Get the plugin form from a config.xml file, if exists
$formFile = $manifestPath . '/config.xml';
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))
else
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
// Get the plugin form from the manifest file
if (!$form->load($xml, false, '//config'))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}

// Get the help data from the XML file if present.
Expand Down

0 comments on commit 87c6f3a

Please sign in to comment.