Skip to content

Commit

Permalink
Updates com_plugins to get the manifest from installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Anderson Grudtner Martins committed Dec 7, 2014
1 parent d4eb6a5 commit eacb480
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions administrator/components/com_plugins/models/plugin.php
Expand Up @@ -170,16 +170,11 @@ 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 @@ -262,28 +257,24 @@ 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');
$manifestPath = JPATH_PLUGINS . '/' . $folder . '/' . $element;

if (!file_exists($formFile))
{
throw new Exception(JText::sprintf('COM_PLUGINS_ERROR_FILE_NOT_FOUND', $element . '.xml'));
}
$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 (file_exists($formFile))
if ($xml = $installer->getManifest())
{
// Get the plugin form.
if (!$form->loadFile($formFile, false, '//config'))
if (!$form->load($xml, 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'));
}
Expand Down

0 comments on commit eacb480

Please sign in to comment.