Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/document/html/renderer/head.php

Documentation is available at head.php

  1. <?php
  2. /**
  3. @version        $Id: head.php 6684 2007-02-19 18:53:46Z louis $
  4. @package        Joomla.Framework
  5. @subpackage    Document
  6. @copyright    Copyright (C) 2005 - 2007 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.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19.  * JDocument head renderer
  20.  *
  21.  * @author        Johan Janssens <[email protected]>
  22.  * @package        Joomla.Framework
  23.  * @subpackage    Document
  24.  * @since        1.5
  25.  */
  26. {
  27.    /**
  28.      * Renders the document head and returns the results as a string
  29.      *
  30.      * @access public
  31.      * @param string     $name        (unused)
  32.      * @param array     $params        Associative array of values
  33.      * @return string    The output of the script
  34.      */
  35.     function render$head null$params array()$content null )
  36.     {
  37.         ob_start();
  38.  
  39.         echo $this->fetchHead($this->_doc);
  40.  
  41.         $contents ob_get_contents();
  42.         ob_end_clean();
  43.  
  44.         return $contents;
  45.     }
  46.  
  47.     /**
  48.      * Generates the head html and return the results as a string
  49.      *
  50.      * @access public
  51.      * @return string 
  52.      */
  53.     function fetchHead(&$document)
  54.     {
  55.         // get line endings
  56.         $lnEnd $document->_getLineEnd();
  57.         $tab $document->_getTab();
  58.  
  59.         $tagEnd        ' />';
  60.         $strHtml    $tab '<title>' htmlspecialchars($document->getTitle()) '</title>' $lnEnd;
  61.  
  62.         $link $document->getLink();
  63.         if(!empty($link)) {
  64.             $strHtml .= $tab '<base href="' $document->getLink('" />' $lnEnd;
  65.         }
  66.  
  67.         $strHtml .= $tab '<meta name="generator" content="' $document->getGenerator('" />' $lnEnd;
  68.         $strHtml .= $tab '<meta name="description" content="' $document->getDescription('" />' $lnEnd;
  69.  
  70.         // Generate META tags
  71.         foreach ($document->_metaTags as $type => $tag{
  72.             foreach ($tag as $name => $content{
  73.                 if ($type == 'http-equiv'{
  74.                     $strHtml .= $tab "<meta http-equiv=\"$name\" content=\"$content\"$tagEnd $lnEnd;
  75.                 elseif ($type == 'standard'{
  76.                     $strHtml .= $tab "<meta name=\"$name\" content=\"$content\"$tagEnd $lnEnd;
  77.                 }
  78.             }
  79.         }
  80.  
  81.         // Generate link declarations
  82.         foreach ($document->_links as $link{
  83.             $strHtml .= $tab $link $tagEnd $lnEnd;
  84.         }
  85.  
  86.         // Generate stylesheet links
  87.         foreach ($document->_styleSheets as $strSrc => $strAttr {
  88.             $strHtml .= $tab "<link rel=\"stylesheet\" href=\"$strSrc\" type=\"".$strAttr['mime'].'"';
  89.             if (!is_null($strAttr['media'])){
  90.                 $strHtml .= ' media="'.$strAttr['media'].'" ';
  91.             }
  92.  
  93.             $strHtml .= JDocumentHelper::implodeAttribs('='' '$strAttr['attribs']);
  94.  
  95.             $strHtml .= $tagEnd $lnEnd;
  96.         }
  97.  
  98.         // Generate stylesheet declarations
  99.         foreach ($document->_style as $styledecl{
  100.             foreach ($styledecl as $type => $content{
  101.                 $strHtml .= $tab '<style type="' $type '">' $lnEnd;
  102.  
  103.                 // This is for full XHTML support.
  104.                 if ($document->_mime == 'text/html' {
  105.                     $strHtml .= $tab $tab '<!--' $lnEnd;
  106.                 else {
  107.                     $strHtml .= $tab $tab '<![CDATA[' $lnEnd;
  108.                 }
  109.  
  110.                 $strHtml .= $content $lnEnd;
  111.  
  112.                 // See above note
  113.                 if ($document->_mime == 'text/html' {
  114.                     $strHtml .= $tab $tab '-->' $lnEnd;
  115.                 else {
  116.                     $strHtml .= $tab $tab ']]>' $lnEnd;
  117.                 }
  118.                 $strHtml .= $tab '</style>' $lnEnd;
  119.             }
  120.         }
  121.  
  122.         // Generate script file links
  123.         foreach ($document->_scripts as $strSrc => $strType{
  124.             $strHtml .= $tab "<script type=\"$strType\" src=\"$strSrc\"></script>$lnEnd;
  125.         }
  126.  
  127.         // Generate script declarations
  128.         foreach ($document->_script as $script{
  129.             foreach ($script as $type => $content{
  130.                 $strHtml .= $tab '<script type="' $type '">' $lnEnd;
  131.  
  132.                 // This is for full XHTML support.
  133.                 if ($document->_mime == 'text/html' {
  134.                     $strHtml .= $tab $tab '// <!--' $lnEnd;
  135.                 else {
  136.                     $strHtml .= $tab $tab '<![CDATA[' $lnEnd;
  137.                 }
  138.  
  139.                 $strHtml .= $content $lnEnd;
  140.  
  141.                 // See above note
  142.                 if ($document->_mime == 'text/html' {
  143.                     $strHtml .= $tab $tab '// -->' $lnEnd;
  144.                 else {
  145.                     $strHtml .= $tab $tab '// ]]>' $lnEnd;
  146.                 }
  147.                 $strHtml .= $tab '</script>' $lnEnd;
  148.             }
  149.         }
  150.  
  151.         foreach($document->_custom as $custom{
  152.             $strHtml .= $tab $custom .$lnEnd;
  153.         }
  154.  
  155.         return $strHtml;
  156.     }
  157. }
  158. ?>

Documentation generated on Mon, 05 Mar 2007 21:05:25 +0000 by phpDocumentor 1.3.1