XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
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 xoops_load('XoopsEditor');
25 
27 {
28  var $language;
29  var $width = "100%";
30  var $height = "500px";
31 
32  var $editor;
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 
54  require_once dirname(__FILE__) . "/tinymce.php";
55  $this->editor = new TinyMCE($this->configs);
56  }
57 
59  {
60  $this->__construct($configs);
61  }
62 
71  function renderValidationJS()
72  {
73  if ($this->isRequired() && $eltname = $this->getName()) {
74  //$eltname = $this->getName();
75  $eltcaption = $this->getCaption();
76  $eltmsg = empty($eltcaption) ? sprintf( _FORM_ENTER, $eltname ) : sprintf( _FORM_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(_LANGCODE));
100  if(strtolower(_CHARSET) == "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(XOOPS_ROOT_PATH . $this->rootPath . "/tinymce.php");
138  }
139 }
140 ?>