1<?php 2/** 3 * ShortURL Plugin 4 * based on redirect plugin 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Andreas Gohr <andi@splitbrain.org> 8 * @author Frank Schiebel <frank@linuxmuster.net> 9 */ 10 11// must be run within Dokuwiki 12if(!defined('DOKU_INC')) die(); 13 14if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15require_once(DOKU_PLUGIN.'admin.php'); 16 17/** 18 * All DokuWiki plugins to extend the admin function 19 * need to inherit from this class 20 */ 21class admin_plugin_shorturl extends DokuWiki_Admin_Plugin { 22 23 /** 24 * Access for managers allowed 25 */ 26 function forAdminOnly(){ 27 return false; 28 } 29 30 /** 31 * return sort order for position in admin menu 32 */ 33 function getMenuSort() { 34 return 140; 35 } 36 37 /** 38 * return prompt for admin menu 39 */ 40 function getMenuText($language) { 41 return $this->getLang('name'); 42 } 43 44 /** 45 * handle user request 46 */ 47 function handle() { 48 if($_POST['redirdata']){ 49 if(io_saveFile($this->getsavedir().'/shorturl.conf',$_POST['redirdata'])){ 50 msg($this->getLang('saved'),1); 51 } 52 } 53 } 54 55 /** 56 * output appropriate html 57 */ 58 function html() { 59 global $lang; 60 echo $this->locale_xhtml('intro'); 61 echo '<form action="" method="post" >'; 62 echo '<input type="hidden" name="do" value="admin" />'; 63 echo '<input type="hidden" name="page" value="shorturl" />'; 64 echo '<textarea class="edit" rows="15" cols="80" style="height: 300px" name="redirdata">'; 65 echo formtext(io_readFile($this->getsavedir().'/shorturl.conf')); 66 echo '</textarea><br />'; 67 echo '<input type="submit" value="'.$lang['btn_save'].'" class="button" />'; 68 echo '</form>'; 69 } 70 71 /** 72 * get savedir 73 */ 74 function getsavedir() { 75 global $conf; 76 if ( $this->getConf('saveconftocachedir') ) { 77 return rtrim($conf['savedir'],"/") . "/cache"; 78 } else { 79 return dirname(__FILE__); 80 } 81 } 82 83} 84//Setup VIM: ex: et ts=4 enc=utf-8 : 85