[cvs] [Wiki] changed: RuleWikilink
Jan Schneider
jan at horde.org
Mon Aug 16 01:39:37 PDT 2004
jan Mon, 16 Aug 2004 01:39:37 -0700
Modified page: http://wiki.horde.org/display.php?page=RuleWikilink
New Revision: 1.1
@@ -1,6 +1,4 @@
-+ {{wikilink}}
-
[[toc]]
++ About This Rule
@@ -8,23 +6,29 @@
|| **Type** || inline ||
|| **Syntax** normal || {{``AnyPageName``}} ||
|| **Syntax** described || {{``[AnyPageName displayed link text]``}} ||
-++ Configuration Values
+++ Parse Configuration Keys
-|| **Name** || **Type** || **Description** ||
-|| {{pages}} || array || A sequential array of page names that exist in the wiki ||
-|| {{view_url}} || string || The base URL to view pages in the wiki ||
-|| {{new_url}} || string || The base URL to create new pages in the wiki ||
-|| {{new_text}} || string || The text displayed after non-existent page names ||
+None.
+
+++ Render Configuration Keys
+
+|| **Format** || **Key** || **Type** || **Description** ||
+|| {{Xhtml}} || {{pages}} || array || A sequential array of page names that exist in the wiki ||
+|| {{Xhtml}} || {{view_url}} || string || The base URL to view pages in the wiki ||
+|| {{Xhtml}} || {{new_url}} || string || The base URL to create new pages in the wiki ||
+|| {{Xhtml}} || {{new_text}} || string || The text displayed after non-existent page names ||
++ Description
As you should know by now, page names in wikis are made of !WordsSmashedTogether in !StudlyCapsMode. The wikilink rule looks for !WikiPages and creates links out of them. This requires some moderate configuration to customize it for your environment.
-The rule needs to know what pages exist in the wiki, so that when it finds a page name in the source text, it can show the proper link (either to view an existing page, or create a page that has been named but does not yet exist). To tell Text_Wiki what wiki pages exist, use the 'pages' key in {{setRuleConf()}}.
+In Text_Wiki, wiki words are allowed to have numbers in them; each digit 0-9 is treated as a lower-case character for purposes of parsing words.
-<php>
+The rule needs to know what pages exist in the wiki, so that when it finds a page name in the source text, it can show the proper link (either to view an existing page, or create a page that has been named but does not yet exist). To tell Text_Wiki what wiki pages exist, use the 'pages' key in {{[MethodSetRenderConf setRenderConf()]}}.
+
+<code type="php">
// [snip] create a Text_Wiki object called $wiki
// get the list of pages in the wiki
$pages = array(
@@ -32,24 +36,29 @@
'WordsSmashedTogether',
'SomeOtherPages'
);
-$wiki->setRuleConf('wikilink', 'pages', $pages);
-</php>
+$wiki->setRenderConf('xhtml', 'wikilink', 'pages', $pages);
+</code>
Now Text_Wiki needs to know where to link pages to. There are two configuration keys for this, 'view_url' and 'new_url'. If the parser finds a page name that exists in the 'pages' array, it will use 'view_url'; if the page is not in the 'pages' array, it will use 'new_url'.
-<php>
-$wiki->setRuleConf('wikilink', 'view_url', 'http://example.php/view.php?page=');
-$wiki->setRuleConf('wikilink', 'new_url', 'http://example.php/new.php?page=');
-</php>
+<code type="php">
+$wiki->setRenderConf('xhtml', 'wikilink', 'view_url',
+ 'http://example.php/view.php?page=%s');
+
+$wiki->setRenderConf('xhtml', 'wikilink', 'new_url',
+ 'http://example.php/new.php?page=%s');
+</code>
+
+> **Note:** Note the use of %s in the above URL strings; the %s will be replaced by the page name. If you specify a string that does not have a %s in it, Text_Wiki will assume that the page name should go at the very end of the string.
Finally, if the page exists, Text_Wiki will make the page name itself a link. If the page does not exist, Text_Wiki will add some text after the page name and make that clickable instead (leading to the 'new_url'). Normally the 'new_text' is just a question mark, but you can place any literal text you like.
-<php>
+<code type="php">
// make the new_text a tilde
-$wiki->setRuleConf('wikilink', 'new_text', '~');
+$wiki->setRenderConf('xhtml', 'wikilink', 'new_text', '~');
// make the new_text an image tag
-$wiki->setRuleConf('wikilink', 'new_text', '<img src="new_page.jpg" />');
-</php>
-
+$wiki->setRenderConf('xhtml', 'wikilink', 'new_text',
+ '<img src="new_page.jpg" />');
+</code>
More information about the cvs
mailing list