From 45e47a27482c3663f5451a61a7aa423aa7bbec3b Mon Sep 17 00:00:00 2001 From: Max Kremmel Date: Mon, 26 Feb 2007 22:35:01 +0000 Subject: add option to limit scanned plugins based on prefix --- LibertySystem.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'LibertySystem.php') diff --git a/LibertySystem.php b/LibertySystem.php index 64b9f63..334de51 100755 --- a/LibertySystem.php +++ b/LibertySystem.php @@ -3,7 +3,7 @@ * System class for handling the liberty package * * @package liberty -* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.61 2007/02/23 12:21:03 squareing Exp $ +* @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertySystem.php,v 1.62 2007/02/26 22:35:01 squareing Exp $ * @author spider */ @@ -135,9 +135,12 @@ class LibertySystem extends LibertyBase { * Load all plugins found in specified directory * Use loadActivePlugins to load only the active plugins * - * @return none - **/ - function scanAllPlugins( $pPluginsPath = NULL ) { + * @param string $pPluginsPath Set the path where to scan for plugins + * @param string $pPrefixPattern Perl regex for filenames can start with to prevent inclusion of unwanted filenames (e.g. (data\.|storage\.)). Final regex: /^{$pPrefixPattern}.*\.php$/ + * @access public + * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure + */ + function scanAllPlugins( $pPluginsPath = NULL, $pPrefixPattern = NULL ) { global $gBitSystem; if( empty( $pPluginsPath ) ) { $pPluginsPath = $this->mPluginPath; @@ -145,7 +148,8 @@ class LibertySystem extends LibertyBase { if( $pluginDir = opendir( $pPluginsPath ) ) { while( FALSE !== ( $plugin = readdir( $pluginDir ) ) ) { - if( preg_match( '/\.php$/', $plugin ) ) { + $pattern = "/^{$pPrefixPattern}.*\.php$/"; + if( preg_match( $pattern, $plugin ) ) { $this->mPluginFileName = basename( $plugin ); include_once( $pPluginsPath.$plugin ); } -- cgit v1.3