Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

JInstaller improvements/adjustments #777

Merged
merged 10 commits into from
Feb 1, 2012
2 changes: 1 addition & 1 deletion libraries/joomla/installer/adapters/language.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function _install($cname, $basePath, $clientId, &$element)
// Update function available or // Update function available or
// Update tag detected // Update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update')) if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
|| is_a($updateElement, 'JXMLElement')) || $updateElement)
{ {
return $this->update(); // transfer control to the update function return $this->update(); // transfer control to the update function
} }
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/installer/adapters/module.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function install()
// Update function available or // Update function available or
// Update tag detected // Update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update')) if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
|| is_a($updateElement, 'JXMLElement')) || $updateElement)
{ {
// Force this one // Force this one
$this->parent->setOverwrite(true); $this->parent->setOverwrite(true);
Expand Down
5 changes: 3 additions & 2 deletions libraries/joomla/installer/adapters/package.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public function install()
$package = JInstallerHelper::unpack($file); $package = JInstallerHelper::unpack($file);
} }
$tmpInstaller = new JInstaller; $tmpInstaller = new JInstaller;
if (!$tmpInstaller->install($package['dir'])) $installResult = $tmpInstaller->install($package['dir']);
if (!$installResult)
{ {
$this->parent->abort( $this->parent->abort(
JText::sprintf( JText::sprintf(
Expand All @@ -193,7 +194,7 @@ public function install()
{ {
$results[$i] = array( $results[$i] = array(
'name' => $tmpInstaller->manifest->name, 'name' => $tmpInstaller->manifest->name,
'result' => $tmpInstaller->install($package['dir']) 'result' => $installResult
); );
} }
$i++; $i++;
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/installer/adapters/plugin.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function install()
// Update function available or // Update function available or
// Update tag detected // Update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update')) if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
|| is_a($updateElement, 'JXMLElement')) || $updateElement)
{ {
// Force this one // Force this one
$this->parent->setOverwrite(true); $this->parent->setOverwrite(true);
Expand Down
38 changes: 30 additions & 8 deletions libraries/joomla/installer/adapters/template.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function loadLanguage($path = null)
*/ */
public function install() public function install()
{ {
// Get a database connector object
$db = $this->parent->getDbo();

$lang = JFactory::getLanguage(); $lang = JFactory::getLanguage();
$xml = $this->parent->getManifest(); $xml = $this->parent->getManifest();


Expand Down Expand Up @@ -109,13 +112,32 @@ public function install()
$this->set('name', $name); $this->set('name', $name);
$this->set('element', $element); $this->set('element', $element);


$db = $this->parent->getDbo(); // Check to see if a template by the same name is already installed.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->select($db->quoteName('extension_id')); $query->select($query->qn('extension_id'))->from($query->qn('#__extensions'));
$query->from($db->quoteName('#__extensions')); $query->where($query->qn('type') . ' = ' . $query->q('template'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('template')); $query->where($query->qn('element') . ' = ' . $query->q($element));
$query->where($db->quoteName('element') . ' = ' . $element); $db->setQuery($query);
$id = $db->loadResult();
try
{
$id = $db->loadResult();
}
catch (JDatabaseException $e)
{
// Install failed, roll back changes
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_ROLLBACK'), $e->getMessage());
return false;
}

// Legacy error handling switch based on the JError::$legacy switch.
// @deprecated 12.1
if (JError::$legacy && $db->getErrorNum())
{
// Install failed, roll back changes
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_TPL_INSTALL_ROLLBACK', $db->stderr(true)));
return false;
}


// Set the template root path // Set the template root path
$this->parent->setPath('extension_root', $basePath . '/templates/' . $element); $this->parent->setPath('extension_root', $basePath . '/templates/' . $element);
Expand All @@ -128,7 +150,7 @@ public function install()
// Update function available or // Update function available or
// Update tag detected // Update tag detected
if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update')) if ($this->parent->isUpgrade() || ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update'))
|| is_a($updateElement, 'JXMLElement')) || $updateElement)
{ {
// Force this one // Force this one
$this->parent->setOverwrite(true); $this->parent->setOverwrite(true);
Expand All @@ -146,7 +168,7 @@ public function install()
$this->parent $this->parent
->abort( ->abort(
JText::sprintf( JText::sprintf(
'JLIB_INSTALLER_ABORT_PLG_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route), 'JLIB_INSTALLER_ABORT_TPL_INSTALL_ANOTHER_TEMPLATE_USING_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route),
$this->parent->getPath('extension_root') $this->parent->getPath('extension_root')
) )
); );
Expand Down