|
|||||||
![]() |
Forum Index > glFusion Development > glFusion Development |
|
|
Plugin Registration System
|
|||
| | | Printable Version |
|
mst3kroqs | ||||||||
|
It occurred to me while working on my plugin today that GL really needs a better plugin registration system for things which would lead to conflicts later on. Mark A. Howard |
![]() Admin Group Comfort Level:: +15 ![]()
Registered: 07/18/07 |
||||||||
|
|||||||||
|
jmucchiello | ||||||||
|
I've wanted a better plugin registration system for a long time. But I don't think there's really an issue with naming conflicts. Most plugins use the plugin name as a prefix for tables: mg_album instead of just album. A conflict there would be pretty weird since the prefix and the table name would both have to conflict. As for "two letter prefixes", I don't use them. I use the whole plugin name or a long name: $_TAGS_CONF, $_LABS_CONF. Using just 2 letters is a bit dangerous. And how would you make that prefix configurable? Double $ vars? $$TAGS_CONF[]? You could make a function to take the config vars out the global name space: PHP Formatted Code function tags_option($index, $unset = null) { static $_MYCONF = Array(); if (count($_MYCONF) == 0) { $res = DB_query("SELECT * FROM {$_TABLES['plugins']} WHERE pi_name = 'tags' and pi_author = 'Joe Mucchiello'"); $A = DB_fetchArray($res); if (version_compare(VERSION, '1.5', '<=')) { // creates a $_MYCONF variable which due to scope becomes the static above instead of a global. include $_CONF['path'] . 'plugins/' . $A['pi_filesystem_name'] . '/config.php'; } else { $c = config::get_instance(); $_MYCONF = $c->get_config('tags'); } } if (array_key_exists($index, $_MYCONF)) { return $_MYCONF[$index]; } return $unset; }
|
![]() Active Member Group Comfort Level:: +2 ![]()
Registered: 05/15/07 |
||||||||
|
|||||||||
|
mst3kroqs | ||||||||
Quote by: jmucchielloI've wanted a better plugin registration system for a long time. But I don't think there's really an issue with naming conflicts.
Mark A. Howard |
![]() Admin Group Comfort Level:: +15 ![]()
Registered: 07/18/07 |
||||||||
|
|||||||||
|
jmucchiello | ||||||||
|
If I told, it wouldn't be a mystery. |
![]() Active Member Group Comfort Level:: +2 ![]()
Registered: 05/15/07 |
||||||||
|
|||||||||
|
mst3kroqs | ||||||||
Quote by: jmucchielloIf I told, it wouldn't be a mystery.
Mark A. Howard |
![]() Admin Group Comfort Level:: +15 ![]()
Registered: 07/18/07 |
||||||||
|
|||||||||
|
jmucchiello | ||||||||
|
Most of the stuff I want requires best practices. When your code version does not match the database version, plugins should disable themselves (assuming the upgrade contain significant changes). It's stuff like this that drive me buggy. PHP Formatted Code <?php // functions.inc $db_ver = DB_getItem($_TABLES['plugins'], 'pi_ver', "pi_name = 'myplugin'"); if ($db_ver == 'current_version_number') { include $_CONF['path'] . 'plugins/myplugin/real_functions.php'; } else { // handle case where filesystem contains updated plugin but the upgrade has not happened yet. $_MYPLG_CONF['disabled'] = true; // must have the upgrade function defined. function plugin_upgrade_myplugin() {} // if there's a phpblock for the plugin, should make sure it is defined. function phpblock_somethingmyplugindoes() { return ''; } // etc. } ?> <?php // public_html/myplugin/index.php include $_CONF['path'] . 'plugins/myplugin/functions.inc'; if ($_MYPLG_CONF['disabled'])) { if (SEC_inGroup('Root')) { // go get someone to upgrade me!!!! COM_refresh($_CONF['site_admin_url'] . '/plugins.php?mode=edit&pi_name=myplugin'); } else { COM_refresh($_CONF['site_url']); } } |
![]() Active Member Group Comfort Level:: +2 ![]()
Registered: 05/15/07 |
||||||||
|
|||||||||
|
| All times are CDT. The time is now 09:05 pm. |
|
|