19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
34 function __construct()
36 $args = func_get_args();
38 if (!is_array($args[0])) {
40 foreach (array(
'caption' ,
'name' ,
'value' ,
'rows' ,
'cols' ,
'hiddentext') as $key) {
41 if (isset($args[
$i])) {
42 $configs[$key] = $args[
$i];
46 $configs = (isset($args[
$i]) && is_array($args[$i])) ? array_merge($configs, $args[$i]) :
$configs;
51 $vars = get_class_vars(__CLASS__);
52 foreach ($configs as $key => $val) {
53 if (method_exists($this,
"set" . ucfirst($key))) {
54 $this->{
"set" . ucfirst($key)}($val);
55 }
else if (array_key_exists(
"_{$key}",
$vars)) {
56 $this->{
"_{$key}"} = $val;
57 }
else if (array_key_exists($key,
$vars)) {
60 $this->configs[$key] = $val;
68 $this->__construct($configs);
73 $this->isEnabled =
true;
74 return $this->isEnabled;
99 $this->root_path = XOOPS_ROOT_PATH .
'/class/xoopseditor';
117 if (!isset($instance)) {
119 $instance =
new $class();
131 function get($name =
'',
$options = null, $noHtml =
false, $OnFailure =
'')
136 $list = array_keys($this->
getList($noHtml));
137 if (empty($OnFailure) || !in_array($OnFailure, $list)) {
138 $OnFailure = $list[0];
157 if (!isset($this->root_path)) {
158 $this->root_path = XOOPS_ROOT_PATH .
'/class/xoopseditor';
159 $GLOBALS[
'xoopsLogger']->addDeprecated(__CLASS__ .
'::' . __FUNCTION__ .
'() should not be called statically.');
168 $_list = XoopsLists::getDirListAsArray($this->root_path .
'/');
169 foreach ($_list as $item) {
170 if (file_exists(
$file = $this->root_path .
'/' . $item .
'/language/' .
$GLOBALS[
'xoopsConfig'][
'language'] .
'.php')) {
172 }
else if (file_exists(
$file = $this->root_path .
'/' . $item .
'/language/english.php')) {
175 if (file_exists(
$file = $this->root_path .
'/' . $item .
'/editor_registry.php')) {
180 $list[$item] = array(
'title' =>
$config[
'title'] ,
'nohtml' =>
$config[
'nohtml']);
183 array_multisort($order, $list);
188 if (!empty($this->allowed_editors)) {
193 if (!empty($noHtml) && empty($list[$name][
'nohtml']))
195 $_list[$name] = $list[$name][
'title'];
208 trigger_error(__CLASS__ .
'::' . __FUNCTION__ .
'() deprecated', E_USER_WARNING);
221 if (method_exists(
$editor,
'setConfig')) {
224 foreach (
$options as $key => $val) {
240 if (empty($name) || !array_key_exists($name, $this->
getList())) {
243 $editor_path = $this->root_path .
'/' . $name;
244 if (file_exists(
$file = $editor_path .
'/language/' .
$GLOBALS[
'xoopsConfig'][
'language'] .
'.php')) {
246 }
else if (file_exists(
$file = $editor_path .
'/language/english.php')) {
249 if (file_exists(
$file = $editor_path .
'/editor_registry.php')) {