static function fetchPackages($parameters = array(), $filterArray = array()) { $packageRepositories = eZPackage::packageRepositories($parameters); $packages = array(); $requiredType = null; $requiredPriority = null; $requiredVendor = null; $requiredExtension = null; if (isset($filterArray['type'])) { $requiredType = $filterArray['type']; } if (isset($filterArray['priority'])) { $requiredPriority = $filterArray['priority']; } if (isset($filterArray['vendor'])) { $requiredVendor = $filterArray['vendor']; } if (isset($filterArray['extension'])) { $requiredExtension = $filterArray['extension']; } $repositoryID = false; if (isset($parameters['repository_id'])) { $repositoryID = $parameters['repository_id']; } $dbAvailable = true; if (isset($parameters['db_available'])) { $dbAvailable = $parameters['db_available']; } foreach ($packageRepositories as $packageRepository) { if (strlen($repositoryID) == 0 or $repositoryID == $packageRepository['id']) { $path = $packageRepository['path']; if (file_exists($path)) { $fileList = array(); $dir = opendir($path); while (($file = readdir($dir)) !== false) { if ($file == '.' or $file == '..') { continue; } $fileList[] = $file; } closedir($dir); sort($fileList); foreach ($fileList as $file) { $dirPath = $path . '/' . $file; if (!is_dir($dirPath)) { continue; } $filePath = $dirPath . '/' . eZPackage::definitionFilename(); if (file_exists($filePath)) { $fileModification = filemtime($filePath); $name = $file; $packageCachePath = $dirPath . '/' . eZPackage::cacheDirectory() . '/package.php'; unset($package); $package = false; $cacheExpired = false; if (eZPackage::useCache()) { $package = eZPackage::fetchFromCache($dirPath, $fileModification, $cacheExpired); } if (!$package) { $package = eZPackage::fetchFromFile($filePath); if ($package and $cacheExpired and eZPackage::useCache()) { $package->storeCache($dirPath . '/' . eZPackage::cacheDirectory()); } } if (!$package) { continue; } if ($dbAvailable) { $package->getInstallState(); } if ($requiredType !== null) { $type = $package->attribute('type'); if ($type != $requiredType) { continue; } } if ($requiredPriority !== null) { $priority = $package->attribute('priority'); if ($priority != $requiredPriority) { continue; } } if ($requiredExtension !== null) { $extension = $package->attribute('extension'); if ($extension != $requiredExtension) { continue; } } if ($requiredVendor !== null) { $vendor = $package->attribute('vendor'); if ($vendor != $requiredVendor) { continue; } } $package->setCurrentRepositoryInformation($packageRepository); $packages[] =& $package; } } } } } return $packages; }