1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 04:32:01 +02:00

fixed codeclimate issues

This commit is contained in:
Achim Ennenbach 2018-07-30 22:17:03 +02:00
parent e692eecebe
commit e54be60012
2 changed files with 39 additions and 43 deletions

View File

@ -3627,56 +3627,52 @@ class e107
/**
* Set or Retrieve WYSIWYG active status. (replaces constant e_WYSIWYG)
*
* @param bool/string $val if null, return current value, otherwise define editor to use
* @param bool $returnEditor true = return name of active editor, false = return "false" for non wysiwyg editor, return "true" if wysiwyg editor should be used
* @return bool|mixed|void
* @return bool|mixed
*/
public static function wysiwyg($val=null, $returnEditor=false)
{
static $editor;
static $editor = 'bbcode';
static $availEditors;
$fallbackEditor = 'bbcode';
// Check the general wysiwyg setting
if (self::getPref('wysiwyg',false) != true)
{
// wysiwyg disabled by global pref
$editor = $fallbackEditor;
return $returnEditor ? $editor : false;
}
if (!isset($editor)) $editor = true;
if (!is_null($val))
else
{
$editor = empty($val) ? $fallbackEditor : ($val === 'default' ? true : $val);
}
// get list of installed wysiwyg editors
if (!isset($availEditors))
{
$availEditors = e107::getPlug()->getInstalledWysiwygEditors();
if (count($availEditors)>0) $availEditors = array_keys($availEditors);
}
// check if choosen editor is installed,
// if not, but a different editor is available use that one (e.g. tinymce4 choosen, but only simplemde available available, use simplemde)
// if no wysiwyg editor available, use fallback editor (bbcode)
if (is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
{
$editor = count($availEditors)>0 ? $availEditors[0] : $fallbackEditor;
if(!isset($availEditors))
{
// init list of installed wysiwyg editors
$availEditors = array_keys(e107::getPlug()->getInstalledWysiwygEditors());
}
if(!is_null($val))
{
// set editor if value given
$editor = empty($val) ? $fallbackEditor : ($val === 'default' ? true : $val);
}
// check if choosen editor is installed,
// if not, but a different editor is available use that one (e.g. tinymce4 choosen, but only simplemde available available, use simplemde)
// if no wysiwyg editor available, use fallback editor (bbcode)
if(is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
{
$editor = count($availEditors) > 0 ? $availEditors[0] : $fallbackEditor;
}
}
// $returnEditor => false:
// false => fallback editor (bbcode)
// true => default wysiwyg editor
// $returnEditor => true:
// return name of the editor
return $returnEditor ? $editor : ($editor === $fallbackEditor || $editor === false ? false : true);
/*
if(is_null($val))
{
return self::getRegistry('core/e107/wysiwyg');
}
else
{
self::setRegistry('core/e107/wysiwyg',$val);
return true;
}
*/
//return $returnEditor ? $editor : ($editor === $fallbackEditor || $editor === false ? false : true);
return $returnEditor ? $editor : ($editor !== $fallbackEditor);
}

View File

@ -131,23 +131,23 @@ class e_plugin
{
$result = array();
foreach($this->getInstalled() as $k=>$v)
foreach(array_keys($this->_installed) as $k)
{
$pl = new e_plugin();
$pl->load($k);
$keys = $pl->getKeywords();
if (is_array($keys))
// check the keywords
if (is_array($keys) && in_array('wysiwyg', $keys['word']))
{
if (in_array('wysiwyg', $keys['word']))
if (in_array('default', $keys['word']))
{
if (in_array('default', $keys['word']))
{
$result = array_merge(array($k => $pl->getName()), $result);
}
else
{
$result[$k] = $pl->getName();
}
// add "default" editor to the beginning of the array
$result = array_merge(array($k => $pl->getName()), $result);
}
else
{
// add all "wysiwyg" editors to the array
$result[$k] = $pl->getName();
}
}