WYMeditor
This commit is contained in:
parent
903a0377af
commit
1c415dbcf8
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -13,3 +13,6 @@
|
||||||
[submodule "jquery-timepicker"]
|
[submodule "jquery-timepicker"]
|
||||||
path = externals/jquery-timepicker
|
path = externals/jquery-timepicker
|
||||||
url = git://github.com/trentrichardson/jQuery-Timepicker-Addon.git
|
url = git://github.com/trentrichardson/jQuery-Timepicker-Addon.git
|
||||||
|
[submodule "wymeditor"]
|
||||||
|
path = externals/wymeditor
|
||||||
|
url = git://github.com/wymeditor/wymeditor.git
|
||||||
|
|
|
@ -14,6 +14,7 @@ function adminer_object() {
|
||||||
new AdminerDumpXml,
|
new AdminerDumpXml,
|
||||||
//~ new AdminerEditCalendar("<script type='text/javascript' src='../externals/jquery-ui/jquery-1.4.4.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.core.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.widget.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.datepicker.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.mouse.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.slider.js'></script>\n<script type='text/javascript' src='../externals/jquery-timepicker/jquery-ui-timepicker-addon.js'></script>\n<link rel='stylesheet' href='../externals/jquery-ui/themes/base/jquery.ui.all.css'>\n<style type='text/css'>\n.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }\n.ui-timepicker-div dl { text-align: left; }\n.ui-timepicker-div dl dt { height: 25px; }\n.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; }\n.ui-timepicker-div td { font-size: 90%; }\n</style>\n", "../externals/jquery-ui/ui/i18n/jquery.ui.datepicker-%s.js"),
|
//~ new AdminerEditCalendar("<script type='text/javascript' src='../externals/jquery-ui/jquery-1.4.4.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.core.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.widget.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.datepicker.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.mouse.js'></script>\n<script type='text/javascript' src='../externals/jquery-ui/ui/jquery.ui.slider.js'></script>\n<script type='text/javascript' src='../externals/jquery-timepicker/jquery-ui-timepicker-addon.js'></script>\n<link rel='stylesheet' href='../externals/jquery-ui/themes/base/jquery.ui.all.css'>\n<style type='text/css'>\n.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }\n.ui-timepicker-div dl { text-align: left; }\n.ui-timepicker-div dl dt { height: 25px; }\n.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; }\n.ui-timepicker-div td { font-size: 90%; }\n</style>\n", "../externals/jquery-ui/ui/i18n/jquery.ui.datepicker-%s.js"),
|
||||||
//~ new AdminerTinymce("../externals/tinymce/jscripts/tiny_mce/tiny_mce_dev.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 AdminerFileUpload(""),
|
||||||
new AdminerSlugify,
|
new AdminerSlugify,
|
||||||
new AdminerTranslation,
|
new AdminerTranslation,
|
||||||
|
|
68
plugins/wymeditor.php
Normal file
68
plugins/wymeditor.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/** Edit all fields containing "_html" by HTML editor WYMeditor and display the HTML in select
|
||||||
|
* @uses WYMeditor, http://www.wymeditor.org/
|
||||||
|
* @author Jakub Vrana, http://www.vrana.cz/
|
||||||
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
||||||
|
*/
|
||||||
|
class AdminerWymeditor {
|
||||||
|
/** @var array @access protected */
|
||||||
|
var $scripts;
|
||||||
|
|
||||||
|
/** @var string @access protected */
|
||||||
|
var $options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array
|
||||||
|
* @param string in format "skin: 'custom', preInit: function () { }"
|
||||||
|
*/
|
||||||
|
function AdminerWymeditor($scripts = array("jquery/jquery.js", "wymeditor/jquery.wymeditor.min.js"), $options = "") {
|
||||||
|
$this->scripts = $scripts;
|
||||||
|
$this->options = $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function head() {
|
||||||
|
foreach ($this->scripts as $script) {
|
||||||
|
echo "<script type='text/javascript' src='" . h($script) . "'></script>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectVal(&$val, $link, $field) {
|
||||||
|
// copied from tinymce.php
|
||||||
|
if (ereg("_html", $field["field"]) && $val != ' ') {
|
||||||
|
$shortened = (substr($val, -10) == "<i>...</i>");
|
||||||
|
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 .= "<i>...</i>";
|
||||||
|
}
|
||||||
|
if (class_exists('DOMDocument')) { // close all opened tags
|
||||||
|
$dom = new DOMDocument;
|
||||||
|
if (@$dom->loadHTML("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>$val")) { // @ - $val can contain errors
|
||||||
|
$val = preg_replace('~.*<body[^>]*>(.*)</body>.*~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 "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>
|
||||||
|
jQuery(function () {
|
||||||
|
jQuery('textarea[name*=\"_html\"]').wymeditor({ updateSelector: '#form [type=\"submit\"]', lang: '$lang'" . ($this->options ? ", $this->options" : "") . " });
|
||||||
|
});
|
||||||
|
</script>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue