Revision 784
Added by doc over 16 years ago
trunk/CHANGELOG | ||
---|---|---|
11 | 11 |
! = Update/Change |
12 | 12 |
|
13 | 13 |
------------------------------------- 2.7.0 ------------------------------------- |
14 |
01-Apr-2008 Christian Sommer |
|
15 |
! added updated edit CSS functions to the Form module |
|
14 | 16 |
31-Mar-2008 Christian Sommer |
15 | 17 |
# fixed bug in output filter (mailto links with HTML entities in optional part) |
16 | 18 |
29-Mar-2008 Christian Sommer |
trunk/wb/modules/form/edit_css.php | ||
---|---|---|
27 | 27 |
require('../../config.php'); |
28 | 28 |
require(WB_PATH.'/modules/admin.php'); |
29 | 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($CAP_EDIT_CSS)) $CAP_EDIT_CSS = 'Edit CSS'; |
|
44 |
if(!isset($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: '; |
|
45 |
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
|
46 |
|
|
30 | 47 |
// include functions to edit the optional module CSS files (frontend.css, backend.css) |
31 | 48 |
require_once('css.functions.php'); |
32 | 49 |
|
50 |
// check if the module directory is valid |
|
51 |
$mod_dir = check_module_dir($_POST['mod_dir']); |
|
52 |
if($mod_dir == '') die(header('Location: index.php')); |
|
53 |
|
|
33 | 54 |
// check if action is: save or edit |
34 |
if(isset($_GET['action']) && $_GET['action'] == 'save' && |
|
35 |
isset($_POST['edit_file']) && mod_file_exists($_POST['edit_file'])) { |
|
55 |
if($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) { |
|
36 | 56 |
/** |
37 |
SAVE THE UPDATED CONTENTS TO THE CSS FILE |
|
57 |
SAVE THE UPDATED CONTENTS TO THE CSS FILE
|
|
38 | 58 |
*/ |
59 |
|
|
39 | 60 |
$css_content = ''; |
40 | 61 |
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) { |
41 |
// if Javascript is enabled, take contents from hidden field: css_codepress
|
|
62 |
// Javascript is enabled so take contents from hidden field: css_codepress
|
|
42 | 63 |
$css_content = stripslashes($_POST['css_codepress']); |
43 | 64 |
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) { |
44 |
// if Javascript is disabled, take contens from textarea: css_data
|
|
65 |
// Javascript disabled, take contens from textarea: css_data
|
|
45 | 66 |
$css_content = stripslashes($_POST['css_data']); |
46 | 67 |
} |
47 | 68 |
|
... | ... | |
62 | 83 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
63 | 84 |
} |
64 | 85 |
|
86 |
|
|
65 | 87 |
} else { |
66 | 88 |
/** |
67 |
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA |
|
89 |
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA
|
|
68 | 90 |
*/ |
69 |
|
|
91 |
// include the backend.css file if exists |
|
92 |
if(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 |
|
|
70 | 98 |
// check which module file to edit (frontend.css, backend.css or '') |
71 |
$css_file = ''; |
|
72 |
if(isset($_GET['edit_file'])) $css_file = edit_mod_file($_GET['edit_file']); |
|
99 |
$css_file = (in_array($_POST['edit_file'], array('frontend.css', 'backend.css'))) ? $_POST['edit_file'] : ''; |
|
73 | 100 |
|
74 | 101 |
// display output |
75 | 102 |
if($css_file == '') { |
... | ... | |
79 | 106 |
$output = "<a href=\"#\" onclick=\"javascript: window.location = '"; |
80 | 107 |
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>"; |
81 | 108 |
echo $output; |
109 |
|
|
82 | 110 |
} else { |
83 | 111 |
// store content of the module file in variable |
84 | 112 |
$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file); |
85 |
// output content of module file to textareas |
|
86 | 113 |
|
87 | 114 |
// make sure that codepress stuff is only used if the framework is available |
88 | 115 |
$CODEPRESS['CLASS'] = ''; |
... | ... | |
91 | 118 |
$CODEPRESS['CLASS'] = 'class="codepress css" '; |
92 | 119 |
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"'; |
93 | 120 |
} |
94 |
|
|
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 |
|
95 | 129 |
?> |
96 |
<form name="edit_module_file" action="<?php echo htmlspecialchars(strip_tags($_SERVER['PHP_SELF'])) .'?action=save';?>" method="post" style="margin: 0;"> |
|
97 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
98 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
130 |
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;"> |
|
99 | 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; ?>"> |
|
100 | 135 |
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" /> |
101 |
|
|
102 |
<h2><?php echo $HEADING_CSS_FILE .'"' .$css_file; ?>"</h2> |
|
103 |
<?php |
|
104 |
// include the toggle button to switch between frontend.css and backend.css (if both files exists) |
|
105 |
toggle_css_file($css_file); |
|
106 |
?> |
|
107 |
<p><?php echo $TXT_EDIT_CSS_FILE; ?></p> |
|
136 |
<input type="hidden" name="action" value="save"> |
|
137 |
|
|
108 | 138 |
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL" |
109 | 139 |
style="margin:2px;"><?php echo $css_content; ?></textarea> |
110 | 140 |
|
trunk/wb/modules/form/css.functions.php | ||
---|---|---|
23 | 23 |
|
24 | 24 |
*/ |
25 | 25 |
|
26 |
// DEFINE LANGUAGE DEPENDING OUTPUTS FOR THE EDIT CSS PART |
|
27 |
$lang_dir = WB_PATH .'/modules/' .basename(dirname(__FILE__)) .'/languages/'; |
|
28 |
if(file_exists($lang_dir .LANGUAGE .'.php')) { |
|
29 |
// try to include custom language file if exists |
|
30 |
require_once($lang_dir .LANGUAGE .'.php'); |
|
31 |
} elseif(file_exists($lang_dir .'EN.php')) { |
|
32 |
// try to include default module language file |
|
33 |
require_once($lang_dir .'EN.php'); |
|
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 |
} |
|
34 | 37 |
} |
35 | 38 |
|
36 |
// set defaults if output varibles are not set in the languages files |
|
37 |
if(!isset($CAP_EDIT_CSS)) $CAP_EDIT_CSS = 'Edit CSS'; |
|
38 |
if(!isset($CAP_TOGGLE_CSS)) $CAP_TOGGLE_CSS = 'Switch to '; |
|
39 |
if(!isset($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: '; |
|
40 |
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
|
41 |
|
|
42 | 39 |
// this function checks if the specified optional module file exists |
43 | 40 |
if (!function_exists('mod_file_exists')) { |
44 |
function mod_file_exists($mod_file='frontend.css') { |
|
45 |
// extract the module directory |
|
46 |
$mod_dir = basename(dirname(__FILE__)) .'/' .$mod_file; |
|
47 |
return file_exists(WB_PATH .'/modules/' .$mod_dir); |
|
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); |
|
48 | 44 |
} |
49 | 45 |
} |
50 | 46 |
|
51 |
// this function displays a "Edit CSS" button in modify.php |
|
52 |
// if the optional module files (module.css, module.js) if exists |
|
47 |
// this function displays the "Edit CSS" button in modify.php |
|
53 | 48 |
if (!function_exists('css_edit')) { |
54 |
function css_edit() { |
|
49 |
function css_edit($mod_dir) {
|
|
55 | 50 |
global $page_id, $section_id, $CAP_EDIT_CSS; |
56 |
// extract the module directory |
|
57 |
$mod_dir = basename(dirname(__FILE__)); |
|
58 |
$frontend_css = mod_file_exists('frontend.css'); |
|
59 |
$backend_css = mod_file_exists('backend.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 |
|
60 | 59 |
if($frontend_css || $backend_css) { |
61 |
// display link to edit the optional CSS module files |
|
62 |
$file = $frontend_css ? 'frontend.css' : 'backend.css'; |
|
63 |
$output = '<div class="mod_' .$mod_dir .'_edit_css"><a href="' .WB_URL .'/modules/' .$mod_dir .'/edit_css.php'; |
|
64 |
$output .= '?page_id=' .$page_id .'§ion_id=' .$section_id .'&edit_file=' .$file .'">'; |
|
65 |
$output .= $CAP_EDIT_CSS .'</a></div>'; |
|
66 |
echo $output; |
|
67 |
} |
|
68 |
} |
|
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 |
if(!isset($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: '; |
|
63 |
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
|
64 |
?> |
|
65 |
<form name="edit_module_file" action="<?php echo WB_URL .'/modules/' .$mod_dir . |
|
66 |
'/edit_css.php';?>" method="post" style="margin: 0; align:right;"> |
|
67 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
68 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
69 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
70 |
<input type="hidden" name="edit_file" value="<?php echo ($frontend_css) ?'frontend.css' : 'backend.css';?>"> |
|
71 |
<input type="hidden" name="action" value="edit"> |
|
72 |
<input type="submit" value="<?php echo $CAP_EDIT_CSS;?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
73 |
</form> |
|
74 |
<?php |
|
75 |
} |
|
76 |
} |
|
69 | 77 |
} |
70 | 78 |
|
71 |
// this function returns a secure module file from $_GET['edit_file'] |
|
72 |
if (!function_exists('edit_mod_file')) { |
|
73 |
function edit_mod_file() { |
|
74 |
$allowed_files = array('frontend.css', 'backend.css'); |
|
75 |
if(isset($_GET['edit_file']) && in_array($_GET['edit_file'], $allowed_files)) { |
|
76 |
return $_GET['edit_file']; |
|
77 |
} elseif(mod_file_exists('frontend.css')) { |
|
78 |
return 'frontend.css'; |
|
79 |
} elseif(mod_file_exists('backend_css')) { |
|
80 |
return 'backend.css'; |
|
81 |
} else { |
|
82 |
return ''; |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
// this function displays a button to toggle between the optional module CSS files |
|
88 |
// function is invoked from edit_css.php file |
|
79 |
// this function displays a button to toggle between CSS files (invoked from edit_css.php) |
|
89 | 80 |
if (!function_exists('toggle_css_file')) { |
90 |
function toggle_css_file($base_css_file = 'frontend.css') { |
|
91 |
$allowed_mod_files = array('frontend.css', 'backend.css'); |
|
92 |
if(!in_array($base_css_file, $allowed_mod_files)) return; |
|
81 |
function toggle_css_file($mod_dir, $base_css_file = 'frontend.css') { |
|
93 | 82 |
global $page_id, $section_id, $CAP_TOGGLE_CSS; |
94 |
// extract the module directory |
|
95 |
$mod_dir = basename(dirname(__FILE__)); |
|
83 |
// check if specified module directory is valid |
|
84 |
if(check_module_dir($mod_dir) == '') return; |
|
85 |
|
|
86 |
// do sanity check of specified css file |
|
87 |
if(!in_array($base_css_file, array('frontend.css', 'backend.css'))) return; |
|
88 |
|
|
89 |
// display button to toggle between the two CSS files: frontend.css, backend.css |
|
96 | 90 |
$toggle_file = ($base_css_file == 'frontend.css') ? 'backend.css' : 'frontend.css'; |
97 |
if(mod_file_exists($toggle_file)) { |
|
98 |
// display button to toggle between the two CSS files: frontend.css, backend.css |
|
99 |
$output = '<div class="mod_' .$mod_dir .'_edit_css"><a href="' .WB_URL .'/modules/' .$mod_dir .'/edit_css.php'; |
|
100 |
$output .= '?page_id=' .$page_id .'§ion_id=' .$section_id .'&edit_file=' .$toggle_file .'">'; |
|
101 |
$output .= $CAP_TOGGLE_CSS .$toggle_file .'</a></div>'; |
|
102 |
echo $output; |
|
91 |
if(mod_file_exists($mod_dir, $toggle_file)) { |
|
92 |
?> |
|
93 |
<form name="toggle_module_file" action="<?php echo WB_URL .'/modules/' .$mod_dir . |
|
94 |
'/edit_css.php';?>" method="post" style="margin: 0; align:right;"> |
|
95 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
|
96 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
|
97 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
|
98 |
<input type="hidden" name="edit_file" value="<?php echo $toggle_file; ?>"> |
|
99 |
<input type="hidden" name="action" value="edit"> |
|
100 |
<input type="submit" value="<?php echo ucwords($toggle_file);?>" class="mod_<?php echo $mod_dir;?>_edit_css"> |
|
101 |
</form> |
|
102 |
<?php |
|
103 | 103 |
} |
104 |
}
|
|
104 |
}
|
|
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
?> |
trunk/wb/modules/form/modify_settings.php | ||
---|---|---|
63 | 63 |
?> |
64 | 64 |
<h2><?php echo $MOD_FORM['SETTINGS']; ?></h2> |
65 | 65 |
<?php |
66 |
// include the button to edit the optionla module CSS files
|
|
66 |
// include the button to edit the optional module CSS files
|
|
67 | 67 |
// Note: CSS styles for the button are defined in backend.css (div class="mod_moduledirectory_edit_css") |
68 |
css_edit(); |
|
68 |
// Place this call outside of any <form></form> construct!!! |
|
69 |
css_edit('form'); |
|
69 | 70 |
?> |
70 | 71 |
|
71 | 72 |
<form name="edit" action="<?php echo WB_URL; ?>/modules/form/save_settings.php" method="post" style="margin: 0;"> |
trunk/wb/modules/form/languages/NL.php | ||
---|---|---|
31 | 31 |
|
32 | 32 |
// Variables for the module CSS edit outputs |
33 | 33 |
$CAP_EDIT_CSS = 'Wijzig CSS'; |
34 |
$CAP_TOGGLE_CSS = 'Wijzig '; |
|
35 | 34 |
$HEADING_CSS_FILE = 'Actuele module bestand: '; |
36 | 35 |
$TXT_EDIT_CSS_FILE = 'Wijzig de CSS definities in het textveld hieronder.'; |
37 | 36 |
|
trunk/wb/modules/form/languages/EN.php | ||
---|---|---|
31 | 31 |
|
32 | 32 |
// Variables for the module CSS edit outputs |
33 | 33 |
$CAP_EDIT_CSS = 'Edit CSS'; |
34 |
$CAP_TOGGLE_CSS = 'Edit '; |
|
35 | 34 |
$HEADING_CSS_FILE = 'Actual module file: '; |
36 | 35 |
$TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.'; |
37 | 36 |
|
trunk/wb/modules/form/languages/RU.php | ||
---|---|---|
31 | 31 |
|
32 | 32 |
// Variables for the module CSS edit outputs |
33 | 33 |
$CAP_EDIT_CSS = 'Редактировать CSS'; |
34 |
$CAP_TOGGLE_CSS = 'Редактировать '; |
|
35 | 34 |
$HEADING_CSS_FILE = 'Имя файла: '; |
36 | 35 |
$TXT_EDIT_CSS_FILE = 'Измените CSS файл, если необходимо:'; |
37 | 36 |
|
trunk/wb/modules/form/languages/DE.php | ||
---|---|---|
31 | 31 |
|
32 | 32 |
// Variablen fuer Textausgabe der frontend.css/backend.css Bearbeitung |
33 | 33 |
$CAP_EDIT_CSS = 'Bearbeite CSS'; |
34 |
$CAP_TOGGLE_CSS = 'Wechsle zu '; |
|
35 | 34 |
$HEADING_CSS_FILE = 'Aktuelle Moduldatei: '; |
36 | 35 |
$TXT_EDIT_CSS_FILE = 'Bearbeite die CSS Definitionen im nachfolgenden Textfeld.'; |
37 | 36 |
|
trunk/wb/modules/form/backend.css | ||
---|---|---|
5 | 5 |
border-top: 1px dashed #fff; |
6 | 6 |
} |
7 | 7 |
|
8 |
div.mod_form_edit_css { |
|
9 |
width: 100%; |
|
8 |
/* |
|
9 |
The definitions below provide the style for the edit CSS button |
|
10 |
Required CSS class name: input.mod_moduledirectory_edit_css |
|
11 |
*/ |
|
12 |
input.mod_form_edit_css { |
|
13 |
color: #000; |
|
14 |
background-color: #F0F0F0; |
|
15 |
border: 1px solid gray; |
|
16 |
padding: 2px; |
|
17 |
margin: 0; |
|
18 |
margin-left: 625px; |
|
10 | 19 |
margin-top: -20px; |
11 |
margin-bottom: 15px; |
|
12 |
text-align: right; |
|
13 |
} |
|
14 |
|
|
15 |
div.mod_form_edit_css a { |
|
16 |
width: 100px; |
|
17 |
padding: 5px; |
|
18 |
border: 1px solid; |
|
19 |
background-color: #F0F0F0; |
|
20 |
margin-bottom: 5px; |
|
21 |
width: 110px; |
|
20 | 22 |
} |
Also available in: Unified diff
added updated edit CSS functions to the Form module