Project

General

Profile

« Previous | Next » 

Revision 1105

Added by Matthias over 15 years ago

Added option to use a frontend_body.js in modules to include javascript from modules in the body of the frontend (Thanks to Luisehahne)

View differences:

module.functions.php
155 155
		
156 156
		if($css_file == 'frontend.css') {
157 157
			// check if frontend.css needs to be included into the <body> section
158
			if(!((!function_exists('register_frontend_modfiles') || !defined('MOD_FRONTEND_CSS_REGISTERED')) && 
158
			if(!((!function_exists('register_frontend_modfiles') || !defined('MOD_FRONTEND_CSS_REGISTERED')) &&
159 159
					file_exists(WB_PATH .'/modules/' .$mymod_dir .'/frontend.css'))) {
160 160
				return false;
161 161
			} 
......
178 178
if (!function_exists('requires_module_js')) {
179 179
	function requires_module_js($mymod_dir, $js_file) {
180 180
		if(!in_array(strtolower($js_file), array('frontend.js', 'backend.js'))) {
181
			echo '<strong>Note: </strong>Javascript file "' .htmlentities($js_file) .'" 
182
			specified in module "' .htmlentities($mymod_dir) .'" not valid.'; 
181
			echo '<strong>Note: </strong>Javascript file "' .htmlentities($js_file) .'"
182
			specified in module "' .htmlentities($mymod_dir) .'" not valid.';
183 183
			return false;
184 184
		}
185
		
185

  
186 186
		if($js_file == 'frontend.js') {
187 187
			// check if frontend.js is included to the <head> section
188 188
			if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) {
......
192 192
				to ensure that module frontend.js files are automatically loaded if required.</p>
193 193
				<code style="color: #800000;">&lt;?php<br />if(function_exists(\'register_frontend_modfiles\')) { <br />
194 194
				&nbsp;&nbsp;register_frontend_modfiles(\'js\');<br />?&gt;</code><br />
195
				<p><strong>Tip:</strong> For WB 2.6.7 copy the code above to the index.php of your template. 
196
				Then open the view.php of the "' .htmlentities($mymod_dir) .'" module and set the variable 
197
				<code>$requires_frontend_js</code> to false. This may do the trick.</p><p>All WB versions below 2.6.7 needs 
195
				<p><strong>Tip:</strong> For WB 2.6.7 copy the code above to the index.php of your template.
196
				Then open the view.php of the "' .htmlentities($mymod_dir) .'" module and set the variable
197
				<code>$requires_frontend_js</code> to false. This may do the trick.</p><p>All WB versions below 2.6.7 needs
198 198
				to be upgraded to work with this module.</p>
199 199
				';
200 200
				return false;
......
214 214
		return true;
215 215
	}
216 216
}
217
// function to check if the optional module Javascript files are loaded into the <body> section
218
if (!function_exists('requires_module_body_js')) {
219
	function requires_module_body_js($mymod_dir, $js_file) {
220
		if(!in_array(strtolower($js_file), array('frontend_body.js', 'backend_body.js'))) {
221
			echo '<strong>Note: </strong>Javascript file "' .htmlentities($js_file) .'"
222
			specified in module "' .htmlentities($mymod_dir) .'" not valid.';
223
			return false;
224
		}
217 225

  
226
		if($js_file == 'frontend_body.js') {
227
			// check if frontend_body.js is included to the <body> section
228
			if(!defined('MOD_FRONTEND_BODY_JAVASCRIPT_REGISTERED')) {
229
				echo '<p><strong>Note:</strong> The module: "' .htmlentities($mymod_dir) .'" requires WB 2.6.7 or higher</p>
230
				<p>This module uses Javascript functions contained in frontend_body.js of the module.<br />
231
				Add the code below before to the &lt;/body&gt; section in the index.php of your template
232
				to ensure that module frontend_body.js files are automatically loaded if required.</p>
233
				<code style="color: #800000;">&lt;?php<br />if(function_exists(\'register_frontend_modfiles_body\')) { <br />
234
				&nbsp;&nbsp;register_frontend_modfiles_body(\'js\');<br />?&gt;</code><br />
235
				<p><strong>Tip:</strong> For WB 2.6.7 copy the code above to the index.php of your template.
236
				Then open the view.php of the "' .htmlentities($mymod_dir) .'" module and set the variable
237
				<code>$requires_frontend_body_js</code> to false. This may do the trick.</p><p>All WB versions below 2.6.7 needs
238
				to be upgraded to work with this module.</p>
239
				';
240
				return false;
241
			}
242
		} else {
243
			// check if backend_body.js is included to the <body> section
244
			global $admin;
245
				if(!method_exists($admin, 'register_backend_modfiles_body') && file_exists(WB_PATH .'/modules/' .$mymod_dir .'/backend_body.js')) {
246
				echo '<p><strong>Note:</strong> The module: "' .htmlentities($mymod_dir) .'" requires WB 2.6.7 or higher</p>
247
				<p>This module uses Javascript functions contained in backend_body.js of the module.<br />
248
				You need WB 2.6.7 or higher to ensure that module backend_body.js files are automatically loaded if required.</p>
249
				<p>Sorry, you can not use this tool with your WB installation, please upgrade to the latest WB version available.</p><br />
250
				';
251
				return false;
252
			}
253
		}
254
		return true;
255
	}
256
}
257

  
218 258
?>

Also available in: Unified diff