register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ()); $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, '_purgecache'); } function insert_button(& $event, $param) { $event->data[] = array ( 'type' => 'dialog', 'title' => $this->getLang('pagequery'), 'icon' => '../../plugins/pagequery/images/pagequery.png', 'html' => $this->_cheatsheet(), 'block' => false ); } private function _cheatsheet() { $list = file(DOKU_PLUGIN . 'pagequery/res/toolbar', FILE_IGNORE_NEW_LINES); $text = '
' . PHP_EOL; foreach($list as $line) { $tab = ''; $item = explode("\t", $line, 2); if (substr($item[0], 0, 1) == '-') { $item[0] = substr($item[0], 2); $tab = "    "; } $text .= $tab . '' . $item[0] . '  ' . $item[1] . '
' . PHP_EOL; } $text .= '
' . PHP_EOL; return $text; } /** * Check for pages changes and eventually purge cache. * * @author Samuele Tognini * * @param Doku_Event $event * @param mixed $param not defined */ function _purgecache(&$event, $param) { global $ID; global $conf; /** @var cache_parser $cache */ $cache = &$event->data; if(!isset($cache->page)) return; //purge only xhtml cache if($cache->mode != "xhtml") return; //Check if it is an pagequery page if(!p_get_metadata($ID, 'pagequery')) return; $aclcache = $this->getConf('aclcache'); if($conf['useacl']) { $newkey = false; if($aclcache == 'user') { //Cache per user if($_SERVER['REMOTE_USER']) $newkey = $_SERVER['REMOTE_USER']; } else if($aclcache == 'groups') { //Cache per groups global $INFO; if($INFO['userinfo']['grps']) $newkey = implode('#', $INFO['userinfo']['grps']); } if($newkey) { $cache->key .= "#".$newkey; $cache->cache = getCacheName($cache->key, $cache->ext); } } //Check if a page is more recent than purgefile. if(@filemtime($cache->cache) < @filemtime($conf['cachedir'].'/purgefile')) { $event->preventDefault(); $event->stopPropagation(); $event->result = false; } } }