1<?php 2/** 3 * DokuWiki Plugin rowmove (Syntax Component) 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author lisps 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.'syntax.php'); 12 13/* 14 * All DokuWiki plugins to extend the parser/rendering mechanism 15 * need to inherit from this class 16 */ 17class syntax_plugin_rowmove extends DokuWiki_Syntax_Plugin{ 18 19 var $idcount = 0; 20 21 /* 22 * What kind of syntax are we? 23 */ 24 function getType() {return 'substition';} 25 26 /* 27 * Where to sort in? 28 */ 29 function getSort() {return 155;} 30 31 /* 32 * Paragraph Type 33 */ 34 function getPType() {return 'normal';} 35 36 /* 37 * Connect pattern to lexer 38 */ 39 function connectTo($mode) { 40 $this->Lexer->addSpecialPattern("<rowmove>",$mode,'plugin_rowmove'); 41 } 42 43 /* 44 * Handle the matches 45 */ 46 function handle($match, $state, $pos, Doku_Handler $handler){ 47 return ($opts); 48 } 49 50 function iswriter() { 51 global $conf; 52 global $INFO; 53 54 return(!$conf['useacl'] || $conf['useacl'] && $INFO['perm'] > AUTH_READ); 55 } 56 57 /* 58 * Create output 59 */ 60 function render($mode, Doku_Renderer $renderer, $opt){ 61 global $INFO; 62 63 if($mode == 'metadata') return false; 64 if($mode == 'xhtml') { 65 $Hajax = plugin_load('helper', 'ajaxedit'); 66 if(!$Hajax){ 67 msg('Plugin ajaxedit is missing'); 68 } 69 70 //insert selector if writable 71 if ($this->iswriter()==TRUE && $Hajax) { 72 $image = "./lib/plugins/rowmove/images/"; 73 $renderer->doc .= "<span class='rowmove'>"; 74 $renderer->doc .= "<img src=\"".$image."arrow_up.gif\" alt='up' class=\"rowmove rowmove_up\" onclick=\"rowup(this,'".base64_encode($INFO["id"])."');\" />"; 75 $renderer->doc .= "<img src=\"".$image."arrow_down.gif\" alt='down' class=\"rowmove\" onclick=\"rowdown(this,'".base64_encode($INFO["id"])."');\" />"; 76 $renderer->doc .= "</span>"; 77 } 78 } 79 return true; 80 } 81 82} 83