[geeklog-cvs] geeklog-1.3/system lib-plugins.php,1.18,1.19

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Thu May 22 17:05:48 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/system
In directory internal.geeklog.net:/tmp/cvs-serv23808

Modified Files:
	lib-plugins.php 
Log Message:
New (extended & buffered) implementation of PLG_showCenterblock().


Index: lib-plugins.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/system/lib-plugins.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** lib-plugins.php	11 May 2003 18:28:55 -0000	1.18
--- lib-plugins.php	22 May 2003 21:05:46 -0000	1.19
***************
*** 41,44 ****
--- 41,49 ----
  require_once($_CONF['path_system'] . 'classes/plugin.class.php');
  
+ // buffer for function names for the center block API
+ $PLG_bufferCenterAPI = array ();
+ $PLG_buffered = false;
+ 
+ 
  /**
  * Calls a function for all enabled plugins
***************
*** 590,611 ****
  * The plugin is responsible to format the output correctly.
  *
  * @return  Formatted center block content
  *
  */
! function PLG_showCenterblock() 
  {
!     global $_TABLES;
  
!     $result = DB_query("SELECT * 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_centerblock_' . $A['pi_name'];
!         if (function_exists($function)) {
! 		   $retval .= $function();
          }
      }
      return $retval;
  }
--- 595,633 ----
  * The plugin is responsible to format the output correctly.
  *
+ * @param   where   int      1 = top, 2 = after feat. story, 3 = bottom of page
+ * @param   page    int      page number (1, ...)
+ * @param   topic   string   topic ID or empty string == front page
  * @return  Formatted center block content
  *
  */
! function PLG_showCenterblock($where = 1, $page = 1, $topic = '') 
  {
!     global $_TABLES, $PLG_bufferCenterAPI, $PLG_buffered;
  
!     $retval = '';
! 
!     // 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;
!             }
          }
+         $PLG_buffered = true;
      }
+ 
+     foreach ($PLG_bufferCenterAPI as $function) {
+         $retval .= $function ($where, $page, $topic);
+ 
+         if (($where == 0) && !empty ($retval)) {
+             break;
+         }
+     }
+ 
      return $retval;
  }





More information about the geeklog-cvs mailing list