コード例 #1
0
 /**
  * @see wcf\system\cache\ICacheBuilder::getData()
  */
 public function getData(array $cacheResource)
 {
     $packageList = new PackageList();
     $packageList->sqlLimit = 0;
     $packageList->readObjects();
     return $packageList->getObjects();
 }
コード例 #2
0
 /**
  * @see	\wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
  */
 public function rebuild(array $parameters)
 {
     $data = array('abbreviation' => array(), 'application' => array(), 'primary' => 0, 'wcf' => null);
     // fetch applications
     $applicationList = new ApplicationList();
     $applicationList->readObjects();
     $applications = $applicationList->getObjects();
     foreach ($applications as $application) {
         $data['application'][$application->packageID] = $application;
         // save primary application's package id
         if ($application->isPrimary) {
             $data['primary'] = $application->packageID;
         }
     }
     // fetch abbreviations
     $packageList = new PackageList();
     $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
     $packageList->readObjects();
     foreach ($packageList->getObjects() as $package) {
         $data['abbreviation'][Package::getAbbreviation($package->package)] = $package->packageID;
     }
     // assign wcf pseudo-application
     if (PACKAGE_ID) {
         $data['wcf'] = $data['application'][1];
         unset($data['application'][1]);
     }
     return $data;
 }
コード例 #3
0
 /**
  * @see	\wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
  */
 public function rebuild(array $parameters)
 {
     $data = array('packages' => array(), 'packageIDs' => array());
     $packageList = new PackageList();
     $packageList->readObjects();
     foreach ($packageList as $package) {
         $data['packages'][$package->packageID] = $package;
         $data['packageIDs'][$package->package] = $package->packageID;
     }
     return $data;
 }
コード例 #4
0
 /**
  * @see	\wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
  */
 public function rebuild(array $parameters)
 {
     $data = array();
     $isACP = $parameters['environment'] == 'admin';
     $packageList = new PackageList();
     $packageList->getConditionBuilder()->add("isApplication = ?", array(1));
     $packageList->readObjects();
     foreach ($packageList as $package) {
         $abbreviation = Package::getAbbreviation($package->package);
         $path = WCF_DIR . $package->packageDir . 'lib/' . ($isACP ? 'acp/' : '');
         $data[$abbreviation] = array('action' => $this->getControllers($path, $abbreviation, 'action', $isACP), 'form' => $this->getControllers($path, $abbreviation, 'form', $isACP), 'page' => $this->getControllers($path, $abbreviation, 'page', $isACP));
     }
     return $data;
 }
コード例 #5
0
 /**
  * @see	\wcf\system\package\plugin\IPackageInstallationPlugin::install()
  */
 public function install()
 {
     parent::install();
     // extract sql file from archive
     if ($queries = $this->getSQL($this->instruction['value'])) {
         $package = $this->installation->getPackage();
         // replace app1_ with app{WCF_N}_ in the table names for
         // all applications
         $packageList = new PackageList();
         $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
         $packageList->readObjects();
         foreach ($packageList as $package) {
             $abbreviation = Package::getAbbreviation($package->package);
             $queries = str_replace($abbreviation . '1_', $abbreviation . WCF_N . '_', $queries);
         }
         // check queries
         $parser = new PackageInstallationSQLParser($queries, $this->installation->getPackage(), $this->installation->getAction());
         $conflicts = $parser->test();
         if (!empty($conflicts) && (isset($conflicts['CREATE TABLE']) || isset($conflicts['DROP TABLE']))) {
             $unknownCreateTable = isset($conflicts['CREATE TABLE']) ? $conflicts['CREATE TABLE'] : array();
             $unknownDropTable = isset($conflicts['DROP TABLE']) ? $conflicts['DROP TABLE'] : array();
             $errorMessage = "Can't";
             if (!empty($unknownDropTable)) {
                 $errorMessage .= " drop unknown table";
                 if (count($unknownDropTable) > 1) {
                     $errorMessage .= "s";
                 }
                 $errorMessage .= " '" . implode("', '", $unknownDropTable) . "'";
             }
             if (!empty($unknownCreateTable)) {
                 if (!empty($unknownDropTable)) {
                     $errorMessage .= " and can't";
                 }
                 $errorMessage .= " overwrite unknown table";
                 if (count($unknownCreateTable) > 1) {
                     $errorMessage .= "s";
                 }
                 $errorMessage .= " '" . implode("', '", $unknownCreateTable) . "'";
             }
             throw new SystemException($errorMessage);
         }
         // execute queries
         $parser->execute();
         // log changes
         $parser->log();
     }
 }
