From 09fe795f2cdb78e3bd80dbc854d09577465431ba Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Thu, 16 Jun 2016 18:53:51 -0500 Subject: [PATCH] Templates are in the scope of JDocument. Fixes #10847 --- administrator/templates/hathor/component.php | 2 ++ administrator/templates/hathor/cpanel.php | 2 ++ administrator/templates/hathor/error.php | 2 ++ administrator/templates/hathor/index.php | 2 ++ administrator/templates/hathor/login.php | 2 ++ administrator/templates/isis/component.php | 21 +++++++------ administrator/templates/isis/error.php | 19 ++++-------- administrator/templates/isis/index.php | 31 ++++++++++---------- administrator/templates/isis/login.php | 17 ++++++----- administrator/templates/system/component.php | 2 ++ administrator/templates/system/error.php | 3 ++ installation/template/index.php | 5 ++-- libraries/joomla/document/document.php | 2 +- templates/beez3/component.php | 2 ++ templates/beez3/error.php | 2 ++ templates/beez3/index.php | 2 ++ templates/protostar/component.php | 11 ++++--- templates/protostar/error.php | 25 ++++++---------- templates/protostar/index.php | 21 +++++++------ templates/protostar/offline.php | 21 +++++++------ templates/system/component.php | 2 ++ templates/system/error.php | 3 +- templates/system/offline.php | 2 ++ 23 files changed, 105 insertions(+), 96 deletions(-) diff --git a/administrator/templates/hathor/component.php b/administrator/templates/hathor/component.php index e74708fd352f4..5d9d4dea96da1 100644 --- a/administrator/templates/hathor/component.php +++ b/administrator/templates/hathor/component.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + // Get additional language strings prefixed with TPL_HATHOR // @todo: Do we realy need this? $lang = JFactory::getLanguage(); diff --git a/administrator/templates/hathor/cpanel.php b/administrator/templates/hathor/cpanel.php index efb0fdb4bb281..c4657cc35aaf3 100644 --- a/administrator/templates/hathor/cpanel.php +++ b/administrator/templates/hathor/cpanel.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); diff --git a/administrator/templates/hathor/error.php b/administrator/templates/hathor/error.php index e381c5751e191..463d2b488fb03 100644 --- a/administrator/templates/hathor/error.php +++ b/administrator/templates/hathor/error.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentError $this */ + $app = JFactory::getApplication(); ?> diff --git a/administrator/templates/hathor/index.php b/administrator/templates/hathor/index.php index a685dd2aa4454..1ae4c8ddb4776 100644 --- a/administrator/templates/hathor/index.php +++ b/administrator/templates/hathor/index.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); diff --git a/administrator/templates/hathor/login.php b/administrator/templates/hathor/login.php index 14cbae8ecb81e..3cb18732f7bcd 100644 --- a/administrator/templates/hathor/login.php +++ b/administrator/templates/hathor/login.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $app = JFactory::getApplication(); $lang = JFactory::getLanguage(); diff --git a/administrator/templates/isis/component.php b/administrator/templates/isis/component.php index d4b429302d38d..be2d17410065c 100644 --- a/administrator/templates/isis/component.php +++ b/administrator/templates/isis/component.php @@ -9,22 +9,21 @@ defined('_JEXEC') or die; -$app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$lang = JFactory::getLanguage(); -$this->language = $doc->language; -$this->direction = $doc->direction; +/** @var JDocumentHtml $this */ + +$app = JFactory::getApplication(); +$lang = JFactory::getLanguage(); // Output as HTML5 -$doc->setHtml5(true); +$this->setHtml5(true); // Add JavaScript Frameworks JHtml::_('bootstrap.framework'); -$doc->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); +$this->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); // Add Stylesheets -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); // Load optional RTL Bootstrap CSS JHtml::_('bootstrap.loadCss', false, $this->direction); @@ -34,7 +33,7 @@ if (is_file($file)) { - $doc->addStyleSheet($file); + $this->addStyleSheet($file); } // Load custom.css @@ -42,13 +41,13 @@ if (is_file($file)) { - $doc->addStyleSheetVersion($file); + $this->addStyleSheetVersion($file); } // Link color if ($this->params->get('linkColor')) { - $doc->addStyleDeclaration('a { color: ' . $this->params->get('linkColor') . '; }'); + $this->addStyleDeclaration('a { color: ' . $this->params->get('linkColor') . '; }'); } ?> diff --git a/administrator/templates/isis/error.php b/administrator/templates/isis/error.php index 3d0af14888087..2fc823ad1e8a7 100644 --- a/administrator/templates/isis/error.php +++ b/administrator/templates/isis/error.php @@ -11,22 +11,15 @@ use Joomla\Registry\Registry; +/** @var JDocumentError $this */ + // Getting params from template $params = JFactory::getApplication()->getTemplate(true)->params; -$app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$lang = JFactory::getLanguage(); -$this->language = $doc->language; -$this->direction = $doc->direction; -$input = $app->input; -$user = JFactory::getUser(); - -// Output document as HTML5. -if (is_callable(array($doc, 'setHtml5'))) -{ - $doc->setHtml5(true); -} +$app = JFactory::getApplication(); +$lang = JFactory::getLanguage(); +$input = $app->input; +$user = JFactory::getUser(); // Gets the FrontEnd Main page Uri $frontEndUri = JUri::getInstance(JUri::root()); diff --git a/administrator/templates/isis/index.php b/administrator/templates/isis/index.php index 2b659f53284ab..01cc78895d83a 100644 --- a/administrator/templates/isis/index.php +++ b/administrator/templates/isis/index.php @@ -9,16 +9,15 @@ defined('_JEXEC') or die; -$app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$lang = JFactory::getLanguage(); -$this->language = $doc->language; -$this->direction = $doc->direction; -$input = $app->input; -$user = JFactory::getUser(); +/** @var JDocumentHtml $this */ + +$app = JFactory::getApplication(); +$lang = JFactory::getLanguage(); +$input = $app->input; +$user = JFactory::getUser(); // Output as HTML5 -$doc->setHtml5(true); +$this->setHtml5(true); // Gets the FrontEnd Main page Uri $frontEndUri = JUri::getInstance(JUri::root()); @@ -28,17 +27,17 @@ // Add JavaScript Frameworks JHtml::_('bootstrap.framework'); -$doc->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); +$this->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); // Add Stylesheets -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template' . ($this->direction == 'rtl' ? '-rtl' : '') . '.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template' . ($this->direction == 'rtl' ? '-rtl' : '') . '.css'); // Load specific language related CSS $languageCss = 'language/' . $lang->getTag() . '/' . $lang->getTag() . '.css'; if (file_exists($languageCss) && filesize($languageCss) > 0) { - $doc->addStyleSheetVersion($languageCss); + $this->addStyleSheetVersion($languageCss); } // Load custom.css @@ -46,7 +45,7 @@ if (file_exists($customCss) && filesize($customCss) > 0) { - $doc->addStyleSheetVersion($customCss); + $this->addStyleSheetVersion($customCss); } // Detecting Active Variables @@ -126,7 +125,7 @@ function colorIsLight($color) // Template color if ($navbar_color) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" .navbar-inner, .navbar-inverse .navbar-inner, .dropdown-menu li > a:hover, @@ -143,7 +142,7 @@ function colorIsLight($color) // Template header color if ($header_color) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" .header { background: " . $header_color . "; }"); @@ -152,7 +151,7 @@ function colorIsLight($color) // Sidebar background color if ($this->params->get('sidebarColor')) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" .nav-list > .active > a, .nav-list > .active > a:hover { background: " . $this->params->get('sidebarColor') . "; @@ -162,7 +161,7 @@ function colorIsLight($color) // Link color if ($this->params->get('linkColor')) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" a, .j-toggle-sidebar-button { color: " . $this->params->get('linkColor') . "; diff --git a/administrator/templates/isis/login.php b/administrator/templates/isis/login.php index 1c1ff71c421a5..e2219ef97e51e 100644 --- a/administrator/templates/isis/login.php +++ b/administrator/templates/isis/login.php @@ -9,12 +9,13 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $app = JFactory::getApplication(); -$doc = JFactory::getDocument(); $lang = JFactory::getLanguage(); // Output as HTML5 -$doc->setHtml5(true); +$this->setHtml5(true); // Gets the FrontEnd Main page Uri $frontEndUri = JUri::getInstance(JUri::root()); @@ -29,7 +30,7 @@ JHtml::_('bootstrap.tooltip'); // Add Stylesheets -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template' . ($this->direction == 'rtl' ? '-rtl' : '') . '.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template' . ($this->direction == 'rtl' ? '-rtl' : '') . '.css'); // Load optional RTL Bootstrap CSS JHtml::_('bootstrap.loadCss', false, $this->direction); @@ -39,7 +40,7 @@ if (is_file($file)) { - $doc->addStyleSheet($file); + $this->addStyleSheet($file); } // Load custom.css @@ -47,7 +48,7 @@ if (is_file($file)) { - $doc->addStyleSheetVersion($file); + $this->addStyleSheetVersion($file); } // Detecting Active Variables @@ -71,14 +72,14 @@ function colorIsLight($color) // Background color if ($background_color) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" .view-login { background-color: " . $background_color . "; }"); } // Responsive Styles -$doc->addStyleDeclaration(" +$this->addStyleDeclaration(" @media (max-width: 480px) { .view-login .container { margin-top: -170px; @@ -92,7 +93,7 @@ function colorIsLight($color) // Check if debug is on if (JPluginHelper::isEnabled('system', 'debug') && ($app->get('debug_lang', 0) || $app->get('debug', 0))) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" .view-login .container { position: static; margin-top: 20px; diff --git a/administrator/templates/system/component.php b/administrator/templates/system/component.php index c8b065636f699..cbae6759a37e4 100644 --- a/administrator/templates/system/component.php +++ b/administrator/templates/system/component.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + // Output as HTML5 $this->setHtml5(true); ?> diff --git a/administrator/templates/system/error.php b/administrator/templates/system/error.php index 856ed0fdd47c3..73b90a8342c70 100644 --- a/administrator/templates/system/error.php +++ b/administrator/templates/system/error.php @@ -8,6 +8,9 @@ */ defined('_JEXEC') or die; + +/** @var JDocumentError $this */ + ?> diff --git a/installation/template/index.php b/installation/template/index.php index 3cefdb3579fb8..b290bcdfd8569 100644 --- a/installation/template/index.php +++ b/installation/template/index.php @@ -8,6 +8,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + // Add Stylesheets JHtml::_('bootstrap.loadCss', true, $this->direction); JHtml::_('stylesheet', 'installation/template/css/template.css'); @@ -19,7 +21,6 @@ JHtml::_('behavior.formvalidator'); JHtml::_('script', 'installation/template/js/installation.js'); - // Load JavaScript message titles JText::script('ERROR'); JText::script('WARNING'); @@ -54,7 +55,7 @@ }); - +
Joomla diff --git a/libraries/joomla/document/document.php b/libraries/joomla/document/document.php index f5979dbbd836c..953a6057386be 100644 --- a/libraries/joomla/document/document.php +++ b/libraries/joomla/document/document.php @@ -349,7 +349,7 @@ public function getType() /** * Get the contents of the document buffer * - * @return The contents of the document buffer + * @return mixed * * @since 11.1 */ diff --git a/templates/beez3/component.php b/templates/beez3/component.php index a435200ab0343..347e5380fae67 100644 --- a/templates/beez3/component.php +++ b/templates/beez3/component.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $color = $this->params->get('templatecolor'); // Output as HTML5 diff --git a/templates/beez3/error.php b/templates/beez3/error.php index 68a1eb31f1a2d..c909416142ef2 100644 --- a/templates/beez3/error.php +++ b/templates/beez3/error.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentError $this */ + $showRightColumn = 0; $showleft = 0; $showbottom = 0; diff --git a/templates/beez3/index.php b/templates/beez3/index.php index 7cc3ea228856a..65564f396be59 100644 --- a/templates/beez3/index.php +++ b/templates/beez3/index.php @@ -10,6 +10,8 @@ // No direct access. defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + JLoader::import('joomla.filesystem.file'); // Check modules diff --git a/templates/protostar/component.php b/templates/protostar/component.php index d80309a8c1965..f6c736a5e65df 100644 --- a/templates/protostar/component.php +++ b/templates/protostar/component.php @@ -9,19 +9,18 @@ defined('_JEXEC') or die; -$app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$this->language = $doc->language; -$this->direction = $doc->direction; +/** @var JDocumentHtml $this */ + +$app = JFactory::getApplication(); // Output as HTML5 -$doc->setHtml5(true); +$this->setHtml5(true); // Add JavaScript Frameworks JHtml::_('bootstrap.framework'); // Add Stylesheets -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); // Load optional rtl Bootstrap css and Bootstrap bugfixes JHtmlBootstrap::loadCss($includeMaincss = false, $this->direction); diff --git a/templates/protostar/error.php b/templates/protostar/error.php index 442f0413cc89d..a4fecd31e28d7 100644 --- a/templates/protostar/error.php +++ b/templates/protostar/error.php @@ -9,17 +9,10 @@ defined('_JEXEC') or die; -$app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$user = JFactory::getUser(); -$this->language = $doc->language; -$this->direction = $doc->direction; +/** @var JDocumentError $this */ -// Output document as HTML5. -if (is_callable(array($doc, 'setHtml5'))) -{ - $doc->setHtml5(true); -} +$app = JFactory::getApplication(); +$user = JFactory::getUser(); // Getting params from template $params = $app->getTemplate(true)->params; @@ -122,17 +115,17 @@
@@ -154,7 +147,7 @@

- getBuffer('module', 'search'); ?> + getBuffer('module', 'search'); ?>

@@ -195,7 +188,7 @@ - getBuffer('modules', 'debug', array('style' => 'none')); ?> + getBuffer('modules', 'debug', array('style' => 'none')); ?> diff --git a/templates/protostar/index.php b/templates/protostar/index.php index e2e54f81cb5f3..af179016e02dc 100644 --- a/templates/protostar/index.php +++ b/templates/protostar/index.php @@ -9,14 +9,13 @@ defined('_JEXEC') or die; -$app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$user = JFactory::getUser(); -$this->language = $doc->language; -$this->direction = $doc->direction; +/** @var JDocumentHtml $this */ + +$app = JFactory::getApplication(); +$user = JFactory::getUser(); // Output as HTML5 -$doc->setHtml5(true); +$this->setHtml5(true); // Getting params from template $params = $app->getTemplate(true)->params; @@ -41,16 +40,16 @@ // Add JavaScript Frameworks JHtml::_('bootstrap.framework'); -$doc->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); +$this->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); // Add Stylesheets -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); // Use of Google Font if ($this->params->get('googleFont')) { - $doc->addStyleSheet('//fonts.googleapis.com/css?family=' . $this->params->get('googleFontName')); - $doc->addStyleDeclaration(" + $this->addStyleSheet('//fonts.googleapis.com/css?family=' . $this->params->get('googleFontName')); + $this->addStyleDeclaration(" h1, h2, h3, h4, h5, h6, .site-title { font-family: '" . str_replace('+', ' ', $this->params->get('googleFontName')) . "', sans-serif; }"); @@ -59,7 +58,7 @@ // Template color if ($this->params->get('templateColor')) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" body.site { border-top: 3px solid " . $this->params->get('templateColor') . "; background-color: " . $this->params->get('templateBackgroundColor') . "; diff --git a/templates/protostar/offline.php b/templates/protostar/offline.php index aec18c868ddc8..d8977ef8ec535 100644 --- a/templates/protostar/offline.php +++ b/templates/protostar/offline.php @@ -9,31 +9,30 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $twofactormethods = JAuthenticationHelper::getTwoFactorMethods(); $app = JFactory::getApplication(); -$doc = JFactory::getDocument(); -$this->language = $doc->language; -$this->direction = $doc->direction; // Output as HTML5 -$doc->setHtml5(true); +$this->setHtml5(true); $fullWidth = 1; // Add JavaScript Frameworks JHtml::_('bootstrap.framework'); -$doc->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); +$this->addScriptVersion($this->baseurl . '/templates/' . $this->template . '/js/template.js'); // Add Stylesheets -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); -$doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/offline.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/template.css'); +$this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/offline.css'); // Use of Google Font if ($this->params->get('googleFont')) { - $doc->addStyleSheet('//fonts.googleapis.com/css?family=' . $this->params->get('googleFontName')); - $doc->addStyleDeclaration(" + $this->addStyleSheet('//fonts.googleapis.com/css?family=' . $this->params->get('googleFontName')); + $this->addStyleDeclaration(" h1, h2, h3, h4, h5, h6, .site-title { font-family: '" . str_replace('+', ' ', $this->params->get('googleFontName')) . "', sans-serif; }"); @@ -42,7 +41,7 @@ // Template color if ($this->params->get('templateColor')) { - $doc->addStyleDeclaration(" + $this->addStyleDeclaration(" body.site { border-top: 3px solid " . $this->params->get('templateColor') . "; background-color: " . $this->params->get('templateBackgroundColor') . "; @@ -67,7 +66,7 @@ if (file_exists($userCss) && filesize($userCss) > 0) { - $doc->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/user.css'); + $this->addStyleSheetVersion($this->baseurl . '/templates/' . $this->template . '/css/user.css'); } // Load optional RTL Bootstrap CSS diff --git a/templates/system/component.php b/templates/system/component.php index a6105d844f6a7..89dd76c5df992 100644 --- a/templates/system/component.php +++ b/templates/system/component.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + // Output as HTML5 $this->setHtml5(true); diff --git a/templates/system/error.php b/templates/system/error.php index 15b8d89474534..5c113f4fe207e 100644 --- a/templates/system/error.php +++ b/templates/system/error.php @@ -9,13 +9,14 @@ defined('_JEXEC') or die; +/** @var JDocumentError $this */ + if (!isset($this->error)) { $this->error = JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); $this->debug = false; } -// Get language and direction $app = JFactory::getApplication(); ?> diff --git a/templates/system/offline.php b/templates/system/offline.php index 8e3d2e7c8dca7..a231473e2eed5 100644 --- a/templates/system/offline.php +++ b/templates/system/offline.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die; +/** @var JDocumentHtml $this */ + $app = JFactory::getApplication(); // Output as HTML5