| 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 |
785
|
doc
|
/**
|
| 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($HEADING_CSS_FILE)) $HEADING_CSS_FILE = 'Actual module file: ';
|
| 44 |
|
|
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.';
|
| 45 |
|
|
|
| 46 |
562
|
Ruebenwurz
|
// include functions to edit the optional module CSS files (frontend.css, backend.css)
|
| 47 |
|
|
require_once('css.functions.php');
|
| 48 |
|
|
|
| 49 |
785
|
doc
|
// check if the module directory is valid
|
| 50 |
|
|
$mod_dir = check_module_dir($_POST['mod_dir']);
|
| 51 |
|
|
if($mod_dir == '') die(header('Location: index.php'));
|
| 52 |
|
|
|
| 53 |
562
|
Ruebenwurz
|
// check if action is: save or edit
|
| 54 |
785
|
doc
|
if($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) {
|
| 55 |
562
|
Ruebenwurz
|
/**
|
| 56 |
785
|
doc
|
SAVE THE UPDATED CONTENTS TO THE CSS FILE
|
| 57 |
562
|
Ruebenwurz
|
*/
|
| 58 |
|
|
$css_content = '';
|
| 59 |
|
|
if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) {
|
| 60 |
785
|
doc
|
// Javascript is enabled so take contents from hidden field: css_codepress
|
| 61 |
562
|
Ruebenwurz
|
$css_content = stripslashes($_POST['css_codepress']);
|
| 62 |
|
|
} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) {
|
| 63 |
785
|
doc
|
// Javascript disabled, take contens from textarea: css_data
|
| 64 |
562
|
Ruebenwurz
|
$css_content = stripslashes($_POST['css_data']);
|
| 65 |
|
|
}
|
| 66 |
|
|
|
| 67 |
|
|
$bytes = 0;
|
| 68 |
|
|
if ($css_content != '') {
|
| 69 |
|
|
// open the module CSS file for writting
|
| 70 |
|
|
$mod_file = @fopen(dirname(__FILE__) .'/' .$_POST['edit_file'], "wb");
|
| 71 |
|
|
// write new content to the module CSS file
|
| 72 |
|
|
$bytes = @fwrite($mod_file, $css_content);
|
| 73 |
|
|
// close the file
|
| 74 |
|
|
@fclose($mod_file);
|
| 75 |
|
|
}
|
| 76 |
|
|
|
| 77 |
|
|
// write out status message
|
| 78 |
|
|
if($bytes == 0 ) {
|
| 79 |
|
|
$admin->print_error($TEXT['ERROR'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
| 80 |
|
|
} else {
|
| 81 |
|
|
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
| 82 |
|
|
}
|
| 83 |
|
|
|
| 84 |
|
|
} else {
|
| 85 |
|
|
/**
|
| 86 |
785
|
doc
|
MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA
|
| 87 |
562
|
Ruebenwurz
|
*/
|
| 88 |
785
|
doc
|
// include the backend.css file if exists
|
| 89 |
|
|
if(file_exists(WB_PATH .'/modules/' .$mod_dir .'/backend.css')) {
|
| 90 |
|
|
echo '<style type="text/css">';
|
| 91 |
|
|
include(WB_PATH .'/modules/' .$mod_dir .'/backend.css');
|
| 92 |
|
|
echo "\n</style>\n";
|
| 93 |
|
|
}
|
| 94 |
|
|
|
| 95 |
562
|
Ruebenwurz
|
// check which module file to edit (frontend.css, backend.css or '')
|
| 96 |
785
|
doc
|
$css_file = (in_array($_POST['edit_file'], array('frontend.css', 'backend.css'))) ? $_POST['edit_file'] : '';
|
| 97 |
562
|
Ruebenwurz
|
|
| 98 |
|
|
// display output
|
| 99 |
|
|
if($css_file == '') {
|
| 100 |
|
|
// no valid module file to edit; display error message and backlink to modify.php
|
| 101 |
|
|
echo "<h2>Nothing to edit</h2>";
|
| 102 |
|
|
echo "<p>No valid module file exists for this module.</p>";
|
| 103 |
|
|
$output = "<a href=\"#\" onclick=\"javascript: window.location = '";
|
| 104 |
|
|
$output .= ADMIN_URL ."/pages/modify.php?page_id=" .$page_id ."'\">back</a>";
|
| 105 |
|
|
echo $output;
|
| 106 |
|
|
} else {
|
| 107 |
|
|
// store content of the module file in variable
|
| 108 |
|
|
$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file);
|
| 109 |
|
|
|
| 110 |
592
|
doc
|
// make sure that codepress stuff is only used if the framework is available
|
| 111 |
|
|
$CODEPRESS['CLASS'] = '';
|
| 112 |
|
|
$CODEPRESS['JS'] = '';
|
| 113 |
|
|
if(file_exists(WB_PATH .'/include/codepress/codepress.js')) {
|
| 114 |
|
|
$CODEPRESS['CLASS'] = 'class="codepress css" ';
|
| 115 |
|
|
$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"';
|
| 116 |
|
|
}
|
| 117 |
785
|
doc
|
|
| 118 |
|
|
// write out heading
|
| 119 |
|
|
echo '<h2>' .$HEADING_CSS_FILE .'"' .$css_file .'"</h2>';
|
| 120 |
|
|
// include button to switch between frontend.css and backend.css (only shown if both files exists)
|
| 121 |
|
|
toggle_css_file($mod_dir, $css_file);
|
| 122 |
|
|
echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>';
|
| 123 |
|
|
|
| 124 |
|
|
// output content of module file to textareas
|
| 125 |
592
|
doc
|
?>
|
| 126 |
785
|
doc
|
<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;">
|
| 127 |
562
|
Ruebenwurz
|
<input type="hidden" name="css_codepress" value="" />
|
| 128 |
785
|
doc
|
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
|
| 129 |
|
|
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
|
| 130 |
|
|
<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>">
|
| 131 |
562
|
Ruebenwurz
|
<input type="hidden" name="edit_file" value="<?php echo $css_file; ?>" />
|
| 132 |
785
|
doc
|
<input type="hidden" name="action" value="save">
|
| 133 |
|
|
|
| 134 |
592
|
doc
|
<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL"
|
| 135 |
|
|
style="margin:2px;"><?php echo $css_content; ?></textarea>
|
| 136 |
|
|
|
| 137 |
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
| 138 |
|
|
<tr>
|
| 139 |
|
|
<td align="left">
|
| 140 |
|
|
<input name="save" type="submit" value="<?php echo $TEXT['SAVE'];?>"
|
| 141 |
|
|
<?php echo $CODEPRESS['JS'];?> style="width: 100px; margin-top: 5px;" />
|
| 142 |
|
|
</td>
|
| 143 |
|
|
<td align="right">
|
| 144 |
|
|
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>"
|
| 145 |
|
|
onclick="javascript: window.location = '<?php echo ADMIN_URL;?>/pages/modify.php?page_id=<?php echo $page_id; ?>';"
|
| 146 |
|
|
style="width: 100px; margin-top: 5px;" />
|
| 147 |
|
|
</td>
|
| 148 |
|
|
</tr>
|
| 149 |
|
|
</table>
|
| 150 |
562
|
Ruebenwurz
|
</form>
|
| 151 |
592
|
doc
|
<?php
|
| 152 |
562
|
Ruebenwurz
|
}
|
| 153 |
|
|
}
|
| 154 |
|
|
|
| 155 |
|
|
// Print admin footer
|
| 156 |
|
|
$admin->print_footer();
|
| 157 |
|
|
|
| 158 |
|
|
?>
|