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

Simplified spaghetti code #8544

merged 2 commits into from
Sep 1, 2016

Conversation

demis-palma
Copy link
Contributor

Removed duplicated code

Removed duplicated code
// 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.

Changed getClientId() with isAdmin() as per request
@demis-palma
Copy link
Contributor Author

Hi @rdeutz I have changed getClientId() with isAdmin() as per request.

if ($app->isSite())
// Set the selected skin in the current side, front-end or back-end
$side = $app->isAdmin() ? 'skin_admin' : 'skin';
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.

@izharaazmi
Copy link
Contributor

@test success

@izharaazmi
Copy link
Contributor

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

The if can be more readable if changed to

if (isset($skindirs[$index]))

or whole thing as a ternary, maybe!

$side  = $app->isAdmin() ? 'skin_admin' : 'skin';
$index = (int) $this->params->get($side, 0);
$skin  = isset($skindirs[$index]) ? basename($skindirs[$index]) : 'lightgray';
$skin  = 'skin : "' . $skin . '",';

Yours is good too. I'm just suggesting. 👍

@conconnl
Copy link
Member

What is the status?
Can we test this, if so can we have a Test scenario?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8544.

@izharaazmi
Copy link
Contributor

izharaazmi commented Jun 28, 2016

IMO, This is most of a code review.

However the current code (without this patch) would break in the case where $app is neither site nor administrator. Try loading TinyMCE editor in the installation application with error display and error reporting on.

Or you can create a third application similar to administrator with client_id = 3 also. But that is too much of work for this small test.

@krim404
Copy link

krim404 commented Aug 2, 2016

I have tested this item ✅ successfully on 3ed4624

Opened TinyMCE normally, worked w/o a problem. Added a tinymce instance in installation app manually, worked as well. Code review seems fine, too. @icampus


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8544.

@alimpam
Copy link

alimpam commented Aug 2, 2016

I have tested this item ✅ successfully on 3ed4624

tested @icampus:
simplification does what it should


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8544.

@roland-d roland-d added this to the Joomla 3.6.2 milestone Aug 2, 2016
@roland-d
Copy link
Contributor

roland-d commented Aug 2, 2016

@demis-palma Could you make the suggested changes please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants