phpOpenTracker/phpOpenTracker API.php,1.40,1.41

Sebastian Bergmann <[email protected]>
Newsgroups gmane.comp.web.phpopentracker.cvs
Message-ID <[email protected]>
Update of /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker
In directory sc8-pr-cvs1:/tmp/cvs-serv20027/phpOpenTracker

Modified Files:
	API.php 
Log Message:
Implement phpOpenTracker_API::loadPlugins(). Move API/plugins/* to API/Plugin/.

Index: API.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/API.php,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** API.php	22 Nov 2003 08:47:43 -0000	1.40
--- API.php	23 Nov 2003 18:15:20 -0000	1.41
***************
*** 20,27 ****
      private $configuration;
      private $container;
!     private $instance = null;
!     private $plugins = array();
  
      private function __construct() {
      }
  
--- 20,28 ----
      private $configuration;
      private $container;
!     private static $instance = null;
!     private static $plugins = array();
  
      private function __construct() {
+         self::loadPlugins();
      }
  
***************
*** 35,47 ****
  
      public static function get($parameters) {
      }
  
      public static function plot($parameters) {
      }
  
      public static function pluginLoaded($pluginName) {
      }
  
!     private function loadPlugins() {
      }
  
--- 36,92 ----
  
      public static function get($parameters) {
+         $api = self::getInstance();
      }
  
      public static function plot($parameters) {
+         $api = self::getInstance();
      }
  
      public static function pluginLoaded($pluginName) {
+         return in_array(
+           $pluginName,
+           self::$plugins
+         );
      }
  
!     private static function loadPlugins() {
!         if ($dir = @opendir(POT_API_PLUGIN_PATH)) {
!             while (($file = @readdir($dir)) !== false) {
!                 if (strstr($file, '.php') &&
!                     substr($file, -1, 1) != "~" &&
!                     substr($file,  0, 1) != "#") {
!                     if (@include(POT_API_PLUGIN_PATH . $file)) {
!                         $this->plugins[] = substr($file, 0, -4);
! 
!                         $class  = 'phpOpenTracker_API_Plugin' . substr($file, 0, -4);
!                         $plugin = new $class;
! 
!                         foreach ($plugin->apiCalls as $apiCall) {
!                             if (!isset($this->apiCalls[$apiCall])) {
!                                 $this->apiCalls[$plugin->apiType][$apiCall] = $plugin;
!                             } else {
!                                 throw new phpOpenTracker_API_Exception(
!                                   sprintf(
!                                     'API Call "%s" already registered.',
! 
!                                     $apiCall
!                                   )
!                                 );
!                             }
!                         }
!                     } else {
!                         throw new phpOpenTracker_API_Exception(
!                             sprintf(
!                               'Cannot load plugin "%s".',
! 
!                               substr($file, 0, -4)
!                             )
!                         );
!                     }
!                 }
!             }
! 
!             @closedir($dir);
!         }
      }
  




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.