1<?php
2/**
3 * DokuWiki Syntax Plugin inlineeditor
4 *
5 *
6 *
7 *
8 * Syntax:  ~~QUICKEDIT~~
9 *
10 * @license GPL 3 (http://www.gnu.org/licenses/gpl.html)
11 * @author  Simon-Shlomo Poil <simon.shlomo@poil.dk>
12* build on the quickedit plugin by  Arthur Lobert, Vincent Fleury
13 */
14// must be run within DokuWiki
15if(!defined('DOKU_INC')) die();
16
17if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
18require_once(DOKU_PLUGIN.'syntax.php');
19
20/**
21 * All DokuWiki plugins to extend the parser/rendering mechanism
22 * need to inherit from this class
23 */
24class syntax_plugin_inlineeditor extends DokuWiki_Syntax_Plugin {
25
26    /**
27     * return some info
28     */
29    function getInfo(){
30        return array(
31            'author' => 'Simon-Shlomo Poil',
32            'email'  => 'simon.shlomo@poil.dk',
33            'date'   => '1 August 2011',
34            'name'   => 'Plugin inlineeditor (syntax component)',
35            'desc'   => 'Edit your page directly by doubleclicking the text',
36            'url'    => 'http://dokuwiki.org/plugin:inlineeditor',
37        );
38    }
39
40    /**
41     * Syntax Type
42     *
43     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
44     */
45    function getType()  { return 'substition'; }
46    function getPType() { return 'block'; }
47    function getSort()  { return 304; }
48
49    /**
50     * Connect pattern to lexer
51     */
52    function connectTo($mode) { $this->Lexer->addSpecialPattern('~~INLINEEDITORSTART~~',$mode,'plugin_inlineeditor');
53    	// $this->Lexer->addSpecialPattern('~~QUICKEDIT~~',$mode,'plugin_quickedit');
54   }
55
56    /**
57     * Handle the match
58     */
59   // function handle($match, $state, $pos, &$handler){
60   // }
61
62    /**
63     * Create output
64     */
65    function render($mode, &$renderer, $data) {
66    	global $ID;
67
68    	if  ($data[0] == 'start')
69    	{
70		$tuto = $data[1]. $ID;
71    		$toto = 'quickedit_start'. $tuto;
72    		$titi = 'quickedit_stop'. $tuto;
73    		$renderer->doc .= "
74    		<div id='quickedit' onDblClick= 'plugin_quickedit_go(".$data[1].",\"".$data[2]."\",\"".$ID."\",\"".$_REQUEST['do']."\" )'>
75    			<div id= '".$toto."' style = 'border : 0px black solid ; display : block'>
76    			<input type='hidden' id='old' value='0' />";
77    	}
78    	if ($data[0] == 'stop')
79    	{
80		$tuto = $data[1]. $ID;
81    		$toto = 'quickedit_start'. $tuto;
82    		$titi = 'quickedit_stop'. $tuto;
83    		$renderer->doc .= "</div>
84    			<div id='".$titi."' style ='border : 1px lightgrey solid ; padding : 5px 10px 5px 5px ; display : none'>
85					<div id='quicktoolbar".$tuto."'></div>
86
87    					<textarea id='quickedit_textbox".$tuto."' rows=3 cols=100 style='width:100%;height:100%' ></textarea>
88    					<div style= 'margin-top : 5px;'>
89
90    					<label class='nowrap' for='edit__summary'>Edit summary
91    						<input type='text' id='editsummary".$tuto."' name='summary' value='' class='edit' size='50' tabindex='2' />
92    					</label>
93    					<label class='nowrap' for='minoredit'>
94    						<input type='checkbox' id='minoredit".$tuto."' name='minor' value='1' tabindex='3' />
95    							<span>
96    							 	Minor Changes
97    							</span>
98    					</label>
99    					<input style='position : relative ; bottom : -4px' type='image' src='lib/plugins/inlineeditor/ressources/add.gif' onClick='quickedit_save(".$data[1].",\"".$data[2]."\",\"".$ID."\")'/>
100    					<input style='position : relative ; bottom : -4px ' type='image' src='lib/plugins/inlineeditor/ressources/delete.gif' onClick='quickedit_cancel(".$data[1].",\"".$data[2]."\",\"".$ID."\")'/>
101    				</div>
102    			</div>
103    			<div id='load".$tuto."' style = 'display : none'>
104    				<img src='lib/images/loading.gif' />
105    			</div>
106    		</div>";}
107
108	}
109}
110// vim:ts=4:sw=4:et:enc=utf-8:
111