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


PHP MVCUtils::getTemplateModule方法代码示例

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


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

示例1: findTemplate

 /**
  * Find a template
  *
  * This will look in the module for the specified template to try and find
  * a path to the template. If it cannot be found, each module will be 
  * serched for the file. The the full path to the requested template will
  * be returned.
  * 
  * @param mixed $template Either a template ID or file name
  * @return string The full path to the template including the file name, or false if not found
  */
 public static function findTemplate($template)
 {
     //Make sure $template is a name, not id
     if (is_numeric($template)) {
         $template = self::getTemplateFileName($template);
     }
     $fullPath = false;
     //Check for windows and unix-type full path
     if (stristr('[A-Z]:', $template) !== false) {
         $fullPath = true;
     } else {
         if (substr($template, 0, 1) == '/') {
             $fullPath = true;
         }
     }
     if ($fullPath && file_exists($template)) {
         return $template;
     }
     static $cache = array();
     global $cfg;
     //Check for cached result
     if (isset($cache[$template])) {
         return $cache[$template];
         //if cached, execution stops here
     }
     //Get the module in which the template reisdes
     $module = MVCUtils::getTemplateModule($template);
     //If the template was found in the database then look for it in the
     //module specified in the database.
     if (!is_null($module)) {
         //Generate the path of the template file
         $path = $cfg['general']['toolkitRoot'] . "/{$module}/templates/{$template}";
         $path = realpath($path);
         //Check the template exists where it should
         if (!file_exists($path)) {
             BasicLogger::logMessage("Template '{$template}' could not be found. I was looking here: {$path}", self::module, 'error');
             return false;
         }
         //Cache the return value
         $cache[$template] = $path;
         return $path;
         //If the template was not found in the database then start searching
         //each modules template directory. The is because templates can
         //request to include a file which is not in the database. This could
         //be more efficiet if there was some method of knowing the directory
         //of the parent template, because only that directory would then need
         //to be searched
     } else {
         foreach ($cfg['modules'] as $module) {
             $path = $cfg['general']['toolkitRoot'] . '/' . $module . '/templates/';
             //Convert relative paths to full paths
             $path = realpath($path);
             if (strlen($path) > 0) {
                 //Recursively search the directory
                 $path = self::findFile($path, $template);
                 if ($path !== false) {
                     //cache the return value
                     $cache[$template] = $path;
                     return $path;
                 }
             }
         }
         return false;
     }
     /*
     		
     		//If execution has got this far then the file has not been found
     		
     		BasicLogger::logMessage("Template '$template' could not be found", self::module, 'error');
     		
     		return false;*/
 }
开发者ID:radiowarwick,项目名称:digiplay_legacy,代码行数:83,代码来源:MVCUtils.class.php


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