LEPTON CMS 7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.toggle_css_file.php
Go to the documentation of this file.
1<?php
2
19// include secure.php to protect this file and the whole CMS!
20if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
21if (defined('LEPTON_PATH')) {
22 include LEPTON_PATH.SEC_FILE;
23} else {
24 $oneback = "../";
25 $root = $oneback;
26 $level = 1;
27 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
28 $root .= $oneback;
29 $level += 1;
30 }
31 if (file_exists($root.SEC_FILE)) {
32 include $root.SEC_FILE;
33 } else {
34 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
35 }
36}
37// end include secure file
38
46function toggle_css_file(string $mod_dir, string $base_css_file = 'frontend.css' ): bool
47{
48 global $page_id, $section_id, $TEXT;
49
50 LEPTON_handle::register("mod_file_exists");
51
52 // check if the required edit_module_css.php file exists
53 if (!file_exists(LEPTON_PATH . '/modules/edit_module_files.php'))
54 {
55 return false;
56 }
57
58 // do sanity check of specified css file
59 if (!in_array ($base_css_file, ['frontend.css', 'css/frontend.css', 'backend.css', 'css/backend.css']))
60 {
61 return false;
62 }
63
64 // display button to toggle between the two CSS files: frontend.css, backend.css
65 switch ($base_css_file)
66 {
67 case 'frontend.css':
68 $toggle_file = 'backend.css';
69 break;
70
71 case 'backend.css':
72 $toggle_file = 'frontend.css';
73 break;
74
75 case 'css/frontend.css':
76 $toggle_file = 'css/backend.css';
77 break;
78
79 case 'css/backend.css':
80 $toggle_file = 'css/frontend.css';
81 break;
82
83 default:
84 return false;
85 }
86
87 // Aldus: another patch for the css-paths.
88 $toggle_file_label = str_replace("css/", "", $toggle_file);
89
90 if (mod_file_exists($mod_dir, $toggle_file))
91 {
92 $oTWIG = lib_twig_box::getInstance();
93
94 $oTWIG->loader->prependPath( LEPTON_PATH."/templates/".DEFAULT_THEME."/templates/" );
95
96 $fields = array(
97 'LEPTON_URL' => LEPTON_URL,
98 'page_id' => $page_id,
99 'section_id' => $section_id,
100 'mod_dir' => $mod_dir,
101 'edit_file' => $toggle_file_label,
102 'label_submit' => ucfirst($toggle_file_label)
103 );
104
105 echo $oTWIG->render(
106 'edit_module_css_form.lte',
107 $fields
108 );
109
110 return true;
111 }
112 else
113 {
114 return false;
115 }
116}
mod_file_exists($mod_dir, $mod_file='frontend.css')
toggle_css_file(string $mod_dir, string $base_css_file='frontend.css')