Revision 460
Added by Matthias over 17 years ago
class.admin.php | ||
---|---|---|
102 | 102 |
'WEBSITE_TITLE' => ($title['value']), |
103 | 103 |
'TEXT_ADMINISTRATION' => $TEXT['ADMINISTRATION'], |
104 | 104 |
'CHARSET' => $charset, |
105 |
'VERSION' => VERSION |
|
105 |
'VERSION' => VERSION, |
|
106 |
'WB_URL' => WB_URL, |
|
107 |
'BACKEND_MODULE_CSS' => $this->register_backend_modfiles('css'), // adds backend.css |
|
108 |
'BACKEND_MODULE_JS' => $this->register_backend_modfiles('js') // adds backend.js |
|
106 | 109 |
) |
107 | 110 |
); |
108 | 111 |
// Create the menu |
... | ... | |
257 | 260 |
} |
258 | 261 |
} |
259 | 262 |
} |
263 |
|
|
264 |
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the backend |
|
265 |
function register_backend_modfiles($file_id="css") { |
|
266 |
// sanity check of parameter passed to the function |
|
267 |
$file_id = strtolower($file_id); |
|
268 |
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") { |
|
269 |
return; |
|
270 |
} |
|
271 |
|
|
272 |
global $database; |
|
273 |
// define default baselink and filename for optional module javascript and stylesheet files |
|
274 |
$head_links = ""; |
|
275 |
if($file_id == "css") { |
|
276 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.css"'; |
|
277 |
$base_link.= 'rel="stylesheet" type="text/css" media="screen" />'; |
|
278 |
$base_file = "backend.css"; |
|
279 |
} else { |
|
280 |
$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.js"></script>'; |
|
281 |
$base_file = "backend.js"; |
|
282 |
} |
|
283 |
|
|
284 |
// check if backend.js or backend.css files needs to be included to the <head></head> section of the backend |
|
285 |
if(isset($_GET['tool'])) { |
|
286 |
// check if displayed page contains a installed admin tool |
|
287 |
$result = $database->query("SELECT * FROM " .TABLE_PREFIX ."addons |
|
288 |
WHERE type = 'module' AND function = 'tool' AND directory = '".$_GET['tool']."'"); |
|
289 |
|
|
290 |
if($result->numRows()) { |
|
291 |
// check if admin tool directory contains a backend.js or backend.css file to include |
|
292 |
$tool = $result->fetchRow(); |
|
293 |
if(file_exists(WB_PATH ."/modules/" .$tool['directory'] ."/$base_file")) { |
|
294 |
// return link to the backend.js or backend.css file |
|
295 |
return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link); |
|
296 |
} |
|
297 |
} |
|
298 |
} elseif(isset($_GET['page_id'])) { |
|
299 |
// check if displayed page in the backend contains a page module |
|
300 |
$page_id = (int) $_GET['page_id']; |
|
301 |
|
|
302 |
// gather information for all models embedded on actual page |
|
303 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections |
|
304 |
WHERE page_id=$page_id AND module<>'wysiwyg'"); |
|
305 |
|
|
306 |
while($row = $query_modules->fetchRow()) { |
|
307 |
// check if page module directory contains a backend.js or backend.css file |
|
308 |
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) { |
|
309 |
// create link with backend.js or backend.css source for the current module |
|
310 |
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link); |
|
311 |
// ensure that backend.js or backend.css is only added once per module type |
|
312 |
if(strpos($head_links, $tmp_link) === false) { |
|
313 |
$head_links .= $tmp_link ."\n"; |
|
314 |
} |
|
315 |
} |
|
316 |
} |
|
317 |
// write out links with all external module javascript/CSS files, remove last line feed |
|
318 |
return rtrim($head_links); |
|
319 |
} |
|
320 |
} |
|
260 | 321 |
} |
261 | 322 |
|
262 | 323 |
?> |
Also available in: Unified diff
Added Changeset [458] and [459] to branches 2.6.x