From 6910454f4f3cde19c89316e8382c5d6e656d2100 Mon Sep 17 00:00:00 2001 From: Hugh Messenger Date: Wed, 1 Jun 2016 17:15:53 -0500 Subject: [PATCH] Adding partial coument type --- libraries/joomla/document/partial/index.html | 1 + libraries/joomla/document/partial/partial.php | 90 ++++++++ .../document/partial/renderer/component.php | 36 +++ .../joomla/document/partial/renderer/head.php | 215 ++++++++++++++++++ .../document/partial/renderer/index.html | 1 + .../document/partial/renderer/message.php | 81 +++++++ .../document/partial/renderer/module.php | 111 +++++++++ .../document/partial/renderer/modules.php | 43 ++++ 8 files changed, 578 insertions(+) create mode 100644 libraries/joomla/document/partial/index.html create mode 100644 libraries/joomla/document/partial/partial.php create mode 100644 libraries/joomla/document/partial/renderer/component.php create mode 100644 libraries/joomla/document/partial/renderer/head.php create mode 100644 libraries/joomla/document/partial/renderer/index.html create mode 100644 libraries/joomla/document/partial/renderer/message.php create mode 100644 libraries/joomla/document/partial/renderer/module.php create mode 100644 libraries/joomla/document/partial/renderer/modules.php diff --git a/libraries/joomla/document/partial/index.html b/libraries/joomla/document/partial/index.html new file mode 100644 index 00000000000..fa6d84e8055 --- /dev/null +++ b/libraries/joomla/document/partial/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/joomla/document/partial/partial.php b/libraries/joomla/document/partial/partial.php new file mode 100644 index 00000000000..053e7ecf324 --- /dev/null +++ b/libraries/joomla/document/partial/partial.php @@ -0,0 +1,90 @@ +_getLineEnd(); + $tab = $this->_getTab(); + $tagEnd = ' />'; + $buffer = ''; + + // Generate script declarations + foreach ($this->_script as $type => $content) + { + $buffer .= $tab . '' . $lnEnd; + } + + return $buffer . $this->_buffer['component']; + } + + /** + * Get the contents of a document include + * + * @param string $type The type of renderer + * @param string $name The name of the element to render + * @param array $attribs Associative array of remaining attributes. + * + * @return The output of the renderer + */ + public function getBuffer($type = null, $name = null, $attribs = array()) + { + if ($type == 'head' || $type == 'component') + { + return parent::getBuffer($type, $name, $attribs); + } + else + { + return ''; + } + } +} diff --git a/libraries/joomla/document/partial/renderer/component.php b/libraries/joomla/document/partial/renderer/component.php new file mode 100644 index 00000000000..2287f0fa772 --- /dev/null +++ b/libraries/joomla/document/partial/renderer/component.php @@ -0,0 +1,36 @@ +fetchHead($this->_doc); + $buffer = ob_get_contents(); + ob_end_clean(); + + return $buffer; + } + + /** + * Generates the head HTML and return the results as a string + * +* @param JDocument &$document The document for which the head will be created + * + * @return string The head hTML + * + * @since 11.1 + */ + public function fetchHead(&$document) + { + // Trigger the onBeforeCompileHead event (skip for installation, since it causes an error) + $app = JFactory::getApplication(); + $app->triggerEvent('onBeforeCompileHead'); + // Get line endings + $lnEnd = $document->_getLineEnd(); + $tab = $document->_getTab(); + $tagEnd = ' />'; + $buffer = ''; + + // Generate base tag (need to happen first) + $base = $document->getBase(); + if (!empty($base)) + { + $buffer .= $tab . '' . $lnEnd; + } + + // Generate META tags (needs to happen as early as possible in the head) + foreach ($document->_metaTags as $type => $tag) + { + foreach ($tag as $name => $content) + { + if ($type == 'http-equiv') + { + $content .= '; charset=' . $document->getCharset(); + $buffer .= $tab . '' . $lnEnd; + } + elseif ($type == 'standard' && !empty($content)) + { + $buffer .= $tab . '' . $lnEnd; + } + } + } + + // Don't add empty descriptions + $documentDescription = $document->getDescription(); + if ($documentDescription) + { + $buffer .= $tab . '' . $lnEnd; + } + + // Don't add empty generators + $generator = $document->getGenerator(); + if ($generator) + { + $buffer .= $tab . '' . $lnEnd; + } + + $buffer .= $tab . '' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '' . $lnEnd; + + // Generate link declarations + foreach ($document->_links as $link => $linkAtrr) + { + $buffer .= $tab . '_styleSheets as $strSrc => $strAttr) + { + $buffer .= $tab . '_style as $type => $content) + { + $buffer .= $tab . '' . $lnEnd; + } + + // Generate script file links + foreach ($document->_scripts as $strSrc => $strAttr) + { + $buffer .= $tab . '' . $lnEnd; + } + + // Generate script language declarations. + if (count(JText::script())) + { + $buffer .= $tab . '' . $lnEnd; + } + + foreach ($document->_custom as $custom) + { + $buffer .= $tab . $custom . $lnEnd; + } + + return $buffer; + } +} diff --git a/libraries/joomla/document/partial/renderer/index.html b/libraries/joomla/document/partial/renderer/index.html new file mode 100644 index 00000000000..2efb97f319a --- /dev/null +++ b/libraries/joomla/document/partial/renderer/index.html @@ -0,0 +1 @@ + diff --git a/libraries/joomla/document/partial/renderer/message.php b/libraries/joomla/document/partial/renderer/message.php new file mode 100644 index 00000000000..a072c7e0ecc --- /dev/null +++ b/libraries/joomla/document/partial/renderer/message.php @@ -0,0 +1,81 @@ +getMessageQueue(); + + // Build the sorted message list + if (is_array($messages) && !empty($messages)) + { + foreach ($messages as $msg) + { + if (isset($msg['type']) && isset($msg['message'])) + { + $lists[$msg['type']][] = $msg['message']; + } + } + } + + // Build the return string + $buffer .= "\n
"; + + // If messages exist render them + if (is_array($lists)) + { + $buffer .= "\n
"; + foreach ($lists as $type => $msgs) + { + if (count($msgs)) + { + $buffer .= "\n
" . FText::_($type) . "
"; + $buffer .= "\n
"; + $buffer .= "\n\t
    "; + foreach ($msgs as $msg) + { + $buffer .= "\n\t\t
  • " . $msg . "
  • "; + } + $buffer .= "\n\t
