Skip to content

Commit

Permalink
Write script options before scripts. Don't explicitly add translation…
Browse files Browse the repository at this point in the history
…s, they are in script options already.
  • Loading branch information
okonomiyaki3000 committed May 29, 2017
1 parent f86c1ff commit d256610
Showing 1 changed file with 6 additions and 68 deletions.
74 changes: 6 additions & 68 deletions libraries/joomla/document/renderer/html/head.php
Expand Up @@ -86,12 +86,6 @@ public function fetchHead($document)
$buffer = array_merge($buffer, $this->fetchStyleDeclarations($document));
}

// Get scripts (loaded as external files)
if (!empty($document->_scripts))
{
$buffer = array_merge($buffer, $this->fetchScripts($document));
}

// Get script options
$scriptOptions = $document->getScriptOptions();

Expand All @@ -100,18 +94,16 @@ public function fetchHead($document)
$buffer = array_merge($buffer, $this->fetchScriptOptions($document));
}

// Get script declarations
if (!empty($document->_script))
// Get scripts (loaded as external files)
if (!empty($document->_scripts))
{
$buffer = array_merge($buffer, $this->fetchScriptDeclarations($document));
$buffer = array_merge($buffer, $this->fetchScripts($document));
}

// Get translation strings for javascript
$script = JText::script();

if (!empty($script))
// Get script declarations
if (!empty($document->_script))
{
$buffer = array_merge($buffer, $this->fetchScriptLanguageDeclarations($document));
$buffer = array_merge($buffer, $this->fetchScriptDeclarations($document));
}

// Get custom tags
Expand Down Expand Up @@ -511,60 +503,6 @@ protected function fetchScriptDeclarations($document)
return $buffer;
}

/**
* Gets a script tag that loads translation strings.
*
* @param JDocumentHtml $document The document for which the head will be created
*
* @return array The tags
*
* @since __DEPLOY_VERSION__
*/
protected function fetchScriptLanguageDeclarations($document)
{
$script = JText::script();

if (empty($script))
{
return array();
}

$tab = $document->_getTab();
$isHtml5 = $document->isHtml5();
$buffer = array();

// Generate script language declarations.
$openTag = $tab . '<script';

if (!$document->isHtml5())
{
$openTag .= ' type="text/javascript"';
}

$openTag .= '>';

$buffer[] = $openTag;

if ($document->_mime != 'text/html')
{
$buffer[] = $tab . $tab . '//<![CDATA[';
}

// Why is this inside of a closure?
$buffer[] = $tab . $tab . '(function() {';
$buffer[] = $tab . $tab . $tab . 'Joomla.JText.load(' . json_encode($script) . ');';
$buffer[] = $tab . $tab . '})();';

if ($document->_mime != 'text/html')
{
$buffer[] = $tab . $tab . '//]]>';
}

$buffer[] = $tab . '</script>';

return $buffer;
}

/**
* Gets the custom tags as an array.
*
Expand Down

0 comments on commit d256610

Please sign in to comment.