summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public_html/lib/plugins/pagetitle/action.php142
1 files changed, 0 insertions, 142 deletions
diff --git a/public_html/lib/plugins/pagetitle/action.php b/public_html/lib/plugins/pagetitle/action.php
deleted file mode 100644
index 9c00b38..0000000
--- a/public_html/lib/plugins/pagetitle/action.php
+++ /dev/null
@@ -1,142 +0,0 @@
1<?php
2/**
3 * DokuWiki Plugin PageTitle; Action component
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Satoshi Sahara <sahara.satoshi@gmail.com>
7 */
8
9if(!defined('DOKU_INC')) die();
10
11class action_plugin_pagetitle extends DokuWiki_Action_Plugin {
12
13 /**
14 * register the event handlers
15 */
16 function register(Doku_Event_Handler $controller) {
17 //$controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'deleteObsoletedSingleClass');
18 $controller->register_hook('INDEXER_VERSION_GET', 'BEFORE', $this, '_indexer_version');
19 $controller->register_hook('INDEXER_PAGE_ADD', 'BEFORE', $this, '_indexer_pagetitle');
20 $controller->register_hook('PARSER_METADATA_RENDER', 'AFTER', $this, '_parser_render');
21 $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, '_prepare_cache');
22 }
23
24 /**
25 * Delete syntax.php which is obsoleted since multi-components syntax structure
26 */
27 function deleteObsoletedSingleClass(Doku_Event $event) {
28 $legacyFile = dirname(__FILE__).'/syntax.php';
29 if (file_exists($legacyFile)) { unlink($legacyFile); }
30 }
31
32
33 /**
34 * INDEXER_VERSION_GET
35 * Set a version string to the metadata index so that
36 * the index will be re-created when the version increased
37 */
38 function _indexer_version(Doku_Event $event, $param) {
39 $event->data['plgin_pagetitle'] = '1.'.$this->getConf('usePersistent');
40 }
41
42 /**
43 * INDEXER_PAGE_ADD
44 * Add id of the page to metadata index, relevant pages should be found
45 * in data/index/plugin_pagetitle_w.idx file
46 */
47 function _indexer_pagetitle(Doku_Event $event, $param) {
48 $id = p_get_metadata($event->data['page'], 'plugin pagetitle');
49 if ($id) {
50 $event->data['metadata']['plugin_pagetitle'] = $id;
51 }
52 }
53
54
55 /**
56 * PAESER_METADATA_RENDER
57 * Use this event to update/reflesh metadata they may have set elseware.
58 * The page metadata is passed including both the current and persistent arrays.
59 */
60 function _parser_render(Doku_Event $event, $param) {
61 global $ID;
62
63 /*
64 * The PageTitle plugin will overwrite "title" metadata of the page
65 * with "pagetitle" specified in page source. The page must be rendered
66 * first in xhtml mode to get pagetitle and to stote it on metadata
67 * storage.
68
69 * Each metadata storage (.meta file) may be expired or refleshed by
70 * DokuWiki or any plugins at elsewhere in any stage. For example,
71 * metadata will be expired when main config modified. DokuWiki will set
72 * again title metadata through calls p_get_first_heading() depending on
73 * $conf['useheading"] setting.
74 *
75 * Since page text is not changed, instruction and xhtml cache files are
76 * used to set title metadata, there is no chance to handle/render page
77 * source to get pagetitle and to overwite title metadata.
78 * Therfore, the value of "title" metadata will remain wrong with that
79 * pagetitle plugin intended.
80 *
81 * For the purpose to trigger PageTitle plugin's renderer, we tentatively
82 * set $ID as "title" to tell DokuWiki caching mechanism so that old
83 * cache need to be purged and metadata must be rebuild again.
84 */
85
86 $meta =& $event->data['current'];
87 $persistent =& $event->data['persistent'];
88
89 // check metadata index whether pagetitle had used in the wiki page
90 $pages = idx_get_indexer()->getPages('plugin_pagetitle');
91 $pageTitled = in_array($ID, $pages);
92
93 if (!$pageTitled) return;
94
95 // check whether page has rendered by pagetitle plugin
96 if (!isset($meta['plugin']['pagetitle'])) {
97 // tentatively assign full id as page title, just to distinguish
98 // with normal setting noNS($ID) and to purge .meta file later
99 $meta['title'] = $ID;
100 }
101
102 // unnecessary persistent metadata should be removed in syntax component,
103 // however it may be possible to remove it here
104 if (!$this->getConf('usePersistent')) {
105 unset($persistent['title']);
106 }
107 }
108
109 /**
110 * PARSER_CACHE_USE
111 * prepare the cache object for default _useCache action
112 */
113 function _prepare_cache(Doku_Event $event, $param) {
114 $cache =& $event->data;
115
116 // we're only interested in wiki pages
117 if (!isset($cache->page)) return;
118
119 // check metadata index whether pagetitle had used in the wiki page
120 $pages = idx_get_indexer()->getPages('plugin_pagetitle');
121 $pageTitled = in_array($cache->page, $pages);
122
123 if (!$pageTitled) return;
124
125 // check title metadata whether cache files should be purged
126 $title = p_get_metadata($cache->page, 'title', METADATA_DONT_RENDER);
127 switch ($cache->mode) {
128 case 'metadata': // metadata cache?
129 $request = ($title == $cache->page) ? true : false;
130 break;
131 case 'i': // instruction cache
132 $request = ($title == $cache->page) ? true : false;
133 break;
134 case 'xhtml': // xhtml cache
135 $request = ($title == $cache->page) ? true : false;
136 break;
137 }
138 // request purge if necessary
139 $cache->depends['purge'] = $request;
140 }
141
142}