Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Source code for file /joomla/document/html/renderer/head.php

Documentation is available at head.php

  1. <?php
  2. /**
  3. @version        $Id: head.php 9888 2008-01-05 19:23:09Z hackwar $
  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.  
  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 <johan.janssens@joomla.org>
  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.  
  61.         $strHtml '';
  62.  
  63.         // Generate base tag (need to happen first)
  64.         $base $document->getBase();
  65.         if(!empty($base)) {
  66.             $strHtml .= $tab.'<base href="'.$document->getBase().'" />'.$lnEnd;
  67.         }
  68.  
  69.         // Generate META tags (needs to happen as early as possible in the head)
  70.         foreach ($document->_metaTags as $type => $tag)
  71.         {
  72.             foreach ($tag as $name => $content)
  73.             {
  74.                 if ($type == 'http-equiv'{
  75.                     $strHtml .= $tab.'<meta http-equiv="'.$name.'" content="'.$content.'"'.$tagEnd.$lnEnd;
  76.                 elseif ($type == 'standard'{
  77.                     $strHtml .= $tab.'<meta name="'.$name.'" content="'.$content.'"'.$tagEnd.$lnEnd;
  78.                 }
  79.             }
  80.         }
  81.  
  82.         $strHtml .= $tab.'<meta name="description" content="'.$document->getDescription().'" />'.$lnEnd;
  83.         $strHtml .= $tab.'<meta name="generator" content="'.$document->getGenerator().'" />'.$lnEnd;
  84.  
  85.         $strHtml .= $tab.'<title>'.htmlspecialchars($document->getTitle()).'</title>'.$lnEnd;
  86.  
  87.         // Generate link declarations
  88.         foreach ($document->_links as $link{
  89.             $strHtml .= $tab.$link.$tagEnd.$lnEnd;
  90.         }
  91.  
  92.         // Generate stylesheet links
  93.         foreach ($document->_styleSheets as $strSrc => $strAttr )
  94.         {
  95.             $strHtml .= $tab '<link rel="stylesheet" href="'.$strSrc.'" type="'.$strAttr['mime'].'"';
  96.             if (!is_null($strAttr['media'])){
  97.                 $strHtml .= ' media="'.$strAttr['media'].'" ';
  98.             }
  99.             if ($temp JArrayHelper::toString($strAttr['attribs'])) {
  100.                 $strHtml .= ' '.$temp;;
  101.             }
  102.             $strHtml .= $tagEnd.$lnEnd;
  103.         }
  104.  
  105.         // Generate stylesheet declarations
  106.         foreach ($document->_style as $type => $content)
  107.         {
  108.             $strHtml .= $tab.'<style type="'.$type.'">'.$lnEnd;
  109.  
  110.             // This is for full XHTML support.
  111.             if ($document->_mime == 'text/html' {
  112.                 $strHtml .= $tab.$tab.'<!--'.$lnEnd;
  113.             else {
  114.                 $strHtml .= $tab.$tab.'<![CDATA['.$lnEnd;
  115.             }
  116.  
  117.             $strHtml .= $content $lnEnd;
  118.  
  119.             // See above note
  120.             if ($document->_mime == 'text/html' {
  121.                 $strHtml .= $tab.$tab.'-->'.$lnEnd;
  122.             else {
  123.                 $strHtml .= $tab.$tab.']]>'.$lnEnd;
  124.             }
  125.             $strHtml .= $tab.'</style>'.$lnEnd;
  126.         }
  127.  
  128.         // Generate script file links
  129.         foreach ($document->_scripts as $strSrc => $strType{
  130.             $strHtml .= $tab.'<script type="'.$strType.'" src="'.$strSrc.'"></script>'.$lnEnd;
  131.         }
  132.  
  133.         // Generate script declarations
  134.         foreach ($document->_script as $type => $content)
  135.         {
  136.             $strHtml .= $tab.'<script type="'.$type.'">'.$lnEnd;
  137.  
  138.             // This is for full XHTML support.
  139.             if ($document->_mime != 'text/html' {
  140.                 $strHtml .= $tab.$tab.'<![CDATA['.$lnEnd;
  141.             }
  142.  
  143.             $strHtml .= $content.$lnEnd;
  144.  
  145.             // See above note
  146.             if ($document->_mime != 'text/html' {
  147.                 $strHtml .= $tab.$tab.'// ]]>'.$lnEnd;
  148.             }
  149.             $strHtml .= $tab.'</script>'.$lnEnd;
  150.         }
  151.  
  152.         foreach($document->_custom as $custom{
  153.             $strHtml .= $tab.$custom.$lnEnd;
  154.         }
  155.  
  156.         return $strHtml;
  157.     }
  158. }

Documentation generated on Tue, 29 Jan 2008 18:47:13 +0000 by phpDocumentor 1.3.1