summaryrefslogtreecommitdiff
path: root/syntax.php
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2011-10-16 22:11:40 +0200
committerYves Fischer <yvesf-git@xapek.org>2011-10-16 22:14:58 +0200
commitca0645e63d39c8cb67423ef76f0415fc09d2aca4 (patch)
treee702ccee04bc6566fc34532f791b7f501a7d4df1 /syntax.php
parenteb26ead488d64ffd2e9dd02d665450c6489b39b7 (diff)
downloaddokuwiki-plugin-treenav-ca0645e63d39c8cb67423ef76f0415fc09d2aca4.tar.gz
dokuwiki-plugin-treenav-ca0645e63d39c8cb67423ef76f0415fc09d2aca4.zip
Page Preferences (~~key:val~~), source modelines
Diffstat (limited to 'syntax.php')
-rw-r--r--syntax.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/syntax.php b/syntax.php
new file mode 100644
index 0000000..fc6f648
--- /dev/null
+++ b/syntax.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Simple Tree Navigation Plugin
+ * @author Yves Fischer <yvesf-git@xapek.org>
+ */
+if(!defined('DOKU_INC')) die();
+if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+require_once DOKU_PLUGIN.'syntax.php';
+
+class syntax_plugin_treenav extends DokuWiki_Syntax_Plugin {
+ private $keys = array("icon", "title");
+
+ function getType() { return 'baseonly'; }
+ function getSort() { return 32; }
+
+ function connectTo($mode) {
+ foreach ($this->keys as $key) {
+ $this->Lexer->addSpecialPattern('~~'.$key.':.*?~~',$mode,'plugin_treenav');
+ }
+ }
+
+ function handle($match, $state, $pos, &$handler) {
+ switch ($state) {
+ case DOKU_LEXER_SPECIAL:
+ $match = substr($match, 2, -2);
+ @list($key, $value) = explode(':', $match, 2);
+ if (in_array($key, $this->keys)) {
+ $this->setMetadata($key, $value);
+ }
+ }
+ }
+
+ function setMetadata($key, $value) {
+ global $ID;
+ $data = p_get_metadata($ID, "treenav", false) or array();
+ $data[$key] = $value;
+ return p_set_metadata($ID, array("treenav" => $data));
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+/* Local Variables: */
+/* tab-width: 4 */
+/* indent-tabs-mode: nil */
+/* c-basic-offset: 4 */
+/* End: */ \ No newline at end of file