Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1880387
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
5 KB
Subscribers
None
View Options
diff --git a/action.php b/action.php
new file mode 100644
--- /dev/null
+++ b/action.php
@@ -0,0 +1,29 @@
+<?php
+
+if(!defined('DOKU_INC')) die();
+
+class action_plugin_abbrlist extends DokuWiki_Action_Plugin {
+
+ // Register our hooks
+ function register(&$controller) {
+ $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'handle_parser_cache_use');
+ }
+
+ function handle_parser_cache_use(&$event, $param)
+ {
+ global $ID;
+ $cache = &$event->data;
+ if(!isset($cache->page)) return;
+ //purge only xhtml cache
+ if($cache->mode != "xhtml") return;
+
+ $abbrMeta = p_get_metadata($ID, 'abbrlist');
+ if(!$abbrMeta)
+ return;
+
+ $cache->depends['files'][] = DOKU_INC + 'conf/acronyms.conf';
+ $cache->depends['files'][] = DOKU_INC + 'conf/acronyms.local.conf';
+
+ }
+
+}
\ No newline at end of file
diff --git a/lang/en/lang.php b/lang/en/lang.php
new file mode 100644
--- /dev/null
+++ b/lang/en/lang.php
@@ -0,0 +1,5 @@
+<?php
+
+$lang['key'] = 'Acronym';
+$lang['value'] = 'Explanation';
+
diff --git a/plugin.info.txt b/plugin.info.txt
new file mode 100644
--- /dev/null
+++ b/plugin.info.txt
@@ -0,0 +1,7 @@
+base abbrlist
+author Andreas Boehler
+email dev@aboehler.at
+date 2015-09-19
+name List abbreviations as a table
+desc Show all abbreviations with their description as a table
+url http://www.dokuwiki.org/plugin:abbrlist
diff --git a/syntax.php b/syntax.php
new file mode 100644
--- /dev/null
+++ b/syntax.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * DokuWiki Plugin DAVCal (Syntax Component)
+ *
+ * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
+ * @author Andreas Böhler <dev@aboehler.at>
+ */
+
+// must be run within Dokuwiki
+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_abbrlist extends DokuWiki_Syntax_Plugin {
+
+
+ /**
+ * What kind of syntax are we?
+ */
+ function getType(){
+ return 'substition';
+ }
+
+ /**
+ * What about paragraphs?
+ */
+ function getPType(){
+ return 'normal';
+ }
+
+ /**
+ * Where to sort in?
+ */
+ function getSort(){
+ return 163;
+ }
+
+ /**
+ * Connect pattern to lexer
+ */
+ function connectTo($mode) {
+ $this->Lexer->addSpecialPattern('\{\{abbrlist>[^}]*\}\}',$mode,'plugin_abbrlist');
+ }
+
+ /**
+ * Handle the match
+ */
+ function handle($match, $state, $pos, &$handler){
+ global $ID;
+ $options = trim(substr($match,11,-2));
+ $options = explode(',', $options);
+ $data = array(
+ 'nointernal' => false,
+ 'sort' => false,
+ 'acronyms' => array()
+ );
+
+ foreach($options as $option)
+ {
+ switch($option)
+ {
+ case 'nointernal':
+ $data['nointernal'] = true;
+ break;
+
+ case 'sort':
+ $data['sort'] = true;
+ break;
+ }
+ }
+
+ // Only parse the local config file if we should omit built-in ones
+ if($data['nointernal'] === true)
+ {
+ global $config_cascade;
+ if (!is_array($config_cascade['acronyms'])) trigger_error('Missing config cascade for "acronyms"',E_USER_WARNING);
+ if (!empty($config_cascade['acronyms']['local']))
+ {
+ foreach($config_cascade['acronyms']['local'] as $file)
+ {
+ if(file_exists($file))
+ {
+ $data['acronyms'] = array_merge($data['acronyms'], confToHash($file));
+ }
+ }
+ }
+ }
+ // otherwise, simply use retrieveConfig to fetch all acronyms
+ else
+ {
+ $data['acronyms'] = retrieveConfig('acronyms', 'confToHash');
+ }
+
+ // Sort the array, if requested
+ if($data['sort'] === true)
+ {
+ ksort($data['acronyms']);
+ }
+ return $data;
+ }
+
+ /**
+ * Create output
+ */
+ function render($format, &$R, $data) {
+ if(($format != 'xhtml') && ($format != 'odt')) return false;
+
+ $R->table_open();
+ $R->tablethead_open();
+ $R->tableheader_open();
+ $R->doc .= $this->getLang('key');
+ $R->tableheader_close();
+ $R->tableheader_open();
+ $R->doc .= $this->getLang('value');
+ $R->tableheader_close();
+ $R->tablethead_close();
+ foreach($data['acronyms'] as $key => $val)
+ {
+ $R->tablerow_open();
+ $R->tablecell_open();
+ $R->doc .= $key;
+ $R->tablecell_close();
+ $R->tablecell_open();
+ $R->doc .= $val;
+ $R->tablecell_close();
+ $R->tablerow_close();
+ }
+ $R->table_close();
+
+ }
+
+
+
+}
+
+// vim:ts=4:sw=4:et:enc=utf-8:
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jan 24, 4:19 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
532452
Default Alt Text
(5 KB)
Attached To
rABBRLIST DokuWiki abbrlist PlugIn
Event Timeline
Log In to Comment