Assembla home | Assembla project page
 

Changeset 178

Show
Ignore:
Timestamp:
03/21/08 22:36:34 (8 months ago)
Author:
Slynderdale
Message:

Added the function getPluginList which returns a list of all the loaded plugins or a list of all the plugins in the Plugin directory. This is used and will be used by several modules.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Driver/Abstract.php

    r172 r178  
    144144 
    145145        /** 
     146        * Returns a list of all the plugins 
     147    * 
     148        * @return array 
     149        */ 
     150        public abstract function getPluginList(); 
     151 
     152        /** 
    146153        * Returns a plugin instance 
    147154        * 
  • trunk/Phergie/Driver/Streams.php

    r172 r178  
    112112        { 
    113113            return $this->plugins; 
     114        } 
     115 
     116        /** 
     117        * Returns a list of all the plugins either currently loaded or within the 
     118        * plugin directory. 
     119        * 
     120        * @param $plugin $dirList If true, scan the Plugin directory for the list 
     121        * @return array 
     122        */ 
     123        public function getPluginList($dirList = false, $preserveExt = false) 
     124        { 
     125                if (!$dirList) { 
     126                        return array_keys($this->plugins); 
     127                } else { 
     128                        $iterator = new DirectoryIterator(PHERGIE_DIR . '/Phergie/Plugin'); 
     129                        $plugins = array(); 
     130 
     131                        foreach ($iterator as $filename) { 
     132                                if ($iterator->isFile()) { 
     133                                        $plugins[] = ($preserveExt ? (string) $filename : basename((string) $filename, '.php')); 
     134                                } 
     135                        } 
     136                        unset($iterator, $filename, $dirList); 
     137 
     138                        return $plugins; 
     139                } 
    114140        } 
    115141