From 1c415dbcf88659366e3d7f2deb46b908e082767c Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 26 Jul 2011 22:10:45 +0200 Subject: [PATCH] WYMeditor --- .gitmodules | 3 ++ adminer/plugin.php | 1 + plugins/wymeditor.php | 68 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 plugins/wymeditor.php diff --git a/.gitmodules b/.gitmodules index 127b40b9..afa3554f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "jquery-timepicker"] path = externals/jquery-timepicker url = git://github.com/trentrichardson/jQuery-Timepicker-Addon.git +[submodule "wymeditor"] + path = externals/wymeditor + url = git://github.com/wymeditor/wymeditor.git diff --git a/adminer/plugin.php b/adminer/plugin.php index 9df8f32a..84198adb 100644 --- a/adminer/plugin.php +++ b/adminer/plugin.php @@ -14,6 +14,7 @@ function adminer_object() { new AdminerDumpXml, //~ new AdminerEditCalendar("\n\n\n\n\n\n\n\n\n", "../externals/jquery-ui/ui/i18n/jquery.ui.datepicker-%s.js"), //~ new AdminerTinymce("../externals/tinymce/jscripts/tiny_mce/tiny_mce_dev.js"), + //~ new AdminerWymeditor(array("../externals/wymeditor/src/jquery/jquery.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.explorer.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.mozilla.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.opera.js", "../externals/wymeditor/src/wymeditor/jquery.wymeditor.safari.js")), new AdminerFileUpload(""), new AdminerSlugify, new AdminerTranslation, diff --git a/plugins/wymeditor.php b/plugins/wymeditor.php new file mode 100644 index 00000000..cb726230 --- /dev/null +++ b/plugins/wymeditor.php @@ -0,0 +1,68 @@ +scripts = $scripts; + $this->options = $options; + } + + function head() { + foreach ($this->scripts as $script) { + echo "\n"; + } + } + + function selectVal(&$val, $link, $field) { + // copied from tinymce.php + if (ereg("_html", $field["field"]) && $val != ' ') { + $shortened = (substr($val, -10) == "..."); + if ($shortened) { + $val = substr($val, 0, -10); + } + //! shorten with regard to HTML tags - http://php.vrana.cz/zkraceni-textu-s-xhtml-znackami.php + $val = preg_replace('~<[^>]*$~', '', html_entity_decode($val, ENT_QUOTES)); // remove ending incomplete tag (text can be shortened) + if ($shortened) { + $val .= "..."; + } + if (class_exists('DOMDocument')) { // close all opened tags + $dom = new DOMDocument; + if (@$dom->loadHTML("$val")) { // @ - $val can contain errors + $val = preg_replace('~.*]*>(.*).*~is', '\\1', $dom->saveHTML()); + } + } + } + } + + function editInput($table, $field, $attrs, $value) { + static $lang = ""; + if (!$lang && ereg("text", $field["type"]) && ereg("_html", $field["field"])) { + $lang = "en"; + if (function_exists('get_lang')) { // since Adminer 3.2.0 + $lang = get_lang(); + $lang = ($lang == "zh" || $lang == "zh-tw" ? "zh_cn" : $lang); + } + return "" . h($value) . ""; + } + } + +}