/libraries/joomla/document/html/renderer/head.php

https://github.com/shafiqissani/Jewelery-Ecommerce- · PHP · 158 lines · 87 code · 25 blank · 46 comment · 16 complexity · b10b74646b96514cf55dfd02b32cf530 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id: head.php 10707 2008-08-21 09:52:47Z eddieajau $
  4. * @package Joomla.Framework
  5. * @subpackage Document
  6. * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7. * @license GNU/GPL, see LICENSE.php
  8. * Joomla! is free software. This version may have been modified pursuant
  9. * to the GNU General Public License, and as distributed it includes or
  10. * is derivative of works licensed under the GNU General Public License or
  11. * other free or open source software licenses.
  12. * See COPYRIGHT.php for copyright notices and details.
  13. */
  14. // Check to ensure this file is within the rest of the framework
  15. defined('JPATH_BASE') or die();
  16. /**
  17. * JDocument head renderer
  18. *
  19. * @package Joomla.Framework
  20. * @subpackage Document
  21. * @since 1.5
  22. */
  23. class JDocumentRendererHead extends JDocumentRenderer
  24. {
  25. /**
  26. * Renders the document head and returns the results as a string
  27. *
  28. * @access public
  29. * @param string $name (unused)
  30. * @param array $params Associative array of values
  31. * @return string The output of the script
  32. */
  33. function render( $head = null, $params = array(), $content = null )
  34. {
  35. ob_start();
  36. echo $this->fetchHead($this->_doc);
  37. $contents = ob_get_contents();
  38. ob_end_clean();
  39. return $contents;
  40. }
  41. /**
  42. * Generates the head html and return the results as a string
  43. *
  44. * @access public
  45. * @return string
  46. */
  47. function fetchHead(&$document)
  48. {
  49. // get line endings
  50. $lnEnd = $document->_getLineEnd();
  51. $tab = $document->_getTab();
  52. $tagEnd = ' />';
  53. $strHtml = '';
  54. // Generate base tag (need to happen first)
  55. $base = $document->getBase();
  56. if(!empty($base)) {
  57. $strHtml .= $tab.'<base href="'.$document->getBase().'" />'.$lnEnd;
  58. }
  59. // Generate META tags (needs to happen as early as possible in the head)
  60. foreach ($document->_metaTags as $type => $tag)
  61. {
  62. foreach ($tag as $name => $content)
  63. {
  64. if ($type == 'http-equiv') {
  65. $strHtml .= $tab.'<meta http-equiv="'.$name.'" content="'.$content.'"'.$tagEnd.$lnEnd;
  66. } elseif ($type == 'standard') {
  67. $strHtml .= $tab.'<meta name="'.$name.'" content="'.$content.'"'.$tagEnd.$lnEnd;
  68. }
  69. }
  70. }
  71. $strHtml .= $tab.'<meta name="description" content="'.$document->getDescription().'" />'.$lnEnd;
  72. $strHtml .= $tab.'<meta name="generator" content="'.$document->getGenerator().'" />'.$lnEnd;
  73. $strHtml .= $tab.'<title>'.htmlspecialchars($document->getTitle()).'</title>'.$lnEnd;
  74. // Generate link declarations
  75. foreach ($document->_links as $link) {
  76. $strHtml .= $tab.$link.$tagEnd.$lnEnd;
  77. }
  78. // Generate stylesheet links
  79. foreach ($document->_styleSheets as $strSrc => $strAttr )
  80. {
  81. $strHtml .= $tab . '<link rel="stylesheet" href="'.$strSrc.'" type="'.$strAttr['mime'].'"';
  82. if (!is_null($strAttr['media'])){
  83. $strHtml .= ' media="'.$strAttr['media'].'" ';
  84. }
  85. if ($temp = JArrayHelper::toString($strAttr['attribs'])) {
  86. $strHtml .= ' '.$temp;;
  87. }
  88. $strHtml .= $tagEnd.$lnEnd;
  89. }
  90. // Generate stylesheet declarations
  91. foreach ($document->_style as $type => $content)
  92. {
  93. $strHtml .= $tab.'<style type="'.$type.'">'.$lnEnd;
  94. // This is for full XHTML support.
  95. if ($document->_mime == 'text/html' ) {
  96. $strHtml .= $tab.$tab.'<!--'.$lnEnd;
  97. } else {
  98. $strHtml .= $tab.$tab.'<![CDATA['.$lnEnd;
  99. }
  100. $strHtml .= $content . $lnEnd;
  101. // See above note
  102. if ($document->_mime == 'text/html' ) {
  103. $strHtml .= $tab.$tab.'-->'.$lnEnd;
  104. } else {
  105. $strHtml .= $tab.$tab.']]>'.$lnEnd;
  106. }
  107. $strHtml .= $tab.'</style>'.$lnEnd;
  108. }
  109. // Generate script file links
  110. foreach ($document->_scripts as $strSrc => $strType) {
  111. $strHtml .= $tab.'<script type="'.$strType.'" src="'.$strSrc.'"></script>'.$lnEnd;
  112. }
  113. // Generate script declarations
  114. foreach ($document->_script as $type => $content)
  115. {
  116. $strHtml .= $tab.'<script type="'.$type.'">'.$lnEnd;
  117. // This is for full XHTML support.
  118. if ($document->_mime != 'text/html' ) {
  119. $strHtml .= $tab.$tab.'<![CDATA['.$lnEnd;
  120. }
  121. $strHtml .= $content.$lnEnd;
  122. // See above note
  123. if ($document->_mime != 'text/html' ) {
  124. $strHtml .= $tab.$tab.'// ]]>'.$lnEnd;
  125. }
  126. $strHtml .= $tab.'</script>'.$lnEnd;
  127. }
  128. foreach($document->_custom as $custom) {
  129. $strHtml .= $tab.$custom.$lnEnd;
  130. }
  131. return $strHtml;
  132. }
  133. }