1<?php
2
3//	This file is part of the "jQuery.Syntax" project, and is distributed under the MIT License.
4//	See <jquery.syntax.js> for licensing details.
5//	Copyright (c) 2011 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
6
7if(!defined('DOKU_INC')) die();
8if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
9require_once DOKU_PLUGIN.'action.php';
10
11class action_plugin_jquerysyntax extends DokuWiki_Action_Plugin {
12	function getInfo() {
13		return array(
14			'author' => 'Samuel Williams',
15			'email'  => 'samuel.williams@oriontransfer.co.nz',
16			'date'   => '2012-06-01',
17			'name'   => 'jQuery.Syntax release-3.1',
18			'desc'   => 'Extreme Client-side Syntax Highlighting. Inserts required JavaScript code.',
19			'url'    => 'http://www.oriontransfer.co.nz/software/jquery-syntax',
20		);
21	}
22
23	function register(&$controller) {
24		$controller->register_hook('TPL_METAHEADER_OUTPUT','BEFORE', $this, '_inject_js');
25	}
26
27	function _inject_js(&$event, $param) {
28		$plugin_root = DOKU_BASE."lib/plugins/jquerysyntax";
29		global $updateVersion;
30		$noConflict = "";
31
32		if ($updateVersion < 36.0) {
33			$event->data['script'][] = array(
34				'type'    => 'text/javascript',
35				'charset' => 'utf-8',
36				'_data'   => '',
37				'src'     => $plugin_root.'/jquery-1.6.min.js'
38				);
39
40			$noConflict = "jQuery.noConflict();";
41		}
42
43		$syntax_root = $plugin_root.'/jquery-syntax/';
44		$event->data['script'][] = array(
45			'type'    => 'text/javascript',
46			'charset' => 'utf-8',
47			'_data'   => "$noConflict jQuery(document).ready(function($) { $.syntax({blockLayout: 'table'}) });"
48			);
49
50		$event->data['script'][] = array(
51			'type'    => 'text/javascript',
52			'charset' => 'utf-8',
53			'_data'   => '',
54			'src'     => $plugin_root.'/jquery-syntax/jquery.syntax.min.js'
55			);
56
57		$event->data['link'][] = array(
58			'type'    => 'text/css',
59			'charset' => 'utf-8',
60			'rel'     => 'stylesheet',
61			'media'   => 'screen',
62			'href'     => $plugin_root.'/dw-fixes.css'
63			);
64	}
65}
66