1 |
562
|
Ruebenwurz
|
<?php
|
2 |
|
|
|
3 |
|
|
// $Id$
|
4 |
|
|
|
5 |
583
|
doc
|
/*
|
6 |
562
|
Ruebenwurz
|
|
7 |
583
|
doc
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2008, Ryan Djurovich
|
9 |
562
|
Ruebenwurz
|
|
10 |
583
|
doc
|
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 |
562
|
Ruebenwurz
|
|
15 |
583
|
doc
|
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 |
562
|
Ruebenwurz
|
|
20 |
583
|
doc
|
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 |
562
|
Ruebenwurz
|
// 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' && isset($_POST['edit_file']) && mod_file_exists($_POST['edit_file'])) {
|
35 |
|
|
/**
|
36 |
|
|
SAVE THE UPDATED CONTENTS TO THE CSS FILE
|
37 |
|
|
*/
|
38 |
|
|
$css_content = '';
|
39 |
|
|
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) {
|
40 |
|
|
// if Javascript is enabled, take contents from hidden field: css_codepress
|
41 |
|
|
$css_content = stripslashes($_POST['css_codepress']);
|
42 |
|
|
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) {
|
43 |
|
|
// if Javascript is disabled, take contens from textarea: css_data
|
44 |
|
|
$css_content = stripslashes($_POST['css_data']);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
$bytes = 0;
|
48 |
|
|
if ($css_content != '') {
|
49 |
|
|
// open the module CSS file for writting
|
50 |
|
|
$mod_file = @fopen(dirname(__FILE__) .'/' .$_POST['edit_file'], "wb");
|
51 |
|
|
// write new content to the module CSS file
|
52 |
|
|
$bytes = @fwrite($mod_file, $css_content);
|
53 |
|
|
// close the file
|
54 |
|
|
@fclose($mod_file);
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
// write out status message
|
58 |
|
|
if($bytes == 0 ) {
|
59 |
|
|
$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
60 |
|
|
} else {
|
61 |
|
|
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
} else {
|
65 |
|
|
/**
|
66 |
|
|
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA
|
67 |
|
|
*/
|
68 |
|
|
|
69 |
|
|
// check which module file to edit (frontend.css, backend.css or '')
|
70 |
|
|
$css_file = '';
|
71 |
|
|
if(isset($_GET['edit_file'])) $css_file = edit_mod_file($_GET['edit_file']);
|
72 |
|
|
|
73 |
|
|
// display output
|
74 |
|
|
if($css_file == '') {
|
75 |
|
|
// no valid module file to edit; display error message and backlink to modify.php
|
76 |
|
|
echo "<h2>Nothing to edit</h2>";
|
77 |
|
|
echo "<p>No valid module file exists for this module.</p>";
|
78 |
|
|
$output = "<a href=\"#\" onclick=\"javascript: window.location = '";
|
79 |
|
|
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>";
|
80 |
|
|
echo $output;
|
81 |
|
|
} else {
|
82 |
|
|
// store content of the module file in variable
|
83 |
|
|
$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file);
|
84 |
|
|
// output content of module file to textareas
|
85 |
|
|
?>
|
86 |
|
|
|
87 |
|
|
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'] .'?action=save';?>" method="post" style="margin: 0;">
|
88 |
|
|
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
|
89 |
|
|
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
|
90 |
|
|
<input type="hidden" name="css_codepress" value="" />
|
91 |
|
|
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" />
|
92 |
|
|
|
93 |
|
|
<h2><?php echo $HEADING_CSS_FILE .'"' .$css_file; ?>"</h2>
|
94 |
|
|
<?php
|
95 |
|
|
// include the toggle button to switch between frontend.css and backend.css (if both files exists)
|
96 |
|
|
toggle_css_file($css_file);
|
97 |
|
|
?>
|
98 |
|
|
|
99 |
|
|
<p><?php echo $TXT_EDIT_CSS_FILE; ?></p>
|
100 |
|
|
|
101 |
583
|
doc
|
<textarea id="css_data" class="codepress css" cols="115" rows="25"
|
102 |
|
|
wrap="VIRTUAL" style="margin:2px;"><?php echo $css_content; ?></textarea>
|
103 |
562
|
Ruebenwurz
|
|
104 |
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
105 |
|
|
<tr>
|
106 |
|
|
<td align="left">
|
107 |
583
|
doc
|
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>"
|
108 |
|
|
onclick="javascript: css_codepress.value = css_data.getCode();" style="width: 100px; margin-top: 5px;" />
|
109 |
562
|
Ruebenwurz
|
</td>
|
110 |
|
|
<td align="right">
|
111 |
583
|
doc
|
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>"
|
112 |
|
|
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
|
113 |
562
|
Ruebenwurz
|
</td>
|
114 |
|
|
</tr>
|
115 |
|
|
</table>
|
116 |
|
|
</form>
|
117 |
|
|
<?php
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
// Print admin footer
|
122 |
|
|
$admin->print_footer();
|
123 |
|
|
|
124 |
|
|
?>
|