Exemple #1
0
 /**
  *   Fly_Flexy_Token_Tag toString
  *
  * @param    object    Fly_Flexy_Token_Tag
  *
  * @return   string     string to build a template
  * @access   public
  * @see      toString*
  */
 function toStringTag($element)
 {
     $original = $element->getAttribute('ALT');
     // techncially only input type=(submit|button|input) alt=.. applies, but we may
     // as well translate any occurance...
     if (($element->tag == 'IMG' || $element->tag == 'INPUT') && is_string($original) && strlen($original)) {
         $this->addStringToGettext($original);
         $quote = $element->ucAttributes['ALT'][0];
         $element->ucAttributes['ALT'] = $quote . $this->translateString($original) . $quote;
     }
     $original = $element->getAttribute('TITLE');
     if (is_string($original) && strlen($original)) {
         $this->addStringToGettext($original);
         $quote = $element->ucAttributes['TITLE'][0];
         $element->ucAttributes['TITLE'] = $quote . $this->translateString($original) . $quote;
     }
     if (strpos($element->tag, ':') === false) {
         $namespace = 'Tag';
     } else {
         $bits = explode(':', $element->tag);
         $namespace = $bits[0];
     }
     if ($namespace[0] == '/') {
         $namespace = substr($namespace, 1);
     }
     if (empty($this->tagHandlers[$namespace])) {
         require_once 'Fly/Flexy/Compiler/Flexy/Tag.php';
         $handler = Fly_Flexy_Compiler_Flexy_Tag::factory($namespace, $this);
         $this->tagHandlers[$namespace] =& $handler;
         if (!$this->tagHandlers[$namespace]) {
             return Fly_Flexy::raiseError('Fly_Flexy::failed to create Namespace Handler ' . $namespace . ' in file ' . $GLOBALS['_FLY_FLEXY']['filename'], FLY_FLEXY_ERROR_SYNTAX, FLY_FLEXY_ERROR_RETURN);
         }
     }
     return $this->tagHandlers[$namespace]->toString($element);
 }
Exemple #2
0
 /**
  *
  * 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   Fly_Flexy_Compiler
  *
  *
  * @return    object    tag compiler
  * @access   public
  */
 public static function factory($type, &$compiler)
 {
     if (!$type) {
         $type = 'Tag';
     }
     $class = 'Fly_Flexy_Compiler_Flexy_' . $type;
     if ($compiler->classExists($class)) {
         $ret = new $class();
         $ret->compiler =& $compiler;
         return $ret;
     }
     $filename = 'Fly/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
     if (!self::fileExistsInPath($filename)) {
         $ret = self::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 'Fly/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
     $class = 'Fly_Flexy_Compiler_Flexy_' . $type;
     if (!$compiler->classExists($class)) {
         $ret = false;
         return $ret;
     }
     $ret = Fly_Flexy_Compiler_Flexy_Tag::factory($type, $compiler);
     return $ret;
 }