"; + $buffer .= "\n
"; + } + } + $buffer .= "\n
"; + } + + $buffer .= "\n
"; + return $buffer; + } +} diff --git a/libraries/joomla/document/partial/renderer/module.php b/libraries/joomla/document/partial/renderer/module.php new file mode 100644 index 00000000000..05bfba459a7 --- /dev/null +++ b/libraries/joomla/document/partial/renderer/module.php @@ -0,0 +1,111 @@ +params = null; + $module->module = $tmp; + $module->id = 0; + $module->user = 0; + } + } + } + + // Get the user and configuration object + // $user = JFactory::getUser(); + $conf = JFactory::getConfig(); + + // Set the module content + if (!is_null($content)) + { + $module->content = $content; + } + + // Get module parameters + $params = new JRegistry; + $params->loadString($module->params); + + // Use parameters from template + if (isset($attribs['params'])) + { + $template_params = new JRegistry; + $template_params->loadString(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8')); + $params->merge($template_params); + $module = clone $module; + $module->params = (string) $params; + } + + $contents = ''; + // Default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the + // module instead + $cachemode = $params->get('cachemode', 'oldstatic'); + + if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') + { + + // Default to itemid creating method and workarounds on + $cacheparams = new stdClass; + $cacheparams->cachemode = $cachemode; + $cacheparams->class = 'JModuleHelper'; + $cacheparams->method = 'renderModule'; + $cacheparams->methodparams = array($module, $attribs); + + $contents = JModuleHelper::ModuleCache($module, $params, $cacheparams); + + } + else + { + $contents = JModuleHelper::renderModule($module, $attribs); + } + + return $contents; + } +} diff --git a/libraries/joomla/document/partial/renderer/modules.php b/libraries/joomla/document/partial/renderer/modules.php new file mode 100644 index 00000000000..38c14be0525 --- /dev/null +++ b/libraries/joomla/document/partial/renderer/modules.php @@ -0,0 +1,43 @@ +_doc->loadRenderer('module'); + $buffer = ''; + + foreach (JModuleHelper::getModules($position) as $mod) + { + $buffer .= $renderer->render($mod, $params, $content); + } + return $buffer; + } +}