tiki-jsmodule.php 1.72 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8 9 10 11
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

/*
12
 * This is used to make module-specific parameters available to jquery
13 14
 * so that the plugin edit popup form for PluginModule can include the parameters for the selected module in the form
 * The java script generated defines tiki_module_params["modulename"] with meta data for the parameters of the module.
15 16
 *
 * Cached by language to allow translations
17 18
 */
header('content-type: application/x-javascript');
19
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+3600*24*30) . ' GMT');
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

require_once 'tiki-filter-base.php';

$filter = TikiFilter::get('alpha');
$_REQUEST['language'] = isset($_GET['language']) ? $_GET['language'] = $filter->filter($_GET['language']) : '';

$cache = "temp/cache/module_ALL_".$_REQUEST['language'];

if ( file_exists($cache) ) {
	readfile($cache);
	exit;
}
include 'tiki-setup.php';
$modlib = TikiLib::lib('mod');
$mods = $modlib->get_all_modules();

ob_start();
?>if ( typeof tiki_module_params == 'undefined' ) { var tiki_module_params = {}; }
38 39
<?php
foreach ( $mods as $mod ) {
40 41 42 43 44 45 46 47 48
	$file = 'modules/mod-func-' . $mod . '.php';
	if (file_exists($file)) {
		include_once($file);
		$info_func = "module_{$mod}_info";
		if (function_exists($info_func)) {
			$info = $info_func();
		} else {
			$info = false;
		}
49 50
	}
?>
51
tiki_module_params.<?php echo TikiLib::remove_non_word_characters_and_accents($mod) ?> = <?php echo json_encode($info) ?>;
52 53
<?php
}
54 55 56
$content = ob_get_contents();
file_put_contents($cache, $content);
ob_end_flush();