Revision 801
Added by doc over 16 years ago
trunk/CHANGELOG | ||
---|---|---|
12 | 12 |
|
13 | 13 |
------------------------------------- 2.7.0 ------------------------------------- |
14 | 14 |
05-Apr-2008 Christian Sommer |
15 |
! moved functions to edit module CSS files into the WB core to avoid duplication of code |
|
15 | 16 |
! minor layout change |
16 | 17 |
! allowed the character "-" to be used in database names |
17 | 18 |
04-Apr-2008 Thomas Hornik |
trunk/wb/framework/module.functions.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
/** |
|
27 |
This file contains the routines to edit the optional module files: frontend.css and backend.css |
|
28 |
Mechanism was introduced with WB 2.7 to provide a global solution for all modules |
|
29 |
To use this function, include this file from your module (e.g. from modify.php) |
|
30 |
Then simply call the function edit_css('your_module_directory') - that?s it |
|
31 |
*/ |
|
32 |
|
|
33 |
// prevent this file from being accessed directly |
|
34 |
if(!defined('WB_PATH')) die(header('Location: index.php')); |
|
35 |
|
|
36 |
// this function checks the validity of the specified module directory |
|
37 |
if(!function_exists('check_module_dir')) { |
|
38 |
function check_module_dir($mod_dir) { |
|
39 |
// check if module directory is formal correct (only characters: "a-z,0-9,_,-") |
|
40 |
if(!preg_match('/^[a-z0-9_-]+$/iD', $mod_dir)) return ''; |
|
41 |
// check if the module folder contains the required info.php file |
|
42 |
return (file_exists(WB_PATH .'/modules/' .$mod_dir .'/info.php')) ? $mod_dir : ''; |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
// this function checks if the specified optional module file exists |
|
47 |
if (!function_exists('mod_file_exists')) { |
|
48 |
function mod_file_exists($mod_dir, $mod_file='frontend.css') { |
|
49 |
// check if the module file exists |
|
50 |
return file_exists(WB_PATH .'/modules/' .$mod_dir .'/' .$mod_file); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
// this function displays the "Edit CSS" button in modify.php |
|
55 |
if (!function_exists('edit_module_css')) { |
|
56 |
function edit_module_css($mod_dir) { |
|
57 |
global $page_id, $section_id, $CAP_EDIT_CSS; |
|
58 |
// check if the required edit_module_css.php file exists |
|
59 |
if(!file_exists(WB_PATH .'/modules/edit_module_files.php')) return; |
|
60 |
|
|
61 |
// check if specified module directory is valid |
|
62 |
if(check_module_dir($mod_dir) == '') return; |
|
63 |
|
|
64 |
// check if frontend.css or backend.css exist |
|
65 |
$frontend_css = mod_file_exists($mod_dir, 'frontend.css'); |
|
66 |
$backend_css = mod_file_exists($mod_dir, 'backend.css'); |
|
67 |
|
|
68 |
// output the edit CSS submtin button if required |
|
69 |
if($frontend_css || $backend_css) { |
|
70 |
// default text used for the edit CSS routines if not defined in the modules language file |
|
71 |
if(!isset($CAP_EDIT_CSS)) $CAP_EDIT_CSS = 'Edit CSS'; |
|
72 |
?> |
|
73 |
<form name="edit_module_file" action="<?php echo WB_URL .'/modules/edit_module_files.php?page_id='.$page_id;?>" |
|
74 |
method="post" style="margin: 0; align:right;"> |
|
75 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
76 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
77 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
78 |
<input type="hidden" name="edit_file" value="<?php echo ($frontend_css) ?'frontend.css' : 'backend.css';?>"> |
|
79 |
<input type="hidden" name="action" value="edit"> |
|
80 |
<input type="submit" value="<?php echo $CAP_EDIT_CSS;?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
81 |
</form> |
|
82 |
<?php |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
// this function displays a button to toggle between CSS files (invoked from edit_css.php) |
|
88 |
if (!function_exists('toggle_css_file')) { |
|
89 |
function toggle_css_file($mod_dir, $base_css_file = 'frontend.css') { |
|
90 |
global $page_id, $section_id; |
|
91 |
// check if the required edit_module_css.php file exists |
|
92 |
if(!file_exists(WB_PATH .'/modules/edit_module_files.php')) return; |
|
93 |
|
|
94 |
// check if specified module directory is valid |
|
95 |
if(check_module_dir($mod_dir) == '') return; |
|
96 |
|
|
97 |
// do sanity check of specified css file |
|
98 |
if(!in_array($base_css_file, array('frontend.css', 'backend.css'))) return; |
|
99 |
|
|
100 |
// display button to toggle between the two CSS files: frontend.css, backend.css |
|
101 |
$toggle_file = ($base_css_file == 'frontend.css') ? 'backend.css' : 'frontend.css'; |
|
102 |
if(mod_file_exists($mod_dir, $toggle_file)) { |
|
103 |
?> |
|
104 |
<form name="toggle_module_file" action="<?php echo WB_URL .'/modules/edit_module_files.php?page_id='.$page_id;?>" |
|
105 |
method="post" style="margin: 0; align:right;"> |
|
106 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
107 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
108 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
109 |
<input type="hidden" name="edit_file" value="<?php echo $toggle_file; ?>"> |
|
110 |
<input type="hidden" name="action" value="edit"> |
|
111 |
<input type="submit" value="<?php echo ucwords($toggle_file);?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
112 |
</form> |
|
113 |
<?php |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
?> |
trunk/wb/modules/edit_module_files.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
/** |
|
27 |
This file contains the routines to edit the optional module files: frontend.css and backend.css |
|
28 |
Mechanism was introduced with WB 2.7 to provide a global solution for all modules |
|
29 |
*/ |
|
30 |
|
|
31 |
// prevent this file from being accessed directly |
|
32 |
if(!(isset($_POST['page_id']) && isset($_POST['section_id']) && isset($_POST['action']) |
|
33 |
&& isset($_POST['mod_dir']) && isset($_POST['edit_file']))) die(header('Location: index.php')); |
|
34 |
|
|
35 |
// include configuration file and admin wrapper script |
|
36 |
require('../config.php'); |
|
37 |
|
|
38 |
// include the and admin wrapper script |
|
39 |
require(WB_PATH.'/modules/admin.php'); |
|
40 |
|
|
41 |
// leave if the required module.functions.php file does not exist |
|
42 |
if(!file_exists(WB_PATH .'/framework/module.functions.php')) { |
|
43 |
echo 'Uups, the required file: /framework/module.functions.php is missing - script stopped.'; |
|
44 |
die; |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
DEFINE LANGUAGE DEPENDING OUTPUTS FOR THE EDIT CSS PART |
|
49 |
*/ |
|
50 |
$lang_dir = WB_PATH .'/modules/' .$_POST['mod_dir'] .'/languages/'; |
|
51 |
if(file_exists($lang_dir .LANGUAGE .'.php')) { |
|
52 |
// try to include custom language file if exists |
|
53 |
require_once($lang_dir .LANGUAGE .'.php'); |
|
54 |
} elseif(file_exists($lang_dir .'EN.php')) { |
|
55 |
// try to include default module language file |
|
56 |
require_once($lang_dir .'EN.php'); |
|
57 |
} |
|
58 |
|
|
59 |
// set defaults if output varibles are not set in the languages files |
|
60 |
if(!isset($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: '; |
|
61 |
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
|
62 |
|
|
63 |
// include functions to edit the optional module CSS files (frontend.css, backend.css) |
|
64 |
require_once(WB_PATH .'/framework/module.functions.php'); |
|
65 |
|
|
66 |
// check if the module directory is valid |
|
67 |
$mod_dir = check_module_dir($_POST['mod_dir']); |
|
68 |
if($mod_dir == '') { |
|
69 |
echo 'The specified module directory is invalid - script stopped.'; |
|
70 |
die; |
|
71 |
}; |
|
72 |
|
|
73 |
// check if action is: save or edit |
|
74 |
if($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) { |
|
75 |
/** |
|
76 |
SAVE THE UPDATED CONTENTS TO THE CSS FILE |
|
77 |
*/ |
|
78 |
|
|
79 |
$css_content = ''; |
|
80 |
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) { |
|
81 |
// Javascript is enabled so take contents from hidden field: css_codepress |
|
82 |
$css_content = stripslashes($_POST['css_codepress']); |
|
83 |
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) { |
|
84 |
// Javascript disabled, take contens from textarea: css_data |
|
85 |
$css_content = stripslashes($_POST['css_data']); |
|
86 |
} |
|
87 |
|
|
88 |
$bytes = 0; |
|
89 |
if ($css_content != '') { |
|
90 |
// open the module CSS file for writting |
|
91 |
$mod_file = @fopen(WB_PATH .'/modules/' .$mod_dir .'/' .$_POST['edit_file'], "wb"); |
|
92 |
// write new content to the module CSS file |
|
93 |
$bytes = @fwrite($mod_file, $css_content); |
|
94 |
// close the file |
|
95 |
@fclose($mod_file); |
|
96 |
} |
|
97 |
|
|
98 |
// write out status message |
|
99 |
if($bytes == 0 ) { |
|
100 |
$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
101 |
} else { |
|
102 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
} else { |
|
107 |
/** |
|
108 |
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA |
|
109 |
*/ |
|
110 |
// check if module backend.css file needs to be included into the <body> |
|
111 |
if((!method_exists($admin, 'register_backend_modfiles') || !isset($_GET['page_id'])) |
|
112 |
&& file_exists(WB_PATH .'/modules/'.$mod_dir.'/backend.css')) { |
|
113 |
echo '<style type="text/css">'; |
|
114 |
include(WB_PATH .'/modules/' .$mod_dir .'/backend.css'); |
|
115 |
echo "\n</style>\n"; |
|
116 |
} |
|
117 |
|
|
118 |
// check which module file to edit (frontend.css, backend.css or '') |
|
119 |
$css_file = (in_array($_POST['edit_file'], array('frontend.css', 'backend.css'))) ? $_POST['edit_file'] : ''; |
|
120 |
|
|
121 |
// display output |
|
122 |
if($css_file == '') { |
|
123 |
// no valid module file to edit; display error message and backlink to modify.php |
|
124 |
echo "<h2>Nothing to edit</h2>"; |
|
125 |
echo "<p>No valid module file exists for this module.</p>"; |
|
126 |
$output = "<a href=\"#\" onclick=\"javascript: window.location = '"; |
|
127 |
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>"; |
|
128 |
echo $output; |
|
129 |
|
|
130 |
} else { |
|
131 |
// store content of the module file in variable |
|
132 |
$css_content = @file_get_contents(WB_PATH .'/modules/' .$mod_dir .'/' .$css_file); |
|
133 |
|
|
134 |
// make sure that codepress stuff is only used if the framework is available |
|
135 |
$CODEPRESS['CLASS'] = ''; |
|
136 |
$CODEPRESS['JS'] = ''; |
|
137 |
if(file_exists(WB_PATH .'/include/codepress/codepress.js')) { |
|
138 |
$CODEPRESS['CLASS'] = 'class="codepress css" '; |
|
139 |
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"'; |
|
140 |
} |
|
141 |
|
|
142 |
// write out heading |
|
143 |
echo '<h2>' .$HEADING_CSS_FILE .'"' .$css_file .'"</h2>'; |
|
144 |
// include button to switch between frontend.css and backend.css (only shown if both files exists) |
|
145 |
toggle_css_file($mod_dir, $css_file); |
|
146 |
echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>'; |
|
147 |
|
|
148 |
// output content of module file to textareas |
|
149 |
?> |
|
150 |
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;"> |
|
151 |
<input type="hidden" name="css_codepress" value="" /> |
|
152 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
153 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
154 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
155 |
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" /> |
|
156 |
<input type="hidden" name="action" value="save"> |
|
157 |
|
|
158 |
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL" |
|
159 |
style="margin:2px;"><?php echo $css_content; ?></textarea> |
|
160 |
|
|
161 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
162 |
<tr> |
|
163 |
<td align="left"> |
|
164 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>" |
|
165 |
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" /> |
|
166 |
</td> |
|
167 |
<td align="right"> |
|
168 |
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" |
|
169 |
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" |
|
170 |
style="width: 100px; margin-top: 5px;" /> |
|
171 |
</td> |
|
172 |
</tr> |
|
173 |
</table> |
|
174 |
</form> |
|
175 |
<?php |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
// Print admin footer |
|
180 |
$admin->print_footer(); |
|
181 |
|
|
182 |
?> |
trunk/wb/modules/form/edit_css.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// include configuration file and admin wrapper script |
|
27 |
require('../../config.php'); |
|
28 |
require(WB_PATH.'/modules/admin.php'); |
|
29 |
|
|
30 |
/** |
|
31 |
DEFINE LANGUAGE DEPENDING OUTPUTS FOR THE EDIT CSS PART |
|
32 |
*/ |
|
33 |
$lang_dir = WB_PATH .'/modules/' .$_POST['mod_dir'] .'/languages/'; |
|
34 |
if(file_exists($lang_dir .LANGUAGE .'.php')) { |
|
35 |
// try to include custom language file if exists |
|
36 |
require_once($lang_dir .LANGUAGE .'.php'); |
|
37 |
} elseif(file_exists($lang_dir .'EN.php')) { |
|
38 |
// try to include default module language file |
|
39 |
require_once($lang_dir .'EN.php'); |
|
40 |
} |
|
41 |
|
|
42 |
// set defaults if output varibles are not set in the languages files |
|
43 |
if(!isset($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: '; |
|
44 |
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
|
45 |
|
|
46 |
// include functions to edit the optional module CSS files (frontend.css, backend.css) |
|
47 |
require_once('css.functions.php'); |
|
48 |
|
|
49 |
// check if the module directory is valid |
|
50 |
$mod_dir = check_module_dir($_POST['mod_dir']); |
|
51 |
if($mod_dir == '') die(header('Location: index.php')); |
|
52 |
|
|
53 |
// check if action is: save or edit |
|
54 |
if($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) { |
|
55 |
/** |
|
56 |
SAVE THE UPDATED CONTENTS TO THE CSS FILE |
|
57 |
*/ |
|
58 |
|
|
59 |
$css_content = ''; |
|
60 |
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) { |
|
61 |
// Javascript is enabled so take contents from hidden field: css_codepress |
|
62 |
$css_content = stripslashes($_POST['css_codepress']); |
|
63 |
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) { |
|
64 |
// Javascript disabled, take contens from textarea: css_data |
|
65 |
$css_content = stripslashes($_POST['css_data']); |
|
66 |
} |
|
67 |
|
|
68 |
$bytes = 0; |
|
69 |
if ($css_content != '') { |
|
70 |
// open the module CSS file for writting |
|
71 |
$mod_file = @fopen(dirname(__FILE__) .'/' .$_POST['edit_file'], "wb"); |
|
72 |
// write new content to the module CSS file |
|
73 |
$bytes = @fwrite($mod_file, $css_content); |
|
74 |
// close the file |
|
75 |
@fclose($mod_file); |
|
76 |
} |
|
77 |
|
|
78 |
// write out status message |
|
79 |
if($bytes == 0 ) { |
|
80 |
$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
81 |
} else { |
|
82 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
83 |
} |
|
84 |
|
|
85 |
|
|
86 |
} else { |
|
87 |
/** |
|
88 |
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA |
|
89 |
*/ |
|
90 |
// check if module backend.css file needs to be included into the <body> |
|
91 |
if((!method_exists($admin, 'register_backend_modfiles') || !isset($_GET['page_id'])) |
|
92 |
&& file_exists(WB_PATH .'/modules/'.$mod_dir.'/backend.css')) { |
|
93 |
echo '<style type="text/css">'; |
|
94 |
include(WB_PATH .'/modules/' .$mod_dir .'/backend.css'); |
|
95 |
echo "\n</style>\n"; |
|
96 |
} |
|
97 |
|
|
98 |
// check which module file to edit (frontend.css, backend.css or '') |
|
99 |
$css_file = (in_array($_POST['edit_file'], array('frontend.css', 'backend.css'))) ? $_POST['edit_file'] : ''; |
|
100 |
|
|
101 |
// display output |
|
102 |
if($css_file == '') { |
|
103 |
// no valid module file to edit; display error message and backlink to modify.php |
|
104 |
echo "<h2>Nothing to edit</h2>"; |
|
105 |
echo "<p>No valid module file exists for this module.</p>"; |
|
106 |
$output = "<a href=\"#\" onclick=\"javascript: window.location = '"; |
|
107 |
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>"; |
|
108 |
echo $output; |
|
109 |
|
|
110 |
} else { |
|
111 |
// store content of the module file in variable |
|
112 |
$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file); |
|
113 |
|
|
114 |
// make sure that codepress stuff is only used if the framework is available |
|
115 |
$CODEPRESS['CLASS'] = ''; |
|
116 |
$CODEPRESS['JS'] = ''; |
|
117 |
if(file_exists(WB_PATH .'/include/codepress/codepress.js')) { |
|
118 |
$CODEPRESS['CLASS'] = 'class="codepress css" '; |
|
119 |
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"'; |
|
120 |
} |
|
121 |
|
|
122 |
// write out heading |
|
123 |
echo '<h2>' .$HEADING_CSS_FILE .'"' .$css_file .'"</h2>'; |
|
124 |
// include button to switch between frontend.css and backend.css (only shown if both files exists) |
|
125 |
toggle_css_file($mod_dir, $css_file); |
|
126 |
echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>'; |
|
127 |
|
|
128 |
// output content of module file to textareas |
|
129 |
?> |
|
130 |
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;"> |
|
131 |
<input type="hidden" name="css_codepress" value="" /> |
|
132 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
133 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
134 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
135 |
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" /> |
|
136 |
<input type="hidden" name="action" value="save"> |
|
137 |
|
|
138 |
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL" |
|
139 |
style="margin:2px;"><?php echo $css_content; ?></textarea> |
|
140 |
|
|
141 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
142 |
<tr> |
|
143 |
<td align="left"> |
|
144 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>" |
|
145 |
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" /> |
|
146 |
</td> |
|
147 |
<td align="right"> |
|
148 |
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" |
|
149 |
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" |
|
150 |
style="width: 100px; margin-top: 5px;" /> |
|
151 |
</td> |
|
152 |
</tr> |
|
153 |
</table> |
|
154 |
</form> |
|
155 |
<?php |
|
156 |
} |
|
157 |
} |
|
158 |
|
|
159 |
// Print admin footer |
|
160 |
$admin->print_footer(); |
|
161 |
|
|
162 |
?> |
|
163 | 0 |
trunk/wb/modules/form/css.functions.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// prevent this file from being accessed directly |
|
27 |
if(!defined('WB_PATH')) die(header('Location: index.php')); |
|
28 |
|
|
29 |
// this function checks the validity of the specified module directory |
|
30 |
if(!function_exists('check_module_dir')) { |
|
31 |
function check_module_dir($mod_dir) { |
|
32 |
// check if module directory is formal correct (only characters: "a-z,0-9,_,-") |
|
33 |
if(!preg_match('/^[a-z0-9_-]+$/iD', $mod_dir)) return ''; |
|
34 |
// check if the module folder contains the required info.php file |
|
35 |
return (file_exists(WB_PATH .'/modules/' .$mod_dir .'/info.php')) ? $mod_dir : ''; |
|
36 |
} |
|
37 |
} |
|
38 |
|
|
39 |
// this function checks if the specified optional module file exists |
|
40 |
if (!function_exists('mod_file_exists')) { |
|
41 |
function mod_file_exists($mod_dir, $mod_file='frontend.css') { |
|
42 |
// check if the module file exists |
|
43 |
return file_exists(WB_PATH .'/modules/' .$mod_dir .'/' .$mod_file); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
// this function displays the "Edit CSS" button in modify.php |
|
48 |
if (!function_exists('css_edit')) { |
|
49 |
function css_edit($mod_dir) { |
|
50 |
global $page_id, $section_id, $CAP_EDIT_CSS; |
|
51 |
// check if specified module directory is valid |
|
52 |
if(check_module_dir($mod_dir) == '') return; |
|
53 |
|
|
54 |
// check if frontend.css or backend.css exist |
|
55 |
$frontend_css = mod_file_exists($mod_dir, 'frontend.css'); |
|
56 |
$backend_css = mod_file_exists($mod_dir, 'backend.css'); |
|
57 |
|
|
58 |
// output the edit CSS submtin button if required |
|
59 |
if($frontend_css || $backend_css) { |
|
60 |
// default text used for the edit CSS routines if not defined in the modules language file |
|
61 |
if(!isset($CAP_EDIT_CSS)) $CAP_EDIT_CSS = 'Edit CSS'; |
|
62 |
?> |
|
63 |
<form name="edit_module_file" action="<?php echo WB_URL .'/modules/' .$mod_dir . |
|
64 |
'/edit_css.php?page_id='.$page_id;?>" method="post" style="margin: 0; align:right;"> |
|
65 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
66 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
67 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
68 |
<input type="hidden" name="edit_file" value="<?php echo ($frontend_css) ?'frontend.css' : 'backend.css';?>"> |
|
69 |
<input type="hidden" name="action" value="edit"> |
|
70 |
<input type="submit" value="<?php echo $CAP_EDIT_CSS;?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
71 |
</form> |
|
72 |
<?php |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
// this function displays a button to toggle between CSS files (invoked from edit_css.php) |
|
78 |
if (!function_exists('toggle_css_file')) { |
|
79 |
function toggle_css_file($mod_dir, $base_css_file = 'frontend.css') { |
|
80 |
global $page_id, $section_id; |
|
81 |
// check if specified module directory is valid |
|
82 |
if(check_module_dir($mod_dir) == '') return; |
|
83 |
|
|
84 |
// do sanity check of specified css file |
|
85 |
if(!in_array($base_css_file, array('frontend.css', 'backend.css'))) return; |
|
86 |
|
|
87 |
// display button to toggle between the two CSS files: frontend.css, backend.css |
|
88 |
$toggle_file = ($base_css_file == 'frontend.css') ? 'backend.css' : 'frontend.css'; |
|
89 |
if(mod_file_exists($mod_dir, $toggle_file)) { |
|
90 |
?> |
|
91 |
<form name="toggle_module_file" action="<?php echo WB_URL .'/modules/' .$mod_dir . |
|
92 |
'/edit_css.php?page_id='.$page_id;?>" method="post" style="margin: 0; align:right;"> |
|
93 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
94 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
95 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
96 |
<input type="hidden" name="edit_file" value="<?php echo $toggle_file; ?>"> |
|
97 |
<input type="hidden" name="action" value="edit"> |
|
98 |
<input type="submit" value="<?php echo ucwords($toggle_file);?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
99 |
</form> |
|
100 |
<?php |
|
101 |
} |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
?> |
|
106 | 0 |
trunk/wb/modules/form/modify_settings.php | ||
---|---|---|
33 | 33 |
// Include WB admin wrapper script |
34 | 34 |
require(WB_PATH.'/modules/admin.php'); |
35 | 35 |
|
36 |
// include functions to edit the optional module CSS files (frontend.css, backend.css)
|
|
37 |
require_once('css.functions.php');
|
|
36 |
// include core functions of WB 2.7 to edit the optional module CSS files (frontend.css, backend.css)
|
|
37 |
@include_once(WB_PATH .'/framework/module.functions.php');
|
|
38 | 38 |
|
39 | 39 |
// check if module language file exists for the language set by the user (e.g. DE, EN) |
40 | 40 |
if(!file_exists(WB_PATH .'/modules/form/languages/'.LANGUAGE .'.php')) { |
... | ... | |
63 | 63 |
?> |
64 | 64 |
<h2><?php echo $MOD_FORM['SETTINGS']; ?></h2> |
65 | 65 |
<?php |
66 |
// include the button to edit the optional module CSS files |
|
67 |
// Note: CSS styles for the button are defined in backend.css (div class="mod_moduledirectory_edit_css") |
|
68 |
// Place this call outside of any <form></form> construct!!! |
|
69 |
css_edit('form'); |
|
66 |
// include the button to edit the optional module CSS files |
|
67 |
// Note: CSS styles for the button are defined in backend.css (div class="mod_moduledirectory_edit_css") |
|
68 |
// Place this call outside of any <form></form> construct!!! |
|
69 |
if(function_exists('edit_module_css')) { |
|
70 |
edit_module_css('form'); |
|
71 |
} |
|
70 | 72 |
?> |
71 | 73 |
|
72 | 74 |
<form name="edit" action="<?php echo WB_URL; ?>/modules/form/save_settings.php" method="post" style="margin: 0;"> |
trunk/wb/modules/news/edit_css.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// include configuration file and admin wrapper script |
|
27 |
require('../../config.php'); |
|
28 |
require(WB_PATH.'/modules/admin.php'); |
|
29 |
|
|
30 |
/** |
|
31 |
DEFINE LANGUAGE DEPENDING OUTPUTS FOR THE EDIT CSS PART |
|
32 |
*/ |
|
33 |
$lang_dir = WB_PATH .'/modules/' .$_POST['mod_dir'] .'/languages/'; |
|
34 |
if(file_exists($lang_dir .LANGUAGE .'.php')) { |
|
35 |
// try to include custom language file if exists |
|
36 |
require_once($lang_dir .LANGUAGE .'.php'); |
|
37 |
} elseif(file_exists($lang_dir .'EN.php')) { |
|
38 |
// try to include default module language file |
|
39 |
require_once($lang_dir .'EN.php'); |
|
40 |
} |
|
41 |
|
|
42 |
// set defaults if output varibles are not set in the languages files |
|
43 |
if(!isset($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: '; |
|
44 |
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
|
45 |
|
|
46 |
// include functions to edit the optional module CSS files (frontend.css, backend.css) |
|
47 |
require_once('css.functions.php'); |
|
48 |
|
|
49 |
// check if the module directory is valid |
|
50 |
$mod_dir = check_module_dir($_POST['mod_dir']); |
|
51 |
if($mod_dir == '') die(header('Location: index.php')); |
|
52 |
|
|
53 |
// check if action is: save or edit |
|
54 |
if($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) { |
|
55 |
/** |
|
56 |
SAVE THE UPDATED CONTENTS TO THE CSS FILE |
|
57 |
*/ |
|
58 |
$css_content = ''; |
|
59 |
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) { |
|
60 |
// Javascript is enabled so take contents from hidden field: css_codepress |
|
61 |
$css_content = stripslashes($_POST['css_codepress']); |
|
62 |
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) { |
|
63 |
// Javascript disabled, take contens from textarea: css_data |
|
64 |
$css_content = stripslashes($_POST['css_data']); |
|
65 |
} |
|
66 |
|
|
67 |
$bytes = 0; |
|
68 |
if ($css_content != '') { |
|
69 |
// open the module CSS file for writting |
|
70 |
$mod_file = @fopen(dirname(__FILE__) .'/' .$_POST['edit_file'], "wb"); |
|
71 |
// write new content to the module CSS file |
|
72 |
$bytes = @fwrite($mod_file, $css_content); |
|
73 |
// close the file |
|
74 |
@fclose($mod_file); |
|
75 |
} |
|
76 |
|
|
77 |
// write out status message |
|
78 |
if($bytes == 0 ) { |
|
79 |
$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
80 |
} else { |
|
81 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
82 |
} |
|
83 |
|
|
84 |
} else { |
|
85 |
/** |
|
86 |
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA |
|
87 |
*/ |
|
88 |
// check if module backend.css file needs to be included into the <body> |
|
89 |
if((!method_exists($admin, 'register_backend_modfiles') || !isset($_GET['page_id'])) |
|
90 |
&& file_exists(WB_PATH .'/modules/'.$mod_dir.'/backend.css')) { |
|
91 |
echo '<style type="text/css">'; |
|
92 |
include(WB_PATH .'/modules/' .$mod_dir .'/backend.css'); |
|
93 |
echo "\n</style>\n"; |
|
94 |
} |
|
95 |
|
|
96 |
// check which module file to edit (frontend.css, backend.css or '') |
|
97 |
$css_file = (in_array($_POST['edit_file'], array('frontend.css', 'backend.css'))) ? $_POST['edit_file'] : ''; |
|
98 |
|
|
99 |
// display output |
|
100 |
if($css_file == '') { |
|
101 |
// no valid module file to edit; display error message and backlink to modify.php |
|
102 |
echo "<h2>Nothing to edit</h2>"; |
|
103 |
echo "<p>No valid module file exists for this module.</p>"; |
|
104 |
$output = "<a href=\"#\" onclick=\"javascript: window.location = '"; |
|
105 |
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>"; |
|
106 |
echo $output; |
|
107 |
} else { |
|
108 |
// store content of the module file in variable |
|
109 |
$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file); |
|
110 |
|
|
111 |
// make sure that codepress stuff is only used if the framework is available |
|
112 |
$CODEPRESS['CLASS'] = ''; |
|
113 |
$CODEPRESS['JS'] = ''; |
|
114 |
if(file_exists(WB_PATH .'/include/codepress/codepress.js')) { |
|
115 |
$CODEPRESS['CLASS'] = 'class="codepress css" '; |
|
116 |
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"'; |
|
117 |
} |
|
118 |
|
|
119 |
// write out heading |
|
120 |
echo '<h2>' .$HEADING_CSS_FILE .'"' .$css_file .'"</h2>'; |
|
121 |
// include button to switch between frontend.css and backend.css (only shown if both files exists) |
|
122 |
toggle_css_file($mod_dir, $css_file); |
|
123 |
echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>'; |
|
124 |
|
|
125 |
// output content of module file to textareas |
|
126 |
?> |
|
127 |
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;"> |
|
128 |
<input type="hidden" name="css_codepress" value="" /> |
|
129 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
130 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
131 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
132 |
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" /> |
|
133 |
<input type="hidden" name="action" value="save"> |
|
134 |
|
|
135 |
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL" |
|
136 |
style="margin:2px;"><?php echo $css_content; ?></textarea> |
|
137 |
|
|
138 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
139 |
<tr> |
|
140 |
<td align="left"> |
|
141 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>" |
|
142 |
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" /> |
|
143 |
</td> |
|
144 |
<td align="right"> |
|
145 |
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" |
|
146 |
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" |
|
147 |
style="width: 100px; margin-top: 5px;" /> |
|
148 |
</td> |
|
149 |
</tr> |
|
150 |
</table> |
|
151 |
</form> |
|
152 |
<?php |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
// Print admin footer |
|
157 |
$admin->print_footer(); |
|
158 |
|
|
159 |
?> |
|
160 | 0 |
trunk/wb/modules/news/css.functions.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2008, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// prevent this file from being accessed directly |
|
27 |
if(!defined('WB_PATH')) die(header('Location: index.php')); |
|
28 |
|
|
29 |
// this function checks the validity of the specified module directory |
|
30 |
if(!function_exists('check_module_dir')) { |
|
31 |
function check_module_dir($mod_dir) { |
|
32 |
// check if module directory is formal correct (only characters: "a-z,0-9,_,-") |
|
33 |
if(!preg_match('/^[a-z0-9_-]+$/iD', $mod_dir)) return ''; |
|
34 |
// check if the module folder contains the required info.php file |
|
35 |
return (file_exists(WB_PATH .'/modules/' .$mod_dir .'/info.php')) ? $mod_dir : ''; |
|
36 |
} |
|
37 |
} |
|
38 |
|
|
39 |
// this function checks if the specified optional module file exists |
|
40 |
if (!function_exists('mod_file_exists')) { |
|
41 |
function mod_file_exists($mod_dir, $mod_file='frontend.css') { |
|
42 |
// check if the module file exists |
|
43 |
return file_exists(WB_PATH .'/modules/' .$mod_dir .'/' .$mod_file); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
// this function displays the "Edit CSS" button in modify.php |
|
48 |
if (!function_exists('css_edit')) { |
|
49 |
function css_edit($mod_dir) { |
|
50 |
global $page_id, $section_id, $CAP_EDIT_CSS; |
|
51 |
// check if specified module directory is valid |
|
52 |
if(check_module_dir($mod_dir) == '') return; |
|
53 |
|
|
54 |
// check if frontend.css or backend.css exist |
|
55 |
$frontend_css = mod_file_exists($mod_dir, 'frontend.css'); |
|
56 |
$backend_css = mod_file_exists($mod_dir, 'backend.css'); |
|
57 |
|
|
58 |
// output the edit CSS submtin button if required |
|
59 |
if($frontend_css || $backend_css) { |
|
60 |
// default text used for the edit CSS routines if not defined in the modules language file |
|
61 |
if(!isset($CAP_EDIT_CSS)) $CAP_EDIT_CSS = 'Edit CSS'; |
|
62 |
?> |
|
63 |
<form name="edit_module_file" action="<?php echo WB_URL .'/modules/' .$mod_dir . |
|
64 |
'/edit_css.php?page_id='.$page_id;?>" method="post" style="margin: 0; align:right;"> |
|
65 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
66 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
67 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
68 |
<input type="hidden" name="edit_file" value="<?php echo ($frontend_css) ?'frontend.css' : 'backend.css';?>"> |
|
69 |
<input type="hidden" name="action" value="edit"> |
|
70 |
<input type="submit" value="<?php echo $CAP_EDIT_CSS;?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
71 |
</form> |
|
72 |
<?php |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
// this function displays a button to toggle between CSS files (invoked from edit_css.php) |
|
78 |
if (!function_exists('toggle_css_file')) { |
|
79 |
function toggle_css_file($mod_dir, $base_css_file = 'frontend.css') { |
|
80 |
global $page_id, $section_id; |
|
81 |
// check if specified module directory is valid |
|
82 |
if(check_module_dir($mod_dir) == '') return; |
|
83 |
|
|
84 |
// do sanity check of specified css file |
|
85 |
if(!in_array($base_css_file, array('frontend.css', 'backend.css'))) return; |
|
86 |
|
|
87 |
// display button to toggle between the two CSS files: frontend.css, backend.css |
|
88 |
$toggle_file = ($base_css_file == 'frontend.css') ? 'backend.css' : 'frontend.css'; |
|
89 |
if(mod_file_exists($mod_dir, $toggle_file)) { |
|
90 |
?> |
|
91 |
<form name="toggle_module_file" action="<?php echo WB_URL .'/modules/' .$mod_dir . |
|
92 |
'/edit_css.php?page_id='.$page_id;?>" method="post" style="margin: 0; align:right;"> |
|
93 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
94 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
95 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
96 |
<input type="hidden" name="edit_file" value="<?php echo $toggle_file; ?>"> |
|
97 |
<input type="hidden" name="action" value="edit"> |
|
98 |
<input type="submit" value="<?php echo ucwords($toggle_file);?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
99 |
</form> |
|
100 |
<?php |
|
101 |
} |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
?> |
|
106 | 0 |
trunk/wb/modules/news/modify_settings.php | ||
---|---|---|
28 | 28 |
// Include WB admin wrapper script |
29 | 29 |
require(WB_PATH.'/modules/admin.php'); |
30 | 30 |
|
31 |
// include functions to edit the optional module CSS files (frontend.css, backend.css)
|
|
32 |
require_once('css.functions.php');
|
|
31 |
// include core functions of WB 2.7 to edit the optional module CSS files (frontend.css, backend.css)
|
|
32 |
@include_once(WB_PATH .'/framework/module.functions.php');
|
|
33 | 33 |
|
34 | 34 |
// check if module language file exists for the language set by the user (e.g. DE, EN) |
35 | 35 |
if(!file_exists(WB_PATH .'/modules/news/languages/'.LANGUAGE .'.php')) { |
... | ... | |
58 | 58 |
?> |
59 | 59 |
<h2><?php echo $MOD_NEWS['SETTINGS']; ?></h2> |
60 | 60 |
<?php |
61 |
// include the button to edit the optional module CSS files |
|
62 |
// Note: CSS styles for the button are defined in backend.css (div class="mod_moduledirectory_edit_css") |
|
63 |
// Place this call outside of any <form></form> construct!!! |
|
64 |
css_edit('news'); |
|
61 |
// include the button to edit the optional module CSS files (function added with WB 2.7) |
|
62 |
// Note: CSS styles for the button are defined in backend.css (div class="mod_moduledirectory_edit_css") |
|
63 |
// Place this call outside of any <form></form> construct!!! |
|
64 |
if(function_exists('edit_module_css')) { |
|
65 |
edit_module_css('news'); |
|
66 |
} |
|
65 | 67 |
?> |
66 | 68 |
|
67 | 69 |
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_settings.php" method="post" style="margin: 0;"> |
Also available in: Unified diff
Moved edit module CSS functions from modules to WB core (avoid code duplication; improve maintenance of code)