? Success

User tests: Successful: Unsuccessful:

avatar frankmayer
frankmayer
1 Oct 2016

This is a small PR which essentially is a proposal to change some string concatenations and array style concatenations to the HEREDOC format.

Why?

  • Personally I always hated it when Javascript or HTML with dynamic content is created using multiple lines of strings bound together with .= and then having a string at every end to include the whitespaces "\n\t\t..."
  • Another thing was the constant escaping of quotes or double-quotes... And also in order to embed the variable or whatever makes the thing dynamic, one has to close the string insert the variable and reopen the string again. Too much quoting-unquoting escaping, etc...

Those first two points make it quite difficult to read the code.

  • Also, in modern development environments one can inject a language into a string by either a phpdoc block (like I did in this PR) or just make the IDE remember that a specific string is a specific language. As soon as that happens, the IDE treats the string as code of that specific language and all the helping functionality of the IDE for that language is available for that string. With concatenated strings that often not possible or too much work to apply to each and every string, and one has still do deal with the first two points...

The changes in this PR are addressing all of the above. If you're OK with those, I've spotted some more, which can be changed as well.

avatar frankmayer frankmayer - open - 1 Oct 2016
avatar frankmayer frankmayer - change - 1 Oct 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Oct 2016
Category Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 1 Oct 2016
Labels Added: ?
avatar sovainfo
sovainfo - comment - 2 Oct 2016

In the installation of Joomla it is used like this:

JFactory::getDocument()->addScriptDeclaration(
<<<JS
    jQuery(document).ready(function($) {
        $(':input[name="jform[activateMultilanguage]"]').each(function(el){
            $(this).click(function(){Install.toggle('installLocalisedContent', 'activateMultilanguage', 1);});
            $(this).click(function(){Install.toggle('activatePluginLanguageCode', 'activateMultilanguage', 1);});
        });
        Install.toggle('installLocalisedContent', 'activateMultilanguage', 1);
        Install.toggle('activatePluginLanguageCode', 'activateMultilanguage', 1);
    });
JS
);

Gets rid of the variable as well, what do you think of that?

Leaves the HERE, currently in use: JS, CSS and ENDDATA. You introduce TAG.
Maybe standardize on HERE, considering the concept is known as HERE document. Thoughts?

avatar frankmayer
frankmayer - comment - 2 Oct 2016

@sovainfo Thanks for your constructive comments. Yes you are right on both counts. However, I didn't put much thought to those issues, as I didn't know if this would be accepted at all.

So, I just pushed a new commit dealing with these, since things look positive up to now.
I used JS for Javascript and introduced HTML for HTML. I also removed a senseless return... (I think this is included in one of the other PR's as well).

avatar sovainfo
sovainfo - comment - 2 Oct 2016

Like it that it tells you the language you are importing (JS, CSS & HTML), only hope it is not going to be used for a combination.

As you discovered, the last line requires a return.

avatar frankmayer
frankmayer - comment - 2 Oct 2016

IMHO if the combination is primarily HTML with a bit of javascript in it, then it should be HTML, if it's the other way around, then JS should be the tag.

Yes I discovered that ?

avatar frankmayer frankmayer - change - 18 Dec 2016
The description was changed
avatar frankmayer
frankmayer - comment - 18 Dec 2016

Conflicts resolved...

avatar priiish priiish - test_item - 23 Jul 2018 - Tested successfully
avatar priiish
priiish - comment - 23 Jul 2018

I have tested this item successfully on b04a96c

- inserted code into libraries/src/Form/Field/ModulepositionField.php (location has been moved)

  • everything seems to work fine
  • contributor is being asked to renew pull request due to patch application failure

@icampus


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12244.
avatar priiish
priiish - comment - 23 Jul 2018

@frankmayer please renew pull request due to patch application failure
bildschirmfoto 2018-07-23 um 15 40 00

avatar nurcihandem nurcihandem - test_item - 24 Jul 2018 - Tested unsuccessfully
avatar nurcihandem
nurcihandem - comment - 24 Jul 2018

I have tested this item ? unsuccessfully on b04a96c


Your changes make definitely sense, but neither the function getInput() of ModulePositionField.php was in use, nor the code snippet you changed in behavior.php still exists.

I put a die() command into the getInput() function and load the page at path
/joomla-cms/administrator/index.php?option=com_modules&view=module&layout=edit but it didn't change anything. After applying that die() command completely outside of the class description, the page stops loading. So this detects that the path should be correct.

@icampus

Found the snippets in following path: libraries/src/Form/Field/ModulePosition.php and libraries/cms/html/behavior.php on version 3.10-dev


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

avatar frankmayer
frankmayer - comment - 7 Aug 2018

@nurcihandem and @priiish This was essentially a proposal to do these things differently. I did this almost two years ago :). Lots has changed since then. Not really sure how to handle this, now. Any ideas?

avatar nurcihandem
nurcihandem - comment - 7 Aug 2018

Hm, I would recommend to close this PR. We actually can't declare this as successful because it's not possible to test the functions. But if these functions should ever get in use again, no problem, the functions would work fine anyway like they did before.

avatar frankmayer
frankmayer - comment - 7 Aug 2018

OK, closing this, as there seems to be no interest in pursuing a change of those things. If anyone feels this should be reopened, just give me a shout. ?

avatar frankmayer frankmayer - change - 7 Aug 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-08-07 15:17:06
Closed_By frankmayer
avatar frankmayer frankmayer - close - 7 Aug 2018

Add a Comment

Login with GitHub to post a comment