1<?php 2/** 3 * Date: 2015/3/11 4 * Time: 4:39 5 */ 6if (!defined('DOKU_INC')) die(); 7if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 8 9require_once (DOKU_PLUGIN . 'action.php'); 10require_once (DOKU_INC.'inc/template.php'); 11 12class action_plugin_pagestat extends DokuWiki_Action_Plugin 13{ 14 function register(Doku_Event_Handler $controller) 15 { 16 $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'set_data', array()); 17 $controller->register_hook('RPC_CALL_ADD', 'AFTER', $this, 'add_rpc_all'); 18 $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton', array()); 19 } 20 21 function set_data(){ 22 global $JSINFO; 23// global $conf; 24// $myste = $conf["metadir"]; 25 $JSINFO['user'] = $_SERVER['REMOTE_USER']; 26 $JSINFO['g_wordlists']=$this->getConf('g_wordlists'); 27 $JSINFO['user_wordlists']=$this->getConf('user_wordlists'); 28 $JSINFO['subtitle_dst']=$this->getConf('subtitle_dst'); 29 $JSINFO['stable_dst']=$this->getConf('stable_dst'); 30 $JSINFO['def_dst']=$this->getConf('def_dst'); 31 $JSINFO['wordlist_dst']=$this->getConf('wordlist_dst'); 32 } 33 34 function add_rpc_all(&$event, $param){ 35 $my_rpc_call=array( 36 'ps.get_wordlist' => array('pagestat', 'get_wordlist'), 37 'ps.check_word'=>array('pagestat', 'check_word'), 38 'ps.getUser' => array('pagestat', 'getUser'), 39 'ps.get_defs'=>array('pagestat','get_defs'), 40 'ps.cp_subtitle'=>array('pagestat','Cp_subtitle'), 41 'ps.cp_defs'=>array('pagestat','Cp_deflist'), 42 'ps.cp_wordlist'=>array('pagestat','Cp_wordlist') 43 ); 44 $event->data=array_merge($event->data,$my_rpc_call); 45 } 46 47 function addbutton(Doku_Event &$event){ 48 global $ID, $REV,$GLOBALS; 49 if($event->data['view'] == 'main'){ 50 $params = array(); 51 52 $mybt=<<<TESTEST 53<li> 54<a href="#" class="action pt_pagetools %s" rel="nofollow" title="i am test"> 55<span>%s</span> 56</a> 57<div class="rawedges pt_pa_sub"> 58TESTEST; 59 if($GLOBALS['ACT']=="edit"){ 60 $tool_page= tpl_include_page("user:admin:etools:edit", false, false); 61 $mybt=sprintf($mybt,"ptools_edit"," in edit"); 62 }else{ 63 $tool_page= tpl_include_page("user:admin:etools:view", false, false); 64 $mybt=sprintf($mybt,"ptools_main"," main edit"); 65 } 66 if($REV){ 67 $params['rev']=$REV; 68 } 69 $event->data['items'] = array_slice($event->data['items'], 0, -1, true) + 70 array('test_bt' =>$mybt.$tool_page."</div></li>") + 71 array_slice($event->data['items'], -1, 1, true); 72 } 73 } 74}