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