[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 template_func.php

Zen Cart 源代码 template_func.php




下载文件

文件名: template_func.php
文件类型: PHP文件
文件大小: 2.35 KiB
MD5: 2c149ea4fef65066f6e64f938537f003

template_func.php - 关闭高亮
  1. <?php
  2. /**
  3.  * template_func Class.
  4.  *
  5.  * @package classes
  6.  * @copyright Copyright 2003-2009 Zen Cart Development Team
  7.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  8.  * @version $Id: template_func.php 14141 2009-08-10 19:34:47Z wilt $
  9.  */
  10. if (!defined('IS_ADMIN_FLAG')) {
  11.   die('Illegal Access');
  12. }
  13. /**
  14.  * template_func Class.
  15.  * This class is used to for template-override calculations
  16.  *
  17.  * @package classes
  18.  */
  19. class template_func extends base {
  20.  
  21.   function template_func($template_dir = 'default') {
  22.     $this->info  = array();
  23.   }
  24.  
  25.   function get_template_part($page_directory, $template_part, $file_extension = '.php') {
  26.     $directory_array = array();
  27.     if ($dir = @dir($page_directory)) {
  28.       while ($file = $dir->read()) {
  29.         if (!is_dir($page_directory . $file)) {
  30.           if (substr($file, strrpos($file, '.')) == $file_extension && preg_match($template_part, $file)) {
  31.             $directory_array[] = $file;
  32.           }
  33.         }
  34.       }
  35.  
  36.       sort($directory_array);
  37.       $dir->close();
  38.     }
  39.     return $directory_array;
  40.   }
  41.  
  42.   function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false) {
  43.     //  echo 'template_default/' . $template_dir . '=' . $template_code;
  44.     if ($this->file_exists($current_template . $current_page, $template_code)) {
  45.       return $current_template . $current_page . '/';
  46.     } elseif ($this->file_exists(DIR_WS_TEMPLATES . 'template_default/' . $current_page, preg_replace('/\//', '', $template_code), $debug)) {
  47.       return DIR_WS_TEMPLATES . 'template_default/' . $current_page;
  48.     } elseif ($this->file_exists($current_template . $template_dir, preg_replace('/\//', '', $template_code), $debug)) {
  49.       return $current_template . $template_dir;
  50.     } else {
  51.       return DIR_WS_TEMPLATES . 'template_default/' . $template_dir;
  52.       //        return $current_template . $template_dir;
  53.     }
  54.   }
  55.   function file_exists($file_dir, $file_pattern, $debug=false) {
  56.     $file_found = false;
  57.     $file_pattern = '/'.str_replace("/", "\/", $file_pattern).'$/';
  58.     if ($mydir = @dir($file_dir)) {
  59.       while ($file = $mydir->read()) {
  60.         if (preg_match($file_pattern, $file)) {
  61.           $file_found = true;
  62.           break;
  63.         }
  64.       }
  65.       $mydir->close();
  66.     }
  67.     return $file_found;
  68.   }
  69. }
  70. ?>