1    <?php
2    /**
3     * RDP Link Plugin
4     *
5     * @license    MIT (http://www.opensource.org/licenses/mit-license.php)
6		 * @author     Justin Shepard <jshepard@cyberdynamic.net>
7		 *
8		 * Permission is hereby granted, free of charge, to any person obtaining
9		 * a copy of this software and associated documentation files (the
10		 * "Software"), to deal in the Software without restriction, including
11		 * without limitation the rights to use, copy, modify, merge, publish,
12		 * distribute, sublicense, and/or sell copies of the Software, and to
13		 * permit persons to whom the Software is furnished to do so, subject
14		 * to the following conditions:
15		 *
16		 * The above copyright notice and this permission notice shall be
17		 * included in all copies or substantial portions of the Software.
18		 *
19		 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20		 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21		 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22		 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23		 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24		 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25		 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26     */
27
28    if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
29    if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
30    require_once(DOKU_PLUGIN.'syntax.php');
31
32    class syntax_plugin_rdplink extends DokuWiki_Syntax_Plugin {
33
34        function getInfo(){
35            return array(
36                'author' => 'Justin Shepard',
37                'email'  => 'jshepard@cyberdynamic.net',
38                'date'   => '2007-08-01',
39                'name'   => 'RDP Link Plugin',
40                'desc'   => 'Embed links to auto-generate and open RDP connection files.',
41                'url'    => 'http://www.dokuwiki.org/plugin:rdplink',
42            );
43        }
44        function getType(){ return 'substition'; }
45        function getSort(){ return 999; }
46        function connectTo($mode) { $this->Lexer->addSpecialPattern('{rdplink:.+?}',$mode,'plugin_rdplink'); }
47        function handle($match, $state, $pos, Doku_Handler $handler){
48            switch ($state) {
49              case DOKU_LEXER_SPECIAL :
50                $match = substr($match,9,-1);
51                $smeta = explode('|',$match,2);
52                if(empty($smeta[1])) $smeta[1] = $smeta[0];
53                return array(
54                    'server'=>$smeta[0],
55                    'desc'=>$smeta[1]
56                );
57                break;
58            }
59            return array();
60        }
61
62        function render($mode, Doku_Renderer $renderer, $data) {
63            if($mode == 'xhtml'){
64    //            $renderer->doc .= "<a href=\"" . DOKU_URL . "lib/plugins/rdplink/rdp.php?server=" . $data['server'] . "\"><img src=\"".DOKU_URL."lib/plugins/rdplink/rdpicon.png\" />" . $data['desc'] . "</a>";
65                $renderer->doc .= "<img src=\"".DOKU_URL."lib/plugins/rdplink/rdpicon.png\" />&nbsp;<a href=\"" . DOKU_URL . "lib/plugins/rdplink/rdp.php?server=" . $data['server'] . "\">" . $data['desc'] . "</a>";
66                return true;
67            }
68            return false;
69        }
70    }
71
72