Пример #1
0
 /**
  * sfSmarty::getSmarty()
  *
  * @return Smarty object
  * @access public
  **/
 public function getSmarty()
 {
     if (!self::$smarty) {
         // get the path and instantiate the smarty object
         $smartyClassPath = sfConfig::get('app_sfSmarty_class_path', 'Smarty');
         if (substr($smartyClassPath, -1) != DIRECTORY_SEPARATOR) {
             $smartyClassPath .= DIRECTORY_SEPARATOR;
         }
         require_once dirname(__FILE__) . '/../../../' . $smartyClassPath . 'Smarty.class.php';
         self::$smarty = new Smarty();
         // set the smarty cache directory
         $smartyDirs = sfConfig::get('app_sfSmarty_cache_dir', sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'Smarty');
         if (substr($smartyDirs, -1) != DIRECTORY_SEPARATOR) {
             $smartyDirs .= DIRECTORY_SEPARATOR;
         }
         self::$smarty->compile_dir = $smartyDirs . 'templates_c';
         self::$smarty->cache_dir = $smartyDirs . 'cache';
         self::$templateSecurity = sfConfig::get('app_sfSmarty_template_security', false);
         self::$smarty->security = self::$templateSecurity;
         if (!file_exists(self::$smarty->compile_dir)) {
             if (!mkdir(self::$smarty->compile_dir, 0777, true)) {
                 throw new sfCacheException('Unable to create cache directory "' . self::$smarty->compile_dir . '"');
             }
             if (self::$log) {
                 self::$log->info(sprintf('{sfSmarty} creating compile directory: %s', self::$smarty->compile_dir));
             }
         }
         if (!file_exists(self::$smarty->cache_dir)) {
             if (!mkdir(self::$smarty->cache_dir, 0777, true)) {
                 throw new sfCacheException('Unable to create cache directory "' . self::$smarty->cache_dir . '"');
             }
             if (self::$log) {
                 self::$log->info(sprintf('{sfSmarty} creating cache directory: %s', self::$smarty->cache_dir));
             }
         }
         self::$smarty->register_compiler_function('use', array($this, 'smartyCompilerfunctionUse'));
         self::$smarty->register_postfilter(array('sfSmarty', 'smartyPostFilter'));
     }
     return self::$smarty;
 }
Пример #2
0
 /**
  * sfSmartyView::registerModifier()
  * this is an access function to the internal smarty instance
  * to register a modifier
  *
  * @param mixed $tag
  * @param mixed $function
  * @return
  **/
 public static function registerModifier($tag, $function)
 {
     self::$smarty->registerModifier($tag, $function);
 }