diff --git a/libraries/joomla/document/document.php b/libraries/joomla/document/document.php index 25ded87605d71..191966a8c9af6 100644 --- a/libraries/joomla/document/document.php +++ b/libraries/joomla/document/document.php @@ -145,6 +145,13 @@ class JDocument */ public $_script = array(); + /** + * Array of scripts options + * + * @var array + */ + public $_script_options = array(); + /** * Array of linked style sheets * @@ -526,6 +533,40 @@ public function addScriptDeclaration($content, $type = 'text/javascript') return $this; } + /** + * Add option for script + * + * @param string $name a full extension name e.g. plg_name, com_name + * @param array $options - scrip options as array + * + * @return JDocument instance of $this to allow chaining + * + */ + public function setScriptOptions($options, $name) + { + $this->_script_options[$name] = $options; + return $this; + } + + /** + * Get script(s) options + * + * @param string $name a full extension name e.g. plg_name, com_name + * + * @return array that contain optios for script/extension by name or all options + * + */ + public function getScriptOptions($name = null) + { + if ($name) + { + return (empty($this->_script_options[$name])) ? array() : $this->_script_options[$name]; + } + else { + return $this->_script_options; + } + } + /** * Adds a linked stylesheet to the page * diff --git a/libraries/joomla/document/html/renderer/head.php b/libraries/joomla/document/html/renderer/head.php index f0007ffd14860..c4c42e33c1f89 100644 --- a/libraries/joomla/document/html/renderer/head.php +++ b/libraries/joomla/document/html/renderer/head.php @@ -63,6 +63,9 @@ public function fetchHead($document) $app = JFactory::getApplication(); $app->triggerEvent('onBeforeCompileHead'); + // Whether debug enabled + $debug = JFactory::getConfig()->get('debug'); + // Get line endings $lnEnd = $document->_getLineEnd(); $tab = $document->_getTab(); @@ -195,6 +198,22 @@ public function fetchHead($document) $buffer .= '>' . $lnEnd; } + // Generate scripts options + if (!empty($document->_script_options)) + { + $buffer .= $tab . '' . $lnEnd; + } + // Generate script declarations foreach ($document->_script as $type => $content) {