Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Respect custom paths for icons in core.js AjaxRequest::toggleVisibility() #8236

Closed
ghost opened this issue Feb 25, 2016 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Feb 25, 2016

Issue by @DanielSchwiperich
December 9th, 2015, 16:50 GMT

If a bundle defines a custom page type for example and uses the core-bundle Hook getPageStatusIcon a public accessible path is returned like bundles/mybundle/custom_page_type-icon.gif

The icon then is shown correct in the page tree. But if the "Hide/Unhide" (eye) Icon is clicked the image disappears because of a smal bug in AjaxRequest::toggleVisibility().
See here:
https://github.com/contao-components/contao/blob/master/js/core.js#L518
and here:
https://github.com/contao-components/contao/blob/master/js/core.js#L545
and maybe here also:
https://github.com/contao-components/contao/blob/master/js/core.js#L573

img.src = AjaxRequest.themePath + (!published ? icon : icond);
The problem here is that AjaxRequest.themePath is prepended which works fine for core icon where only the icon name is set and the path finding is handled by Contao\Image::getHtml but not for custom icons where the data attributes contain the full web url relative path.

Core Icon with name only:

<img src="system/themes/flexible/images/regular.gif" data-icon="regular.gif" data-icon-disabled="regular_1.gif" height="18" width="18">

Custom icons with complete path (relative to web folder)

<img src="/bundles/mybundle/custom_page_type-icon.png" data-icon="/bundles/mybundle/custom_page_type-icon.png" data-icon-disabled="/bundles/mybundle/custom_page_type-icon_1.png" height="14" width="18">

(Doesn't matter it with or without / at path start)

This is then converted to system/themes/flexible/images/bundles/mybundle/custom_page_type-icon_1.png

An easy fix could be to only prepend AjaxRequest.themePath if the icon / icond do not contain slashes / a path

@ghost ghost added the defect label Feb 25, 2016
@ghost
Copy link
Author

ghost commented Feb 25, 2016

Comment by @leofeyer
February 19th, 2016, 18:08 GMT

This issue occurs in Contao 3 as well, doesn't it?

@ghost
Copy link
Author

ghost commented Feb 25, 2016

Comment by @DanielSchwiperich
February 25th, 2016, 08:50 GMT

I did not validate it, since the my test case / module is only contao 4, and I didn't find a contao 3 module where we use the hook, but looking at https://github.com/contao/core/blob/master/assets/contao/js/core-uncompressed.js the bug must also exists in contao 3.

If you like / need I could setup a test module on the weekend for contao 3 to test it.

@leofeyer
Copy link
Member

Fixed in d00c6aa.

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Mar 5, 2016
### 4.1.1 (2015-03-03)

 * Remove the "disable IP check" field from the back end settings (see #436).
 * Do not quote the search string in `FIND_IN_SET()` (see #424).
 * Always fix the domain and language when generating URLs (see contao/core#8238).
 * Fix two issues with the flexible back end theme (see contao/core#8227).
 * Correctly toggle custom page type icons (see contao/core#8236).
 * Correctly render the links in the monthly/yearly event list menu (see contao/core#8140).
 * Skip the registration related fields if a user is duplicated (see contao/core#8185).
 * Correctly show the form field type help text (see contao/core#8200).
 * Correctly create the initial version of a record (see contao/core#8141).
 * Correctly show the "expand preview" buttons (see contao/core#8146).
 * Correctly check that a password does not match the username (see contao/core#8209).
 * Check if a directory exists before executing `mkdir()` (see contao/core#8150).
 * Do not link to the maintenance module if the user cannot access it (see contao/core#8151).
 * Show the "new folder" button in the template manager (see contao/core#8138).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant