1<?php
2/**
3 * SyntaxHighlighter plugin
4 *
5 * @license    LGPL 2 (http://www.gnu.org/licenses/lgpl.html)
6 * @author     David Shin <dshin@pimpsmart.com>
7 */
8if(!defined('DOKU_INC')) die();
9if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10require_once(DOKU_PLUGIN.'action.php');
11
12class action_plugin_syntaxhighlighter extends DokuWiki_Action_Plugin {
13
14  /**
15   * return some info
16   */
17  function getInfo(){
18    return array(
19                 'author' => 'David Shin',
20                 'email'  => 'dshin@pimpsmart.com',
21                 'date'   => '2008-12-04',
22                 'name'   => '<code> tag replacement',
23                 'desc'   => 'Replaces GeSHi server-side code highlighting with client-side SyntaxHightlighter 1.5.1 by Alex Gorbatchev. SyntaxHighlighter can be found at http://code.google.com/p/syntaxhighlighter/.',
24                 'url'    => 'http://wiki.splitbrain.org/plugin:syntaxhighlighter',
25                 );
26  }
27
28  /*
29   * plugin should use this method to register its handlers with the dokuwiki's event controller
30   */
31  function register(&$controller) {
32    $controller->register_hook('TPL_METAHEADER_OUTPUT',
33                               'BEFORE',
34                               $this,
35                               '_hooksh');
36  }
37
38  /**
39   *  Inject the SyntaxHightlighter files
40   *
41   *  @author David Shin <dshin@pimpsmart.com>
42   *  @param $event object target event
43   *  @param $param mixed event parameters passed from register_hook
44   *
45   *  To add other languages, add additional events to this function
46   */
47  function _hooksh (&$event, $param) {
48      $event->data['link'][] = array( 'rel'=>'stylesheet'
49                                     ,'type'=>'text/css'
50                                     ,'title'=>'SyntaxHighlighter styles'
51                                     ,'href'=>DOKU_BASE.'lib/plugins/syntaxhighlighter/Styles/SyntaxHighlighter.css'
52                                     ,'_data'=>'');
53      $event->data["script"][] = array ("type" => "text/javascript",
54	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shCore.js"
55				          );
56      $event->data["script"][] = array ("type" => "text/javascript",
57	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushCpp.js"
58				          );
59      $event->data["script"][] = array ("type" => "text/javascript",
60	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushCSharp.js"
61				          );
62      $event->data["script"][] = array ("type" => "text/javascript",
63	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushCss.js"
64				          );
65      $event->data["script"][] = array ("type" => "text/javascript",
66	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushDelphi.js"
67				          );
68      $event->data["script"][] = array ("type" => "text/javascript",
69	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushJava.js"
70				          );
71      $event->data["script"][] = array ("type" => "text/javascript",
72	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushPhp.js"
73				          );
74      $event->data["script"][] = array ("type" => "text/javascript",
75	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushPython.js"
76				          );
77      $event->data["script"][] = array ("type" => "text/javascript",
78	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushRuby.js"
79				          );
80      $event->data["script"][] = array ("type" => "text/javascript",
81	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushSql.js"
82				          );
83      $event->data["script"][] = array ("type" => "text/javascript",
84	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushVb.js"
85				          );
86      $event->data["script"][] = array ("type" => "text/javascript",
87	  "src" => DOKU_BASE."lib/plugins/syntaxhighlighter/Uncompressed/shBrushXml.js"
88				          );
89  }
90}
91