Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions administrator/components/com_installer/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
label="COM_INSTALLER_PREFERENCES_LABEL"
description="COM_INSTALLER_PREFERENCES_DESCRIPTION"
>
<field
name="show_jed_info"
type="radio"
label="COM_INSTALLER_SHOW_JED_INFORMATION_LABEL"
description="COM_INSTALLER_SHOW_JED_INFORMATION_DESC"
class="btn-group"
default="1">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="cachetimeout"
type="integer"
Expand All @@ -13,8 +25,7 @@
first="0"
last="24"
step="1"
default="6"
/>
default="6" />
</fieldset>
<fieldset
name="permissions"
Expand Down
88 changes: 69 additions & 19 deletions administrator/components/com_installer/models/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,60 @@ public function install()
JClientHelper::setCredentialsFromRequest('ftp');
$app = JFactory::getApplication();

switch ($app->input->getWord('installtype'))
// Load installer plugins for assistance if required:
JPluginHelper::importPlugin('installer');
$dispatcher = JEventDispatcher::getInstance();

$package = null;

// This event allows an input pre-treatment, a custom pre-packing or custom installation (e.g. from a JSON description)
$results = $dispatcher->trigger('onInstallerBeforeInstallation', array($this, &$package));

if (in_array(true, $results, true))
{
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you have a return true here for a return true from a plugin event? Typically in core, the only time a plugin alters processing is if there's a return false from the plugin in an error state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is a good reason: It's a 3 possible results case:

  • null: no change of program flow
  • false: interruption of program flow with error (means the plugin disallows normal execution)
  • true: interruption of program flow without error (means the plugin did all the remaining work, e.g. when a new installation method that is not in the normal installer is implemented in an installer-type plugin, e.g. install from a JSON-URL ;-) )

}
elseif (in_array(false, $results, true))
{
return false;
}

if ($package === null)
{
switch ($app->input->getWord('installtype'))
{
case 'folder':
// Remember the 'Install from Directory' path.
$app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory');
$package = $this->_getPackageFromFolder();
break;

case 'upload':
$package = $this->_getPackageFromUpload();
break;

case 'url':
$package = $this->_getPackageFromUrl();
break;

default:
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));

return false;
break;
}
}

// This event allows a custom installation of the package or a customization of the package:
$results = $dispatcher->trigger('onInstallerBeforeInstaller', array($this, &$package));

if (in_array(true, $results, true))
{
return true;
}
elseif (in_array(false, $results, true))
{
case 'folder':
// Remember the 'Install from Directory' path.
$app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory');
$package = $this->_getPackageFromFolder();
break;

case 'upload':
$package = $this->_getPackageFromUpload();
break;

case 'url':
$package = $this->_getPackageFromUrl();
break;

default:
$app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
return false;
break;
return false;
}

// Was the package unpacked?
Expand All @@ -120,6 +154,9 @@ public function install()
$result = true;
}

// This event allows a custom a post-flight:
$dispatcher->trigger('onInstallerAfterInstaller', array($this, &$package, $installer, &$result, &$msg));

// Set some model state values
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
Expand Down Expand Up @@ -255,6 +292,19 @@ protected function _getPackageFromUrl()
return false;
}

// Handle updater XML file case:
if (preg_match('/\.xml\s*$/', $url))
{
jimport('joomla.updater.update');
$update = new JUpdate;
$update->loadFromXML($url);
$package_url = trim($update->get('downloadurl', false)->_data);
if ($package_url)
{
$url = $package_url;
}
}

// Download the package at the URL given
$p_file = JInstallerHelper::downloadPackage($url);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defined('_JEXEC') or die;
?>
<script type="text/javascript">
Joomla.submitbutton = function(pressbutton)
Joomla.submitbutton = function()
{
var form = document.getElementById('adminForm');

Expand All @@ -20,12 +20,14 @@
}
else
{
jQuery('#loading').css('display', 'block');

form.installtype.value = 'upload';
form.submit();
}
}
};

Joomla.submitbutton3 = function(pressbutton)
Joomla.submitbutton3 = function()
{
var form = document.getElementById('adminForm');

Expand All @@ -35,12 +37,14 @@
}
else
{
jQuery('#loading').css('display', 'block');

form.installtype.value = 'folder';
form.submit();
}
}
};

Joomla.submitbutton4 = function(pressbutton)
Joomla.submitbutton4 = function()
{
var form = document.getElementById('adminForm');

Expand All @@ -50,13 +54,43 @@
}
else
{
jQuery('#loading').css('display', 'block');

form.installtype.value = 'url';
form.submit();
}
}
};

Joomla.submitbuttonInstallWebInstaller = function()
{
var form = document.getElementById('adminForm');

form.install_url.value = 'http://appscdn.joomla.org/webapps/jedapps/webinstaller.xml';

Joomla.submitbutton4();
};

