Init TinyMCE in head

This commit is contained in:
Jakub Vrana 2011-05-31 07:55:14 +02:00
parent 0f00277b82
commit 00342a1532

View file

@ -16,31 +16,7 @@ class AdminerTinymce {
$this->path = $path; $this->path = $path;
} }
function selectVal(&$val, $link, $field) { function head() {
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 $tiny_mce = false;
if (ereg("text", $field["type"]) && ereg("_html", $field["field"])) {
if (!$tiny_mce) {
$tiny_mce = true;
$lang = "en"; $lang = "en";
if (function_exists('get_lang')) { // since Adminer 3.2.0 if (function_exists('get_lang')) { // since Adminer 3.2.0
$lang = get_lang(); $lang = get_lang();
@ -66,7 +42,31 @@ tinyMCE.init({
}); });
</script> </script>
<?php <?php
return true;
} }
function selectVal(&$val, $link, $field) {
if (ereg("_html", $field["field"]) && $val != '&nbsp;') {
$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) {
if (ereg("text", $field["type"]) && ereg("_html", $field["field"])) {
return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>tinyMCE.execCommand('mceAddControl', true, 'fields-" . js_escape($field["field"]) . "');</script>"; return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>tinyMCE.execCommand('mceAddControl', true, 'fields-" . js_escape($field["field"]) . "');</script>";
} }
} }