Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified spaghetti code #8544

Merged
merged 2 commits into from
Sep 1, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,15 @@ public function onInit()
// List the skins
$skindirs = glob(JPATH_ROOT . '/media/editors/tinymce/skins' . '/*', GLOB_ONLYDIR);

// Set the selected skin
if ($app->isSite())
// Set the selected skin in the current side, front-end or back-end
$side = $app->getClientId() ? 'skin_admin' : 'skin';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use $app->isAdmin(), because it is better readable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree @rdeutz, in this case $app->isAdmin() would be more appropriate.

if ((int) $this->params->get($side, 0) < count($skindirs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS: Blank line before if statement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(int) $this->params->get($side, 0) is used twice. Can be refactored.

{
if ((int) $this->params->get('skin', 0) < count($skindirs))
{
$skin = 'skin : "' . basename($skindirs[(int) $this->params->get('skin', 0)]) . '",';
}
else
{
$skin = 'skin : "lightgray",';
}
$skin = 'skin : "' . basename($skindirs[(int) $this->params->get($side, 0)]) . '",';
}

// Set the selected administrator skin
elseif ($app->isAdmin())
else
{
if ((int) $this->params->get('skin_admin', 0) < count($skindirs))
{
$skin = 'skin : "' . basename($skindirs[(int) $this->params->get('skin_admin', 0)]) . '",';
}
else
{
$skin = 'skin : "lightgray",';
}
$skin = 'skin : "lightgray",';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving $skin = 'skin : "lightgray",'; before the if(){} you can also drop the else part


$entity_encoding = $this->params->get('entity_encoding', 'raw');
Expand Down