XOOPS  2.6.0
formtinymce.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
24 XoopsLoad::load('XoopsEditor');
25 
27 {
28  var $language;
29  var $width = "100%";
30  var $height = "500px";
31  var $editor;
32 
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 
60  {
61  $this->__construct($configs);
62  }
63 
71  function renderValidationJS()
72  {
73  if ($this->isRequired() && $eltname = $this->getName()) {
74  //$eltname = $this->getName();
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 
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 
122  function render()
123  {
124  $ret = $this->editor->render();
125  $ret .= parent::render();
126 
127  return $ret;
128  }
129 
135  function isActive()
136  {
137  return is_readable(\XoopsBaseConfig::get('root-path') . $this->rootPath . "/tinymce.php");
138  }
139 }
140 ?>
$current_path
Definition: config.php:3
const F_ENTER
Definition: en_US.php:408
defined('DS') or define('DS' DIRECTORY_SEPARATOR
Definition: common.php:41
XoopsFormTinymce($configs)
Definition: formtinymce.php:59
static get($name)
static load($name, $type="core")
Definition: xoopsload.php:65
setClass($class)
Definition: Element.php:283
static getLangCode()
Definition: Abstract.php:68
__construct($configs)
Definition: formtinymce.php:38