Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        module
5
 * @package         droplet
6
 * @author          Ruud Eisinga (Ruud) John (PCWacht),WebsiteBaker Project
7
 * @copyright       2009-2012, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: modify_droplet.php 2033 2013-12-16 03:04:56Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/modify_droplet.php $
14
 * @lastmodified    $Date: 2013-12-16 04:04:56 +0100 (Mon, 16 Dec 2013) $
15
 *
16
 */
17

    
18
require('../../config.php');
19

    
20
require_once(WB_PATH.'/framework/class.admin.php');
21
require_once(WB_PATH.'/framework/functions.php');
22

    
23
$admintool_link = ADMIN_URL .'/admintools/index.php';
24
$module_edit_link = ADMIN_URL .'/admintools/tool.php?tool=droplets';
25
$admin = new admin('admintools', 'admintools');
26

    
27
// Get id
28
$droplet_id = intval($admin->checkIDKEY('droplet_id', false, 'GET'));
29
if (!$droplet_id) {
30
	$admin->print_error('IDKEY::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], $module_edit_link);
31
}
32
/*
33
// check if backend.css file needs to be included into the <body></body> of modify.php
34
if(!method_exists($admin, 'register_backend_modfiles') && file_exists(WB_PATH ."/modules/droplets/backend.css")) {
35
	echo '<style type="text/css">';
36
	include(WB_PATH .'/modules/droplets/backend.css');
37
	echo "n</style>n";
38
}
39
*/
40
// Load Language file
41
if(LANGUAGE_LOADED) {
42
	if(!file_exists(WB_PATH.'/modules/droplets/languages/'.LANGUAGE.'.php')) {
43
		require_once(WB_PATH.'/modules/droplets/languages/EN.php');
44
	} else {
45
		require_once(WB_PATH.'/modules/droplets/languages/'.LANGUAGE.'.php');
46
	}
47
}
48
require_once(WB_PATH . '/include/editarea/wb_wrapper_edit_area.php');
49

    
50
/**
51
 * toolbar: define the toolbar that will be displayed, each element being separated by a ",".
52
 * Type: String (combinaison of: "|", "*", "search", "go_to_line", "undo", "redo", "change_smooth_selection", "reset_highlight", "highlight", "word_wrap", "help", "save", "load", "new_document", "syntax_selection")
53
 * "|" or "separator" make appears a separator in the toolbar.
54
 * "*" or "return" make appears a line-break in the toolbar
55
 * Default: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
56

    
57
$aDefaultSettings = array (
58
		'id' => "src"	// should contain the id of the textarea that should be converted into an editor
59
		,'language' => "en"
60
		,'syntax' => ""
61
		,'start_highlight' => false	// if start with highlight
62
		,'is_multi_files' => false		// enable the multi file mode (the textarea content is ignored)
63
		,'min_width' => 400
64
		,'min_height' => 125
65
		,'allow_resize' => "y"	// possible values: "no", "both", "x", "y"
66
		,'allow_toggle' => true		// true or false
67
		,'plugins' => "" // comma separated plugin list
68
		,'browsers' => "all"	// all or known
69
		,'display' => "onload" 		// onload or later
70
		,'toolbar' => "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
71
		,'begin_toolbar' => ""		//  "new_document, save, load, |"
72
		,'end_toolbar' => ""		// or end_toolbar
73
		,'font_size' => "10"		// not for IE
74
		,'font_family' => "monospace"	// can be "verdana,monospace". Allow non monospace font but Firefox get smaller tabulation with non monospace fonts. IE doesn't change the tabulation width and Opera doesn't take this option into account... 
75
		,'cursor_position' => "begin"
76
		,'gecko_spellcheck' => false	// enable/disable by default the gecko_spellcheck
77
		,'max_undo' => 30
78
		,'fullscreen' => false
79
		,'is_editable' => true
80
		,'word_wrap' => false		// define if the text is wrapped of not in the textarea
81
		,'replace_tab_by_spaces' => false
82
		,'debug' => false		// used to display some debug information into a newly created textarea. Can be usefull to display trace info in it if you want to modify the code
83
		,'show_line_colors' => false	// if the highlight is disabled for the line currently beeing edited (if enabled => heavy CPU use)
84
		,'syntax_selection_allow' => "basic,brainfuck,c,coldfusion,cpp,css,html,java,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml"
85
		,'smooth_selection' => true
86
		,'autocompletion' => false	// NOT IMPLEMENTED			
87
		,'load_callback' => ""		// click on load button (function name)
88
		,'save_callback' => ""		// click on save button (function name)
89
		,'change_callback' => ""	// textarea onchange trigger (function name)
90
		,'submit_callback' => ""	// form submited (function name)
91
		,'EA_init_callback' => ""	// EditArea initiliazed (function name)
92
		,'EA_delete_callback' => ""	// EditArea deleted (function name)
93
		,'EA_load_callback' => ""	// EditArea fully loaded and displayed (function name)
94
		,'EA_unload_callback' => ""	// EditArea delete while being displayed (function name)
95
		,'EA_toggle_on_callback' => ""	         // EditArea toggled on (function name)
96
		,'EA_toggle_off_callback' => ""	        // EditArea toggled off (function name)
97
		,'EA_file_switch_on_callback' => ""	    // a new tab is selected (called for the newly selected file)
98
		,'EA_file_switch_off_callback' => ""	// a new tab is selected (called for the previously selected file)
99
		,'EA_file_close_callback' => ""		    // close a tab
100
	);
101
 */
102

    
103
/**
104
 * 
105
 */
106
$aInitEditArea = getEditareaDefaultSettings();
107
$aInitEditArea['id'] = 'contentedit';
108
$aInitEditArea['syntax'] = 'php';
109
$aInitEditArea['allow_resize'] = 'y';
110
$aInitEditArea['allow_toggle'] = true;
111
$aInitEditArea['start_highlight'] = true;
112
$aInitEditArea['min_width'] = 200;
113
$aInitEditArea['min_height'] = 250;
114
$aInitEditArea['toolbar'] = 'default';
115
$aInitEditArea['syntax_selection_allow'] = 'basic,php,css,html';
116
echo registerEditArea($aInitEditArea);
117

    
118
/**
119
 * 
120
echo registerEditArea ('contentedit'
121
                      ,'php'
122
                      ,'basic,php,css,html'
123
                      ,'y'
124
                      ,true
125
                      ,true
126
                      ,200
127
                      ,250
128
                      ,'default'
129
//                      ,'search, fullscreen, |, undo, redo, |, select_font,|, highlight, word_wrap, |, help'
130
);
131
 */
132

    
133
$modified_when = time();
134
$modified_by = ($admin->ami_group_member('1') ? 1 : $admin->get_user_id());
135
$sOverviewDroplets = $TEXT['LIST_OPTIONS'].' '.$DR_TEXT['DROPLETS'];
136

    
137
// Get header and footer
138
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_droplets` ';
139
$sql .= 'WHERE id = '.$droplet_id;
140
$sql .= '';
141

    
142
$query_content = $database->query($sql);
143

    
144
$fetch_content = $query_content->fetchRow();
145
$content = (htmlspecialchars($fetch_content['code']));
146
?>
147
<div class="droplets" style="margin-top: 6px;">
148
<h4 style="margin: 0; border-bottom: 1px solid #DDD; padding-bottom: 5px;">
149
	<a href="<?php echo $admintool_link;?>" title="<?php echo $HEADING['ADMINISTRATION_TOOLS']; ?>"><?php echo $HEADING['ADMINISTRATION_TOOLS']; ?></a>
150
	<span> &raquo; </span>
151
	<a href="<?php echo $module_edit_link;?>" title="<?php echo $sOverviewDroplets ?>" alt="<?php echo $sOverviewDroplets ?>">Droplet Overview</a>
152
</h4>
153
<br />
154
<form name="modify" action="<?php echo WB_URL; ?>/modules/droplets/save_droplet.php" method="post" style="margin: 0;">
155
<input type="hidden" name="data_codepress" value="" />
156
<input type="hidden" name="droplet_id" value="<?php echo $admin->getIDKEY($droplet_id); ?>" />
157
<input type="hidden" name="show_wysiwyg" value="<?php echo $fetch_content['show_wysiwyg']; ?>" />
158
<?php echo $admin->getFTAN(); ?>
159

    
160
<table class="row_a">
161
		<tr>
162
		<td width="10%" class="setting_name">
163
			<?php echo $TEXT['NAME']; ?>:
164
		</td>
165
		<td width="90%">
166
			<input type="text" name="title" value="<?php echo stripslashes($fetch_content['name']); ?>" style="width: 38%;" maxlength="32" />
167
		</td>
168
	</tr>
169
	<tr>
170
		<td valign="top" class="setting_name" width="60px"><?php echo $TEXT['DESCRIPTION']; ?>:</td>
171
		<td>
172
			<input type="text" name="description" value="<?php echo stripslashes($fetch_content['description']); ?>" style="width: 98%;" />
173
		</td>
174
	</tr>
175
	<tr>
176
		<td class="setting_name" width="60px">
177
			<?php echo $TEXT['ACTIVE']; ?>:
178
		</td>
179
		<td>
180
			<input type="radio" name="active" id="active_true" value="1" <?php if($fetch_content['active'] == 1) { echo ' checked="checked"'; } ?> />
181
			<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
182
			<label><?php echo $TEXT['YES']; ?></label>
183
			</a>
184
			<input type="radio" name="active" id="active_false" value="0" <?php if($fetch_content['active'] == 0) { echo ' checked="checked"'; } ?> />
185
			<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
186
			<label><?php echo $TEXT['NO']; ?></label>
187
			</a>
188
		</td>
189
	</tr>
190
<?php
191
// Next show only if admin is logged in, user_id = 1
192
if ($modified_by == 1) {
193
	?>
194
	<tr>
195
		<td class="setting_name" width="60px">
196
			<?php echo $TEXT['ADMIN']; ?>:
197
		</td>
198
		<td>
199
			<?php echo $DR_TEXT['ADMIN_EDIT']; ?>&nbsp;
200
			<input type="radio" name="admin_edit" id="admin_edit_true" value="1" <?php if($fetch_content['admin_edit'] == 1) { echo ' checked="checked"'; } ?> />
201
			<a href="#" onclick="javascript: document.getElementById('admin_edit_true').checked = true;">
202
			<label><?php echo $TEXT['YES']; ?></label>
203
			</a>
204
			<input type="radio" name="admin_edit" id="admin_edit_false" value="0" <?php if($fetch_content['admin_edit'] == 0) { echo ' checked="checked"'; } ?> />
205
			<a href="#" onclick="javascript: document.getElementById('admin_edit_false').checked = true;">
206
			<label><?php echo $TEXT['NO']; ?></label>
207
			</a>
208
			&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
209
			<?php echo $DR_TEXT['ADMIN_VIEW']; ?>:
210
			<input type="radio" name="admin_view" id="admin_view_true" value="1" <?php if($fetch_content['admin_view'] == 1) { echo ' checked="checked"'; } ?> />
211
			<a href="#" onclick="javascript: document.getElementById('admin_view_true').checked = true;">
212
			<label><?php echo $TEXT['YES']; ?></label>
213
			</a>
214
			<input type="radio" name="admin_view" id="admin_view_false" value="0" <?php if($fetch_content['admin_view'] == 0) { echo ' checked="checked"'; } ?> />
215
			<a href="#" onclick="javascript: document.getElementById('admin_view_false').checked = true;">
216
			<label><?php echo $TEXT['NO']; ?></label>
217
			</a>
218
		</td>
219
	</tr>
220
	<?php
221
}
222
?>
223
	<tr>
224
		<td valign="top" class="setting_name" width="60px"><?php echo $TEXT['CODE']; ?>:</td>
225
		<td ><textarea name="savecontent" id ="contentedit" style="width: 98%; height: 450px;" rows="10" cols="12"><?php echo $content; ?></textarea>&nbsp;
226
		</td>
227
	</tr>
228
	<tr>
229
		<td colspan="2">
230
		</td>
231
	</tr>
232
	<tr>
233
		<td valign="top" class="setting_name" width="60px"><?php echo $TEXT['COMMENTS']; ?>:</td>
234
		<td>
235
			<textarea name="comments" style="width: 98%; height: 100px;" rows="50" cols="120"><?php echo stripslashes($fetch_content['comments']); ?></textarea>
236
		</td>
237
	</tr>
238
	<tr>
239
		<td colspan="2">&nbsp;
240
		</td>
241
	</tr>
242
</table>
243
<br />
244
<table cellpadding="0" cellspacing="0" border="0" width="100%">
245
	<tr>
246
		<td align="left">
247
<?php
248
// Show only save button if allowed....
249
if ($modified_by == 1 OR $fetch_content['admin_edit'] == 0 ) {
250
	?>
251
			<button  class="save" name="save" type="submit"><?php echo $TEXT['SAVE']; ?></button>
252
	<?php
253
}
254
?>
255
		</td>
256
		<td align="right">
257
			<button class="cancel" type="button" onclick="javascript: window.location = '<?php echo $module_edit_link; ?>';"><?php echo $TEXT['CANCEL']; ?></button>
258
		</td>
259
	</tr>
260
</table>
261
</form>
262
</div>
263
<?php
264

    
265
// Print admin footer
266
$admin->print_footer();
(11-11/16)