コード例 #1
1
ファイル: Tag.php プロジェクト: alexzita/alex_blog
 /**
  *   
  * Factory method to create Tag Handlers
  *
  * $type = namespace eg. <flexy:toJavascript loads Flexy.php
  * the default is this... (eg. Tag)
  * 
  * 
  * @param   string    Namespace handler for element.
  * @param   object   HTML_Template_Flexy_Compiler  
  * 
  *
  * @return    object    tag compiler
  * @access   public
  */
 function &factory($type, &$compiler)
 {
     if (!$type) {
         $type = 'Tag';
     }
     $class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;
     if (class_exists($class)) {
         $ret = new $class();
         $ret->compiler =& $compiler;
         return $ret;
     }
     $filename = 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
     if (!HTML_Template_Flexy_Compiler_Flexy_Tag::fileExistsInPath($filename)) {
         $ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory('Tag', $compiler);
         return $ret;
     }
     // if we dont have a handler - just use the basic handler.
     if (!file_exists(dirname(__FILE__) . '/' . ucfirst(strtolower($type)) . '.php')) {
         $type = 'Tag';
     }
     include_once 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
     $class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;
     if (!class_exists($class)) {
         $ret = false;
         return $ret;
     }
     $ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory($type, $compiler);
     return $ret;
 }