[geeklog-cvs] geeklog-1.3/system lib-plugins.php,1.27,1.28
vinny at iowaoutdoors.org
vinny at iowaoutdoors.org
Tue Apr 27 23:21:41 EDT 2004
Update of /var/cvs/geeklog-1.3/system
In directory www:/tmp/cvs-serv10948/d
Modified Files:
lib-plugins.php
Log Message:
Cached enabled plugins to improve performance.
Index: lib-plugins.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/system/lib-plugins.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** lib-plugins.php 14 Feb 2004 19:19:13 -0000 1.27
--- lib-plugins.php 28 Apr 2004 03:21:38 -0000 1.28
***************
*** 51,54 ****
--- 51,60 ----
$PLG_buffered = false;
+ // buffer enabled plugins
+ $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
+ $_PLUGINS = array();
+ while ($A = DB_fetchArray($result)) {
+ $_PLUGINS[] = $A['pi_name'];
+ }
/**
***************
*** 60,70 ****
function PLG_callFunctionForAllPlugins($function_name)
{
! global $_TABLES;
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = $function_name . $A['pi_name'];
if (function_exists($function)) {
$function();
--- 66,73 ----
function PLG_callFunctionForAllPlugins($function_name)
{
! global $_TABLES, $_PLUGINS;
! foreach ($_PLUGINS as $pi_name) {
! $function = $function_name . $pi_name;
if (function_exists($function)) {
$function();
***************
*** 111,116 ****
default:
return $function($args);
! break;
! }
} else {
return false;
--- 114,119 ----
default:
return $function($args);
! break;
! }
} else {
return false;
***************
*** 187,198 ****
function PLG_getMenuItems()
{
! global $_TABLES;
- $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
- $nrows = DB_numRows($result);
$menu = array();
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_getmenuitems_' . $A['pi_name'];
if (function_exists($function)) {
$menuitems = $function();
--- 190,198 ----
function PLG_getMenuItems()
{
! global $_TABLES, $_PLUGINS;
$menu = array();
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_getmenuitems_' . $pi_name;
if (function_exists($function)) {
$menuitems = $function();
***************
*** 270,287 ****
function PLG_getPluginStats($showsitestats)
{
! global $_TABLES;
$retval = '';
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_showstats_' . $A['pi_name'];
! if (function_exists($function)) {
! //great, stats function is there, call it
! $retval .= $function($showsitestats);
! } // no else because this is not a required API function
! }
return $retval;
--- 270,284 ----
function PLG_getPluginStats($showsitestats)
{
! global $_TABLES, $_PLUGINS;
$retval = '';
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_showstats_' . $pi_name;
! if (function_exists($function)) {
! //great, stats function is there, call it
! $retval .= $function($showsitestats);
! } // no else because this is not a required API function
! }
return $retval;
***************
*** 298,311 ****
function PLG_getSearchTypes()
{
! global $_TABLES;
$types = array();
$cur_types = array();
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_searchtypes_' . $A['pi_name'];
if (function_exists($function)) {
//great, stats function is there, call it
--- 295,305 ----
function PLG_getSearchTypes()
{
! global $_TABLES, $_PLUGINS;
$types = array();
$cur_types = array();
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_searchtypes_' . $pi_name;
if (function_exists($function)) {
//great, stats function is there, call it
***************
*** 355,378 ****
function PLG_doSearch($query, $datestart, $dateend, $topic, $type, $author)
{
! global $_TABLES, $_CONF;
$search_results = array();
require_once($_CONF['path_system'] . 'classes/plugin.class.php');
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! $nrows_plugins = 0;
! $total_plugins = 0;
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_dopluginsearch_' . $A['pi_name'];
! if (function_exists($function)) {
! $plugin_result = $function($query, $datestart, $dateend, $topic, $type, $author);
! $nrows_plugins = $nrows_plugins + $plugin_result->num_searchresults;
! $total_plugins = $total_plugins + $plugin_result->num_itemssearched;
$search_results[$i] = $plugin_result;
! } // no else because implementation of this API function not required
! }
! return array($nrows_plugins, $total_plugins, $search_results);
}
--- 349,369 ----
function PLG_doSearch($query, $datestart, $dateend, $topic, $type, $author)
{
! global $_TABLES, $_CONF, $_PLUGINS;
$search_results = array();
require_once($_CONF['path_system'] . 'classes/plugin.class.php');
! $nrows_plugins = 0;
! $total_plugins = 0;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_dopluginsearch_' . $pi_name;
! if (function_exists($function)) {
! $plugin_result = $function($query, $datestart, $dateend, $topic, $type, $author);
! $nrows_plugins = $nrows_plugins + $plugin_result->num_searchresults;
! $total_plugins = $total_plugins + $plugin_result->num_itemssearched;
$search_results[$i] = $plugin_result;
! } // no else because implementation of this API function not required
! }
! return array($nrows_plugins, $total_plugins, $search_results);
}
***************
*** 386,402 ****
function PLG_getSubmissionCount()
{
! global $_TABLES;
- $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
- $nrows = DB_numRows($result);
$num = 0;
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_submissioncount_' . $A['pi_name'];
if (function_exists($function)) {
$num = $num + $function();
}
}
! return $num;
}
--- 377,390 ----
function PLG_getSubmissionCount()
{
! global $_TABLES, $_PLUGINS;
$num = 0;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_submissioncount_' . $pi_name;
if (function_exists($function)) {
$num = $num + $function();
}
}
! return $num;
}
***************
*** 411,425 ****
function PLG_getUserOptions()
{
! global $_TABLES;
$plgresults = array ();
- $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
- $nrows = DB_numRows($result);
$plugin = new Plugin();
$counter = 0;
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_getuseroption_' . $A['pi_name'];
if (function_exists($function)) {
// I know this uses the adminlabel, adminurl but who cares?
--- 399,410 ----
function PLG_getUserOptions()
{
! global $_TABLES, $_PLUGINS;
$plgresults = array ();
$plugin = new Plugin();
$counter = 0;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_getuseroption_' . $pi_name;
if (function_exists($function)) {
// I know this uses the adminlabel, adminurl but who cares?
***************
*** 447,459 ****
function PLG_getAdminOptions()
{
! global $_TABLES;
- $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
- $nrows = DB_numRows($result);
$plugin = new Plugin();
$counter = 0;
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_getadminoption_' . $A['pi_name'];
if (function_exists($function)) {
list($plugin->adminlabel, $plugin->adminurl, $plugin->numsubmissions) = $function();
--- 432,441 ----
function PLG_getAdminOptions()
{
! global $_TABLES, $_PLUGINS;
$plugin = new Plugin();
$counter = 0;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_getadminoption_' . $pi_name;
if (function_exists($function)) {
list($plugin->adminlabel, $plugin->adminurl, $plugin->numsubmissions) = $function();
***************
*** 480,485 ****
function PLG_approveSubmission($type, $id)
{
! $args[1] = $id;
! return PLG_callFunctionForOnePlugin('plugin_moderationapprove_' . $type, $args);
}
--- 462,467 ----
function PLG_approveSubmission($type, $id)
{
! $args[1] = $id;
! return PLG_callFunctionForOnePlugin('plugin_moderationapprove_' . $type, $args);
}
***************
*** 524,546 ****
function PLG_getCCOptions()
{
! global $_TABLES, $_CONF;
- $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
- $nrows = DB_numRows($result);
require_once($_CONF['path_system'] . 'classes/plugin.class.php');
$cur_plugin = new Plugin();
$plugins = array();
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_cclabel_' . $A['pi_name'];
if (function_exists($function)) {
$cur_plugin->reset();
$cclabel = $function ();
if ($cclabel !== false) {
! list($cur_plugin->adminlabel, $cur_plugin->adminurl, $cur_plugin->plugin_image) = $cclabel;
if (!empty ($cur_plugin->adminlabel) &&
!empty ($cur_plugin->adminurl) &&
!empty ($cur_plugin->plugin_image)) {
! $plugins[$i] = $cur_plugin;
}
}
--- 506,525 ----
function PLG_getCCOptions()
{
! global $_TABLES, $_CONF, $_PLUGINS;
require_once($_CONF['path_system'] . 'classes/plugin.class.php');
$cur_plugin = new Plugin();
$plugins = array();
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_cclabel_' . $pi_name;
if (function_exists($function)) {
$cur_plugin->reset();
$cclabel = $function ();
if ($cclabel !== false) {
! list($cur_plugin->adminlabel, $cur_plugin->adminurl, $cur_plugin->plugin_image) = $cclabel;
if (!empty ($cur_plugin->adminlabel) &&
!empty ($cur_plugin->adminurl) &&
!empty ($cur_plugin->plugin_image)) {
! $plugins[$i] = $cur_plugin;
}
}
***************
*** 559,573 ****
function PLG_showModerationList()
{
! global $_TABLES, $_CONF;
$retval = '';
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <=$nrows; $i++) {
! $A = DB_fetchArray($result);
! $retval .= itemlist($A['pi_name']);
}
!
return $retval;
}
--- 538,549 ----
function PLG_showModerationList()
{
! global $_TABLES, $_CONF, $_PLUGINS;
$retval = '';
! foreach ($_PLUGINS as $pi_name) {
! $retval .= itemlist($pi_name);
}
!
return $retval;
}
***************
*** 612,616 ****
function PLG_showCenterblock($where = 1, $page = 1, $topic = '')
{
! global $_TABLES, $PLG_bufferCenterAPI, $PLG_buffered;
$retval = '';
--- 588,592 ----
function PLG_showCenterblock($where = 1, $page = 1, $topic = '')
{
! global $_TABLES, $PLG_bufferCenterAPI, $PLG_buffered, $_PLUGINS;
$retval = '';
***************
*** 618,629 ****
// buffer function names since we're coming back for them two more times
if (!$PLG_buffered) {
- $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
- $nrows = DB_numRows($result);
$PLG_bufferCenterAPI = array ();
! for ($i = 0; $i < $nrows; $i++) {
! $A = DB_fetchArray ($result);
! $function = 'plugin_centerblock_' . $A['pi_name'];
if (function_exists ($function)) {
! $PLG_bufferCenterAPI[$A['pi_name']] = $function;
}
}
--- 594,602 ----
// buffer function names since we're coming back for them two more times
if (!$PLG_buffered) {
$PLG_bufferCenterAPI = array ();
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_centerblock_' . $pi_name;
if (function_exists ($function)) {
! $PLG_bufferCenterAPI[$pi_name] = $function;
}
}
***************
*** 650,660 ****
function PLG_createUser ($uid)
{
! global $_TABLES;
! $result = DB_query ("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows ($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray ($result);
! $function = 'plugin_user_create_' . $A['pi_name'];
if (function_exists ($function)) {
$function ($uid);
--- 623,630 ----
function PLG_createUser ($uid)
{
! global $_TABLES, $_PLUGINS;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_user_create_' . $pi_name;
if (function_exists ($function)) {
$function ($uid);
***************
*** 671,681 ****
function PLG_deleteUser ($uid)
{
! global $_TABLES;
! $result = DB_query ("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows ($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray ($result);
! $function = 'plugin_user_delete_' . $A['pi_name'];
if (function_exists ($function)) {
$function ($uid);
--- 641,648 ----
function PLG_deleteUser ($uid)
{
! global $_TABLES, $_PLUGINS;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_user_delete_' . $pi_name;
if (function_exists ($function)) {
$function ($uid);
***************
*** 694,704 ****
function PLG_profileVariablesEdit ($uid, &$template)
{
! global $_TABLES;
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_profilevariablesedit_' . $A['pi_name'];
if (function_exists($function)) {
$function ($uid, $template);
--- 661,668 ----
function PLG_profileVariablesEdit ($uid, &$template)
{
! global $_TABLES, $_PLUGINS;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_profilevariablesedit_' . $pi_name;
if (function_exists($function)) {
$function ($uid, $template);
***************
*** 717,729 ****
function PLG_profileBlocksEdit ($uid)
{
! global $_TABLES;
$retval = '';
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_profileblocksedit_' . $A['pi_name'];
if (function_exists($function)) {
$retval .= $function ($uid);
--- 681,690 ----
function PLG_profileBlocksEdit ($uid)
{
! global $_TABLES, $_PLUGINS;
$retval = '';
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_profileblocksedit_' . $pi_name;
if (function_exists($function)) {
$retval .= $function ($uid);
***************
*** 744,754 ****
function PLG_profileVariablesDisplay ($uid, &$template)
{
! global $_TABLES;
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_profilevariablesdisplay_' . $A['pi_name'];
if (function_exists($function)) {
$function ($uid, $template);
--- 705,712 ----
function PLG_profileVariablesDisplay ($uid, &$template)
{
! global $_TABLES, $_PLUGINS;
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_profilevariablesdisplay_' . $pi_name;
if (function_exists($function)) {
$function ($uid, $template);
***************
*** 767,779 ****
function PLG_profileBlocksDisplay ($uid)
{
! global $_TABLES;
$retval = '';
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_profileblocksdisplay_' . $A['pi_name'];
if (function_exists($function)) {
$retval .= $function ($uid);
--- 725,734 ----
function PLG_profileBlocksDisplay ($uid)
{
! global $_TABLES, $_PLUGINS;
$retval = '';
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_profileblocksdisplay_' . $pi_name;
if (function_exists($function)) {
$retval .= $function ($uid);
***************
*** 811,823 ****
function PLG_getHeaderCode()
{
! global $_TABLES;
$headercode = '';
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $function = 'plugin_getheadercode_' . $A['pi_name'];
if (function_exists($function)) {
$headercode .= $function();
--- 766,775 ----
function PLG_getHeaderCode()
{
! global $_TABLES, $_PLUGINS;
$headercode = '';
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_getheadercode_' . $pi_name;
if (function_exists($function)) {
$headercode .= $function();
***************
*** 838,854 ****
function PLG_supportingFeeds ()
{
! global $_TABLES;
$plugins = array ();
! $result = DB_query ("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $nrows = DB_numRows ($result);
! for ($i = 0; $i < $nrows; $i++) {
! $A = DB_fetchArray ($result);
! $function = 'plugin_getfeednames_' . $A['pi_name'];
if (function_exists ($function)) {
$feeds = $function ();
if (is_array ($feeds) && (sizeof ($feeds) > 0)) {
! $plugins[] = $A['pi_name'];
}
}
--- 790,803 ----
function PLG_supportingFeeds ()
{
! global $_TABLES, $_PLUGINS;
$plugins = array ();
! foreach ($_PLUGINS as $pi_name) {
! $function = 'plugin_getfeednames_' . $pi_name;
if (function_exists ($function)) {
$feeds = $function ();
if (is_array ($feeds) && (sizeof ($feeds) > 0)) {
! $plugins[] = $pi_name;
}
}
***************
*** 949,953 ****
function PLG_getWhatsNew ()
{
! global $_TABLES;
$newheadlines = array ();
--- 898,902 ----
function PLG_getWhatsNew ()
{
! global $_TABLES, $_PLUGINS;
$newheadlines = array ();
***************
*** 955,963 ****
$newcontent = array ();
! $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
! $numPlg = DB_numRows ($result);
! for ($i = 0; $i < $numPlg; $i++) {
! $A = DB_fetchArray ($result);
! $fn_head = 'plugin_whatsnewsupported_' . $A['pi_name'];
if (function_exists ($fn_head)) {
$supported = $fn_head ();
--- 904,909 ----
$newcontent = array ();
! foreach ($_PLUGINS as $pi_name) {
! $fn_head = 'plugin_whatsnewsupported_' . $pi_name;
if (function_exists ($fn_head)) {
$supported = $fn_head ();
***************
*** 965,969 ****
list ($headline, $byline) = $supported;
! $fn_new = 'plugin_getwhatsnew_' . $A['pi_name'];
if (function_exists ($fn_new)) {
$whatsnew = $fn_new ();
--- 911,915 ----
list ($headline, $byline) = $supported;
! $fn_new = 'plugin_getwhatsnew_' . $pi_name;
if (function_exists ($fn_new)) {
$whatsnew = $fn_new ();
More information about the geeklog-cvs
mailing list