1
|
<?php
|
2
|
|
3
|
// $Id: edit_css.php 656 2008-02-01 22:53:02Z thorn $
|
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
|
// include functions to edit the optional module CSS files (frontend.css, backend.css)
|
31
|
require_once('css.functions.php');
|
32
|
|
33
|
// 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'])) {
|
36
|
/**
|
37
|
SAVE THE UPDATED CONTENTS TO THE CSS FILE
|
38
|
*/
|
39
|
$css_content = '';
|
40
|
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) {
|
41
|
// if Javascript is enabled, take contents from hidden field: css_codepress
|
42
|
$css_content = stripslashes($_POST['css_codepress']);
|
43
|
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) {
|
44
|
// if Javascript is disabled, take contens from textarea: css_data
|
45
|
$css_content = stripslashes($_POST['css_data']);
|
46
|
}
|
47
|
|
48
|
$bytes = 0;
|
49
|
if ($css_content != '') {
|
50
|
// open the module CSS file for writting
|
51
|
$mod_file = @fopen(dirname(__FILE__) .'/' .$_POST['edit_file'], "wb");
|
52
|
// write new content to the module CSS file
|
53
|
$bytes = @fwrite($mod_file, $css_content);
|
54
|
// close the file
|
55
|
@fclose($mod_file);
|
56
|
}
|
57
|
|
58
|
// write out status message
|
59
|
if($bytes == 0 ) {
|
60
|
$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
61
|
} else {
|
62
|
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
63
|
}
|
64
|
|
65
|
} else {
|
66
|
/**
|
67
|
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA
|
68
|
*/
|
69
|
|
70
|
// 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']);
|
73
|
|
74
|
// display output
|
75
|
if($css_file == '') {
|
76
|
// no valid module file to edit; display error message and backlink to modify.php
|
77
|
echo "<h2>Nothing to edit</h2>";
|
78
|
echo "<p>No valid module file exists for this module.</p>";
|
79
|
$output = "<a href=\"#\" onclick=\"javascript: window.location = '";
|
80
|
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>";
|
81
|
echo $output;
|
82
|
} else {
|
83
|
// store content of the module file in variable
|
84
|
$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file);
|
85
|
// output content of module file to textareas
|
86
|
|
87
|
// make sure that codepress stuff is only used if the framework is available
|
88
|
$CODEPRESS['CLASS'] = '';
|
89
|
$CODEPRESS['JS'] = '';
|
90
|
if(file_exists(WB_PATH .'/include/codepress/codepress.js')) {
|
91
|
$CODEPRESS['CLASS'] = 'class="codepress css" ';
|
92
|
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"';
|
93
|
}
|
94
|
|
95
|
?>
|
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; ?>">
|
99
|
<input type="hidden" name="css_codepress" value="" />
|
100
|
<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>
|
108
|
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL"
|
109
|
style="margin:2px;"><?php echo $css_content; ?></textarea>
|
110
|
|
111
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
112
|
<tr>
|
113
|
<td align="left">
|
114
|
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>"
|
115
|
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" />
|
116
|
</td>
|
117
|
<td align="right">
|
118
|
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>"
|
119
|
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';"
|
120
|
style="width: 100px; margin-top: 5px;" />
|
121
|
</td>
|
122
|
</tr>
|
123
|
</table>
|
124
|
</form>
|
125
|
<?php
|
126
|
}
|
127
|
}
|
128
|
|
129
|
// Print admin footer
|
130
|
$admin->print_footer();
|
131
|
|
132
|
?>
|