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

Source for file function.themelist.php

Documentation is available at function.themelist.php

  1. <?php
  2. /**
  3.  * pnRender plugin
  4.  *
  5.  * This file is a plugin for pnRender, the Zikula implementation of Smarty
  6.  *
  7.  * @package      Xanthia_Templating_Environment
  8.  * @subpackage   pnRender
  9.  * @version      $Id: function.themelist.php 24342 2008-06-06 12:03:14Z markwest $
  10.  * @author       The Zikula development team
  11.  * @link         http://www.zikula.org  The Zikula Home Page
  12.  * @copyright    Copyright (C) 2002 by the Zikula Development Team
  13.  * @license      http://www.gnu.org/copyleft/gpl.html GNU General Public License
  14.  */
  15.  
  16.  
  17. /**
  18.  * Smarty function to display a drop down list of themes
  19.  *
  20.  * Available parameters:
  21.  *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
  22.  *   - selected: Selected value
  23.  *
  24.  * Example
  25.  *   <!--[themelist selected=ExtraLite]-->
  26.  *
  27.  *
  28.  * @author       Mark West
  29.  * @since        25 April 2004
  30.  * @param        array       $params      All attributes passed to this function from the template
  31.  * @param        object      &$smarty     Reference to the Smarty object
  32.  * @return       string      the value of the last status message posted, or void if no status message exists
  33.  */
  34. function smarty_function_themelist($params&$smarty)
  35. {
  36.     if (!isset($selected)) {
  37.         $selected 'ExtraLite';
  38.     else {
  39.         $selected $params['selected'];
  40.     }
  41.  
  42.     $handle opendir('themes');
  43.     while (false !== ($f readdir($handle))) {
  44.         if (is_dir("themes/$f"&& file_exists("themes/$f/images/preview_medium.png")) {
  45.             $themelist[$f"themes/$f/images/preview_medium.png";
  46.         }
  47.     }
  48.     closedir ($handle);
  49.  
  50.     $themestring '<table id="themeselector" width="100%">';
  51.     foreach ($themelist as $theme => $imagepath{
  52.         $themestring .= '<tr>';
  53.         $themestring .= '<td class="themename"><label for="theme-' DataUtil::formatForDisplay($theme)'">' DataUtil::formatForDisplay($theme'</label></td>';
  54.         $themestring .= '<td class="themeselect"><input id="theme-' DataUtil::formatForDisplay($theme'" type="radio" name="defaulttheme" value="' DataUtil::formatForDisplay($theme'"';
  55.         if ($theme == $selected$themestring .= ' checked="checked"';
  56.         $themestring .= ' /></td>';
  57.         $themestring .= '<td class="themepreview"><img src="' DataUtil::formatForDisplay($imagepath'" alt="" /></td>';
  58.         $themestring .= '</tr>';
  59.         $i++;
  60.     }
  61.     $themestring .= '</table>';
  62.  
  63.     if (isset($params['assign'])) {
  64.         $smarty->assign($params['assign']$themestring);
  65.     else {
  66.         return $themestring;
  67.     }
  68. }

Documentation generated on Fri, 18 Jul 2008 21:46:22 +0200 by phpDocumentor 1.4.1