Skip to content

Commit

Permalink
Moving HTML/JS output to a layout to allow template overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Hunziker committed May 26, 2016
1 parent 49e416a commit 4abda6a
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 89 deletions.
36 changes: 4 additions & 32 deletions plugins/installer/folderinstaller/folderinstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,14 @@ class PlgInstallerFolderInstaller extends JPlugin
*/
public function onInstallerAddInstallationTab()
{
$app = JFactory::getApplication('administrator');

$tab = array();
$tab['name'] = 'folder';
$tab['label'] = JText::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT');
$tab['content'] = '<legend>' . JText::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT') . '</legend>'
. '<div class="control-group">'
. '<label for="install_directory" class="control-label">' . JText::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT') . '</label>'
. '<div class="controls">'
. '<input type="text" id="install_directory" name="install_directory" class="span5 input_box" size="70" value="'
. $app->input->get('install_directory', $app->get('tmp_path')) . '" />'
. '</div>'
. '</div>'
. '<div class="form-actions">'
. '<input type="button" class="btn btn-primary" id="installbutton_directory"
value="' . JText::_('PLG_INSTALLER_FOLDERINSTALLER_BUTTON') . '" onclick="Joomla.submitbuttonfolder()" />'
. '</div>';

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbuttonfolder = function()
{
var form = document.getElementById("adminForm");
// do field validation
if (form.install_directory.value == "")
{
alert("' . JText::_('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH') . '");
}
else
{
jQuery("#loading").css("display", "block");
form.installtype.value = "folder"
form.submit();
}
};
');
// Render the input
ob_start();
include JPluginHelper::getLayoutPath('installer', 'folderinstaller');
$tab['content'] = ob_get_clean();

return $tab;
}
Expand Down
44 changes: 44 additions & 0 deletions plugins/installer/folderinstaller/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.folderinstaller
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

$app = JFactory::getApplication('administrator');

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbuttonfolder = function()
{
var form = document.getElementById("adminForm");
// do field validation
if (form.install_directory.value == "")
{
alert("' . JText::_('PLG_INSTALLER_FOLDERINSTALLER_NO_INSTALL_PATH') . '");
}
else
{
jQuery("#loading").css("display", "block");
form.installtype.value = "folder"
form.submit();
}
};
');
?>
<legend><?php echo JText::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT'); ?></legend>
<div class="control-group">
<label for="install_directory" class="control-label"><?php echo JText::_('PLG_INSTALLER_FOLDERINSTALLER_TEXT'); ?></label>
<div class="controls">
<input type="text" id="install_directory" name="install_directory" class="span5 input_box" size="70"
value="<?php echo $app->input->get('install_directory', $app->get('tmp_path')); ?>" />
</div>
</div>
<div class="form-actions">
<input type="button" class="btn btn-primary" id="installbutton_directory"
value="<?php echo JText::_('PLG_INSTALLER_FOLDERINSTALLER_BUTTON'); ?>" onclick="Joomla.submitbuttonfolder()" />
</div>
33 changes: 4 additions & 29 deletions plugins/installer/packageinstaller/packageinstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,11 @@ public function onInstallerAddInstallationTab()
$tab = array();
$tab['name'] = 'package';
$tab['label'] = JText::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_PACKAGE_FILE');
$tab['content'] = '<legend>' . JText::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_INSTALL_JOOMLA_EXTENSION') . '</legend>'
. '<div class="control-group">'
. '<label for="install_package" class="control-label">' . JText::_('PLG_INSTALLER_PACKAGEINSTALLER_EXTENSION_PACKAGE_FILE') . '</label>'
. '<div class="controls">'
. '<input class="input_box" id="install_package" name="install_package" type="file" size="57" />'
. '</div>'
. '</div>'
. '<div class="form-actions">'
. '<button class="btn btn-primary" type="button" id="installbutton_package" onclick="Joomla.submitbuttonpackage()">'
. JText::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_AND_INSTALL') . '</button>'
. '</div>';

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbuttonpackage = function()
{
var form = document.getElementById("adminForm");
// do field validation
if (form.install_package.value == "")
{
alert("' . JText::_('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE') . '");
}
else
{
jQuery("#loading").css("display", "block");
form.installtype.value = "upload"
form.submit();
}
};
');
// Render the input
ob_start();
include JPluginHelper::getLayoutPath('installer', 'packageinstaller');
$tab['content'] = ob_get_clean();

