Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions installation/application/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public function dispatch()
// Register the document object with JFactory.
JFactory::$document = $document;

// Register our JHtml service
JHtml::getServiceRegistry()->register('installation', new InstallationHtmlHelper($this));

// Define component path.
define('JPATH_COMPONENT', JPATH_BASE);
define('JPATH_COMPONENT_SITE', JPATH_SITE);
Expand Down
38 changes: 29 additions & 9 deletions installation/html/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,34 @@
*/
class InstallationHtmlHelper
{
/**
* The active application
*
* @var InstallationApplicationWeb
* @since __DEPLOY_VERSION__
*/
private $application;

/**
* Service constructor
*
* @param InstallationApplicationWeb $application The active application
*
* @since __DEPLOY_VERSION__
*/
public function __construct(InstallationApplicationWeb $application)
{
$this->application = $application;
}

/**
* Method to generate the side bar.
*
* @return string Markup for the side bar.
*
* @since 1.6
*/
public static function stepbar()
public function stepbar()
{
// Determine if the configuration file path is writable.
$path = JPATH_CONFIGURATION . '/configuration.php';
Expand All @@ -44,7 +64,7 @@ public static function stepbar()

foreach ($tabs as $tab)
{
$html[] = static::getTab($tab, $tabs);
$html[] = $this->getTab($tab, $tabs);
}

$html[] = '</ul>';
Expand All @@ -59,7 +79,7 @@ public static function stepbar()
*
* @since 3.1
*/
public static function stepbarlanguages()
public function stepbarlanguages()
{
$tabs = array();
$tabs[] = 'languages';
Expand All @@ -71,7 +91,7 @@ public static function stepbarlanguages()

foreach ($tabs as $tab)
{
$html[] = static::getTab($tab, $tabs);
$html[] = $this->getTab($tab, $tabs);
}

$html[] = '</ul>';
Expand All @@ -89,11 +109,11 @@ public static function stepbarlanguages()
*
* @since 3.1
*/
private static function getTab($id, $tabs)
private function getTab($id, $tabs)
{
$input = JFactory::getApplication()->input;
$num = static::getTabNumber($id, $tabs);
$view = static::getTabNumber($input->getWord('view'), $tabs);
$input = $this->application->input;
$num = $this->getTabNumber($id, $tabs);
$view = $this->getTabNumber($input->getWord('view'), $tabs);
$tab = '<span class="badge badge-default">' . $num . '</span> ' . JText::_('INSTL_STEP_' . strtoupper($id) . '_LABEL');
$active = $num == $view ? ' active' : '';

Expand Down Expand Up @@ -123,7 +143,7 @@ private static function getTab($id, $tabs)
*
* @since 3.1
*/
private static function getTabNumber($id, $tabs)
private function getTabNumber($id, $tabs)
{
$num = (int) array_search($id, $tabs, true);
$num++;
Expand Down
2 changes: 1 addition & 1 deletion installation/view/database/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* @var InstallationViewDefault $this */
?>
<?php echo JHtml::_('InstallationHtml.helper.stepbar'); ?>
<?php echo JHtml::_('installation.stepbar'); ?>
<form action="index.php" method="post" id="adminForm" class="form-validate">
<div class="btn-toolbar justify-content-end">
<div class="btn-group">
Expand Down
2 changes: 1 addition & 1 deletion installation/view/defaultlanguage/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
JS
);
?>
<?php echo JHtml::_('InstallationHtml.helper.stepbarlanguages'); ?>
<?php echo JHtml::_('installation.stepbarlanguages'); ?>
<form action="index.php" method="post" id="adminForm" class="form-validate">
<div class="btn-toolbar justify-content-end">
<div class="btn-group">
Expand Down
2 changes: 1 addition & 1 deletion installation/view/ftp/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/* @var InstallationViewDefault $this */
?>
<?php echo JHtml::_('InstallationHtml.helper.stepbar'); ?>
<?php echo JHtml::_('installation.stepbar'); ?>
<form action="index.php" method="post" id="adminForm" class="form-validate">
<div class="btn-toolbar justify-content-end">
<div class="btn-group">
Expand Down
2 changes: 1 addition & 1 deletion installation/view/languages/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function installLanguages() {
}
</script>

<?php echo JHtml::_('InstallationHtml.helper.stepbarlanguages'); ?>
<?php echo JHtml::_('installation.stepbarlanguages'); ?>
<form action="index.php" method="post" id="adminForm" class="form-validate">
<div class="btn-toolbar justify-content-end">
<div class="btn-group">
Expand Down
2 changes: 1 addition & 1 deletion installation/view/site/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* @var InstallationViewDefault $this */
?>
<?php echo JHtml::_('InstallationHtml.helper.stepbar'); ?>
<?php echo JHtml::_('installation.stepbar'); ?>
<div class="btn-toolbar justify-content-end">
<div class="btn-group">
<a href="#" class="btn btn-primary" onclick="Install.submitform();" rel="next" title="<?php echo JText::_('JNEXT'); ?>"><span class="fa fa-arrow-right icon-white"></span> <?php echo JText::_('JNEXT'); ?></a>
Expand Down
2 changes: 1 addition & 1 deletion installation/view/summary/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$useftp = file_exists($path) ? !is_writable($path) : !is_writable(JPATH_CONFIGURATION . '/');
$prev = $useftp ? 'ftp' : 'database';
?>
<?php echo JHtml::_('InstallationHtml.helper.stepbar'); ?>
<?php echo JHtml::_('installation.stepbar'); ?>
<form action="index.php" method="post" id="adminForm" class="form-validate">
<div class="btn-toolbar justify-content-end">
<div class="btn-group">
Expand Down
107 changes: 107 additions & 0 deletions libraries/cms/html/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\HTML\Registry;
use Joomla\CMS\Log\Log;
use Joomla\Utilities\ArrayHelper;

jimport('joomla.environment.browser');
Expand Down Expand Up @@ -40,6 +42,7 @@ abstract class JHtml
*
* @var string[]
* @since 1.5
* @deprecated 5.0
*/
protected static $includePaths = array();

Expand All @@ -48,9 +51,18 @@ abstract class JHtml
*
* @var callable[]
* @since 1.6
* @deprecated 5.0
*/
protected static $registry = array();

/**
* The service registry for custom and overridden JHtml helpers
*
* @var Registry
* @since __DEPLOY_VERSION__
*/
protected static $serviceRegistry;

/**
* Method to extract a key
*
Expand All @@ -68,6 +80,22 @@ protected static function extract($key)
// Check to see whether we need to load a helper file
$parts = explode('.', $key);

if (count($parts) === 3)
{
try
{
Log::add(
'Support for a three segment service key is deprecated and will be removed in Joomla 5.0, use the service registry instead',
Log::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational message only, continue on
}
}

$prefix = count($parts) === 3 ? array_shift($parts) : 'JHtml';
$file = count($parts) === 2 ? array_shift($parts) : '';
$func = array_shift($parts);
Expand Down Expand Up @@ -105,6 +133,30 @@ public static function _($key)
return static::call($function, $args);
}

/*
* Support fetching services from the registry if a custom class prefix was not given (a three segment key),
* the service comes from a class other than this one, and a service has been registered for the file.
*/
if ($prefix === 'JHtml' && $file !== '' && static::getServiceRegistry()->hasService($file))
{
$service = static::getServiceRegistry()->getService($file);

$toCall = array($service, $func);

if (!is_callable($toCall))
{
throw new InvalidArgumentException(sprintf('%s::%s not found.', $service, $func), 500);
}

static::register($key, $toCall);
$args = func_get_args();

// Remove function name from arguments
array_shift($args);

return static::call($toCall, $args);
}

$className = $prefix . ucfirst($file);

if (!class_exists($className))
Expand Down Expand Up @@ -152,6 +204,19 @@ public static function _($key)
*/
public static function register($key, callable $function)
{
try
{
Log::add(
'Support for registering functions is deprecated and will be removed in Joomla 5.0, use the service registry instead',
Log::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational message only, continue on
}

list($key) = static::extract($key);

static::$registry[$key] = $function;
Expand All @@ -170,6 +235,19 @@ public static function register($key, callable $function)
*/
public static function unregister($key)
{
try
{
Log::add(
'Support for registering functions is deprecated and will be removed in Joomla 5.0, use the service registry instead',
Log::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational message only, continue on
}

list($key) = static::extract($key);

if (isset(static::$registry[$key]))
Expand Down Expand Up @@ -198,6 +276,22 @@ public static function isRegistered($key)
return isset(static::$registry[$key]);
}

/**
* Retrieves the service registry.
*
* @return Registry
*
* @since __DEPLOY_VERSION__
*/
public static function getServiceRegistry()
{
if (!static::$serviceRegistry)
{
static::$serviceRegistry = new Registry;
}

return static::$serviceRegistry;
}
/**
* Function caller method
*
Expand Down Expand Up @@ -1145,6 +1239,19 @@ public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attri
*/
public static function addIncludePath($path = '')
{
try
{
Log::add(
'Support for registering lookup paths is deprecated and will be removed in Joomla 5.0, use the service registry instead',
Log::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational message only, continue on
}

// Loop through the path directories
foreach ((array) $path as $dir)
{
Expand Down
Loading