Page 1 of 1

future adaptations to plugins

Posted: Wed Feb 16, 2011 7:53 pm
by Timbalu
Dear plugin authors

Since we will make use of Smarty3 in future hopefully, which is rewritten in OOP, PHP5 and getting better and better, there are some things to know.

Normally Serendipity plugins take the fetch method to display and parse templates via

Code: Select all

        $content = $serendipity['smarty']->fetch('file:'. $tfile, null, null, false);
which orientated itself on the old Smarty2 API. And we got used to it.

But with Smarty3 they have changed the parameter order in the fetch method and added a new 4th parameter, to now have 5 of them. Using our code now would need a serendipity wrapper to keep this thing as it used to be. This isn't really a performance runner.

I started to rewrite my plugins to perform in both worlds without using a possible wrapper.
Now it looks like

Code: Select all

        $content = $serendipity['smarty']->fetch('file:'. $tfile, null, null);
and we could even go to

Code: Select all

        $content = $serendipity['smarty']->fetch('file:'. $tfile);
without problems, because nobody is really using the 2cd, 3td, 4th or 5th parameter, I assume.

I haven't discussed this with Garvin, but I think this is a way to go for us all and to avoid wrappers and old behaviour as much as possible for maximum efficiency. With this we don't loose compatibility between Smarty 2 and 3 users, at least in the plugins.

If this is ok for you Garvin, we could make this thread sticky and add some more of these in future.

Re: future adaptations to plugins

Posted: Thu Feb 17, 2011 2:57 pm
by garvinhicking
Hi!

You're completely right. I just patched all spartacus plugins for this.

Regards,
Garvin

Re: future adaptations to plugins

Posted: Thu Feb 17, 2011 5:36 pm
by Timbalu
Gun boy! No discussion? No sleep over? No hearing? :roll:

For me its ok. Simplicity in Serendipity at his best! ;-)

Re: future adaptations to plugins

Posted: Fri Feb 18, 2011 3:18 pm
by garvinhicking
Hi!

I don't see anything that could have a negative impact on that, so I didn't think any discussion would be necessary.

If someone thinks otherwise, let's start it. :)

Regards,
Garvin

Re: future adaptations to plugins

Posted: Thu Mar 24, 2011 5:16 pm
by Timbalu
Dear Plugin Authors

I have another idea to optimize plugin usage to get better bundled with upcoming Smarty 3.
Some of us use log files or other temorary stuff in our Smarty template compile dir named 'templates_c'.
This can look like the one from Maltes dbclean plugin:

Code: Select all

277 	$this->debug_fp = @fopen ( $serendipity ['serendipityPath'] . 'templates_c/dbclean.log', 'a' );
As of thinking to pluginize some sort of Serendipity free cache function (maybe with future dashboard, which is actually what I am trying to do) with Smartys own function like clearCompiledTemplate() and clearCache(), I realized Smarty 2 will delete all files, but Smarty 3 has the improvement not to delete files starting with '.' from cache and template_c folders on clearCompiledTemplate() and clearCache().

So: everybody using 'templates_c' as an temporary archive for plugin files could rewrite them to be a .filename.ext, to be independend from clearing cache automatically or by accident.

When I reworked the Downloadmanger Plugin I decided to store temporary files into /archives/, by the way, which is more likely a better place to store files created by serendipity plugins. But if this is the prefered option for all other plugins, I can't say, until Garvin will uprise his thumb.

Re: future adaptations to plugins

Posted: Thu Mar 24, 2011 9:34 pm
by garvinhicking
Hi!

Hm, I think this could be problematic, as "." files are by default hidden in FTP clients and this will lead to confusion... I would leave it as normal files. IMHO cachefiles should always be stored in templates_c, if the plugin regenerates those files when they are missing.

Any file that is required to exist or that is externally linked to (like generated .pdf files or feeds or whatever) should be stored in archives/ though.

Regards,
Garvin

Re: future adaptations to plugins

Posted: Fri Mar 25, 2011 9:25 am
by Timbalu
Hi Garvin

I don't think this ftp feature is problematic or confusing.
Why should you want to download files like this via ftp?
There is a better way doing this via plugin, having a log file download option, which is recommended to have (well maybe not if your spamblock logfile is > 10MB ;-) ) everywhere.

About caching: Smarty normally makes differences having a compile dir (templates_c) and a cache dir (cache).

Re: future adaptations to plugins

Posted: Fri Mar 25, 2011 6:51 pm
by garvinhicking
Hi!

For backups, or when things are misbheaving and we tell people to check out those files. :-)

Let's put it the other way around, what's the real benefit of "." files? Everything in templates_c should be removeable at best...if you know of plugins that don't behave like that, please tell so I'll try to put such files in archives/ instead.

Regards,
Garvin