Project

General

Profile

« Previous | Next » 

Revision 785

Added by doc over 16 years ago

added updated edit CSS functions to the News module

View differences:

edit_css.php
27 27
require('../../config.php');
28 28
require(WB_PATH.'/modules/admin.php');
29 29

  
30
/**
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($CAP_EDIT_CSS)) $CAP_EDIT_CSS	= 'Edit CSS';
44
if(!isset($HEADING_CSS_FILE))	$HEADING_CSS_FILE = 'Actual module file: ';
45
if(!isset($TXT_EDIT_CSS_FILE)) $TXT_EDIT_CSS_FILE = 'Edit the CSS definitions in the textarea below.';
46

  
30 47
// include functions to edit the optional module CSS files (frontend.css, backend.css)
31 48
require_once('css.functions.php');
32 49

  
50
// check if the module directory is valid
51
$mod_dir = check_module_dir($_POST['mod_dir']);
52
if($mod_dir == '') die(header('Location: index.php'));
53

  
33 54
// 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'])) {
55
if($_POST['action'] == 'save' && mod_file_exists($mod_dir, $_POST['edit_file'])) {
36 56
	/** 
37
	SAVE THE UPDATED CONTENTS TO THE CSS FILE
57
		SAVE THE UPDATED CONTENTS TO THE CSS FILE
38 58
	*/
39 59
	$css_content = '';
40 60
	if(isset($_POST['css_codepress']) && strlen($_POST['css_codepress']) > 0) {
41
		// if Javascript is enabled, take contents from hidden field: css_codepress
61
		// Javascript is enabled so take contents from hidden field: css_codepress
42 62
		$css_content = stripslashes($_POST['css_codepress']);
43 63
	} elseif(isset($_POST['css_data']) && strlen($_POST['css_data']) > 0) {
44
		// if Javascript is disabled, take contens from textarea: css_data
64
		// Javascript disabled, take contens from textarea: css_data
45 65
		$css_content = stripslashes($_POST['css_data']);
46 66
	}
47 67

  
......
64 84

  
65 85
} else {
66 86
	/** 
67
	MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA 
87
		MODIFY CONTENTS OF THE CSS FILE VIA TEXT AREA 
68 88
	*/
69
	
89
	// include the backend.css file if exists
90
	if(file_exists(WB_PATH .'/modules/' .$mod_dir .'/backend.css')) {
91
		echo '<style type="text/css">';
92
		include(WB_PATH .'/modules/' .$mod_dir .'/backend.css');
93
		echo "\n</style>\n";
94
	}
95

  
70 96
	// 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']);
97
	$css_file = (in_array($_POST['edit_file'], array('frontend.css', 'backend.css'))) ? $_POST['edit_file'] : '';
73 98

  
74 99
	// display output
75 100
	if($css_file == '') {
......
82 107
	} else {
83 108
		// store content of the module file in variable
84 109
		$css_content = @file_get_contents(dirname(__FILE__) .'/' .$css_file);
85
	  	// output content of module file to textareas
86 110

  
87 111
		// make sure that codepress stuff is only used if the framework is available
88 112
		$CODEPRESS['CLASS'] = '';
......
91 115
			$CODEPRESS['CLASS'] = 'class="codepress css" ';
92 116
			$CODEPRESS['JS'] = 'onclick="javascript: css_codepress.value = area_codepress.getCode();"';
93 117
		}
94
			
118

  
119
		// write out heading
120
		echo '<h2>' .$HEADING_CSS_FILE .'"' .$css_file .'"</h2>';
121
		// include button to switch between frontend.css and backend.css (only shown if both files exists)
122
		toggle_css_file($mod_dir, $css_file); 
123
	  echo '<p>' .$TXT_EDIT_CSS_FILE .'</p>';
124

  
125
		// output content of module file to textareas
95 126
	?>
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; ?>">
127
		<form name="edit_module_file" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" style="margin: 0;">
99 128
			<input type="hidden" name="css_codepress" value="" />
129
	  	<input type="hidden" name="page_id" value="<?php echo $page_id; ?>">
130
	  	<input type="hidden" name="section_id" value="<?php echo $section_id; ?>">
131
	  	<input type="hidden" name="mod_dir" value="<?php echo $mod_dir; ?>">
100 132
			<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> 
133
	  	<input type="hidden" name="action" value="save">
134

  
108 135
			<textarea id="area_codepress" name="css_data" <?php echo $CODEPRESS['CLASS'];?>cols="115" rows="25" wrap="VIRTUAL" 
109 136
				style="margin:2px;"><?php echo $css_content; ?></textarea>
110 137

  

Also available in: Unified diff