private function do_parse()
 {
     $template_element = new TextTemplateSyntaxElement();
     $template_element->parse(new TemplateSyntaxParserContext(), $this->input, $this->output);
     if ($this->input->has_next()) {
         throw new TemplateRenderingException('Unknown statement', $this->input);
     }
 }
 public function parse(TemplateSyntaxParserContext $context, StringInputStream $input, StringOutputStream $output)
 {
     $matches = array();
     if ($input->consume_next('(?P<var>\\w+)', '', $matches)) {
         $varname = $matches['var'];
         $output->write(TemplateSyntaxElement::DATA . '->get(\'' . $varname . '\')');
     } else {
         throw new TemplateRenderingException('invalid simple variable name', $input);
     }
 }
 public function parse(TemplateSyntaxParserContext $context, StringInputStream $input, StringOutputStream $output)
 {
     $matches = array();
     if ($input->consume_next('(?P<constant>(?:[0-9]+(?:\\.[0-9]+)?)|(?:\'[^\']*\')|(?:true)|(?:false))', '', $matches)) {
         $constant = $matches['constant'];
         $output->write($constant);
     } else {
         throw new TemplateRenderingException('invalid constant variable', $input);
     }
 }
 private function compute_position()
 {
     $position = $this->input->tell();
     $string = $this->input->entire_string();
     $str_to_position = substr($string, 0, $position);
     $this->tpl_line = substr_count($string, "\n", 0, $position) + 1;
     $last_line_index = strrpos($str_to_position, "\n");
     $line_content = substr($str_to_position, $last_line_index + 1);
     $this->offset = strlen($line_content);
 }
 public function parse(TemplateSyntaxParserContext $context, StringInputStream $input, StringOutputStream $output)
 {
     $matches = array();
     if ($input->consume_next('@(?P<html>H\\|)?(?P<msg>[a-z0-9A-Z_][\\w_.]*)', '', $matches)) {
         $is_html = $matches['html'];
         $msg = $matches['msg'];
         $function = $is_html ? 'i18nraw' : 'i18n';
         $output->write(TemplateSyntaxElement::FUNCTIONS . '->' . $function . '(\'' . $msg . '\')');
     } else {
         throw new TemplateRenderingException('invalid simple variable name', $input);
     }
 }
 public static function is_element(StringInputStream $input)
 {
     return $input->assert_next('#\\sSTART\\s+(?:\\w+\\.)*\\w+\\s#');
 }
 public static function is_element(StringInputStream $input)
 {
     return $input->assert_next('\\s*\\[');
 }
Beispiel #8
0
 /**
  * Load a file input stream.
  * 
  * @param string $data
  *   The file or url path to load.
  */
 function __construct($data, $encoding = 'UTF-8', $debug = '')
 {
     // Get the contents of the file.
     $content = file_get_contents($data);
     parent::__construct($content, $encoding, $debug);
 }
 protected function parseHTML($content)
 {
     $tokenizer = HtmlTokenizer::create(StringInputStream::create($content))->lowercaseTags(true)->lowercaseAttributes(true);
     $insideHead = false;
     while ($token = $tokenizer->nextToken()) {
         if (!$insideHead) {
             if ($token instanceof SgmlOpenTag && $token->getId() == 'head') {
                 $insideHead = true;
                 continue;
             }
         }
         if ($insideHead) {
             if ($token instanceof SgmlEndTag && $token->getId() == 'head') {
                 break;
             }
             if ($token instanceof SgmlOpenTag && $token->getId() == 'link' && $token->hasAttribute('rel') && $token->hasAttribute('href')) {
                 if ($token->getAttribute('rel') == 'openid.server') {
                     $this->server = HttpUrl::create()->parse($token->getAttribute('href'));
                 }
                 if ($token->getAttribute('rel') == 'openid.delegate') {
                     $this->realId = HttpUrl::create()->parse($token->getAttribute('href'));
                 }
             }
             if ($token instanceof SgmlOpenTag && $token->getId() == 'meta' && $token->hasAttribute('content') && $token->hasAttribute('http-equiv') && mb_strtolower($token->getAttribute('http-equiv')) == self::HEADER_XRDS_LOCATION) {
                 $this->loadXRDS($token->getAttribute('content'));
                 return $this;
             }
         }
     }
     return $this;
 }
 public static function is_element(StringInputStream $input)
 {
     return $input->assert_next('(?:\\w+\\.)+\\w+');
 }
 public static function is_element(StringInputStream $input)
 {
     return $input->assert_next('\\s*(?:\\w+::)?\\w+\\(\\s*');
 }
 public static function is_element(StringInputStream $input)
 {
     return $input->assert_next('#\\s+INCLUDE');
 }
 public static function is_element(StringInputStream $input)
 {
     return $input->assert_next('\\s*(?:@(?:H\\|)?)?(?:[a-z0-9A-Z_]\\w+\\.)*[a-z0-9A-Z_]\\w+\\s*');
 }