当前位置: 首页>>代码示例>>PHP>>正文


PHP Smarty_Resource::compileds方法代码示例

本文整理汇总了PHP中Smarty_Resource::compileds方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Resource::compileds方法的具体用法?PHP Smarty_Resource::compileds怎么用?PHP Smarty_Resource::compileds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smarty_Resource的用法示例。


在下文中一共展示了Smarty_Resource::compileds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public static function init()
 {
     error_reporting(E_ALL | E_STRICT);
     self::_init(SmartyTests::$smarty);
     self::_init(SmartyTests::$smartyBC);
     SmartyTests::$smartyBC->registerPlugin('block', 'php', 'smarty_php_tag');
     Smarty_Resource::$sources = array();
     Smarty_Resource::$compileds = array();
 }
开发者ID:noiselabs,项目名称:smarty,代码行数:9,代码来源:smartytestdebug.inc.php

示例2: clearCompiledTemplate

 /**
  * Delete compiled template file
  *
  * @param string  $resource_name template name
  * @param string  $compile_id    compile id
  * @param integer $exp_time      expiration time
  * @param Smarty  $smarty        Smarty instance
  * @return integer number of template files deleted
  */
 public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
 {
     $_compile_dir = $smarty->getCompileDir();
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w\\|]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? DS : '^';
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = false;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         if ($tpl->source->exists) {
             $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath));
             // remove from template cache
             unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
         } else {
             // remove from template cache
             unset($smarty->template_objects[sha1(join(DIRECTORY_SEPARATOR, $smarty->getTemplateDir()) . $tpl->template_resource . $tpl->cache_id . $tpl->compile_id)]);
             return 0;
         }
         $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
     } else {
         $_resource_part = '';
     }
     $_dir = $_compile_dir;
     if ($smarty->use_sub_dirs && isset($_compile_id)) {
         $_dir .= $_compile_id . $_dir_sep;
     }
     if (isset($_compile_id)) {
         $_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep;
     }
     $_count = 0;
     $_compileDirs = new RecursiveDirectoryIterator($_dir);
     $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($_compile as $_file) {
         if (substr($_file->getBasename(), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
             continue;
         }
         if ($_file->isDir()) {
             if (!$_compile->isDot()) {
                 // delete folder if empty
                 @rmdir($_file->getPathname());
             }
         } else {
             if ((!isset($_compile_id) || strlen((string) $_file) > strlen($_compile_id_part) && substr_compare((string) $_file, $_compile_id_part, 0, strlen($_compile_id_part)) == 0) && (!isset($resource_name) || strlen((string) $_file) > strlen($_resource_part_1) && substr_compare((string) $_file, $_resource_part_1, -strlen($_resource_part_1), strlen($_resource_part_1)) == 0 || strlen((string) $_file) > strlen($_resource_part_2) && substr_compare((string) $_file, $_resource_part_2, -strlen($_resource_part_2), strlen($_resource_part_2)) == 0)) {
                 if (isset($exp_time)) {
                     if (time() - @filemtime($_file) >= $exp_time) {
                         $_count += @unlink((string) $_file) ? 1 : 0;
                     }
                 } else {
                     $_count += @unlink((string) $_file) ? 1 : 0;
                 }
             }
         }
     }
     // clear compiled cache
     Smarty_Resource::$sources = array();
     Smarty_Resource::$compileds = array();
     return $_count;
 }
开发者ID:harmofwk,项目名称:harmofwk,代码行数:68,代码来源:smarty_internal_utility.php

示例3: clearCompiledTemplate

 /**
  * Delete compiled template file
  *
  * @param  string  $resource_name template name
  * @param  string  $compile_id    compile id
  * @param  integer $exp_time      expiration time
  * @param  Smarty  $smarty        Smarty instance
  *
  * @return integer number of template files deleted
  */
 public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
 {
     $_compile_dir = realpath($smarty->getCompileDir()) . '/';
     $_compile_id = isset($compile_id) ? preg_replace('![^\\w\\|]+!', '_', $compile_id) : null;
     $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
     if (isset($resource_name)) {
         $_save_stat = $smarty->caching;
         $smarty->caching = false;
         $tpl = new $smarty->template_class($resource_name, $smarty);
         $smarty->caching = $_save_stat;
         // remove from template cache
         $tpl->source;
         // have the template registered before unset()
         if ($smarty->allow_ambiguous_resources) {
             $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
         } else {
             $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
         }
         if (isset($_templateId[150])) {
             $_templateId = sha1($_templateId);
         }
         unset($smarty->template_objects[$_templateId]);
         if ($tpl->source->exists) {
             $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath));
             $_resource_part_1_length = strlen($_resource_part_1);
         } else {
             return 0;
         }
         $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
         $_resource_part_2_length = strlen($_resource_part_2);
     }
     $_dir = $_compile_dir;
     if ($smarty->use_sub_dirs && isset($_compile_id)) {
         $_dir .= $_compile_id . $_dir_sep;
     }
     if (isset($_compile_id)) {
         $_compile_id_part = str_replace('\\', '/', $_compile_dir . $_compile_id . $_dir_sep);
         $_compile_id_part_length = strlen($_compile_id_part);
     }
     $_count = 0;
     try {
         $_compileDirs = new RecursiveDirectoryIterator($_dir);
         // NOTE: UnexpectedValueException thrown for PHP >= 5.3
     } catch (Exception $e) {
         return 0;
     }
     $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($_compile as $_file) {
         if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
             continue;
         }
         $_filepath = str_replace('\\', '/', (string) $_file);
         if ($_file->isDir()) {
             if (!$_compile->isDot()) {
                 // delete folder if empty
                 @rmdir($_file->getPathname());
             }
         } else {
             $unlink = false;
             if ((!isset($_compile_id) || isset($_filepath[$_compile_id_part_length]) && ($a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) && (!isset($resource_name) || isset($_filepath[$_resource_part_1_length]) && substr_compare($_filepath, $_resource_part_1, -$_resource_part_1_length, $_resource_part_1_length) == 0 || isset($_filepath[$_resource_part_2_length]) && substr_compare($_filepath, $_resource_part_2, -$_resource_part_2_length, $_resource_part_2_length) == 0)) {
                 if (isset($exp_time)) {
                     if (time() - @filemtime($_filepath) >= $exp_time) {
                         $unlink = true;
                     }
                 } else {
                     $unlink = true;
                 }
             }
             if ($unlink && @unlink($_filepath)) {
                 $_count++;
             }
         }
     }
     // clear compiled cache
     Smarty_Resource::$sources = array();
     Smarty_Resource::$compileds = array();
     return $_count;
 }
开发者ID:Geo-Developers,项目名称:geo-developers-site,代码行数:88,代码来源:smarty_internal_utility.php


注:本文中的Smarty_Resource::compileds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。