1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8function wikiplugin_jq_info() 9{ 10 return [ 11 'name' => tra('jQuery'), 12 'documentation' => 'PluginJQ', 13 'description' => tra('Add jQuery JavaScript code'), 14 'prefs' => [ 'wikiplugin_jq' ], 15 'body' => tra('JavaScript code'), 16 'validate' => 'all', 17 'filter' => 'none', 18 'iconname' => 'code', 19 'introduced' => 3, 20 'params' => [ 21 'notonready' => [ 22 'required' => false, 23 'name' => tra('Not On Ready'), 24 'description' => tra('Do not execute on document ready (execute inline)'), 25 'since' => '3.0', 26 ], 27 'nojquery' => [ 28 'required' => false, 29 'name' => tra('No JavaScript'), 30 'description' => tra('Optional markup for when JavaScript is off'), 31 'since' => '3.0', 32 ], 33 'lang' => [ 34 'required' => false, 35 'name' => tra('Language'), 36 'description' => tra('Language to apply JQuery to'), 37 'since' => '13.0', 38 ], 39 ] 40 ]; 41} 42 43function wikiplugin_jq($data, $params) 44{ 45 global $prefs; 46 $headerlib = TikiLib::lib('header'); 47 extract($params, EXTR_SKIP); 48 49 $nojquery = isset($nojquery) ? $nojquery : tr('<!-- jq plugin inactive: JavaScript off -->'); 50 if ($prefs['javascript_enabled'] != 'y') { 51 return $nojquery; 52 } 53 $notonready = isset($notonready) ? $notonready : false; 54 55 if (! empty($lang) && $lang != $prefs['language']) { 56 return; 57 } 58 59 // Need to manually decode greater than and less than (not sure if we want to decode all HTML entities 60 $data = str_replace('<', '<', $data); 61 $data = str_replace('>', '>', $data); 62 63 if (! $notonready) { 64 $headerlib->add_jq_onready($data); 65 } else { 66 $headerlib->add_js($data); 67 } 68 return ''; 69} 70