Skip to content

Commit

Permalink
Updates com_modules 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 63697f0 commit d4eb6a5
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions administrator/components/com_modules/models/module.php
Expand Up @@ -798,16 +798,11 @@ public function getItem($pk = null)

// Get the module XML.
$client = JApplicationHelper::getClientInfo($table->client_id);
$path = JPath::clean($client->path . '/modules/' . $table->module . '/' . $table->module . '.xml');
$path = JPath::clean($client->path . '/modules/' . $table->module);

if (file_exists($path))
{
$this->_cache[$pk]->xml = simplexml_load_file($path);
}
else
{
$this->_cache[$pk]->xml = null;
}
$installer = JInstaller::getInstance();
$installer->setPath('source', $path);
$this->_cache[$pk]->xml = $installer->getManifest();
}

return $this->_cache[$pk];
Expand Down Expand Up @@ -876,23 +871,19 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
$clientId = $this->getState('item.client_id');
$module = $this->getState('item.module');

$client = JApplicationHelper::getClientInfo($clientId);
$formFile = JPath::clean($client->path . '/modules/' . $module . '/' . $module . '.xml');
$client = JApplicationHelper::getClientInfo($clientId);
$manifestPath = $client->path . '/modules/' . $module;
$installer = JInstaller::getInstance();
$installer->setPath('source', $manifestPath);

// Load the core and/or local language file(s).
$lang->load($module, $client->path, null, false, true)
|| $lang->load($module, $client->path . '/modules/' . $module, null, false, true);

if (file_exists($formFile))
if ($xml = $installer->getManifest())
{
// Get the module 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))
if (!$form->load($xml, false, '//config'))
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
Expand All @@ -909,6 +900,10 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
$this->helpURL = $helpURL ? $helpURL : $this->helpURL;
}
}
else
{
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}

// Load the default advanced params
JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_modules/models/forms');
Expand Down

0 comments on commit d4eb6a5

Please sign in to comment.