24 |
24 |
*/
|
25 |
25 |
|
26 |
26 |
/**
|
27 |
|
This file contains the routines to edit the optional module files: frontend.css and backend.css
|
|
27 |
This file contains routines to edit the optional module files: frontend.css and backend.css
|
28 |
28 |
Mechanism was introduced with WB 2.7 to provide a global solution for all modules
|
29 |
29 |
To use this function, include this file from your module (e.g. from modify.php)
|
30 |
30 |
Then simply call the function edit_css('your_module_directory') - that?s it
|
|
31 |
NOTE: Some functions were added for module developers to make the creation of own module easier
|
31 |
32 |
*/
|
32 |
33 |
|
33 |
34 |
// prevent this file from being accessed directly
|
34 |
35 |
if(!defined('WB_PATH')) die(header('Location: index.php'));
|
35 |
36 |
|
|
37 |
/*
|
|
38 |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
39 |
FUNCTIONS REQUIRED TO EDIT THE OPTIONAL MODULE CSS FILES
|
|
40 |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
41 |
*/
|
|
42 |
|
36 |
43 |
// this function checks the validity of the specified module directory
|
37 |
44 |
if(!function_exists('check_module_dir')) {
|
38 |
45 |
function check_module_dir($mod_dir) {
|
... | ... | |
115 |
122 |
}
|
116 |
123 |
}
|
117 |
124 |
|
|
125 |
/*
|
|
126 |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
127 |
FUNCTIONS WHICH CAN BE USED BY MODULE DEVELOPERS FOR OWN MODULES (E.G. VIEW.PHP, MODIFY.PHP)
|
|
128 |
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
129 |
*/
|
|
130 |
|
|
131 |
// function to obtain the module language file depending on the backend language of the current user
|
|
132 |
if (!function_exists('get_module_language_file')) {
|
|
133 |
function get_module_language_file($mymod_dir) {
|
|
134 |
$mymod_dir = strip_tags($mymod_dir);
|
|
135 |
if(file_exists(WB_PATH .'/modules/' .$mymod_dir .'/languages/' .LANGUAGE .'.php')) {
|
|
136 |
// a module language file exists for the users backend language
|
|
137 |
return (WB_PATH .'/modules/' .$mymod_dir .'/languages/' .LANGUAGE .'.php');
|
|
138 |
} else {
|
|
139 |
// an English module language file must exist in all multi-lingual modules
|
|
140 |
if(file_exists(WB_PATH .'/modules/' .$mymod_dir .'/languages/EN.php')) {
|
|
141 |
return (WB_PATH .'/modules/' .$mymod_dir .'/languages/EN.php');
|
|
142 |
} else {
|
|
143 |
echo '<p><strong>Error: </strong>';
|
|
144 |
echo 'Default language file (EN.php) of module "' .htmlentities($mymod_dir) .'" does not exist.</p><br />';
|
|
145 |
return false;
|
|
146 |
}
|
|
147 |
}
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
// function to include module CSS files in <body> (only if WB < 2.6.7 or register_frontend_modfiles('css') not invoked in template)
|
|
152 |
if (!function_exists('include_module_css')) {
|
|
153 |
function include_module_css($mymod_dir, $css_file) {
|
|
154 |
if(!in_array(strtolower($css_file), array('frontend.css', 'backend.css'))) return;
|
|
155 |
|
|
156 |
if($css_file == 'frontend.css') {
|
|
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')) &&
|
|
159 |
file_exists(WB_PATH .'/modules/' .$mymod_dir .'/frontend.css'))) {
|
|
160 |
return false;
|
|
161 |
}
|
|
162 |
} else {
|
|
163 |
// check if backend.css needs to be included into the <body> section
|
|
164 |
global $admin;
|
|
165 |
if(!(!method_exists($admin, 'register_backend_modfiles') && file_exists(WB_PATH .'/modules/' .$mymod_dir .'/backend.css'))) {
|
|
166 |
return false;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
// include frontend.css or backend.css into the <body> section
|
|
170 |
echo "\n".'<style type="text/css">'."\n";
|
|
171 |
include(WB_PATH .'/modules/' .$mymod_dir .'/' .$css_file);
|
|
172 |
echo "\n</style>\n";
|
|
173 |
return true;
|
|
174 |
}
|
|
175 |
}
|
|
176 |
|
|
177 |
// function to check if the optional module Javascript files are loaded into the <head> section
|
|
178 |
if (!function_exists('requires_module_js')) {
|
|
179 |
function requires_module_js($mymod_dir, $js_file) {
|
|
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.';
|
|
183 |
return false;
|
|
184 |
}
|
|
185 |
|
|
186 |
if($js_file == 'frontend.js') {
|
|
187 |
// check if frontend.js is included to the <head> section
|
|
188 |
if(!defined('MOD_FRONTEND_JAVASCRIPT_REGISTERED')) {
|
|
189 |
echo '<p><strong>Note:</strong> The module: "' .htmlentities($mymod_dir) .'" requires WB 2.6.7 or higher</p>
|
|
190 |
<p>This module uses Javascript functions contained in frontend.js of the module.<br />
|
|
191 |
Add the code below to the <head> section in the index.php of your template
|
|
192 |
to ensure that module frontend.js files are automatically loaded if required.</p>
|
|
193 |
<code style="color: #800000;"><?php<br />if(function_exists(\'register_frontend_modfiles\')) { <br />
|
|
194 |
register_frontend_modfiles(\'js\');<br />?></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
|
|
198 |
to be upgraded to work with this module.</p>
|
|
199 |
';
|
|
200 |
return false;
|
|
201 |
}
|
|
202 |
} else {
|
|
203 |
// check if backend.js is included to the <head> section
|
|
204 |
global $admin;
|
|
205 |
if(!method_exists($admin, 'register_backend_modfiles') && file_exists(WB_PATH .'/modules/' .$mymod_dir .'/backend.js')) {
|
|
206 |
echo '<p><strong>Note:</strong> The module: "' .htmlentities($mymod_dir) .'" requires WB 2.6.7 or higher</p>
|
|
207 |
<p>This module uses Javascript functions contained in backend.js of the module.<br />
|
|
208 |
You need WB 2.6.7 or higher to ensure that module backend.js files are automatically loaded if required.</p>
|
|
209 |
<p>Sorry, you can not use this tool with your WB installation, please upgrade to the latest WB version available.</p><br />
|
|
210 |
';
|
|
211 |
return false;
|
|
212 |
}
|
|
213 |
}
|
|
214 |
return true;
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
118 |
218 |
?>
|
Added some basic functions for module developers