Skip to content
Newer
Older
100644 60 lines (54 sloc) 1.92 KB
4f9ff89 @vrana Plugins
authored Feb 9, 2011
1 <?php
2
3 /** Edit all fields containg "_html" by HTML editor TinyMCE and display the HTML in select
4 * @author Jakub Vrana, http://www.vrana.cz/
5 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
6 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
7 */
8 class AdminerTinymce {
9 var $path;
10
11 /**
12 * @param string
13 */
14 function AdminerTinymce($path = "tiny_mce/tiny_mce.js") {
15 $this->path = $path;
16 }
17
18 function selectVal(&$val, $link, $field) {
19 if (ereg("_html", $field["field"]) && $val != '&nbsp;') {
20 $val = preg_replace('~<[^>]*$~', '', html_entity_decode($val, ENT_QUOTES, 'utf-8')); //! close all opened tags (text can be shortened)
21 }
22 }
23
24 function editInput($table, $field, $attrs, $value) {
25 static $tiny_mce = false;
26 if (ereg("text", $field["type"]) && ereg("_html", $field["field"])) {
27 if (!$tiny_mce) {
28 $tiny_mce = true;
29 $lang = "en";
30 if (function_exists('get_lang')) { // since Adminer 3.2.0
31 $lang = get_lang();
32 $lang = ($lang == "zh" ? "zh-cn" : ($lang == "zh-tw" ? "zh" : $lang));
33 if (!file_exists(dirname($this->path) . "/langs/$lang.js")) {
34 $lang = "en";
35 }
36 }
37 ?>
38 <script type="text/javascript" src="<?php echo h($this->path); ?>"></script>
39 <script type="text/javascript">
40 tinyMCE.init({
41 mode: 'none',
42 theme: 'advanced',
43 plugins: 'contextmenu,paste,table',
44 entity_encoding: 'raw',
45 theme_advanced_buttons1: 'bold,italic,link,unlink,|,sub,sup,|,bullist,numlist,|,cleanup,code',
46 theme_advanced_buttons2: 'tablecontrols',
47 theme_advanced_buttons3: '',
48 theme_advanced_toolbar_location: 'top',
49 theme_advanced_toolbar_align: 'left',
50 language: '<?php echo $lang; ?>'
51 });
52 </script>
53 <?php
54 }
55 return "<textarea$attrs id='fields-$field[field]' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>tinyMCE.execCommand('mceAddControl', true, 'fields-$field[field]');</script>";
56 }
57 }
58
59 }
Something went wrong with that request. Please try again.