コード例 #1
0
ファイル: Controller.php プロジェクト: techart/tao
 public function view_path_for($template)
 {
     if (Templates::is_absolute_path($template)) {
         return $template;
     }
     foreach ((array) $this->views_path as $path) {
         $controller_path = Templates::add_extension("{$path}/{$template}", '.phtml');
         if (IO_FS::exists($controller_path)) {
             return $controller_path;
         }
     }
     return $template;
 }
コード例 #2
0
ファイル: Fields.php プロジェクト: techart/tao
 public function template($data = array(), $name = 'template')
 {
     static $template = array();
     if (Templates::is_absolute_path($name)) {
         return $name;
     }
     if (isset($data['template'])) {
         $data_templates = is_string($data['template']) ? array('template' => $data['template']) : $data['template'];
         if (isset($data_templates[$name]) && IO_FS::exists($data_templates[$name])) {
             return $data_templates[$name];
         }
     }
     $type = isset($data['type']) ? $data['type'] : 'input';
     $key = $type . '_' . $name;
     if (isset($template[$key])) {
         return $template[$key];
     }
     /*if ($name == 'template' && isset($data['template name']))
       $name = $data['template name'];*/
     $file = $this->dir() . "/{$name}.phtml";
     if (IO_FS::exists($file)) {
         return $template[$key] = $file;
     }
     $types = array($type);
     $parents = Core_Types::class_hierarchy_for($this);
     if (count($parents) >= 3) {
         foreach (array_slice($parents, 1, count($parents) - 2) as $p) {
             $type = CMS_Fields::type_by_class($p);
             if (empty($type)) {
                 $type = CMS_Fields::type_by_class(Core_Types::module_name_for($p));
             }
             $types[] = $type;
         }
     }
     foreach ($types as $t) {
         if (empty($t)) {
             continue;
         }
         $view = Templates_HTML::Template('fields/' . $t . '/' . $name);
         if ($view->exists()) {
             return $template[$key] = $view->path;
         }
     }
     $view = Templates_HTML::Template('fields/' . $name);
     if ($view->exists()) {
         return $template[$key] = $view->path;
     }
     return $template[$key] = $name;
 }
コード例 #3
0
ファイル: HTML.php プロジェクト: techart/tao
 /**
  * Возвращает путь до partial шаблона
  *
  * @param string $name
  *
  * @return string
  */
 protected function get_partial_path($name, $paths = array())
 {
     if (Core_Strings::starts_with($name, '!')) {
         $trace = debug_backtrace();
         foreach ($trace as $k => $t) {
             if (Core_Strings::ends_with($t['file'], $this->extension)) {
                 break;
             }
         }
         return Templates::add_extension(dirname($trace[$k]['file']) . '/' . substr($name, 1), $this->extension);
     }
     $file = Templates::add_extension($name, $this->extension);
     if (Templates::is_absolute_path($name)) {
         return $file;
     }
     $paths = array_merge($paths, $this->partial_paths(), Templates::option('templates_root'));
     foreach ($paths as $path) {
         $result = rtrim($path, '/') . '/' . $file;
         if (is_file($result)) {
             return $result;
         }
     }
     return $result;
 }