return $tab;
}
Expand Down
42 changes: 42 additions & 0 deletions plugins/installer/packageinstaller/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.packageinstaller
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbuttonpackage = function()
{
var form = document.getElementById("adminForm");
// do field validation
if (form.install_package.value == "")
{
alert("' . JText::_('PLG_INSTALLER_PACKAGEINSTALLER_NO_PACKAGE') . '");
}
else
{
jQuery("#loading").css("display", "block");
form.installtype.value = "upload"
form.submit();
}
};
');
?>
<legend><?php echo JText::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_INSTALL_JOOMLA_EXTENSION'); ?></legend>
<div class="control-group">
<label for="install_package" class="control-label"><?php echo JText::_('PLG_INSTALLER_PACKAGEINSTALLER_EXTENSION_PACKAGE_FILE'); ?></label>
<div class="controls">
<input class="input_box" id="install_package" name="install_package" type="file" size="57" />
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" type="button" id="installbutton_package" onclick="Joomla.submitbuttonpackage()">
<?php echo JText::_('PLG_INSTALLER_PACKAGEINSTALLER_UPLOAD_AND_INSTALL'); ?>
</button>
</div>
40 changes: 40 additions & 0 deletions plugins/installer/urlinstaller/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Installer.urlinstaller
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbuttonurl = function()
{
var form = document.getElementById("adminForm");
// do field validation
if (form.install_url.value == "" || form.install_url.value == "http://" || form.install_url.value == "https://") {
alert("' . JText::_('PLG_INSTALLER_URLINSTALLER_NO_URL', true) . '");
}
else
{
jQuery("#loading").css("display", "block");
form.installtype.value = "url"
form.submit();
}
};
');
?>
<legend><?php echo JText::_('PLG_INSTALLER_URLINSTALLER_TEXT'); ?></legend>
<div class="control-group">
<label for="install_url" class="control-label"><?php echo JText::_('PLG_INSTALLER_URLINSTALLER_TEXT'); ?></label>
<div class="controls">
<input type="text" id="install_url" name="install_url" class="span5 input_box" size="70" placeholder="https://"/>
</div>
</div>
<div class="form-actions">
<input type="button" class="btn btn-primary" id="installbutton_url"
value="<?php echo JText::_('PLG_INSTALLER_URLINSTALLER_BUTTON'); ?>" onclick="Joomla.submitbuttonurl()" />'
</div>
32 changes: 4 additions & 28 deletions plugins/installer/urlinstaller/urlinstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,11 @@ public function onInstallerAddInstallationTab()
$tab = array();
$tab['name'] = 'url';
$tab['label'] = JText::_('PLG_INSTALLER_URLINSTALLER_TEXT');
$tab['content'] = '<legend>' . JText::_('PLG_INSTALLER_URLINSTALLER_TEXT') . '</legend>'
. '<div class="control-group">'
. '<label for="install_url" class="control-label">' . JText::_('PLG_INSTALLER_URLINSTALLER_TEXT') . '</label>'
. '<div class="controls">'
. '<input type="text" id="install_url" name="install_url" class="span5 input_box" size="70" placeholder="https://"/>'
. '</div>'
. '</div>'
. '<div class="form-actions">'
. '<input type="button" class="btn btn-primary" id="installbutton_url" value="'
. JText::_('PLG_INSTALLER_URLINSTALLER_BUTTON') . '" onclick="Joomla.submitbuttonurl()" />'
. '</div>';

JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbuttonurl = function()
{
var form = document.getElementById("adminForm");
// do field validation
if (form.install_url.value == "" || form.install_url.value == "http://" || form.install_url.value == "https://") {
alert("' . JText::_('PLG_INSTALLER_URLINSTALLER_NO_URL', true) . '");
}
else
{
jQuery("#loading").css("display", "block");
form.installtype.value = "url"
form.submit();
}
};
');
// Render the input
ob_start();
include JPluginHelper::getLayoutPath('installer', 'urlinstaller');
$tab['content'] = ob_get_clean();

return $tab;
}
Expand Down

0 comments on commit 4abda6a

Please sign in to comment.