1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
23:
24: XoopsLoad::load('XoopsEditor');
25:
26: class XoopsFormTinymce extends XoopsEditor
27: {
28: var $language;
29: var $width = "100%";
30: var $height = "500px";
31: var $editor;
32:
33: 34: 35: 36: 37:
38: function __construct($configs)
39: {
40: $current_path = __FILE__;
41: if (DIRECTORY_SEPARATOR !== "/") {
42: $current_path = str_replace(strpos($current_path, "\\\\", 2) ? "\\\\" : DIRECTORY_SEPARATOR, "/", $current_path);
43: }
44:
45: $this->rootPath = "/class/xoopseditor/tinymce";
46: parent::__construct($configs);
47: $this->configs["elements"] = $this->getName();
48: $this->configs["language"] = $this->getLanguage();
49: $this->configs["rootpath"] = $this->rootPath;
50: $this->configs["area_width"] = isset($this->configs["width"]) ? $this->configs["width"] : $this->width;
51: $this->configs["area_height"] = isset($this->configs["height"]) ? $this->configs["height"] : $this->height;
52: $this->configs["fonts"] = $this->getFonts();
53: $this->setClass($this->getName());
54:
55: require_once __DIR__ . "/tinymce.php";
56: $this->editor = new TinyMCE($this->configs);
57: }
58:
59: function XoopsFormTinymce($configs)
60: {
61: $this->__construct($configs);
62: }
63:
64: 65: 66: 67: 68: 69: 70:
71: function renderValidationJS()
72: {
73: if ($this->isRequired() && $eltname = $this->getName()) {
74:
75: $eltcaption = $this->getCaption();
76: $eltmsg = empty($eltcaption) ? sprintf(XoopsLocale::F_ENTER, $eltname) : sprintf(XoopsLocale::F_ENTER, $eltcaption);
77: $eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
78: $ret = "\n";
79: $ret .= "if ( tinyMCE.get('{$eltname}').getContent() == \"\" || tinyMCE.get('{$eltname}').getContent() == null) ";
80: $ret .= "{ window.alert(\"{$eltmsg}\"); tinyMCE.get('{$eltname}').focus(); return false; }";
81: return $ret;
82: }
83: return '';
84: }
85:
86: 87: 88: 89: 90:
91: function getLanguage()
92: {
93: if ($this->language) {
94: return $this->language;
95: }
96: if (defined("_XOOPS_EDITOR_TINYMCE_LANGUAGE")) {
97: $this->language = strtolower(constant("_XOOPS_EDITOR_TINYMCE_LANGUAGE"));
98: } else {
99: $this->language = str_replace('_', '-', strtolower(XoopsLocale::getLangCode()));
100: if (strtolower(XoopsLocale::getCharset()) === "utf-8") {
101: $this->language .= "_utf8";
102: }
103: }
104:
105: return $this->language;
106: }
107:
108: function getFonts()
109: {
110: if (empty($this->config["fonts"]) && defined("_XOOPS_EDITOR_TINYMCE_FONTS")) {
111: $this->config["fonts"] = constant("_XOOPS_EDITOR_TINYMCE_FONTS");
112: }
113:
114: return @$this->config["fonts"];
115: }
116:
117: 118: 119: 120: 121:
122: function render()
123: {
124: $ret = $this->editor->render();
125: $ret .= parent::render();
126:
127: return $ret;
128: }
129:
130: 131: 132: 133: 134:
135: function isActive()
136: {
137: return is_readable(\XoopsBaseConfig::get('root-path') . $this->rootPath . "/tinymce.php");
138: }
139: }
140: