Plugindir
| From: | Linus McCabe | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Plugindir | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3547@lists.php.net to get a copy of this message | ||
Hello,
recently on this list I recall some people requesting multiple plugins
directories. The main reason not to add this functionality is parsing time
and time to search through the directories iirc.
I'm making a site and it has (will have) a bunch of plugins (compiler) that
are very specific to the site and useless for anyone else. For this reason
I'd like to have the option of specifying a second pluginsdir (not to mix
smarty and own plugins) so I altered smarty.class and
smarty_compiler.class to let me have a second directory.
It didnt take many changes and afaik it barely changed performance (I did
not scan the second dir for filters, though)
For example, I changed:
$plugin_file = SMARTY_DIR .
$this->plugins_dir .
'/' .
$type .
'.' .
$name .
'.php';
$found = true;
if (!file_exists($plugin_file) || !is_readable($plugin_file)) {
$message = "could not load plugin file $plugin_file\n";
$found = false;
}
to
$plugin_file = SMARTY_DIR .
$this->plugins_dir .
'/' .
$type .
'.' .
$name .
'.php';
$found = true;
if (!file_exists($plugin_file) || !is_readable($plugin_file)) {
$plugin_file = $this->extra_plugins_dir .
'/' .
$type .
'.' .
$name .
'.php';
if(!file_exists($plugin_file) || !is_readable($plugin_file)) {
$message = "could not load plugin file $plugin_file\n";
$found = false;
}
}
the second dir is only search if there was no hit in the first. (and i used
absolute path for the extra plugins dir)
No major deal Id think?
I'd suggest:
Have two plugins dirs in smarty.
One that is distributed with smarty that contains all the standard plugins.
One that is user specified that contains 'private' plugins and filters.
The user-specified pluginsdir is searched first, so that the user can
override smarty standard plugins.
The user specified pluginsdir is the only one scanned for pre/post filters
(as I figure these kind of filters are always applied and therefore quite
site-specific?)
This way, on a server with multiple sites only one smarty installation is
needed, standard plugins needs only to be installed in one dir and site
specific plugins/filters can easily be used and distributed with 3rd party
applications (without the need of registering every plugin-function).
Hope this made some kind of sence :)
/linus