Page 1 of 1

Plugin Icons for Plugins in plugin.local

Posted: 18 Mar 2016, 13:56
by mate
Hi!

Maybe I missunderstood something, so im searching for clearness :)

I install all my extra plugins to "plugins.local" directory. Most "Sharing" plugins, for example "Google+" from https://tt-rss.org/gitlab/fox/tt-rss-at ... er/plugins have links to images hardcoded to plugin directory. E.g. from init.php / function hook_article_button($line) :

src=\"plugins/googleplus/googleplus.png\"

should be

src=\"plugins.local/googleplus/googleplus.png\"

but better a variable or function with the plugin directory. Is there such a funtion

Or is it just wrong that I use the plugins.local directory?

Im not such a PHP crack, but here is my suggestions to solve this issue:

Code: Select all

function hook_article_button($line) {
      return "<img src=\"".substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT']))."/googleplus.png\"
         class='tagsPic' style=\"cursor : pointer\"
         onclick=\"shareArticleToGooglePlus(".$line["id"].")\"
         title='".__('Share on Google+')."'>";
   }

Maybe ther is a better way to get the relative directory of the running script.

Thanks for discussion
Mate

Re: Plugin Icons for Plugins in plugin.local

Posted: 18 Mar 2016, 14:14
by fox
i dunno if relying on document root is a good idea (maybe it is) but overall doing something with __DIR__ here makes sense, maybe in a more elegant way of some kind

attic repo plugins have this hardcoded because they were written before plugins.local was added

e: maybe there should be a method of pluginhost which gives the plugin relative path to itself

Re: Plugin Icons for Plugins in plugin.local

Posted: 18 Mar 2016, 15:10
by HeikoAdams
In my case

Code: Select all

basename(dirname(dirname(__FILE__)))

did the job

Re: Plugin Icons for Plugins in plugin.local

Posted: 18 Mar 2016, 15:13
by fox
you can replace one dirname(__FILE__) with __DIR__

Re: Plugin Icons for Plugins in plugin.local

Posted: 22 Mar 2016, 12:52
by mate
I can confirm that

Code: Select all

basename(dirname(__DIR__))
is working. I tried to fork the project on ttrss gitlab, but have no rights to have projects at all, and also commits are forbidden, so maybe someone with rights can make the changes in ttrss-attic project.

Re: Plugin Icons for Plugins in plugin.local

Posted: 22 Mar 2016, 13:24
by fox
post your gitlab username, i'll give you necessary permissions

Re: Plugin Icons for Plugins in plugin.local

Posted: 24 Mar 2016, 13:09
by mate
fox wrote:post your gitlab username, i'll give you necessary permissions

Send you a pm

Re: Plugin Icons for Plugins in plugin.local

Posted: 24 Mar 2016, 13:55
by mate