コード例 #6
0
 /**
  * @see	wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // read applications
     $this->applicationList = new PackageList();
     $this->applicationList->getConditionBuilder()->add("package.isApplication = ?", array(1));
     $this->applicationList->getConditionBuilder()->add("package.packageID <> ?", array(1));
     $this->applicationList->sqlLimit = 0;
     $this->applicationList->readObjects();
     // read plugins
     $this->pluginList = Package::getPluginList();
     // count total plugins
     $this->pluginCount = $this->pluginList->countObjects();
     // read plugins
     $this->pluginList->sqlLimit = 20;
     $this->pluginList->readObjects();
 }
コード例 #7
0
ファイル: Application.class.php プロジェクト: nick-strohm/WCF
 /**
  * Returns the directory of the application with the given abbrevation.
  * 
  * @param	string		$abbreviation
  * @return	string
  */
 public static function getDirectory($abbreviation)
 {
     if (static::$directories === null) {
         static::$directories = array();
         // read application directories
         $packageList = new PackageList();
         $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
         $packageList->readObjects();
         foreach ($packageList as $package) {
             $abbr = Package::getAbbreviation($package->package);
             static::$directories[$abbr] = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->packageDir));
         }
     }
     if (!isset(static::$directories[$abbreviation])) {
         throw new SystemException("Unknown application '" . $abbreviation . "'");
     }
     return static::$directories[$abbreviation];
 }
コード例 #8
0
 /**
  * @see wcf\system\cache\ICacheBuilder::getData()
  */
 public function getData(array $cacheResource)
 {
     list($cache, $packageID) = explode('-', $cacheResource['cache']);
     $data = array('abbreviation' => array(), 'application' => array(), 'group' => null, 'primary' => 0, 'wcf' => null);
     // lookup group id for currently active application
     $sql = "SELECT\tgroupID\n\t\t\tFROM\twcf" . WCF_N . "_application\n\t\t\tWHERE\tpackageID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($packageID));
     $row = $statement->fetchArray();
     // current application is not part of an application group
     if (!$row || $row['groupID'] == 0 || $row['groupID'] === null) {
         $data['application'] = array($packageID => new application\Application($packageID));
     } else {
         // fetch applications
         $applicationList = new application\ApplicationList();
         $applicationList->getConditionBuilder()->add("application.groupID = ?", array($row['groupID']));
         $applicationList->sqlLimit = 0;
         $applicationList->readObjects();
         $applications = $applicationList->getObjects();
         foreach ($applications as $application) {
             $data['application'][$application->packageID] = $application;
             // save primary application's package id
             if ($application->isPrimary) {
                 $data['primary'] = $application->packageID;
             }
         }
         // fetch application group
         $data['group'] = new ApplicationGroup($row['groupID']);
     }
     // fetch abbreviations
     $packageList = new PackageList();
     $packageList->getConditionBuilder()->add('packageID IN (?)', array(array_keys($data['application'])));
     $packageList->readObjects();
     foreach ($packageList->getObjects() as $package) {
         $data['abbreviation'][Package::getAbbreviation($package->package)] = $package->packageID;
     }
     // fetch wcf pseudo-application
     $data['wcf'] = new application\Application(1);
     return $data;
 }
コード例 #9
0
 /**
  * Returns the database table name for the object type's search index.
  * 
  * @param	mixed				$objectType
  * @param	\wcf\data\package\Package	$package
  * @return	string
  */
 public static function getTableName($objectType, $package = null)
 {
     if (is_string($objectType)) {
         $objectType = self::getInstance()->getObjectType($objectType);
     }
     if ($objectType->searchindex) {
         $tableName = $objectType->searchindex;
         if (!empty($tableName)) {
             if (empty(self::$packages)) {
                 $packageList = new PackageList();
                 $packageList->getConditionBuilder()->add('package.isApplication = ?', array(1));
                 $packageList->readObjects();
                 self::$packages = $packageList->getObjects();
             }
             // replace app1_ with app{WCF_N}_ in the table name
             foreach (self::$packages as $package) {
                 $abbreviation = Package::getAbbreviation($package->package);
                 $tableName = str_replace($abbreviation . '1_', $abbreviation . WCF_N . '_', $tableName);
             }
             return $tableName;
         }
     }
     return 'wcf' . WCF_N . '_search_index_' . substr(sha1($objectType->objectType), 0, 8);
 }
コード例 #10
0
 /**
  * Returns an ordered list of depenencies for given package id. The order is
  * curcial, whereas the first package has to be uninstalled first.
  * 
  * @package	integer
  * @return	wcf\data\package\PackageList
  */
 public static function getOrderedPackageDependencies($packageID)
 {
     $sql = "SELECT\t\tpackageID, MAX(level) AS level\n\t\t\tFROM\t\twcf" . WCF_N . "_package_requirement_map\n\t\t\tWHERE\t\trequirement = ?\n\t\t\tGROUP BY\tpackageID";
     $statement = WCF::getDB()->prepareStatement($sql);
     $statement->execute(array($packageID));
     $dependencies = array();
     while ($row = $statement->fetchArray()) {
         $dependencies[$row['packageID']] = $row['level'];
     }
     $packageIDs = array();
     $maxLevel = max(array_values($dependencies));
     if ($maxLevel == 0) {
         // order does not matter
         $packageIDs = array_keys($dependencies);
     } else {
         // order by level while ignoring individual connections as they don't
         // matter if uninstall begins with the lowest dependency in tree
         for ($i = $maxLevel; $i >= 0; $i--) {
             foreach ($dependencies as $packageID => $level) {
                 if ($level == $i) {
                     $packageIDs[] = $packageID;
                     unset($dependencies[$packageID]);
                 }
             }
         }
     }
     // get packages
     $packageList = new PackageList();
     $packageList->sqlLimit = 0;
     $packageList->getConditionBuilder()->add("packageID IN (?)", array($packageIDs));
     $packageList->readObjects();
     return $packageList;
 }