1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +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) * 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/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 * @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) public static function wysiwyg($val=null, $returnEditor=false)
{ {
static $editor; static $editor = 'bbcode';
static $availEditors; static $availEditors;
$fallbackEditor = 'bbcode'; $fallbackEditor = 'bbcode';
// Check the general wysiwyg setting
if (self::getPref('wysiwyg',false) != true) if (self::getPref('wysiwyg',false) != true)
{ {
// wysiwyg disabled by global pref
$editor = $fallbackEditor; $editor = $fallbackEditor;
return $returnEditor ? $editor : false;
} }
if (!isset($editor)) $editor = true; else
if (!is_null($val))
{ {
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); $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, // 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 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 no wysiwyg editor available, use fallback editor (bbcode)
if (is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors))) if(is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
{ {
$editor = count($availEditors)>0 ? $availEditors[0] : $fallbackEditor; $editor = count($availEditors) > 0 ? $availEditors[0] : $fallbackEditor;
}
} }
// $returnEditor => false: // $returnEditor => false:
// false => fallback editor (bbcode) // false => fallback editor (bbcode)
// true => default wysiwyg editor // true => default wysiwyg editor
// $returnEditor => true: // $returnEditor => true:
// return name of the editor // return name of the editor
return $returnEditor ? $editor : ($editor === $fallbackEditor || $editor === false ? false : true); //return $returnEditor ? $editor : ($editor === $fallbackEditor || $editor === false ? false : true);
/* return $returnEditor ? $editor : ($editor !== $fallbackEditor);
if(is_null($val))
{
return self::getRegistry('core/e107/wysiwyg');
}
else
{
self::setRegistry('core/e107/wysiwyg',$val);
return true;
}
*/
} }

View File

@@ -131,25 +131,25 @@ class e_plugin
{ {
$result = array(); $result = array();
foreach($this->getInstalled() as $k=>$v) foreach(array_keys($this->_installed) as $k)
{ {
$pl = new e_plugin(); $pl = new e_plugin();
$pl->load($k); $pl->load($k);
$keys = $pl->getKeywords(); $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']))
{ {
// add "default" editor to the beginning of the array
$result = array_merge(array($k => $pl->getName()), $result); $result = array_merge(array($k => $pl->getName()), $result);
} }
else else
{ {
// add all "wysiwyg" editors to the array
$result[$k] = $pl->getName(); $result[$k] = $pl->getName();
} }
} }
}
} }
return $result; return $result;