1<?php 2/** 3 * DokuWiki Action Plugin quickedit 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Michael Klier <chi@chimeric.de> 7 */ 8// must be run within Dokuwiki 9if(!defined('DOKU_INC')) die(); 10 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 12if(!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13 14require_once(DOKU_PLUGIN.'action.php'); 15 16/** 17 * All DokuWiki plugins to extend the admin function 18 * need to inherit from this class 19 */ 20 21class action_plugin_quickedit extends DokuWiki_Action_Plugin { 22 23 function getInfo() { 24 return array( 25 'author' => 'Arthur Lobert', 26 'email' => 'arthur.lobert@thalesgroup.com', 27 'date' => @file_get_contents(DOKU_PLUGIN.'quickedit/VERSION'), 28 'name' => 'quickedit Plugin (action component)', 29 'desc' => 'open edition in text box', 30 'url' => 'http://dokuwiki.org/plugin:quickedit', 31 ); 32 } 33 34 // register hook 35 function register(&$controller) { 36 $controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'insert_quickedit'); 37 } 38 39 /** 40 * Modifies the final instruction list of a page and adds instructions for 41 * an uparow link. 42 * 43 * Michael Klier <chi@chimeric.de> 44 */ 45 46 function insert_quickedit(&$event, $param){ 47 48 $ins_new = array(); 49 $ins =& $event->data->calls; 50 $num = count($ins); 51 $nb_push = 0; 52 $no_par = 0; 53 for($i=0;$i<$num;$i++) { 54 if($ins[$i - 1][0] == 'section_open') { 55 $nb = $ins[$i - 1][2]; 56 $tmp = $i + $nb_push ; 57 $quickedit_start = array('plugin', array('quickedit', array ('start', $tmp, $nb), 1, '~~QUICKEDITSTART~~')); 58 array_push($ins_new, $quickedit_start); 59 $nb_push+=2; 60 $no_par = 1; 61 } 62 if($ins[$i][0] == 'section_close') { 63 64 $ins_new[$tmp][1][1][2] .='-'.$ins[$i][2]; 65 66 $quickedit_stop = array('plugin', array('quickedit', array ('stop',$tmp, $ins_new[$tmp][1][1][2]), 1, '~~QUICKEDITSTOP~~')); 67 array_push($ins_new, $quickedit_stop); 68 $no_par = 0; 69 } 70 if($ins[$i - 1][0] == 'p_open' && $no_par == 0) 71 { 72 $nb = $ins[$i - 1][2]; 73 $tmp = $i + $nb_push ; 74 $quickedit_start = array('plugin', array('quickedit', array ('start', $tmp, $nb), 1, '~~QUICKEDITSTART~~')); 75 array_push($ins_new, $quickedit_start); 76 $nb_push+=2; 77 } 78 if($ins[$i][0] == 'p_close' && $no_par == 0) { 79 $ins_new[$tmp][1][1][2] .= '-'.($ins[$i][2]); 80 $quickedit_stop = array('plugin', array('quickedit', array ('stop',$tmp, $ins_new[$tmp][1][1][2]), 1, '~~QUICKEDITSTOP~~')); 81 array_push($ins_new, $quickedit_stop); 82 } 83 array_push($ins_new, $ins[$i]); 84 85 } 86 $ins = $ins_new; 87 } 88} 89 90// vim:ts=4:sw=4:et:enc=utf-8: 91