ea-Geiercode-base
[ class tree: ea-Geier ] [ index: ea-Geier ] [ all elements ]

Source for file smarty.class.php

Documentation is available at smarty.class.php

  1. <?php 
  2. /**
  3.  * smarty wrapper class
  4.  *
  5.  * LICENSE:
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
  13.  * GNU General Public License for more details.
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program; if not, write to the Free Software Foundation, Inc.,
  16.  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17.  *
  18.  * @package       ea-Geier
  19.  * @subpackage code/base
  20.  * @author       m2mtech <tech@m2m.at>
  21.  * @copyright  2007 m2m server software gmbh
  22.  * @license       http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
  23.  * @version       $Id: smarty.class.php 149 2007-09-08 16:35:19Z m2mtech $
  24.  * @link       http://www.ea-geier.at/
  25.  */
  26.  
  27. /**
  28.  * path to smarty library
  29.  * @ignore
  30.  *  attention: might have been defined already in
  31.  *  config/config.php or code/config.php
  32.  */
  33. if (!defined('eaSMARTY_DIR')) define('eaSMARTY_DIR''3party/smarty/Smarty-2.6.18/libs/');
  34.  
  35. /**
  36.  * path to temporary smarty folder
  37.  * @ignore
  38.  *  attention: might have been defined already in
  39.  *  config/config.php or code/config.php
  40.  */
  41. if (!defined('eaSMARTY_TMP')) define('eaSMARTY_TMP''tmp/smarty/');
  42.  
  43. /**
  44.  * path to template folder for smarty
  45.  * @ignore
  46.  *  attention: might have been defined already in
  47.  *  config/config.php or code/config.php
  48.  */
  49. if (!defined('eaSMARTY_HTML')) define('eaSMARTY_HTML''html/');
  50.  
  51. /**
  52.  * path to language folder for smarty
  53.  * @ignore
  54.  *  attention: might have been defined already in
  55.  *  config/config.php or code/config.php
  56.  */
  57. if (!defined('eaSMARTY_LANG')) define('eaSMARTY_LANG''lang/');
  58.  
  59. /**
  60.  * load smarty library
  61.  */
  62. require_once(eaSMARTY_DIR 'Smarty.class.php');
  63.     
  64. /**
  65.  * wrapper smarty library
  66.  *
  67.  * holds local extension of the smarty library e.g. language handling
  68.  *
  69.  * @package       ea-Geier
  70.  */
  71. class eaSmarty extends Smarty {
  72.  
  73.     /**
  74.      * user language
  75.      *
  76.      * 'de', 'en'
  77.      *
  78.      * @var string 
  79.      */
  80.     var $language = 'de';
  81.  
  82.     /**
  83.      * constructor of smarty wrapper
  84.      *
  85.      * defines the environmental settings
  86.      */
  87.     function eaSmarty($lang false{
  88.         if ($lang$this->language = $lang;
  89.         $this->template_dir eaSMARTY_HTML;
  90.         $this->debug_tpl preg_replace('/[^\/]+\//i''../'eaSMARTY_HTMLeaSMARTY_DIR 'debug.tpl';
  91.         $this->changeLanguage($this->language);
  92.         $this->plugins_dir[dirname(__file__'/smartyplugins';
  93.         return $this->Smarty();
  94.     }
  95.             
  96.     /**
  97.      * changes user language
  98.      *
  99.      * and adjusts folder settins accordingly
  100.      *
  101.      * @param  string    $lang  user language ('de'|'en')
  102.      * @return bool 
  103.      */
  104.     function changeLanguage($lang{
  105.         if (!$langreturn false;
  106.         if (!preg_match('/[a-z]{2}/'$lang)) return false;
  107.         
  108.         $result true;
  109.         if (!is_dir(eaSMARTY_LANG $lang)) {
  110.             $lang 'de';
  111.             $result false;
  112.         }
  113.         $this->language = $lang;
  114.         $this->config_dir eaSMARTY_LANG $lang '/';
  115.         $this->compile_dir eaSMARTY_TMP '/templates_c/' $lang '/';
  116.         if (!is_dir($this->compile_dir)) mkdir($this->compile_dir);
  117.         $this->cache_dir eaSMARTY_TMP '/cache/' $lang '/';
  118.         if (!is_dir($this->cache_dir)) mkdir($this->cache_dir);
  119.         return $result;
  120.     }
  121.     
  122. }
  123.     
  124. ?>

Documentation generated on Sun, 09 Sep 2007 17:09:34 +0200 by phpDocumentor 1.3.1