| 1 |
801
|
doc
|
<?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 |
806
|
Ruebenwurz
|
<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>
|
| 159 |
801
|
doc
|
|
| 160 |
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
| 161 |
|
|
<tr>
|
| 162 |
|
|
<td align="left">
|
| 163 |
|
|
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>"
|
| 164 |
|
|
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" />
|
| 165 |
|
|
</td>
|
| 166 |
|
|
<td align="right">
|
| 167 |
|
|
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>"
|
| 168 |
|
|
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';"
|
| 169 |
|
|
style="width: 100px; margin-top: 5px;" />
|
| 170 |
|
|
</td>
|
| 171 |
|
|
</tr>
|
| 172 |
|
|
</table>
|
| 173 |
|
|
</form>
|
| 174 |
|
|
<?php
|
| 175 |
|
|
}
|
| 176 |
|
|
}
|
| 177 |
|
|
|
| 178 |
|
|
// Print admin footer
|
| 179 |
|
|
$admin->print_footer();
|
| 180 |
|
|
|
| 181 |
|
|
?>
|