// Add spindle-wheel for installations:
jQuery(document).ready(function($) {
var outerDiv = $('#installer-install');

$('<div id="loading"></div>')
.css("background", "rgba(255, 255, 255, .8) url('../media/jui/img/ajax-loader.gif') 50% 15% no-repeat")
.css("top", outerDiv.position().top - $(window).scrollTop())
.css("left", outerDiv.position().left - $(window).scrollLeft())
.css("width", outerDiv.width())
.css("height", outerDiv.height())
.css("position", "fixed")
.css("opacity", "0.80")
.css("-ms-filter", "progid:DXImageTransform.Microsoft.Alpha(Opacity = 80)")
.css("filter", "alpha(opacity = 80)")
.css("display", "none")
.appendTo(outerDiv);
});

</script>

<div id="installer-install">
<div id="installer-install" class="clearfix">
<form enctype="multipart/form-data" action="<?php echo JRoute::_('index.php?option=com_installer&view=install');?>" method="post" name="adminForm" id="adminForm" class="form-horizontal">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
Expand All @@ -70,15 +104,24 @@
<!-- Render messages set by extension install scripts here -->
<?php if ($this->showMessage) : ?>
<?php echo $this->loadTemplate('message'); ?>
<?php elseif ($this->showJedAndWebInstaller) : ?>
<div class="alert alert-info j-jed-message" style="margin-bottom: 40px; line-height: 2em; color:#333333;">
<a href="index.php?option=com_config&view=component&component=com_installer&path=&return=<?php echo urlencode(base64_encode(JUri::getInstance())); ?>" class="close" data-dismiss="alert">&times;</a>
<a href="http://extensions.joomla.org" target="_blank">Joomla Extension Directory</a>
now available with <a href="http://extensions.joomla.org" target="_blank">Install from Web</a> on this page:&nbsp;&nbsp;
<input class="btn" type="button" value="<?php echo JText::_('Add &quot;Install from Web&quot; tab'); ?>" onclick="Joomla.submitbuttonInstallWebInstaller()" />
</div>
<?php endif; ?>

<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'upload')); ?>

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'upload', JText::_('COM_INSTALLER_UPLOAD_PACKAGE_FILE', true)); ?>
<?php JEventDispatcher::getInstance()->trigger('onInstallerViewBeforeFirstTab', array('bootstrap')); ?>

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'upload', JText::_('COM_INSTALLER_UPLOAD_PACKAGE_FILE', true)); ?>
<fieldset class="uploadform">
<legend><?php echo JText::_('COM_INSTALLER_UPLOAD_PACKAGE_FILE'); ?></legend>
<legend><?php echo JText::_('COM_INSTALLER_UPLOAD_INSTALL_JOOMLA_EXTENSION'); ?></legend>
<div class="control-group">
<label for="install_package" class="control-label"><?php echo JText::_('COM_INSTALLER_PACKAGE_FILE'); ?></label>
<label for="install_package" class="control-label"><?php echo JText::_('COM_INSTALLER_EXTENSION_PACKAGE_FILE'); ?></label>
<div class="controls">
<input class="input_box" id="install_package" name="install_package" type="file" size="57" />
</div>
Expand Down Expand Up @@ -117,6 +160,9 @@
<input type="button" class="btn btn-primary" value="<?php echo JText::_('COM_INSTALLER_INSTALL_BUTTON'); ?>" onclick="Joomla.submitbutton4()" />
</div>
</fieldset>

<?php JEventDispatcher::getInstance()->trigger('onInstallerViewAfterLastTab', array('bootstrap')); ?>

<?php echo JHtml::_('bootstrap.endTab'); ?>

<?php if ($this->ftp) : ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public function display($tpl = null)
$this->paths = &$paths;
$this->state = &$state;

$this->showJedAndWebInstaller = JComponentHelper::getParams('com_installer')->get('show_jed_info', 1);

JPluginHelper::importPlugin('installer');

$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onInstallerBeforeDisplay', array(&$this->showJedAndWebInstaller, $this));

