register_hook( 'TPL_METAHEADER_OUTPUT', 'AFTER', $this, 'loadScript'); $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'create_ebook_button'); $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, 'get_epub'); $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'check_scriptLoaded'); $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'prevent_cache'); } /** */ function create_ebook_button($event,$param) { global $INFO; global $ACT; if(!$this->getConf('permalink')) return; if($ACT != 'show') return; if(!$this->helper) { $this->helper = $this->loadHelper('epub', true); } if (!$this->helper->is_inCache($INFO['id'])) return; $auth = auth_quickaclcheck($INFO['id']); if($auth) { $page_data = $this->helper->get_page_data($INFO['id']); if(!$page_data) return; $ebook = $page_data['epub']; $link = ml($ebook); $title = $page_data['title']; echo $this->getLang('download'); //The most recent ebook for this page is: echo " $title ($ebook).
"; echo $this->getLang('download_click'); // To download it, click on the link. echo $this->getLang('download_alt'); // If you have an ebook reader plugin installed, right-click on the link and select 'Save . . . As'."; } } function get_epub($event, $param) { global $ID; global $USERINFO; if(!isset($USERINFO)) return; $user = $USERINFO['name']; global $ACT; global $INFO; if($ACT != 'show') return; if(!$this->helper) { $this->helper = $this->loadHelper('epub', true); } if (!$this->helper->is_inCache($INFO['id'])) return; //cache set in syntax.php if(strpos($INFO['id'],'epub') === false) return; $wiki_file = wikiFN($INFO['id']); if(!@file_exists($wiki_file)) return; $epub_group = $this->getConf('group'); $groups=$USERINFO['grps']; $auth = auth_quickaclcheck('epub:*'); if($auth < 8 && !in_array($epub_group,$groups)) return; $auth = auth_quickaclcheck($INFO['id']); if($auth < 4) return; $client=$INFO['client']; $button_name = $this->getLang('button_start'); //"Start"; //$this->getLang('btn_generate'); $button="
"; $button .= "
"; $button .="  "; $button .= $this->getLang('label_start'); //"Click the Start Button to Create your eBook"; $button .="
"; echo $button; $id = $INFO['id']; $button_name = $this->getLang('button_remove'); $button="

"; $button .= "
"; $button .= '
'. $this->locale_xhtml('remove'); echo $button; } function prevent_cache(&$event) { global $INFO; if(!$this->helper) { $this->helper = $this->loadHelper('epub', true); } if (!$this->helper->is_inCache($INFO['id'])) return; //cache set in syntax.php $event->preventDefault(); } function loadScript(&$event) { echo << SCRIPT; } function check_scriptLoaded(&$event) { $url = DOKU_URL . 'lib/plugins/epub/script.js'; echo << SCRIPT; } function write_debug($what) { return; $what = print_r($what,true); $handle = fopen('epub-action.txt', 'a'); fwrite($handle,"$what\n"); fclose($handle); } } //Setup VIM: ex: et ts=4 enc=utf-8 :