function testHandlePlural()
 {
     $this->info['Policies'] = false;
     $this->info['Policy'] = array('pageName' => 'Policy', 'description' => 'Some Page', 'lastModif' => 1234567890);
     $link = new WikiParser_OutputLink();
     $link->setIdentifier('Policies');
     $link->setWikiLookup(array($this, 'getPageInfo'));
     $link->setWikiLinkBuilder(array($this, 'getWikiLink'));
     $link->setHandlePlurals(true);
     $this->assertXmlStringEqualsXmlString('<a href="Policy" title="Some Page" class="wiki wiki_page">Policies</a>', $link->getHtml());
 }
Example #2
0
 function testRenderFromDifferentNamespaceWithMultipleParts()
 {
     $this->info['Abc_Def_HelloWorld_Test'] = array('pageName' => 'Abc_Def_HelloWorld_Test', 'prettyName' => 'Abc / Def / HelloWorld / Test', 'namespace' => 'Abc_Def_HelloWorld', 'namespace_parts' => array('Abc', 'Def', 'HelloWorld'), 'baseName' => 'Test', 'description' => '', 'lastModif' => 1234567890);
     // ((Test)) within a page in HelloWorld namespace
     $link = new WikiParser_OutputLink();
     $link->setWikiLookup(array($this, 'getPageInfo'));
     $link->setNamespace('Foobar', '_');
     $link->setIdentifier('Abc_Def_HelloWorld_Test');
     $this->assertLinkIs('<a href="Abc_Def_HelloWorld_Test" title="Abc / Def / HelloWorld / Test" class="wiki wiki_page"><span class="namespace first">Abc</span><span class="namespace">Def</span><span class="namespace last">HelloWorld</span>Test</a>', $link->getHtml());
 }
Example #3
0
 function get_wiki_link_replacement($pageLink, $extra = array(), $ck_editor = false)
 {
     global $tikilib, $prefs;
     $wikilib = TikiLib::lib('wiki');
     // Fetch all externals once
     static $externals = false;
     if (false === $externals) {
         $externals = $tikilib->fetchMap('SELECT LOWER(`name`), `extwiki` FROM `tiki_extwiki`');
     }
     $displayLink = $pageLink;
     // HTML entities encoding breaks page lookup
     $pageLink = html_entity_decode($pageLink, ENT_COMPAT, 'UTF-8');
     $description = null;
     $reltype = null;
     $processPlural = false;
     $anchor = null;
     if (array_key_exists('description', $extra)) {
         $description = $extra['description'];
     }
     if (array_key_exists('reltype', $extra)) {
         $reltype = $extra['reltype'];
     }
     if (array_key_exists('plural', $extra)) {
         $processPlural = (bool) $extra['plural'];
     }
     if (array_key_exists('anchor', $extra)) {
         $anchor = $extra['anchor'];
     }
     $link = new WikiParser_OutputLink();
     $link->setIdentifier($pageLink);
     $link->setQualifier($reltype);
     $link->setDescription($description);
     $link->setWikiLookup(array($this, 'parser_helper_wiki_info_getter'));
     $link->setWikiLinkBuilder(array($this, 'parser_helper_wiki_link_builder'));
     $link->setExternals($externals);
     $link->setHandlePlurals($processPlural);
     $link->setAnchor($anchor);
     if ($prefs['feature_multilingual'] == 'y' && isset($GLOBALS['pageLang'])) {
         $link->setLanguage($GLOBALS['pageLang']);
     }
     return $link->getHtml($ck_editor);
 }