asikart / remoteimage

Asikart RemoteImage helps you manage Joomla CMS image and media files on local and remote FTP host.
http://ext.asikart.com/extensions/asikart-remoteimage.html
10 stars 11 forks source link

Javascript file 'remoteimage-admin.js' loaded on all pages frontend #34

Closed shkodskihk closed 9 years ago

shkodskihk commented 9 years ago

[Version: 2.0.1] Javascript file 'remoteimage-admin.js' loaded on all pages frontend, including those where it is not needed (where there is no editor). Which is not good. It would be better to make a choice:

What is your opinion about this?

asika32764 commented 9 years ago

I think it is a mistake. I'll try to find the reason and solve it.

Thank you for report.

asika32764 commented 9 years ago

OK, Remoteimage will remove this js file if you disable all com_media replacement options in 2.0.2.

It will be hard to disable this JS by user authorized because there are many use cases which will including the built-in media manager, for instance, editor, file input, any custom inputs of 3rd components. So this script must load every where to make sure com_media replacement can work.

shkodskihk commented 9 years ago

Thank you for your support.

See what happened.

[Extension Version 2.0.2; Joomla! 3.3.6] script file remoteimage-admin.js use and load both plugins: [A]. {SITEROOT}/plugins/editors-xtd/remoteimage/remoteimage.php [B]. {SITEROOT}/plugins/system/remoteimage/remoteimage.php

wherein

  1. The script remoteimage-admin.js missing in your frontend of the component: {SITEROOT}/components/com_remoteimage/asset/js/
  2. OK, if I put the script remoteimage-admin.js to folder {SITEROOT}/components/com_remoteimage/asset/js/, then after editing a frontend - the script is loaded twice. Of paths: (1) {SITEROOT}/components/com_remoteimage/asset/js/remoteimage-admin.js (2) {SITEROOT}/administrator/components/com_remoteimage/asset/js/remoteimage-admin.js

See screenshot: http://i.imgur.com/Ee0cAl1.png

  1. The script still loaded plugin [B] in the Frontend on all pages, even if the user is not authorized.

I added to plugin [B] your code that checks the user authorization in the Frontend: $ user = JFactory :: getUser (); if ($ app-> isSite () &&! $ user-> authorise ('frontend.access')) { return array (); } and it solved the problem: the script was the loaded only when the user is logged in.

What do you think about how to solve the problem of dual boot file remoteimage-admin.js?

  1. Load the script file with both plugins only one path: from the backend part.
  2. Inside the plugins to check that if is already loaded script remoteimage-admin.js: if it loaded one plugin, the other no longer loads.
asika32764 commented 9 years ago

OK, I know about the front-end issues, I'll find a solution to solve this problem.

It is not necessary to worry about loaded twice of the script, if I load them from same path, JDocument will merge them as one.

Please wait.

asika32764 commented 9 years ago

Added front.access check for system plugin in 2.0.3