Ejemplo n.º 1
0
 private function parse_text($text)
 {
     if (!empty($text)) {
         if ($this->current->allowsChildren()) {
             $sPos = 0;
             //process data bindings
             while (preg_match(self::PARSE_DATABINDINGS, $text, $match, PREG_OFFSET_CAPTURE, $sPos)) {
                 list(list($brData, $brPos)) = $match;
                 if ($brPos > $sPos) {
                     //append previous literal content
                     $this->text_addComponent(substr($text, $sPos, $brPos - $sPos), self::TRIM_LEFT);
                 }
                 //create databound literal
                 $l = strlen($brData);
                 $this->text_addComponent($brData);
                 $sPos = $brPos + $l;
             }
             //append remaining literal content
             $this->text_addComponent(substr($text, $sPos), self::TRIM_RIGHT);
         } else {
             $props = $this->current->supportsProperties() ? $this->current->props->getPropertyNames() : [];
             $s = $props ? '<' . join('>, <', array_map('ucfirst', $props)) . '>' : 'none';
             throw new ParseException("\n<h4>You may not define literal content at this location.</h4>\n<table>\n  <tr><th>Component:<td class='fixed'>&lt;{$this->current->getTagName()}&gt;\n  <tr><th>Expected&nbsp;tags:<td class='fixed'>{$s}\n</table>", $this->source, $this->prevTagEnd, $this->currentTagStart - 1);
         }
     }
 }