Zikula_Template_Plugins
[ class tree: Zikula_Template_Plugins ] [ index: Zikula_Template_Plugins ] [ all elements ]

Source for file function.modulestylesheet.php

Documentation is available at function.modulestylesheet.php

  1. <?php
  2. /**
  3.  * Zikula Application Framework
  4.  *
  5.  * @copyright (c) 2004, Zikula Development Team
  6.  * @link http://www.zikula.org
  7.  * @version $Id: function.modulestylesheet.php 24342 2008-06-06 12:03:14Z markwest $
  8.  * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
  9.  * @package Zikula_Template_Plugins
  10.  * @subpackage Functions
  11.  */
  12.  
  13. /**
  14.  * Smarty function to provide easy access to a stylesheet
  15.  *
  16.  * This function provides an easy way to include a stylesheet. The function will add the stylesheet
  17.  * file to the 'stylesheet' pagevar be default
  18.  *
  19.  * available parameters:
  20.  *  - xhtml       (obsolete!) if set, the xhtml format of the stylesheet tag will be used
  21.  *  - modname     module name (if not set, the current module is assumed)
  22.  *  - stylesheet  name of the style sheet. If not set, style.css is assumed
  23.  *  - assign      if set, the tag and the style sheet are returned
  24.  *  - returntag   if set to true the plugin returns a tag, if set to false the return is
  25.  *                the path to css file (default:true)
  26.  *
  27.  * Example: <!--[modulestylesheet]-->
  28.  * Output:  *nothing*, css file gets added to 'stylesheet' pagevar
  29.  *
  30.  * Example: <!--[modulestylesheet modname="foobar" stylesheet="mystyle.css" assign="style"]-->
  31.  * Will output nothing; and the Smarty variable "style" will be set:
  32.  *
  33.  * <!--[$style.tag]-->           -- the full tag:
  34.  * <link rel="stylesheet" href="http://www.example.com/modules/foobar/pnstyle/mystyle.css" type="text/css">
  35.  *
  36.  * <!--[$style.stylesheet]-->    -- the path and the name of the stylesheet:
  37.  * http://www.example.com/modules/foobar/pnstyle/mystyle.css
  38.  *
  39.  *
  40.  * @author       Mark West
  41.  * @author       Jörg Napp
  42.  * @since        12. Feb. 2004
  43.  * @param        array       $params      All attributes passed to this function from the template
  44.  * @param        object      &$smarty     Reference to the Smarty object
  45.  * @return       string      The tag
  46.  */
  47. function smarty_function_modulestylesheet($params&$smarty)
  48. {
  49.     // get the parameters
  50.     extract($params);
  51.     unset($params['xhtml']);
  52.  
  53.     // default for the module
  54.     if (!isset($modname)) {
  55.         $modname pnModGetName();
  56.     }
  57.  
  58.     // now check that the modname is ok
  59.     if (!isset($modname|| empty($modname|| !pnModAvailable($modname)) {
  60.         return;
  61.     }
  62.  
  63.     if (!isset($returntag|| !is_bool($returntag)) {
  64.         $returntag true;
  65.     }
  66.  
  67.     $csssrc ThemeUtil::getModuleStylesheet($modnameisset($stylesheet$stylesheet null);
  68.  
  69.     // if no module stylesheet is present then return no content
  70.     if (!empty($csssrc)) {
  71.         // create xhtml specifier
  72.         $xhtmltag '';
  73.         if (isset($xhtml)) {
  74.             // backwards compatibility
  75.             $xhtmltag ' /';
  76.         else {
  77.             $themeinfo ThemeUtil::getInfo(ThemeUtil::getIDFromName(pnUserGetTheme()));
  78.             if ($themeinfo['xhtml']{
  79.                 $xhtmltag ' /';
  80.             }
  81.         }
  82.         $cssfile pnGetBaseURL($csssrc;
  83.         $tag '<link rel="stylesheet" href="' $cssfile '" type="text/css"' $xhtmltag '>';
  84.     }
  85.  
  86.     if (isset($tag)) {
  87.         if (isset($assign)) {
  88.             $params['stylesheet'$csssrc;
  89.             $params['tag'$tag;
  90.             $params['cssfile'$cssfile;
  91.             $smarty->assign($assign$params);
  92.         else {
  93.             if ($returntag{
  94.                 PageUtil::addVar('stylesheet'$csssrc)
  95.             else {
  96.                 return $cssfile;
  97.             }
  98.         }
  99.     }
  100. }

Documentation generated on Fri, 18 Jul 2008 21:45:30 +0200 by phpDocumentor 1.4.1