Ejemplo n.º 1
0
 public function __construct(CApiGlobalManager $oApiGlobalManager)
 {
     $this->_aHooks = array();
     $this->_aServiceHooks = array();
     $this->_aQueryHooks = array();
     $this->_aJsFiles = array();
     $this->_aJsonHooks = array();
     $this->_aCssFiles = array();
     $this->_aImageFiles = array();
     $this->_aPlugins = array();
     $this->_aTemplates = array();
     $this->_aAddTemplates = array();
     $this->_mState = null;
     $this->_oApiGlobalManager = $oApiGlobalManager;
     $this->_oActions = null;
     $this->bIsEnabled = (bool) CApi::GetConf('plugins', false) && CApi::IsMainModule();
     if ($this->bIsEnabled) {
         $sPluginsPath = $this->GetPluginsPath();
         if (@is_dir($sPluginsPath)) {
             if (false !== ($rDirHandle = @opendir($sPluginsPath))) {
                 while (false !== ($sFile = @readdir($rDirHandle))) {
                     if (0 < strlen($sFile) && '.' !== $sFile[0] && preg_match('/^[a-z0-9\\-]+$/', $sFile) && (CApi::GetConf('plugins.config.include-all', false) || CApi::GetConf('plugins.' . $sFile, false)) && @file_exists($sPluginsPath . $sFile . '/index.php')) {
                         $oPlugin = (include $sPluginsPath . $sFile . '/index.php');
                         if ($oPlugin instanceof AApiPlugin) {
                             $oPlugin->SetName($sFile);
                             $oPlugin->SetPath($sPluginsPath . $sFile);
                             $oPlugin->init();
                             //								$oPlugin->Log('INIT > '.get_class($oPlugin));
                             $this->_aPlugins[$sFile] = $oPlugin;
                         }
                     }
                 }
                 @closedir($rDirHandle);
             }
         }
     }
 }