{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/12627","repository_url":"https://api.github.com/repos/joomla/joomla-cms","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12627/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12627/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12627/events","html_url":"https://github.com/joomla/joomla-cms/pull/12627","id":186102101,"number":12627,"title":"Fix placeholder showing \"Select a User\" when in readonly mode (e.g. modified_by)","user":{"login":"matrikular","id":1304616,"avatar_url":"https://avatars.githubusercontent.com/u/1304616?v=3","gravatar_id":"","url":"https://api.github.com/users/matrikular","html_url":"https://github.com/matrikular","followers_url":"https://api.github.com/users/matrikular/followers","following_url":"https://api.github.com/users/matrikular/following{/other_user}","gists_url":"https://api.github.com/users/matrikular/gists{/gist_id}","starred_url":"https://api.github.com/users/matrikular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrikular/subscriptions","organizations_url":"https://api.github.com/users/matrikular/orgs","repos_url":"https://api.github.com/users/matrikular/repos","events_url":"https://api.github.com/users/matrikular/events{/privacy}","received_events_url":"https://api.github.com/users/matrikular/received_events","type":"User","site_admin":false},"labels":[{"id":60721348,"url":"https://api.github.com/repos/joomla/joomla-cms/labels/PR-staging","name":"PR-staging","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-10-29T21:30:22Z","updated_at":"2016-10-30T12:02:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/12627","html_url":"https://github.com/joomla/joomla-cms/pull/12627","diff_url":"https://github.com/joomla/joomla-cms/pull/12627.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/12627.patch"},"body":"### Summary of Changes\r\nFix placeholder showing \"Select a User\" when in readonly mode (e.g. modified_by)\r\n\r\n**Additional changes:**\r\n**Layout (Mootools Version ~ hathor):**\r\n- Change htmlspecialchars($VARNAME, ENT_COMPAT, 'UTF-8') to $this->escape($VARNAME)\r\n- Refactor code to remove the ternary overuse\r\n- Change JHtml::script call to JHtml::_('script' ...) to allow overrides via custom register method\r\n- Correct variable name ($exclude) in doc block to match extracted name ($excluded)\r\n- Remove obsolete extracted variables that are not present for this field type\r\n\r\n**Layout (jQuery / Bootstrap Version ~ isis):**\r\n- Same as for the Mootools implementation + removed the class suffix from the hidden field\r\n- Remove (Fix) obsolete whitespace in class attribute for the visible field when no suffix was entered\r\n\r\n**JFormFieldUser:**\r\n- Satisfy Code Sniffer (e.g. @since)\r\n- Remove else block after variable initialisation\r\n- Fixe typo in doc block of the added custom fields handling method\r\n- Changed getExcluded method return value to match doc block\r\n\r\n### Testing Instructions\r\n* Open a new banner'' item in the back-end and switch to the \"Publishing\" tab.\r\nBefore the patch, the \"Modified By\" field shows a \"Select a User\" placeholder. Since you cannot really select a user here, that text is obsolete in that context.\r\n\r\n''You could also open a new article but in the hathor template, the modified_by field won't show up until the article has actually been modified which would then of course override the placeholder. Hence, a banner item.\r\n\r\n* Apply the patch, refresh the view or open another banner item. The placeholder should be gone.\r\n\r\nNow, this PR changes both the \"old\" Mootools and the jQuery / Bootstrap implementation of the layout(s), where Mootools version is currently the \"default\". I put default in quotes because we think of isis as the default admin template and that template has got an override for the field layout which uses jQuery / Bootstrap code to open the modal window.\r\n\r\nSo, to fully verifiy that everything works as expected, please make sure that you test the field both in hathor and isis. That is, not only confirm that the placeholder text disappears from the \"Modified By\" field, but also that the \"Created By\" still works as it should (because it is the same field).\r\n\r\n### Caveat\r\nI would go so far and move a few more lines, but before that, I would like your opinion first.\r\n- Even though JHtml::script makes sure that a script only gets included ones, I would move the call for the modal stuff inside the !readonly block. The \"Modified By\" field is almost always(?!) added with the unset filter and readonly attribute, so no modal code is really needed here and neither is the hidden input field.\r\n\r\nLong story short: Any objections?"},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/257147084","html_url":"https://github.com/joomla/joomla-cms/pull/12627#issuecomment-257147084","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/12627","id":257147084,"user":{"login":"matrikular","id":1304616,"avatar_url":"https://avatars.githubusercontent.com/u/1304616?v=3","gravatar_id":"","url":"https://api.github.com/users/matrikular","html_url":"https://github.com/matrikular","followers_url":"https://api.github.com/users/matrikular/followers","following_url":"https://api.github.com/users/matrikular/following{/other_user}","gists_url":"https://api.github.com/users/matrikular/gists{/gist_id}","starred_url":"https://api.github.com/users/matrikular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrikular/subscriptions","organizations_url":"https://api.github.com/users/matrikular/orgs","repos_url":"https://api.github.com/users/matrikular/repos","events_url":"https://api.github.com/users/matrikular/events{/privacy}","received_events_url":"https://api.github.com/users/matrikular/received_events","type":"User","site_admin":false},"created_at":"2016-10-30T12:02:27Z","updated_at":"2016-10-30T12:02:27Z","body":"Yes, it was to make sure that UTF8 is used for htmlspecialchars in PHP versions below 5.4.\r\n\r\nAs well as the JViewLegacy class, JLayoutBase has a method called escape which does exactly that:\r\nhttps://github.com/joomla/joomla-cms/blob/staging/libraries/cms/layout/base.php#L114\r\n\r\nIt was used in the user field layout here:\r\nhttps://github.com/joomla/joomla-cms/blob/staging/layouts/joomla/form/field/user.php#L82\r\n\r\nSo instead of having to change every occurrence of htmlspecialchars($VARNAME, ENT_COMPAT, 'UTF-8') you could use the escape method and only have to change one place (JLayoutBase) if the implementation should change for whatever reason.\r\n\r\n**Trivia:**\r\nThere are debates in the interwebs if whether or not one should create proxy methods for core PHP functions but, for the unforeseeable future, that method is available in JLayoutBase, JViewLegacy and some more to be used for exactly that purpose."}}
{"actor":{"display_login":"matrikular"}}