parent::display($tpl);
}

Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/en-GB.com_installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COM_INSTALLER_EXTENSION_DISABLE="Disable extension"
COM_INSTALLER_EXTENSION_DISABLED="Disabled extension"
COM_INSTALLER_EXTENSION_ENABLE="Enable extension"
COM_INSTALLER_EXTENSION_ENABLED="Enabled extension"
COM_INSTALLER_EXTENSION_PACKAGE_FILE="Extension package file"
COM_INSTALLER_EXTENSION_PROTECTED="Protected extension"
COM_INSTALLER_EXTENSION_PUBLISHED="Extension successfully enabled."
COM_INSTALLER_EXTENSION_UNPUBLISHED="Extension successfully disabled."
Expand Down Expand Up @@ -125,6 +126,8 @@ COM_INSTALLER_NO_INSTALL_TYPE_FOUND="No Install Type Found"
COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED="Package download failed: %s"
COM_INSTALLER_PACKAGE_FILE="Package File"
COM_INSTALLER_PURGED_UPDATES="Purged updates"
COM_INSTALLER_SHOW_JED_INFORMATION_LABEL="Show top information"
COM_INSTALLER_SHOW_JED_INFORMATION_DESC="This parameter allows to hide the information at the top of the installer page about the Joomla Extension Directory."
COM_INSTALLER_SUBMENU_DATABASE="Database"
COM_INSTALLER_SUBMENU_DISCOVER="Discover"
COM_INSTALLER_SUBMENU_INSTALL="Install"
Expand Down Expand Up @@ -165,6 +168,7 @@ COM_INSTALLER_UNINSTALL_ERROR="Error uninstalling %s."
COM_INSTALLER_UNINSTALL_LANGUAGE="A language should always have been installed as a package. <br />To uninstall a language, filter type by package and uninstall the package."
COM_INSTALLER_UNINSTALL_SUCCESS="Uninstalling %s was successful."
COM_INSTALLER_UPLOAD_AND_INSTALL="Upload &amp; Install"
COM_INSTALLER_UPLOAD_INSTALL_JOOMLA_EXTENSION="Upload & Install Joomla Extension"
COM_INSTALLER_UPLOAD_PACKAGE_FILE="Upload Package File"
COM_INSTALLER_VALUE_CLIENT_SELECT="- Select Location -"
COM_INSTALLER_VALUE_FOLDER_NONAPPLICABLE="N/A"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defined('_JEXEC') or die;
?>
<script type="text/javascript">
Joomla.submitbutton = function(pressbutton)
Joomla.submitbutton = function()
{
var form = document.getElementById('adminForm');

Expand All @@ -23,9 +23,9 @@
form.installtype.value = 'upload';
form.submit();
}
}
};

Joomla.submitbutton3 = function(pressbutton)
Joomla.submitbutton3 = function()
{
var form = document.getElementById('adminForm');

Expand All @@ -38,9 +38,9 @@
form.installtype.value = 'folder';
form.submit();
}
}
};

Joomla.submitbutton4 = function(pressbutton)
Joomla.submitbutton4 = function()
{
var form = document.getElementById('adminForm');

Expand All @@ -53,7 +53,16 @@
form.installtype.value = 'url';
form.submit();
}
}
};

Joomla.submitbuttonInstallWebInstaller = function()
{
var form = document.getElementById('adminForm');

form.install_url.value = 'http://appscdn.joomla.org/webapps/jedapps/webinstaller.xml';

Joomla.submitbutton4();
};
</script>

<form enctype="multipart/form-data" action="<?php echo JRoute::_('index.php?option=com_installer&view=install');?>" method="post" name="adminForm" id="adminForm">
Expand All @@ -65,10 +74,23 @@
<?php else : ?>
<div id="j-main-container">
<?php endif;?>

<?php if ($this->showJedAndWebInstaller && !$this->showMessage) : ?>
<div class="alert j-jed-message" style="margin-bottom: 20px; line-height: 2em; color:#333333; clear:both;">
<a href="index.php?option=com_config&view=component&component=com_installer&path=&return=<?php echo urlencode(base64_encode(JUri::getInstance())); ?>" class="close" data-dismiss="alert">&times;</a>
<a href="http://extensions.joomla.org" target="_blank">Joomla Extension Directory</a>
now available with <a href="http://extensions.joomla.org" target="_blank">Install from Web</a> on this page:&nbsp;&nbsp;
<input class="btn" type="button" value="<?php echo JText::_('Add &quot;Install from Web&quot; tab'); ?>" onclick="Joomla.submitbuttonInstallWebInstaller()" />
</div>
<?php endif; ?>

<?php if ($this->ftp) : ?>
<?php echo $this->loadTemplate('ftp'); ?>
<?php endif; ?>
<div class="width-70 fltlft">

<?php JEventDispatcher::getInstance()->trigger('onInstallerViewBeforeFirstTab', array('hathor')); ?>

<fieldset class="uploadform">
<legend><?php echo JText::_('COM_INSTALLER_UPLOAD_PACKAGE_FILE'); ?></legend>
<label for="install_package"><?php echo JText::_('COM_INSTALLER_PACKAGE_FILE'); ?></label>
Expand All @@ -88,6 +110,9 @@
<input type="text" id="install_url" name="install_url" class="input_box" size="70" value="http://" />
<input type="button" class="button" value="<?php echo JText::_('COM_INSTALLER_INSTALL_BUTTON'); ?>" onclick="Joomla.submitbutton4()" />
</fieldset>

<?php JEventDispatcher::getInstance()->trigger('onInstallerViewAfterLastTab', array('hathor')); ?>

<input type="hidden" name="type" value="" />
<input type="hidden" name="installtype" value="upload" />
<input type="hidden" name="task" value="install.install" />
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/installer/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function downloadPackage($url, $target = false)
}
elseif (200 != $response->code)
{
JLog::add(JText::_('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT'), JLog::WARNING, 'jerror');
JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_DOWNLOAD_SERVER_CONNECT', $response->code), JLog::WARNING, 'jerror');

return false;
}
Expand Down
Binary file added media/jui/img/ajax-loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.