register_hook('HTMLOK_ACCESS_EVENT', 'BEFORE', $this, 'errors_top'); $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'bypasss_cache'); $controller->register_hook('TEMPLATE_USERTOOLS_DISPLAY', 'BEFORE', $this, 'action_link', array('user')); $controller->register_hook('TEMPLATE_HTMLOKAYTOOLS_DISPLAY', 'BEFORE', $this, 'action_link', array('ok')); $controller->register_hook('ACTION_HEADERS_SEND', 'BEFORE', $this, 'modify_headers', array()); $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'dw_started', array()); $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'errors_top', array()); } function dw_started(&$event, $param) { $this->_init(); } function modify_headers(&$event, $param) { global $INFO, $ID; $this->get_info(); $page = noNS($ID) . '.txt'; if(!$this->files) { return; } if(!in_array('all', $this->files) && !in_array($page, $this->files)) { return; } $event->data[] = 'Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT'; $event->data[] = 'Cache-control: no-cache,must-revalidate,no-store'; } function bypasss_cache(&$event, $param) { global $INFO; $cache =$event->data; if (!isset($cache->page)) return; if (isset($cache->mode) && $cache->mode == 'metadata') return; $depends = p_get_metadata($cache->page, 'relation htmlokay'); $meta_file = metaFN($cache->page,'.meta'); if(isset($depends)) { if(!empty($cache->depends['files'])) { $cache->depends['files'][] = $meta_file; //msg($cache->cache); //msg('
c = ' . print_r($event->data, 1) .'
'); } else $cache->depends['files'] = array($meta_file); } } function get_info() { global $conf; global $INFO; $this->helper->get_info(); $namespace = $this->helper->get_namespace(); $this->namespace = $namespace; $namespace = str_replace(':', '#', $namespace); $access_file = $this->helper->get_access_file(HTMLOK_ACCESS_DIR, $namespace); $this->set_dbg_msg("access file: $access_file"); if (file_exists($access_file)) { $INFO['htmlOK_access_scope'] = $this->helper->get_access_scope($access_file); $this->set_dbg_msg("file exists: access file: $access_file"); $this->saved_inf = $this->helper->get_saved_inf(); if (!$this->saved_inf) { return; } $this->files = $this->saved_inf['filespecs']; if(!empty($INFO['filepath'])) { $this->curent_file = basename($INFO['filepath']); } else { $this->curent_file = noNS($ID) . '.txt'; } $this->access_file = $access_file; } } function action_link(&$event, $param) { global $INFO; if(!empty($INFO['userinfo'])) { $name = "HTML Error Window"; if($param[0] == 'ok') { $htm_open = ''; $htm_close = ''; } else { $htm_open = '
  • '; $htm_close = '
  • '; } $event->data['items']['htmlokay'] = $htm_open .''. $name.'' . $htm_close; } } function set_dbg_msg($msg) { if(!$this->do_dbg) return; $this->db_msg .= $msg . '
    '; } function _init() { global $INFO, $JSINFO; $this->helper = $this->loadhelper('htmlOKay',1); if(isset($_GET['htmlOKay_dbg'])) { $this->do_dbg = true; } $this->get_info(); $JSINFO['path'] = HTMLOK_WIKI_PATH; } function htmlOK_plugin_shutdown() { global $conf; plugin_disable('htmlOK'); } function setup_debug(&$event, $param) { $this->format_error_window(); $this->debug(); } function get_JSErrString($msg) { $msg = trim($msg); static $msgs_inx = -1; if (!isset($msg) || empty($msg)) return ""; $msgs_inx++; ptln('htmlOK_ERRORS_HEADER[' . $msgs_inx . ']="' . $msg . '";'); } function errors_top(&$event,$params) { global $INFO; static $done = false; if($done) return; $done = true; $this->setup_debug ($event,$params); ptln( ''); } function format_error_window() { echo << ERRORWINDOW; } function debug() { global $INFO; global $ID; global $conf; global $NS; if(!isset($INFO['userinfo']) ) return ; // && !$INFO['htmlOK_client']) return; if(!$this->do_dbg) return; echo << show debug  close debug DBG_JS; echo '
     
    '; echo $this->db_msg; echo '
    '; echo "Current File: $this->curent_file
    "; echo "Access Directory: " . HTMLOK_ACCESS_DIR . "
    Access File: $this->access_file
    \n"; echo "Client: " . $INFO['client'] . '
    '; echo "HTML_OK: " . $conf['htmlok'] . "
    "; echo "Name Space: " . getNS($ID). " --> $NS\n"; echo "\$INFO['htmlOK_client']: " . $INFO['htmlOK_client'] . "   --Writable: " . $INFO['writable'] . "    --Editable: " . $INFO['editable'] . '
    '; echo "Access level: {$INFO['hmtlOK_access_level']}
    "; echo "
    ";
            echo "
    \$INFO array:
    "; $str = print_r($INFO,true); echo htmlentities($str,ENT_QUOTES); echo "
    \$conf array:
    "; $str = print_r($conf,true); echo htmlentities($str,ENT_QUOTES); echo "
    Saved Info:"; print_r($this->saved_inf,true); echo "
    "; echo "
    "; } function write_debug($what) { return; $handle = fopen("htmlok_php.txt", "a"); if(is_array($what)) $what = print_r($what,true); fwrite($handle,"$what\n"); fclose($handle); } } ?>