1<?php 2/** 3 * Ahref menu: generates tree of business terms 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Robert Srna <srnar@volny.cz> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'admin.php'); 12 13/** 14 * All DokuWiki plugins to extend the admin function 15 * need to inherit from this class 16 */ 17class admin_plugin_ahrefmenu extends DokuWiki_Admin_Plugin { 18 19 var $output = 'init'; 20 var $plug_dir = './lib/plugins/ahrefmenu/'; 21 22 /** 23 * return some info 24 */ 25 function getInfo(){ 26 return array( 27 'author' => 'Robert Srna', 28 'email' => 'srnar@volny.cz', 29 'date' => '2009-03-11', 30 'name' => 'admin plugin ahrefmenu', 31 'desc' => 'Generates html tree based on A HREF attributes', 32 'url' => 'http://www.dokuwiki.org/plugin:ahrefmenu', 33 ); 34 } 35 36 /** 37 * return sort order for position in admin menu 38 */ 39 function getMenuSort() { 40 return 999; 41 } 42 43 /** 44 * return a menu prompt for the admin menu 45 * NOT REQUIRED - its better to place $lang['menu'] string in localised string file 46 * only use this function when you need to vary the string returned 47 */ 48// function getMenuText() { 49// return 'a menu prompt'; 50// } 51 52 /** 53 * handle user request 54 */ 55 function handle() { 56 global $conf; 57 58 if (!isset($_REQUEST['cmd'])) return; // first time - nothing to do 59 60 $this->output = 'invalid'; 61 62 if (!is_array($_REQUEST['cmd'])) return; 63 64 // verify valid values 65 switch (key($_REQUEST['cmd'])) { 66 case 'init' : 67 //$this->output = 'init'; 68 break; 69 case 'generate' : 70 if ($conf['template'] != "default") 71 { 72 $this->output = 'invalidtemplate'; 73 break; 74 } 75 //run external xml generation 76 exec($this->getConf('pythonpath') . ' "' . $this->plug_dir . 'generate_map.py" "' . $this->getConf('rooturl'). '" "'. $this->getConf('deeppages') . '" "' . $this->getConf('ignorepages') . '" > "' . $this->plug_dir . 'local_map.xml"'); 77 $this->output = 'init'; 78 break; 79 } 80 } 81 82 // 83 function refresh_date() { 84 global $conf; 85 return strftime($conf['dformat'], filemtime($this->plug_dir . "local_map.xml")); 86 } 87 88 /** 89 * output appropriate html 90 */ 91 function html() { 92 ptln('<p>'.htmlspecialchars($this->getLang($this->output)).'</p>'); 93 94 ptln('<form action="'.wl($ID).'" method="post">'); 95 96 // output hidden values to ensure dokuwiki will return back to this plugin 97 ptln(' <input type="hidden" name="do" value="admin" />'); 98 ptln(' <input type="hidden" name="page" value="'.$this->getPluginName().'" />'); 99 100 ptln(' <a href="'.$this->plug_dir.'ahrefmap.htm">' .$this->getLang('output_msg'). ' ' .$this->refresh_date(). '</a></p>'); 101 ptln(' <input type="submit" name="cmd[generate]" value="'.$this->getLang('btn_generate').'" />'); 102 ptln('</form>'); 103 } 104 105}