示例#1
0
 function is_custom_tag()
 {
     static $tag = NULL;
     if (!$tag) {
         $tag = Haanga_Extension::getInstance('Tag');
     }
     $value = $tag->isValid($this->value);
     $this->token = $value ? $value : HG_Parser::T_ALPHA;
 }
示例#2
0
 function do_filtering($name, $args)
 {
     static $filter;
     if (!$filter) {
         $filter = Haanga_Extension::getInstance('Filter');
     }
     if (is_array($name)) {
         /*
           prepare array for ($func_name, $arg1, $arg2 ... )
           where $arg1 = last expression and $arg2.. $argX is
           defined in the template
         */
         $args = array_merge($args, $name['args']);
         $name = $name[0];
     }
     if (!$filter->isValid($name)) {
         throw new Exception("{$name} is an invalid filter");
     }
     if ($filter->isSafe($name)) {
         /* check if the filter is return HTML-safe data (to avoid double scape) */
         $this->var_is_safe = TRUE;
     }
     if ($filter->hasGenerator($name)) {
         return $filter->generator($name, $this, $args);
     }
     $fnc = $filter->getFunctionAlias($name);
     if (!$fnc) {
         $fnc = $this->get_custom_filter($name);
     }
     $args = array_merge(array($fnc), $args);
     $exec = call_user_func_array('hexec', $args);
     return $exec;
 }
示例#3
0
 function yylex_main()
 {
     $data =& $this->data;
     for ($i =& $this->N; is_null($this->token) && $i < $this->length; ++$i) {
         switch ($data[$i]) {
             /* strings {{{ */
             case '"':
             case "'":
                 $end = $data[$i];
                 $value = "";
                 while ($data[++$i] != $end) {
                     switch ($data[$i]) {
                         case "\\":
                             switch ($data[++$i]) {
                                 case "n":
                                     $value .= "\n";
                                     break;
                                 case "t":
                                     $value .= "\t";
                                     break;
                                 default:
                                     $value .= $data[$i];
                             }
                             break;
                         case $end:
                             --$i;
                             break 2;
                         default:
                             if ($data[$i] == "\n") {
                                 $this->line++;
                             }
                             $value .= $data[$i];
                     }
                     if (!isset($data[$i + 1])) {
                         $this->Error("unclosed string");
                     }
                 }
                 $this->value = $value;
                 $this->token = HG_Parser::T_STRING;
                 break;
                 /* }}} */
                 /* number {{{ */
             /* }}} */
             /* number {{{ */
             case '0':
             case '1':
             case '2':
             case '3':
             case '4':
             case '5':
             case '6':
             case '7':
             case '8':
             case '9':
                 $value = "";
                 $dot = FALSE;
                 for ($e = 0; $i < $this->length; ++$e, ++$i) {
                     switch ($data[$i]) {
                         case '0':
                         case '1':
                         case '2':
                         case '3':
                         case '4':
                         case '5':
                         case '6':
                         case '7':
                         case '8':
                         case '9':
                             $value .= $data[$i];
                             break;
                         case '.':
                             if (!$dot) {
                                 $value .= ".";
                                 $dot = TRUE;
                             } else {
                                 $this->error("Invalid number");
                             }
                             break;
                         default:
                             break 2;
                             /* break the main loop */
                     }
                 }
                 if (!$this->is_token_end($data[$i]) && !isset(self::$operators_single[$data[$i]]) || $value[$e - 1] == '.') {
                     $this->error("Unexpected '{$data[$i]}'");
                 }
                 $this->value = $value;
                 $this->token = HG_Parser::T_NUMERIC;
                 break 2;
                 /* }}} */
             /* }}} */
             case "\n":
             case " ":
             case "\t":
             case "\r":
             case "\f":
                 for (; is_null($this->token) && $i < $this->length; ++$i) {
                     switch ($data[$i]) {
                         case "\n":
                             $this->line++;
                         case " ":
                         case "\t":
                         case "\r":
                         case "\f":
                             break;
                         case '.':
                             if ($data[$i + 1] != '.') {
                                 $this->token = HG_Parser::T_CONCAT;
                                 $this->value = '.';
                                 $i++;
                                 return;
                             }
                         default:
                             /* break main loop */
                             /* and decrease because last processed byte */
                             /* wasn't a dot (T_CONCAT)                  */
                             --$i;
                             break 2;
                     }
                 }
                 break;
                 /* whitespaces are ignored */
             /* whitespaces are ignored */
             default:
                 if (!$this->getTag() && !$this->getOperator()) {
                     $alpha = $this->getAlpha();
                     if ($alpha === FALSE) {
                         $this->error("error: unexpected " . substr($data, $i));
                     }
                     static $tag = NULL;
                     if (!$tag) {
                         $tag = Haanga_Extension::getInstance('Tag');
                     }
                     $value = $tag->isValid($alpha);
                     $this->token = $value ? $value : HG_Parser::T_ALPHA;
                     $this->value = $alpha;
                 }
                 break 2;
         }
     }
     if ($this->token == HG_Parser::T_TAG_CLOSE || $this->token == HG_Parser::T_PRINT_CLOSE) {
         $this->status = self::IN_NONE;
     }
 }
 function do_filtering($name, $args)
 {
     static $filter;
     if (!$filter) {
         $filter = Haanga_Extension::getInstance('Filter');
     }
     if (is_array($name)) {
         /*
           prepare array for ($func_name, $arg1, $arg2 ... ) 
           where $arg1 = last expression and $arg2.. $argX is 
           defined in the template 
         */
         $args = array_merge($args, $name['args']);
         $name = $name[0];
     }
     if (!$filter->isValid($name)) {
         $this->Error("{$name} is an invalid filter");
     }
     if ($filter->hasGenerator($name)) {
         return $filter->generator($name, $this, $args);
     }
     $fnc = $filter->getFunctionAlias($name);
     if (!$fnc) {
         $fnc = $this->get_custom_filter($name);
     }
     $args = array_merge(array($fnc), $args);
     $exec = call_user_func_array('hexec', $args);
     return $exec;
 }
示例#5
0
 function get_custom_filter($name)
 {
     static $filter = NULL;
     if (!$filter) {
         $filter = Haanga_Extension::getInstance('Filter');
     }
     $loaded =& $this->filters;
     if (!isset($loaded[$name])) {
         $this->prepend_op->comment("Load filter {$name} definition");
         $this->prepend_op->do_exec('require_once', $filter->getFilePath($name, FALSE));
         $loaded[$name] = TRUE;
     }
     return $filter->getClassName($name) . "::main";
 }