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'><{$this->current->getTagName()}>\n <tr><th>Expected tags:<td class='fixed'>{$s}\n</table>", $this->source, $this->prevTagEnd, $this->currentTagStart - 1); } } }
static function throwUnknownComponent(DocumentContext $context, $tagName, Component $parent, $filename = null) { $paths = implode('', map($context->matisseSettings->getMacrosDirectories(), function ($dir) { return "<li><path>{$dir}</path></li>"; })); $filename = $filename ? "<kbd>{$filename}</kbd>" : "it"; throw new ComponentException(null, "<h3>Unknown component / macro: <b>{$tagName}</b></h3>\n<p>Neither a <b>class</b>, nor a <b>property</b>, nor a <b>macro</b> with the specified name were found.\n<p>If it's a component, perhaps you forgot to register the tag...\n<p>If it's a macro, Matisse is searching for {$filename} on these paths:<ul>{$paths}</ul>\n<table>\n <th>Container component:<td><b><{$parent->getTagName()}></b>, of type <b>{$parent->className}</b>\n</table>\n"); }
/** * Checks if the given component matches the preset's selector. * * @param Component $component * @return bool */ function matches(Component $component) { if ($this->matchTag && $this->matchTag !== $component->getTagName()) { return false; } if ($this->matchClass && (!$component instanceof HtmlComponent || !preg_match($this->matchClass, $component->props->class))) { return false; } if ($component->supportsProperties() && ($prop = $this->matchPropName)) { if (!$component->props->defines($prop)) { return false; } if ($this->matchPropValue !== '') { if ($component->props->{$prop} != $this->matchPropValue) { return false; } } else { if (!exists($component->props->{$prop})) { return false; } } } return true; }