Revision 909
Added by doc almost 16 years ago
edit_module_files.php | ||
---|---|---|
5 | 5 |
/* |
6 | 6 |
|
7 | 7 |
Website Baker Project <http://www.websitebaker.org/> |
8 |
Copyright (C) 2004-2008, Ryan Djurovich
|
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich
|
|
9 | 9 |
|
10 | 10 |
Website Baker is free software; you can redistribute it and/or modify |
11 | 11 |
it under the terms of the GNU General Public License as published by |
... | ... | |
44 | 44 |
die; |
45 | 45 |
} |
46 | 46 |
|
47 |
// register the textarea to use edit_area |
|
48 |
echo (function_exists('registerEditArea')) ? registerEditArea('code_area', 'css', false) : ''; |
|
49 |
|
|
47 | 50 |
// set default text output if varibles are not defined in the global WB language files |
48 | 51 |
$HEADING_CSS_FILE = (isset($GLOBALS['TEXT']['HEADING_CSS_FILE'])) ?$GLOBALS['TEXT']['HEADING_CSS_FILE'] :'Actual module file: '; |
49 | 52 |
$TXT_EDIT_CSS_FILE = (isset($GLOBALS['TEXT']['TXT_EDIT_CSS_FILE'])) ?$GLOBALS['TEXT']['TXT_EDIT_CSS_FILE'] :'Edit the CSS definitions in the textarea below.'; |
... | ... | |
63 | 66 |
/** |
64 | 67 |
SAVE THE UPDATED CONTENTS TO THE CSS FILE |
65 | 68 |
*/ |
66 |
|
|
67 | 69 |
$css_content = ''; |
68 |
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) { |
|
69 |
// Javascript is enabled so take contents from hidden field: css_codepress |
|
70 |
$css_content = stripslashes($_POST['css_codepress']); |
|
71 |
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) { |
|
72 |
// Javascript disabled, take contens from textarea: css_data |
|
70 |
if (isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) { |
|
73 | 71 |
$css_content = stripslashes($_POST['css_data']); |
74 | 72 |
} |
75 | 73 |
|
76 | 74 |
$bytes = 0; |
77 | 75 |
if ($css_content != '') { |
78 | 76 |
// open the module CSS file for writting |
79 |
$mod_file = @fopen(WB_PATH .'/modules/' .$mod_dir .'/' .$_POST['edit_file'], "wb");
|
|
77 |
$mod_file = @fopen(WB_PATH .'/modules/' .$mod_dir .'/' .$_POST['edit_file'], 'wb');
|
|
80 | 78 |
// write new content to the module CSS file |
81 | 79 |
$bytes = @fwrite($mod_file, $css_content); |
82 | 80 |
// close the file |
... | ... | |
118 | 116 |
} else { |
119 | 117 |
// store content of the module file in variable |
120 | 118 |
$css_content = @file_get_contents(WB_PATH .'/modules/' .$mod_dir .'/' .$css_file); |
121 |
|
|
122 |
// make sure that codepress stuff is only used if the framework is available |
|
123 |
$CODEPRESS['CLASS'] = ''; |
|
124 |
$CODEPRESS['JS'] = ''; |
|
125 |
if(file_exists(WB_PATH .'/include/codepress/codepress.js')) { |
|
126 |
$CODEPRESS['CLASS'] = 'class="codepress css" '; |
|
127 |
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"'; |
|
128 |
} |
|
129 |
|
|
130 | 119 |
// write out heading |
131 | 120 |
echo '<h2>' .$HEADING_CSS_FILE .'"' .$css_file .'"</h2>'; |
132 | 121 |
// include button to switch between frontend.css and backend.css (only shown if both files exists) |
133 | 122 |
toggle_css_file($mod_dir, $css_file); |
134 |
echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>';
|
|
123 |
echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>';
|
|
135 | 124 |
|
136 | 125 |
// output content of module file to textareas |
137 | 126 |
?> |
138 | 127 |
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;"> |
139 |
<input type="hidden" name="css_codepress" value="" /> |
|
140 | 128 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>"> |
141 | 129 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>"> |
142 | 130 |
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>"> |
143 |
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" />
|
|
131 |
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" /> |
|
144 | 132 |
<input type="hidden" name="action" value="save"> |
145 | 133 |
|
146 |
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL" style="margin:2px;"><?php echo $css_content; ?></textarea> |
|
134 |
<textarea id="code_area" name="css_data" cols="115" rows="25" wrap="VIRTUAL" style="margin:2px;"><?php echo $css_content; ?> |
|
135 |
</textarea> |
|
147 | 136 |
|
148 | 137 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
149 | 138 |
<tr> |
150 | 139 |
<td align="left"> |
151 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>" |
|
152 |
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" /> |
|
140 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>" style="width: 100px; margin-top: 5px;" /> |
|
153 | 141 |
</td> |
154 | 142 |
<td align="right"> |
155 | 143 |
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" |
Also available in: Unified diff
Added Javascript syntax highlighting framework EditArea as replacement for Codepress.