PageRenderTime 764ms CodeModel.GetById 101ms app.highlight 443ms RepoModel.GetById 142ms app.codeStats 11ms

/htdocs/wp-content/plugins/tinymce-advanced/tadv_admin.php

https://bitbucket.org/dkrzos/phc
PHP | 413 lines | 328 code | 85 blank | 0 comment | 83 complexity | b1c3020318480b1fcda9b5dee9f635e1 MD5 | raw file
  1<?php
  2
  3if ( !defined('TADV_ADMIN_PAGE') || !current_user_can('manage_options') )
  4	wp_die('Access denied');
  5
  6if ( isset( $_POST['tadv_uninstall'] ) ) {
  7	check_admin_referer( 'tadv-uninstall' );
  8
  9	delete_option('tadv_options');
 10	delete_option('tadv_toolbars');
 11	delete_option('tadv_plugins');
 12	delete_option('tadv_btns1');
 13	delete_option('tadv_btns2');
 14	delete_option('tadv_btns3');
 15	delete_option('tadv_btns4');
 16	delete_option('tadv_allbtns');
 17
 18	?>
 19	<div class="updated" style="margin-top:30px;">
 20	<p><?php _e('All options have been removed from the database. You can', 'tadv'); ?> <a href="plugins.php"><?php _e('deactivate TinyMCE Advanced', 'tadv'); ?></a> <?php _e('or', 'tadv'); ?> <a href=""> <?php _e('reload this page', 'tadv'); ?></a> <?php _e('to reset them to the default values.', 'tadv'); ?></p>
 21	</div>
 22	<?php
 23
 24	return;
 25}
 26
 27if ( ! isset($GLOBALS['wp_version']) || version_compare($GLOBALS['wp_version'], '3.1', '<') ) { // if less than ...
 28	?>
 29	<div class="error" style="margin-top:30px;">
 30	<p><?php _e('This plugin requires WordPress version 3.1 or newer. Please upgrade your WordPress installation or download an', 'tadv'); ?> <a href="http://wordpress.org/extend/plugins/tinymce-advanced/download/"><?php _e('older version of the plugin.', 'tadv'); ?></a></p>
 31	</div>
 32	<?php
 33
 34	return;
 35}
 36
 37$imgpath = TADV_URL . 'images/';
 38$tadv_toolbars = get_option('tadv_toolbars');
 39
 40function _tadv_parse_buttons($row) {
 41	$arr = array();
 42
 43	if ( !empty($_POST['toolbar_' . $row . 'order']) ) {
 44		parse_str($_POST['toolbar_' . $row . 'order'], $arr);
 45
 46		if ( !empty($arr['pre']) && is_array($arr['pre']) )
 47			$arr = $arr['pre'];
 48	}
 49
 50	return $arr;
 51}
 52
 53if ( empty($tadv_toolbars) || ! is_array($tadv_toolbars) ) {
 54	@include_once( TADV_PATH . 'tadv_defaults.php');
 55} else {
 56	$tadv_options = get_option('tadv_options');
 57	$tadv_toolbars['toolbar_1'] = isset($tadv_toolbars['toolbar_1']) && is_array($tadv_toolbars['toolbar_1']) ? $tadv_toolbars['toolbar_1'] : array();
 58	$tadv_toolbars['toolbar_2'] = isset($tadv_toolbars['toolbar_2']) && is_array($tadv_toolbars['toolbar_2']) ? $tadv_toolbars['toolbar_2'] : array();
 59	$tadv_toolbars['toolbar_3'] = isset($tadv_toolbars['toolbar_3']) && is_array($tadv_toolbars['toolbar_3']) ? $tadv_toolbars['toolbar_3'] : array();
 60	$tadv_toolbars['toolbar_4'] = isset($tadv_toolbars['toolbar_4']) && is_array($tadv_toolbars['toolbar_4']) ? $tadv_toolbars['toolbar_4'] : array();
 61}
 62
 63if ( isset( $_POST['tadv-save'] ) ) {
 64	check_admin_referer( 'tadv-save-buttons-order' );
 65
 66	$tadv_toolbars['toolbar_1'] = _tadv_parse_buttons(1);
 67	$tadv_toolbars['toolbar_2'] = _tadv_parse_buttons(2);
 68	$tadv_toolbars['toolbar_3'] = _tadv_parse_buttons(3);
 69	$tadv_toolbars['toolbar_4'] = _tadv_parse_buttons(4);
 70
 71	$tadv_options['advlink1'] = !empty($_POST['advlink1']) ? 1 : 0;
 72	$tadv_options['advimage'] = !empty($_POST['advimage']) ? 1 : 0;
 73	$tadv_options['advlist'] = !empty($_POST['advlist']) ? 1 : 0;
 74	$tadv_options['contextmenu'] = !empty($_POST['contextmenu']) ? 1 : 0;
 75
 76	$tadv_options['editorstyle'] = !empty($_POST['editorstyle']) ? 1 : 0;
 77	$tadv_options['hideclasses'] = !empty($_POST['hideclasses']) ? 1 : 0;
 78	$tadv_options['no_autop'] = !empty($_POST['no_autop']) ? 1 : 0;
 79	
 80	update_option( 'tadv_toolbars', $tadv_toolbars );
 81	update_option( 'tadv_options', $tadv_options );
 82}
 83
 84$btns = array();
 85$hidden_row = 0;
 86$i = 0;
 87foreach ( $tadv_toolbars as $toolbar ) {
 88	$l = $t = false;
 89	$i++;
 90
 91	if ( empty($toolbar) ) {
 92		$btns["toolbar_$i"] = array();
 93		continue;
 94	}
 95
 96	foreach( $toolbar as $k => $v ) {
 97		if ( strpos($v, 'separator') !== false )
 98			$toolbar[$k] = 'separator';
 99
100		if ( 'layer' == $v )
101			$l = $k;
102
103		if ( 'tablecontrols' == $v )
104			$t = $k;
105		
106		if ( empty($v) )
107			unset($toolbar[$k]);
108	}
109
110	if ( $l !== false )
111		array_splice( $toolbar, $l, 1, array('insertlayer', 'moveforward', 'movebackward', 'absolute') );
112
113	if ( $t !== false )
114		array_splice( $toolbar, $t + 1, 0, 'delete_table,' );
115
116	$btns["toolbar_$i"] = $toolbar;
117}
118extract($btns);
119
120if ( empty($toolbar_1) && empty($toolbar_2) && empty($toolbar_3) && empty($toolbar_4) ) {
121	?><div class="error" id="message"><p><?php _e('All toolbars are empty! Default buttons loaded.', 'tadv'); ?></p></div><?php
122
123	@include_once( TADV_PATH . 'tadv_defaults.php' );
124	$used_buttons = array_merge( $tadv_btns1, $tadv_btns2, $tadv_btns3, $tadv_btns4 );
125} else {
126	$used_buttons = array_merge( $toolbar_1, $toolbar_2, $toolbar_3, $toolbar_4 );
127}
128
129if ( in_array('advhr', $used_buttons, true) )
130	$plugins[] = 'advhr';
131
132if ( in_array('insertlayer', $used_buttons, true) )
133	$plugins[] = 'layer';
134
135if ( in_array('visualchars', $used_buttons, true) )
136	$plugins[] = 'visualchars';
137
138if ( in_array('nonbreaking', $used_buttons, true) )
139	$plugins[] = 'nonbreaking';
140
141if ( in_array('styleprops', $used_buttons, true) )
142	$plugins[] = 'style';
143
144if ( in_array('emotions', $used_buttons, true) )
145	$plugins[] = 'emotions';
146
147if ( in_array('insertdate', $used_buttons, true) || in_array('inserttime', $used_buttons, true) )
148	$plugins[] = 'insertdatetime';
149
150if ( in_array('tablecontrols', $used_buttons, true) )
151	$plugins[] = 'table';
152
153if ( in_array('print', $used_buttons, true) )
154	$plugins[] = 'print';
155
156if ( in_array('iespell', $used_buttons, true) )
157	$plugins[] = 'iespell';
158
159if ( in_array('search', $used_buttons, true) || in_array('replace', $used_buttons, true) )
160	$plugins[] = 'searchreplace';
161
162if ( in_array('cite', $used_buttons, true) || in_array('ins', $used_buttons, true) ||
163	in_array('del', $used_buttons, true) || in_array('abbr', $used_buttons, true) ||
164	in_array('acronym', $used_buttons, true) || in_array('attribs', $used_buttons, true) )
165		$plugins[] = 'xhtmlxtras';
166
167if ( !empty($tadv_options['advlink1']) )
168	$plugins[] = 'advlink';
169
170if ( !empty($tadv_options['advlist']) )
171	$plugins[] = 'advlist';
172
173if ( !empty($tadv_options['advimage']) )
174	$plugins[] = 'advimage';
175
176if ( !empty($tadv_options['contextmenu']) )
177	$plugins[] = 'contextmenu';
178
179$buttons = array( 'Horizontal rule' => 'hr', 'Hide next row' => 'wp_adv', 'Quote' => 'blockquote', 'Bold' => 'bold', 'Italic' => 'italic', 'Strikethrough' => 'strikethrough', 'Underline' => 'underline', 'Bullet List' => 'bullist', 'Numbered List' => 'numlist', 'Outdent' => 'outdent', 'Indent' => 'indent', 'Allign Left' => 'justifyleft', 'Center' => 'justifycenter', 'Alligh Right' => 'justifyright', 'Justify' => 'justifyfull', 'Cut' => 'cut', 'Copy' => 'copy', 'Paste' => 'paste', 'Link' => 'link', 'Remove Link' => 'unlink', 'Insert Image' => 'image', 'More Tag' => 'wp_more', 'Split Page' => 'wp_page', 'Search' => 'search', 'Replace' => 'replace', '<!--fontselect-->' => 'fontselect', '<!--fontsizeselect-->' => 'fontsizeselect', 'Help' => 'wp_help', 'Full Screen' => 'fullscreen', '<!--styleselect-->' => 'styleselect', '<!--formatselect-->' => 'formatselect', 'Text Color' => 'forecolor', 'Back Color' => 'backcolor', 'Paste as Text' => 'pastetext', 'Paste from Word' => 'pasteword', 'Remove Format' => 'removeformat', 'Clean Code' => 'cleanup', 'Check Spelling' => 'spellchecker', 'Character Map' => 'charmap', 'Print' => 'print', 'Undo' => 'undo', 'Redo' => 'redo', 'Table' => 'tablecontrols', 'Citation' => 'cite', 'Inserted Text' => 'ins', 'Deleted Text' => 'del', 'Abbreviation' => 'abbr', 'Acronym' => 'acronym', 'XHTML Attribs' => 'attribs', 'Layer' => 'layer', 'Advanced HR' => 'advhr', 'View HTML' => 'code', 'Hidden Chars' => 'visualchars', 'NB Space' => 'nonbreaking', 'Sub' => 'sub', 'Sup' => 'sup', 'Visual Aids' => 'visualaid', 'Insert Date' => 'insertdate', 'Insert Time' => 'inserttime', 'Anchor' => 'anchor', 'Style' => 'styleprops', 'Smilies' => 'emotions', 'Insert Movie' => 'media', 'IE Spell' => 'iespell' );
180
181if ( function_exists('moxiecode_plugins_url') ) {
182	if ( moxiecode_plugins_url('imagemanager') )
183		$buttons['MCFileManager'] = 'insertimage';
184
185	if ( moxiecode_plugins_url('filemanager') )
186		$buttons['MCImageManager'] = 'insertfile';
187}
188
189$tadv_allbtns = array_values($buttons);
190$tadv_allbtns[] = 'separator';
191$tadv_allbtns[] = '|';
192
193for ( $i = 1; $i < 21; $i++ )
194	$buttons["s$i"] = "separator$i";
195
196if ( isset($_POST['tadv-save']) ) {
197	update_option( 'tadv_plugins', $plugins );
198	update_option( 'tadv_btns1', $toolbar_1 );
199	update_option( 'tadv_btns2', $toolbar_2 );
200	update_option( 'tadv_btns3', $toolbar_3 );
201	update_option( 'tadv_btns4', $toolbar_4 );
202	update_option( 'tadv_allbtns', $tadv_allbtns );
203?>
204	<div class="updated" id="message"><p><?php _e('Options saved', 'tadv'); ?></p></div>
205<?php } ?>
206
207<div class="wrap" id="contain">
208
209	<h2><?php _e('TinyMCE Buttons Arrangement', 'tadv'); ?></h2>
210
211	<form id="tadvadmin" method="post" action="" onsubmit="">
212	<p><?php _e('Drag and drop buttons onto the toolbars below.', 'tadv'); ?></p>
213
214	<div id="tadvzones">
215		<input id="toolbar_1order" name="toolbar_1order" value="" type="hidden" />
216		<input id="toolbar_2order" name="toolbar_2order" value="" type="hidden" />
217		<input id="toolbar_3order" name="toolbar_3order" value="" type="hidden" />
218		<input id="toolbar_4order" name="toolbar_4order" value="" type="hidden" />
219		<input name="tadv-save" value="1" type="hidden" />
220
221	<div class="tadvdropzone">
222	<ul style="position: relative;" id="toolbar_1" class="container">
223<?php
224if ( is_array($tadv_toolbars['toolbar_1']) ) {
225	$tb1 = array();
226	foreach( $tadv_toolbars['toolbar_1'] as $k ) {
227		$t = array_intersect( $buttons, (array) $k );
228		$tb1 += $t;
229	}
230
231	foreach( $tb1 as $name => $btn ) {
232		if ( strpos( $btn, 'separator' ) !== false ) { ?>
233
234	<li class="separator" id="pre_<?php echo $btn; ?>">
235	<div class="tadvitem"> </div></li>
236<?php	} else { ?>
237
238	<li class="tadvmodule" id="pre_<?php echo $btn; ?>">
239	<div class="tadvitem"><div id="<?php echo $btn; ?>" title="<?php echo $name; ?>"></div>
240	<span class="descr"> <?php echo $name; ?></span>
241	</div></li>
242<?php   }
243	}
244	$buttons = array_diff( $buttons, $tb1 );
245} ?>
246	</ul></div>
247	<br class="clear" />
248
249	<div class="tadvdropzone">
250	<ul style="position: relative;" id="toolbar_2" class="container">
251<?php
252if ( is_array($tadv_toolbars['toolbar_2']) ) {
253	$tb2 = array();
254	foreach( $tadv_toolbars['toolbar_2'] as $k ) {
255		$t = array_intersect( $buttons, (array) $k );
256		$tb2 = $tb2 + $t;
257	}
258	foreach( $tb2 as $name => $btn ) {
259		if ( strpos( $btn, 'separator' ) !== false ) { ?>
260
261	<li class="separator" id="pre_<?php echo $btn; ?>">
262	<div class="tadvitem"> </div></li>
263<?php	} else { ?>
264
265	<li class="tadvmodule" id="pre_<?php echo $btn; ?>">
266	<div class="tadvitem"><div id="<?php echo $btn; ?>" title="<?php echo $name; ?>"></div>
267	<span class="descr"> <?php echo $name; ?></span></div></li>
268<?php   }
269	}
270	$buttons = array_diff( $buttons, $tb2 );
271} ?>
272	</ul></div>
273	<br class="clear" />
274
275	<div class="tadvdropzone">
276	<ul style="position: relative;" id="toolbar_3" class="container">
277<?php
278if ( is_array($tadv_toolbars['toolbar_3']) ) {
279	$tb3 = array();
280	foreach( $tadv_toolbars['toolbar_3'] as $k ) {
281		$t = array_intersect( $buttons, (array) $k );
282		$tb3 += $t;
283	}
284	foreach( $tb3 as $name => $btn ) {
285		if ( strpos( $btn, 'separator' ) !== false ) { ?>
286
287	<li class="separator" id="pre_<?php echo $btn; ?>">
288	<div class="tadvitem"> </div></li>
289<?php	} else { ?>
290
291	<li class="tadvmodule" id="pre_<?php echo $btn; ?>">
292	<div class="tadvitem"><div id="<?php echo $btn; ?>" title="<?php echo $name; ?>"></div>
293	<span class="descr"> <?php echo $name; ?></span></div></li>
294<?php   }
295	}
296	$buttons = array_diff( $buttons, $tb3 );
297} ?>
298	</ul></div>
299	<br class="clear" />
300
301	<div class="tadvdropzone">
302	<ul style="position: relative;" id="toolbar_4" class="container">
303<?php
304if ( is_array($tadv_toolbars['toolbar_4']) ) {
305	$tb4 = array();
306	foreach( $tadv_toolbars['toolbar_4'] as $k ) {
307		$t = array_intersect( $buttons, (array) $k );
308		$tb4 += $t;
309	}
310	foreach( $tb4 as $name => $btn ) {
311		if ( strpos( $btn, 'separator' ) !== false ) { ?>
312
313	<li class="separator" id="pre_<?php echo $btn; ?>">
314	<div class="tadvitem"> </div></li>
315<?php	} else { ?>
316
317	<li class="tadvmodule" id="pre_<?php echo $btn; ?>">
318	<div class="tadvitem"><div id="<?php echo $btn; ?>" title="<?php echo $name; ?>"></div>
319	<span class="descr"> <?php echo $name; ?></span></div></li>
320<?php   }
321	}
322	$buttons = array_diff( $buttons, $tb4 );
323} ?>
324	</ul></div>
325	<br class="clear" />
326	</div>
327
328	<div id="tadvWarnmsg">&nbsp;
329	<span id="too_long" style="display:none;"><?php _e('Adding too many buttons will make the toolbar too long and will not display correctly in TinyMCE!', 'tadv'); ?></span>
330	</div>
331
332	<div id="tadvpalettediv">
333	<ul style="position: relative;" id="tadvpalette">
334<?php
335if ( is_array($buttons) ) {
336	foreach( $buttons as $name => $btn ) {
337		if ( strpos( $btn, 'separator' ) !== false ) { ?>
338
339	<li class="separator" id="pre_<?php echo $btn; ?>">
340	<div class="tadvitem"> </div></li>
341<?php	} else { ?>
342
343	<li class="tadvmodule" id="pre_<?php echo $btn; ?>">
344	<div class="tadvitem"><div id="<?php echo $btn; ?>" title="<?php echo $name; ?>"></div>
345	<span class="descr"> <?php echo $name; ?></span></div></li>
346<?php   }
347	}
348} ?>
349	</ul>
350	</div>
351
352	<table class="clear" style="margin:10px 0"><tr><td style="padding:2px 12px 8px;">
353		Also enable:
354		
355		<label for="advimage" class="tadv-box"><?php _e('Advanced Image', 'tadv'); ?> &nbsp;
356		<input type="checkbox" class="tadv-chk"  name="advimage" id="advimage" <?php if ( !empty($tadv_options['advimage']) ) echo ' checked="checked"'; ?> /></label> &bull;
357		
358		<label for="advlist" class="tadv-box"><?php _e('Advanced List Options', 'tadv'); ?> &nbsp;
359		<input type="checkbox" class="tadv-chk"  name="advlist" id="advlist" <?php if ( !empty($tadv_options['advlist']) ) echo ' checked="checked"'; ?> /></label> &bull;
360
361		<label for="contextmenu" class="tadv-box"><?php _e('Context Menu', 'tadv'); ?> &nbsp;
362		<input type="checkbox" class="tadv-chk"  name="contextmenu" id="contextmenu" <?php if ( !empty($tadv_options['contextmenu']) ) echo ' checked="checked"'; ?> /></label>
363		<?php _e('(to show the browser context menu in Firefox, hold down the Ctrl key).', 'tadv'); ?>
364		</td></tr>
365
366		<tr><td style="border:1px solid #CD0000;padding:2px 12px 8px;">
367		<p style="font-weight:bold;color:#CD0000;"><?php _e('Advanced Options', 'tadv'); ?></p>
368
369		<p><input type="checkbox" class="tadv-chk"  name="advlink1" id="advlink1" <?php if ( !empty($tadv_options['advlink1']) ) echo ' checked="checked"'; ?> /> <label for="advlink1" class="tadv-box"><?php _e('Advanced Link', 'tadv'); ?></label> <?php _e('Enabling this TinyMCE plugin will overwrite the internal links feature in WordPress 3.1 and newer. Cuttently there is no way to enable both of them at the same time.', 'tadv'); ?></p>
370		
371<?php	if ( ! current_theme_supports( 'editor-style' ) ) { ?>
372		<p><?php _e('It seems your theme (still) doesn\'t support customised styles for the editor. If you would like to use that, you can create a file named <i>editor-style.css</i> and add it to your theme\'s directory. You can use the editor-style.css from the Twenty Ten theme as a template.', 'tadv'); ?></p>
373
374		<p><input type="checkbox" class="tadv-chk"  name="editorstyle" id="editorstyle" <?php if ( !empty($tadv_options['editorstyle']) ) echo ' checked="checked"'; ?> /> <label for="editorstyle" class="tadv-box"><?php _e('Import editor-style.css.', 'tadv'); ?></label> <?php _e('This is only needed if you created that file. Themes that style the editor will import the stylesheet automatically.', 'tadv'); ?></p>
375<?php	} ?>
376
377		<p><input type="checkbox" class="tadv-chk"  name="hideclasses" id="hideclasses" <?php if ( !empty($tadv_options['hideclasses']) ) echo ' checked="checked"'; ?> /> <label for="hideclasses" class="tadv-box"><?php _e('Hide all CSS classes in the editor menus.', 'tadv'); ?></label> <?php _e('Note that selecting this will also disable the Styles drop-down menu.', 'tadv'); ?></p>
378
379		<p><input type="checkbox" class="tadv-chk"  name="no_autop" id="no_autop" <?php if ( !empty($tadv_options['no_autop']) ) echo ' checked="checked"'; ?> /> <label for="no_autop" class="tadv-box"><?php _e('Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the HTML editor', 'tadv'); ?></label> <?php _e('This will make it possible to use more advanced coding in the HTML editor without the back-end filtering affecting it much. However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. Also line breaks in the HTML editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br /&gt; tags.', 'tadv'); ?></p>
380		</td></tr>
381<?php
382	$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) );
383	if ( $mce_locale != 'en' ) {
384		if ( ! @file_exists(TADV_PATH . 'mce/advlink/langs/' . $mce_locale . '_dlg.js') ) { ?>
385		<tr><td style="padding:2px 12px 8px;">
386		<p style="font-weight:bold;"><?php _e('Language Settings', 'tadv'); ?></p>
387		<p><?php _e('Your WordPress language is set to', 'tadv'); ?> <strong><?php echo get_locale(); ?></strong>. <?php _e('However there is no matching language installed for TinyMCE plugins. This plugin includes several translations: German, French, Italian, Spanish, Portuguese, Russian, Japanese and Chinese. More translations are available at the', 'tadv'); ?> <a href="http://www.tinymce.com/i18n/index.php?ctrl=lang&act=download&pr_id=1"><?php _e('TinyMCE web site.', 'tadv'); ?></a></p>
388		</td></tr>
389<?php	}
390	} // end mce_locale
391?>
392	</table>
393
394<p>
395	<?php wp_nonce_field( 'tadv-save-buttons-order' ); ?>
396	<input class="button tadv_btn" type="button" class="tadv_btn" value="<?php _e('Remove Settings', 'tadv'); ?>" onclick="document.getElementById('tadv_uninst_div').style.display = 'block';" />
397	<input class="button-primary tadv_btn" type="button" value="<?php _e('Save Changes', 'tadv'); ?>" onclick="tadvSortable.serialize();" />
398</p>
399</form>
400
401<div id="tadvWarnmsg2">&nbsp;
402	<span id="sink_err" style="display:none;"><?php _e('The Kitchen Sink button shows/hides the next toolbar row. It will not work at the current place.', 'tadv'); ?></span>
403</div>
404
405<div id="tadv_uninst_div" style="">
406<form method="post" action="">
407<?php wp_nonce_field('tadv-uninstall'); ?>
408<div><?php _e('Remove all saved settings from the database?', 'tadv'); ?>
409<input class="button tadv_btn" type="button" name="cancel" value="<?php _e('Cancel', 'tadv'); ?>" onclick="document.getElementById('tadv_uninst_div').style.display = 'none';" style="margin-left:20px" />
410<input class="button tadv_btn" type="submit" name="tadv_uninstall" value="<?php _e('Continue', 'tadv'); ?>" /></div>
411</form>
412</div>
413</div>