1<?php 2/** 3 * DokuWiki Plugin custombuttons (Admin Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Xanthopoulos Constantinos <conx@xanthopoulos.info> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once DOKU_PLUGIN.'admin.php'; 17 18class admin_plugin_codebutton2 extends DokuWiki_Admin_Plugin 19{ 20 21 function getInfo(){ 22 return array( 23 'author' => 'Reshetnikov Anton', 24 'email' => 'resheto@gmail.com', 25 'date' => '2010-12-11', 26 'name' => 'CodeButton2', 27 'desc' => 'A plugin for adding code buttons', 28 'url' => 'http://www.dokuwiki.org/plugin:codebutton2', 29 ); 30 } 31 32 33 function forAdminOnly() 34 { 35 return true; 36 } 37 38 function handle() 39 { 40 global $config_cascade; 41 42 if (isset($_REQUEST['config'])) 43 { 44 $fh = fopen(DOKU_PLUGIN."codebutton2/config.ini", 'w'); 45 46 if($fh) 47 { 48 fwrite($fh, $_REQUEST["config"]); 49 } 50 fclose($fh); 51 @touch(reset($config_cascade['main']['local'])); 52 } 53 } 54 55 function html() 56 { 57 global $ID; 58 59 ptln('<h1>CodeButtons2 Configurations</h1>'); 60 ptln('<div>Add your code buttons in CODE block of your edit toolbar the following format:<br><pre class="code"><button name> = <geshi code name><br></pre>Example:</br><pre class="code">.bat=winbatch</pre>'); 61 ptln('It will produce button with name ".bat". Push on this button surround your selected text with <code winbatch> </code></div>'); 62 ptln('<form name="frm" action="'.wl($ID).'" method="post">'); 63 ptln('<input type="hidden" name="do" value="admin" />'); 64 ptln('<input type="hidden" name="page" value="'.$this->getPluginName().'" />'); 65 ptln('<input type="hidden" name="id" value="'.$ID.'" />'); 66 ptln('<textarea rows=10 cols=50 name="config">'); 67 echo file_get_contents(DOKU_PLUGIN."codebutton2/config.ini"); 68 ptln('</textarea>'); 69 ptln('<br><input type=submit value="Save"></form>'); 70 } 71} 72 73// vim:ts=4:sw=4:et:enc=utf-8: 74