public function __construct(WikiLingoWYSIWYG\Parser &$wikiLingoParser) { require_once 'lib/wikiLingo_tiki/WikiPluginStub.php'; $stub = self::$bridge = new WikiPluginStub(); Type::Events($wikiLingoParser->events)->bind(new Event\Expression\Plugin\Exists(function (Plugin &$plugin) use($wikiLingoParser, $stub) { if (!$plugin->exists) { $plugin->exists = true; $plugin->class = $stub; $wikiLingoParser->pluginInstances[$plugin->classType] = $stub; } })); }
public function __construct(&$parser) { if (!$parser->wysiwyg) { $parser->clearTypes(); Type::Events($parser->events)->bind(new Event\Parsed\RenderPermission(function (Parsed &$parsed) { if ($parsed->type == "Plugin" && $parsed->expression->type == "Illegal") { $parsed->expressionPermissible = false; } })); } $this->source = "{ILLEGAL()}\n\t\t {DIV()}\n!Header 1\n!Header 2\n\t\t {DIV}\n{ILLEGAL}{DIV()}\n!Header 3\n{DIV}"; $this->expected = "{ILLEGAL()}\n\t\t {DIV()}\n!Header 1\n!Header 2\n\t\t {DIV}\n{ILLEGAL}<div class='Div' id='Div2'><h1 id='Header-3'>Header 3</h1></div>"; }
public function __construct(&$parser) { if (!$parser->wysiwyg) { Type::Events($parser->events)->bind(new Event\Parsed\RenderPermission(function (Parsed &$parsed) { if ($parsed->type == "Plugin" && $parsed->expression->type == "Illegal") { $parsed->expressionPermissible = false; } }))->bind(new Event\Parsed\RenderBlocked(function (Parsed &$parsed, &$return) { $return = ''; })); } $this->source = "{ILLEGAL()}\n {DIV()}\n!Header 1\n!Header 2\n {DIV}\n{ILLEGAL}"; $this->expected = ""; }
public function __construct(&$parser) { if ($parser != null) { Type::Events($parser->events)->bind(new Event\Translate(function ($value, $context) { switch ($value) { case 'not translated': return 'is translated'; } return $value; })); } $this->source = "{T()}not translated{T}"; $this->expected = "<span class='T' id='T1'>is translated</span>"; }
public function __construct(&$parser) { if ($parser != null) { Type::Events($parser->events)->bind(new Event\Expression\Variable\Context(function (WikiLingo\Expression\Plugin $plugin) { $type = $plugin->parameter('type'); switch ($type) { case 'lookup': return array(array("variable" => "value 1"), array("variable" => "value 2")); } return array(); })); } $this->source = "{TEMPLATE(type=`lookup`)}%variable%{TEMPLATE}"; $this->expected = "<span>value 1</span><span>value 2</span>"; }
public function __construct(&$parser) { $parser->events->WikiLingoEventExpressionVariableContext = array(); if ($parser != null) { Type::Events($parser->events)->bind(new Event\Expression\Variable\Context(function (WikiLingo\Expression\Plugin $plugin) { $type = $plugin->parameter('type'); switch ($type) { case 'parent': return array(array("name" => "first parent"), array("name" => "second parent")); case 'child': return array(array("name" => "first child")); } return null; })); } $this->source = "{TEMPLATE(type=`parent`)}\n%name%\n{TEMPLATE(type=`child`)}\n%name%\n{TEMPLATE}\n{TEMPLATE}"; $this->expected = "<br/>" . "<span>first parent</span><br/>" . "<br/>" . "<span>first child</span><br/>" . "<br/>" . "<br/>" . "<span>second parent</span><br/>" . "<br/>" . "<span>first child</span><br/>" . "<br/>"; }
public function __construct(&$parser) { if (!$parser->wysiwyg) { Type::Events($parser->events)->bind(new Event\Parsed\RenderPermission(function (Parsed &$parsed) { if ($parsed->type == "Plugin" && $parsed->expression->type == "Permission") { $allow = $parsed->expression->parametersRaw['allow']; $parsed->expressionPermissible = $allow == 'true' ? true : false; } }))->bind(new Event\Parsed\RenderBlocked(function (Parsed &$parsed, &$return) { $return = ''; })); } $this->source = <<<WL {PERMISSION(allow="true")} :) {PERMISSION} {PERMISSION(allow="false")} :( {PERMISSION} WL; $this->expected = "<div class='Permission' id='Permission1'><br/>:)<br/></div><br/>"; }
public function __construct(WikiLingo\Parser &$wikiLingoParser, $bindFLP = true) { global $prefs, $page; $headerlib = TikiLib::lib('header'); if ($page == null && $bindFLP) { throw new \Exception("Page undefined"); } require_once 'lib/wikiLingo_tiki/WikiPluginBridge.php'; $bridge = self::$bridge = new WikiPluginBridge(); $events = Type::Events($wikiLingoParser->events); $events->bind(new Event\Expression\Plugin\Exists(function (Plugin &$plugin) use($wikiLingoParser, $bridge) { if (!$plugin->exists) { switch ($plugin->classType) { case "WikiLingo\\Plugin\\Maketoc": if (self::$toc == null) { self::$toc = new WikiLingo\Plugin\Toc(); } $plugin->exists = true; $plugin->class = self::$toc; $wikiLingoParser->pluginInstances[$plugin->classType] = self::$toc; break; default: $plugin->exists = true; $plugin->class = $bridge; $wikiLingoParser->pluginInstances[$plugin->classType] = $bridge; } } })); if ($bindFLP) { //FutureLink-Protocol Events FLP\Events::bind(new FLP\Event\MetadataLookup(function ($linkType, &$metadata) use($page, $headerlib) { $metadataLookup = new WikiMetadataLookup($page); $metadataTemp = $metadataLookup->getPartial(); $metadataTemp->href = TikiLib::tikiUrl('tiki-index.php') . '?page=' . $page; $metadataTemp->text = $metadata->text; $metadata = $metadataTemp; })); } }
public function __construct(&$parser) { $parser->events->WikiLingoEventExpressionVariableContext = array(); if ($parser != null) { Type::Events($parser->events)->bind(new Event\Expression\Variable\Context(function (WikiLingo\Expression\Plugin $plugin) { $type = $plugin->parameter('type'); switch ($type) { case 'lookup1': return array(array("variable" => "1.1"), array("variable" => "1.2")); //lookup 2 is null, thus should not be shown //lookup 2 is null, thus should not be shown case 'lookup2': return null; case 'lookup3': return array(array("variable" => "3.1"), array("variable" => "3.2")); } return null; })); } $this->source = "{TEMPLATE(type=`lookup1`)}\n! Header %variable%\n{TEMPLATE}\n{TEMPLATE(type=`lookup2`)}\n!Header %variable%\n{TEMPLATE}\n{TEMPLATE(type=`lookup3`)}\n!header %variable%\n{TEMPLATE}"; $this->expected = "<h1 id='Header-1-1'><span class='whitespace'> </span>Header <span>1.1</span></h1>" . "<h1 id='Header-1-2'><span class='whitespace'> </span>Header <span>1.2</span></h1>" . "<br/>" . "<br/>" . "<h1 id='header-3-1'>header <span>3.1</span></h1>" . "<h1 id='header-3-2'>header <span>3.2</span></h1>"; }