1<?php 2/** 3 * DokuWiki Action Plugin inlineeditor 4 * 5 * @license GPL 3 (http://www.gnu.org/licenses/gpl.html) 6 * @author Simon-Shlomo Poil (simon.shlomo@poil.dk) 7 * build on the quickedit plugin by Arthur Lobert, Vincent Fleury 8 */ 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 13if(!defined('DOKU_LF')) define('DOKU_LF', "\n"); 14 15require_once(DOKU_PLUGIN.'action.php'); 16 17/** 18 * All DokuWiki plugins to extend the admin function 19 * need to inherit from this class 20 */ 21 22class action_plugin_inlineeditor extends DokuWiki_Action_Plugin { 23 24 function getInfo() { 25 return array( 26 'author' => 'Simon-Shlomo Poil', 27 'email' => 'simon.shlomo@poil.dk', 28 'date' => '1 August 2011', 29 'name' => 'inlineeditor Plugin ', 30 'desc' => 'inline editor', 31 'url' => 'http://dokuwiki.org/plugin:inlineeditor', 32 ); 33 } 34 35 // register hook 36 function register(&$controller) { 37 $controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'insert_inlineeditor'); 38 } 39 40 41 function insert_inlineeditor(&$event, $param){ 42 43 $ins_new = array(); 44 $ins =& $event->data->calls; 45 $num = count($ins); 46 $nb_push = 0; 47 $no_par = 0; 48 for($i=0;$i<$num;$i++) { 49 if($ins[$i - 1][0] == 'section_open') { 50 $nb = $ins[$i - 1][2]; 51 $tmp = $i + $nb_push ; 52 $inlineeditor_start = array('plugin', array('inlineeditor', array ('start', $tmp, $nb), 1, '~~INLINEEDITORSTART~~')); 53 array_push($ins_new, $inlineeditor_start); 54 $nb_push+=2; 55 $no_par = 1; 56 } 57 if($ins[$i][0] == 'section_close') { 58 59 $ins_new[$tmp][1][1][2] .='-'.$ins[$i][2]; 60 61 $inlineeditor_stop = array('plugin', array('inlineeditor', array ('stop',$tmp, $ins_new[$tmp][1][1][2]), 1, '~~INLINEEDITORSTOP~~')); 62 array_push($ins_new, $inlineeditor_stop); 63 $no_par = 0; 64 } 65// if($ins[$i - 1][0] == 'p_open' && $no_par == 0) 66 // { 67 // $nb = $ins[$i - 1][2]; 68 // $tmp = $i + $nb_push ; 69 // $quickedit_start = array('plugin', array('quickedit', array ('start', $tmp, $nb), 1, '~~QUICKEDITSTART~~')); 70 // array_push($ins_new, $quickedit_start); 71 // $nb_push+=2; 72 // } 73 // if($ins[$i][0] == 'p_close' && $no_par == 0) { 74 // $ins_new[$tmp][1][1][2] .= '-'.($ins[$i][2]); 75 // $quickedit_stop = array('plugin', array('quickedit', array ('stop',$tmp, $ins_new[$tmp][1][1][2]), 1, '~~QUICKEDITSTOP~~')); 76 // array_push($ins_new, $quickedit_stop); 77 // } 78 array_push($ins_new, $ins[$i]); 79 80 } 81 $ins = $ins_new; 82 } 83} 84 85// vim:ts=4:sw=4:et:enc=utf-8: 86