From: Matthias Schmidt Date: Sat, 13 Aug 2011 06:02:09 +0000 (+0200) Subject: Renamed cache builders X-Git-Tag: 2.0.0_Beta_1~1879^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f00e0692077801e78fe43a15dbc60d2385d3d292;p=GitHub%2FWoltLab%2FWCF.git Renamed cache builders --- diff --git a/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php new file mode 100644 index 0000000000..f809dc6ffc --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php @@ -0,0 +1,152 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class ACPMenuCacheBuilder implements ICacheBuilder { + protected $optionCategoryStructure = array(); + + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID) = explode('-', $cacheResource['cache']); + $data = array(); + + // get all menu items and filter menu items with low priority + $sql = "SELECT menuItem, menuItemID + FROM wcf".WCF_N."_acp_menu_item menu_item + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (menu_item.packageID = package_dependency.dependency) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + $itemIDs = array(); + while ($row = $statement->fetchArray()) { + $itemIDs[$row['menuItem']] = $row['menuItemID']; + } + + if (count($itemIDs) > 0) { + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("menuItemID IN (?)", array($itemIDs)); + + // get needed menu items and build item tree + $sql = "SELECT menu_item.packageID, menuItem, parentMenuItem, + menuItemLink, permissions, options, packageDir + FROM wcf".WCF_N."_acp_menu_item menu_item + LEFT JOIN wcf".WCF_N."_package package + ON (package.packageID = menu_item.packageID) + ".$conditions." + ORDER BY showOrder ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + if (!isset($data[$row['parentMenuItem']])) { + $data[$row['parentMenuItem']] = array(); + } + + $data[$row['parentMenuItem']][] = new ACPMenuItem(null, $row); + } + } + + // get top option categories + $optionCategories = $this->getTopOptionCategories($packageID); + if (count($optionCategories) > 0) { + if (!isset($data['wcf.acp.menu.link.option.category'])) { + $data['wcf.acp.menu.link.option.category'] = array(); + } + + // get option category data + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("categoryID IN (?)", array($optionCategories)); + + $sql = "SELECT * + FROM wcf".WCF_N."_option_category + ".$conditions." + ORDER BY showOrder ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array( + 'packageID' => $packageID, + 'menuItem' => 'wcf.acp.option.category.'.$row['categoryName'], + 'parentMenuItem' => 'wcf.acp.menu.link.option.category', + 'menuItemLink' => 'index.php?form=Option&categoryID='.$row['categoryID'], + 'packageDir' => '', + 'permissions' => $row['permissions'], + 'options' => $row['options'] + )); + } + } + + return $data; + } + + protected function getTopOptionCategories($packageID) { + // get all option categories and filter categories with low priority + $sql = "SELECT categoryName, categoryID + FROM wcf".WCF_N."_option_category option_category + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = option_category.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + $optionCategories = array(); + while ($row = $statement->fetchArray()) { + $optionCategories[$row['categoryName']] = $row['categoryID']; + } + + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("categoryID IN (?)", array($optionCategories)); + $statementParameters = $conditions->getParameters(); + array_unshift($statementParameters, $packageID); + + $sql = "SELECT categoryID, parentCategoryName, categoryName, + ( + SELECT COUNT(*) FROM wcf".WCF_N."_option WHERE categoryName = category.categoryName AND packageID IN ( + SELECT dependency FROM wcf".WCF_N."_package_dependency WHERE packageID = ? + ) + ) AS count + FROM wcf".WCF_N."_option_category category + ".$conditions; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($statementParameters); + while ($row = $statement->fetchArray()) { + if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) $this->optionCategoryStructure[$row['parentCategoryName']] = array(); + $this->optionCategoryStructure[$row['parentCategoryName']][] = $row; + } + + $topOptionCategories = array(); + foreach ($this->optionCategoryStructure[''] as $optionCategory) { + $count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']); + if ($count > 0) $topOptionCategories[] = $optionCategory['categoryID']; + } + + return $topOptionCategories; + } + + protected function countOptions($parentCategoryName) { + if (!isset($this->optionCategoryStructure[$parentCategoryName])) return 0; + + $count = 0; + foreach ($this->optionCategoryStructure[$parentCategoryName] as $optionCategory) { + $count += $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']); + } + + return $count; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php new file mode 100644 index 0000000000..610d686d03 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/ApplicationCacheBuilder.class.php @@ -0,0 +1,80 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class ApplicationCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($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 groupID + FROM wcf".WCF_N."_application + WHERE packageID = ?"; + $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; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderACPMenu.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderACPMenu.class.php deleted file mode 100644 index 11d2a9f247..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderACPMenu.class.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderACPMenu implements ICacheBuilder { - protected $optionCategoryStructure = array(); - - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID) = explode('-', $cacheResource['cache']); - $data = array(); - - // get all menu items and filter menu items with low priority - $sql = "SELECT menuItem, menuItemID - FROM wcf".WCF_N."_acp_menu_item menu_item - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (menu_item.packageID = package_dependency.dependency) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - $itemIDs = array(); - while ($row = $statement->fetchArray()) { - $itemIDs[$row['menuItem']] = $row['menuItemID']; - } - - if (count($itemIDs) > 0) { - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("menuItemID IN (?)", array($itemIDs)); - - // get needed menu items and build item tree - $sql = "SELECT menu_item.packageID, menuItem, parentMenuItem, - menuItemLink, permissions, options, packageDir - FROM wcf".WCF_N."_acp_menu_item menu_item - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = menu_item.packageID) - ".$conditions." - ORDER BY showOrder ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - if (!isset($data[$row['parentMenuItem']])) { - $data[$row['parentMenuItem']] = array(); - } - - $data[$row['parentMenuItem']][] = new ACPMenuItem(null, $row); - } - } - - // get top option categories - $optionCategories = $this->getTopOptionCategories($packageID); - if (count($optionCategories) > 0) { - if (!isset($data['wcf.acp.menu.link.option.category'])) { - $data['wcf.acp.menu.link.option.category'] = array(); - } - - // get option category data - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("categoryID IN (?)", array($optionCategories)); - - $sql = "SELECT * - FROM wcf".WCF_N."_option_category - ".$conditions." - ORDER BY showOrder ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array( - 'packageID' => $packageID, - 'menuItem' => 'wcf.acp.option.category.'.$row['categoryName'], - 'parentMenuItem' => 'wcf.acp.menu.link.option.category', - 'menuItemLink' => 'index.php?form=Option&categoryID='.$row['categoryID'], - 'packageDir' => '', - 'permissions' => $row['permissions'], - 'options' => $row['options'] - )); - } - } - - return $data; - } - - protected function getTopOptionCategories($packageID) { - // get all option categories and filter categories with low priority - $sql = "SELECT categoryName, categoryID - FROM wcf".WCF_N."_option_category option_category - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = option_category.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - $optionCategories = array(); - while ($row = $statement->fetchArray()) { - $optionCategories[$row['categoryName']] = $row['categoryID']; - } - - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("categoryID IN (?)", array($optionCategories)); - $statementParameters = $conditions->getParameters(); - array_unshift($statementParameters, $packageID); - - $sql = "SELECT categoryID, parentCategoryName, categoryName, - ( - SELECT COUNT(*) FROM wcf".WCF_N."_option WHERE categoryName = category.categoryName AND packageID IN ( - SELECT dependency FROM wcf".WCF_N."_package_dependency WHERE packageID = ? - ) - ) AS count - FROM wcf".WCF_N."_option_category category - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($statementParameters); - while ($row = $statement->fetchArray()) { - if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) $this->optionCategoryStructure[$row['parentCategoryName']] = array(); - $this->optionCategoryStructure[$row['parentCategoryName']][] = $row; - } - - $topOptionCategories = array(); - foreach ($this->optionCategoryStructure[''] as $optionCategory) { - $count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']); - if ($count > 0) $topOptionCategories[] = $optionCategory['categoryID']; - } - - return $topOptionCategories; - } - - protected function countOptions($parentCategoryName) { - if (!isset($this->optionCategoryStructure[$parentCategoryName])) return 0; - - $count = 0; - foreach ($this->optionCategoryStructure[$parentCategoryName] as $optionCategory) { - $count += $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']); - } - - return $count; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderApplication.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderApplication.class.php deleted file mode 100644 index 6cf0250405..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderApplication.class.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderApplication implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($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 groupID - FROM wcf".WCF_N."_application - WHERE packageID = ?"; - $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; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCleanupAdapter.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCleanupAdapter.class.php deleted file mode 100644 index 9375c38113..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCleanupAdapter.class.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderCleanupAdapter implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID) = explode('-', $cacheResource['cache']); - $data = array( - 'adapters' => array(), - 'objectTypes' => array(), - 'packageIDs' => array() - ); - - $sql = "SELECT listener.*, package.packageDir - FROM wcf".WCF_N."_cleanup_listener listener - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = listener.packageID) - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = listener.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - while ($row = $statement->fetchArray()) { - if (!is_array($data['adapters'][$row['objectType']])) $data['adapters'][$row['objectType']] = array(); - $data['adapters'][$row['objectType']][] = $row; - - if (!is_array($data['objectTypes'][$row['objectType']])) $data['objectTypes'][$row['objectType']] = array(); - $data['objectTypes'][$row['objectType']][] = $row['packageID']; - } - - $data['objectTypes'] = array_unique($data['objectTypes']); - $data['packageIDs'] = array_unique($data['packageIDs']); - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCoreObject.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCoreObject.class.php deleted file mode 100644 index 5dccc69f24..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCoreObject.class.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderCoreObject implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID) = explode('-', $cacheResource['cache']); - $data = array(); - - $coreObjectList = new CoreObjectList(); - $coreObjectList->getConditionBuilder()->add("core_object.packageID IN (?)", array(PackageDependencyHandler::getDependencies())); - $coreObjectList->sqlLimit = 0; - $coreObjectList->readObjects(); - $coreObjects = $coreObjectList->getObjects(); - - foreach ($coreObjects as $coreObject) { - if (!isset($data[$coreObject->packageID])) { - $data[$coreObject->packageID] = array(); - } - - $tmp = explode('\\', $coreObject->objectName); - $className = array_pop($tmp); - $data[$coreObject->packageID][$className] = $coreObject->objectName; - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCronjob.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCronjob.class.php deleted file mode 100644 index fd0903eb3e..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderCronjob.class.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderCronjob implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - // get next execution time - $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies())); - - $sql = "SELECT MIN(nextExec) AS nextExec, - MIN(afterNextExec) AS afterNextExec - FROM wcf".WCF_N."_cronjob - ".$conditionBuilder->__toString(); - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditionBuilder->getParameters()); - $row = $statement->fetchArray(); - - return array( - 'afterNextExec' => $row['afterNextExec'], - 'nextExec' => $row['nextExec'] - ); - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderEventListener.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderEventListener.class.php deleted file mode 100644 index 776ebb2c29..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderEventListener.class.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderEventListener implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID) = explode('-', $cacheResource['cache']); - $data = array( - 'actions' => array('user' => array(), 'admin' => array()), - 'inheritedActions' => array('user' => array(), 'admin' => array()) - ); - - // get all listeners and filter options with low priority - $sql = "SELECT event_listener.* - FROM wcf".WCF_N."_event_listener event_listener - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = event_listener.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - while ($row = $statement->fetchArray()) { - // distinguish between inherited actions and non-inherited actions - if (!$row['inherit']) { - $data['actions'][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row; - } - else { - if (!isset($data['inheritedActions'][$row['eventClassName']])) $data['inheritedActions'][$row['eventClassName']] = array(); - $data['inheritedActions'][$row['eventClassName']][$row['eventName']][] = $row; - } - } - - // sort data by nice value and class name - foreach ($data['actions'] as $key => $listeners) { - uasort($data['actions'][$key], array(__CLASS__, 'sortListeners')); - } - - foreach ($data['inheritedActions'] as $class => $listeners) { - foreach ($listeners as $key => $val) { - uasort($data['inheritedActions'][$class][$key], array(__CLASS__, 'sortListeners')); - } - } - - return $data; - } - - /** - * Sorts the event listeners alphabetically. - */ - public static function sortListeners($listenerA, $listenerB) { - if ($listenerA['niceValue'] < $listenerB['niceValue']) { - return -1; - } - else if ($listenerA['niceValue'] > $listenerB['niceValue']) { - return 1; - } - else { - return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']); - } - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderIcon.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderIcon.class.php deleted file mode 100644 index d3db376fe5..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderIcon.class.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderIcon implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID, $styleID) = explode('-', $cacheResource['cache']); - $data = array(); - - // get active package - $activePackage = new Package($packageID); - $activePackageDir = FileUtil::getRealPath(WCF_DIR.$activePackage->getDir()); - - // get package dirs - $packageDirs = array(); - $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add("packageID IN (?) AND packageDir <> ''", array(PackageDependencyHandler::getDependenciesString())); - $sql = "SELECT DISTINCT packageDir - FROM wcf".WCF_N."_package package - ".$conditionBuilder->__toString()." - ORDER BY priority DESC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditionBuilder->getParameters()); - while ($row = $statement->fetchArray()) { - $packageDirs[] = FileUtil::getRealPath(WCF_DIR.$row['packageDir']); - } - $packageDirs[] = WCF_DIR; - - // get style icon path - $iconDirs = array(); - $sql = "SELECT variableValue - FROM wcf".WCF_N."_style_variable - WHERE styleID = ? - AND variableName = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($styleID, 'global.icons.location')); - $row = $statement->fetchArray(); - if (!empty($row['variableValue'])) $iconDirs[] = FileUtil::addTrailingSlash($row['variableValue']); - if (!in_array('icon/', $iconDirs)) $iconDirs[] = 'icon/'; - - // get icons - foreach ($packageDirs as $packageDir) { - $relativePackageDir = ($activePackageDir != $packageDir ? FileUtil::getRelativePath($activePackageDir, $packageDir) : ''); - - foreach ($iconDirs as $iconDir) { - $path = FileUtil::addTrailingSlash($packageDir.$iconDir); - $icons = self::getIconFiles($path); - foreach ($icons as $icon) { - $icon = str_replace($path, '', $icon); - if (!isset($data[$icon])) { - $data[$icon] = $relativePackageDir.$iconDir.$icon; - } - } - } - } - - return $data; - } - - protected static function getIconFiles($path) { - $files = array(); - if (is_dir($path)) { - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); - foreach ($iterator as $file) { - if (preg_match('/\.png$/', $file->getFilename())) { - $files[] = $file->getPathname(); - } - } - } - - return $files; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderLanguage.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderLanguage.class.php deleted file mode 100644 index 1908fab53d..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderLanguage.class.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderLanguage implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $languageToPackages = array(); - $data = array( - 'codes' => array(), - 'languages' => array(), - 'packages' => array(), - 'default' => 0, - 'categories' => array() - ); - - // get language to packages - $sql = "SELECT package.languageID, package.packageID - FROM wcf".WCF_N."_language_to_package package - LEFT JOIN wcf".WCF_N."_language language - ON (language.languageID = package.languageID) - ORDER BY language.isDefault DESC, - language.languageCode ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - // package to languages - if (!isset($data['packages'][$row['packageID']])) { - $data['packages'][$row['packageID']] = array(); - } - $data['packages'][$row['packageID']][] = $row['languageID']; - - // language to packages - if (!isset($languageToPackages[$row['languageID']])) { - $languageToPackages[$row['languageID']] = array(); - } - $languageToPackages[$row['languageID']][] = $row['packageID']; - } - - // get languages - $sql = "SELECT * - FROM wcf".WCF_N."_language"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - // language data - $data['languages'][$row['languageID']] = $row; - - // language to packages - if (!isset($languageToPackages[$row['languageID']])) { - $languageToPackages[$row['languageID']] = array(); - } - $data['languages'][$row['languageID']]['packages'] = $languageToPackages[$row['languageID']]; - - // default language - if ($row['isDefault']) { - $data['default'] = $row['languageID']; - } - - // language code to language id - $data['codes'][$row['languageCode']] = $row['languageID']; - } - - // get language categories - $sql = "SELECT * - FROM wcf".WCF_N."_language_category"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - // package to languages - $data['categories'][$row['languageCategory']] = $row; - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderOption.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderOption.class.php deleted file mode 100644 index 3a5432f575..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderOption.class.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderOption implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $information = explode('-', $cacheResource['cache']); - if (count($information) == 3) { - $type = $information[0].'_'; - $packageID = $information[2]; - } - else { - $type = ''; - $packageID = $information[1]; - } - - $data = array( - 'categories' => array(), - 'options' => array(), - 'categoryStructure' => array(), - 'optionToCategories' => array() - ); - - // option categories - // get all option categories and sort categories by priority - $sql = "SELECT categoryName, categoryID - FROM wcf".WCF_N."_".$type."option_category option_category - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = option_category.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - $optionCategories = array(); - while ($row = $statement->fetchArray()) { - $optionCategories[$row['categoryName']] = $row['categoryID']; - } - - if (count($optionCategories) > 0) { - // get needed option categories - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("categoryID IN (?)", array($optionCategories)); - - $sql = "SELECT option_category.*, package.packageDir - FROM wcf".WCF_N."_".$type."option_category option_category - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = option_category.packageID) - ".$conditions." - ORDER BY showOrder ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - $data['categories'][$row['categoryName']] = new OptionCategory(null, $row); - if (!isset($data['categoryStructure'][$row['parentCategoryName']])) { - $data['categoryStructure'][$row['parentCategoryName']] = array(); - } - - $data['categoryStructure'][$row['parentCategoryName']][] = $row['categoryName']; - } - } - - // options - // get all options and sort options by priority - $optionIDs = array(); - $sql = "SELECT optionName, optionID - FROM wcf".WCF_N."_".$type."option option_table - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = option_table.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - while ($row = $statement->fetchArray()) { - $optionIDs[$row['optionName']] = $row['optionID']; - } - - if (count($optionIDs) > 0) { - // get needed options - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("optionID IN (?)", array($optionIDs)); - - $sql = "SELECT * - FROM wcf".WCF_N."_".$type."option - ".$conditions." - ORDER BY showOrder ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - $data['options'][$row['optionName']] = new Option(null, $row); - if (!isset($data['optionToCategories'][$row['categoryName']])) { - $data['optionToCategories'][$row['categoryName']] = array(); - } - - $data['optionToCategories'][$row['categoryName']][] = $row['optionName']; - } - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPackage.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPackage.class.php deleted file mode 100644 index 592a121677..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPackage.class.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderPackage implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $packageList = new PackageList(); - $packageList->sqlLimit = 0; - $packageList->readObjects(); - - return $packageList->getObjects(); - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPackageDependency.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPackageDependency.class.php deleted file mode 100644 index 02eec5cec0..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPackageDependency.class.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderPackageDependency implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID) = explode('-', $cacheResource['cache']); - $data = array( - 'dependency' => array(), - 'resolve' => array() - ); - - if ($packageID != 0) { - // general dependencies for current package id - $sql = "SELECT dependency - FROM wcf".WCF_N."_package_dependency - WHERE packageID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - while ($row = $statement->fetchArray()) { - $data['dependency'][] = $row['dependency']; - } - - // resolve package id by package name - $sql = "SELECT package.packageID, package.package - FROM wcf".WCF_N."_package_dependency package_dependency - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = package_dependency.dependency) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - while ($row = $statement->fetchArray()) { - if (!isset($data['resolve'][$row['package']])) $data['resolve'][$row['package']] = array(); - $data['resolve'][$row['package']][] = $row['packageID']; - } - - foreach ($data['resolve'] as $package => $packageIDArray) { - if (count($packageIDArray) == 1) { - $data[$package] = array_shift($packageIDArray); - } - } - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPageMenu.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPageMenu.class.php deleted file mode 100644 index 33f90cbb84..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderPageMenu.class.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderPageMenu implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID) = explode('-', $cacheResource['cache']); - $data = array(); - - // get all menu items and filter menu items with low priority - $sql = "SELECT menuItem, menuItemID - FROM wcf".WCF_N."_page_menu_item menu_item - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = menu_item.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - $itemIDs = array(); - while ($row = $statement->fetchArray()) { - $itemIDs[$row['menuItem']] = $row['menuItemID']; - } - - if (count($itemIDs) > 0) { - // get needed menu items and build item tree - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("menu_item.menuItemID IN (?)", array($itemIDs)); - $conditions->add("menu_item.isDisabled = ?", array(0)); - - $sql = "SELECT menuItemID, menuItem, parentMenuItem, menuItemLink, - permissions, options, packageDir, menuPosition, className, - CASE WHEN parentPackageID <> 0 THEN parentPackageID ELSE menu_item.packageID END AS packageID - FROM wcf".WCF_N."_page_menu_item menu_item - LEFT JOIN wcf".WCF_N."_package package - ON (package.packageID = menu_item.packageID) - ".$conditions." - ORDER BY showOrder ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - $data[($row['parentMenuItem'] ? $row['parentMenuItem'] : $row['menuPosition'])][] = new PageMenuItem(null, $row); - } - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderSpider.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderSpider.class.php deleted file mode 100644 index 65ad4921a3..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderSpider.class.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderSpider implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $spiderList = new SpiderList(); - $spiderList->sqlOrderBy = "spider.spiderID ASC"; - $spiderList->sqlLimit = 0; - $spiderList->readObjects(); - - return $spiderList->getObjects(); - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderStyle.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderStyle.class.php deleted file mode 100644 index 05097f18b3..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderStyle.class.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderStyle implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $data = array('default' => 0, 'styles' => array(), 'packages' => array()); - - // get all styles - $sql = "SELECT * - FROM wcf".WCF_N."_style - ORDER BY styleName ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - if ($row['isDefault']) $data['default'] = $row['styleID']; - $row['variables'] = array(); - - // get variable - $sql = "SELECT * - FROM wcf".WCF_N."_style_variable - WHERE styleID = ?"; - $statement2 = WCF::getDB()->prepareStatement($sql); - $statement2->execute(array($row['styleID'])); - while ($row = $statement2->fetchArray()) { - - $row['variables'][$row2['variableName']] = $row2['variableValue']; - } - - $data['styles'][$row['styleID']] = new Style(null, $row); - } - - // get style to packages - $sql = "SELECT * - FROM wcf".WCF_N."_style_to_package - ORDER BY packageID ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - while ($row = $statement->fetchArray()) { - - if (!isset($data['packages'][$row['packageID']])) { - $data['packages'][$row['packageID']] = array('default' => 0, 'disabled' => array()); - } - - if ($row['isDefault']) { - $data['packages'][$row['packageID']]['default'] = $row['styleID']; - } - $data['packages'][$row['packageID']]['disabled'][$row['styleID']] = $row['disabled']; - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplate.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplate.class.php deleted file mode 100644 index 95cf542b66..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplate.class.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderTemplate implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $information = explode('-', $cacheResource['cache']); - if (count($information) == 3) { - $prefix = $information[0].'_'; - $packageID = $information[2]; - } - else { - $prefix = ''; - $packageID = $information[1]; - } - - $data = array(); - - // get package directory for given package id - $sql = "SELECT packageDir - FROM wcf".WCF_N."_package - WHERE packageID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - $row = $statement->fetchArray(); - - // get all templates and filter options with low priority - $sql = "SELECT templateName, template.packageID - FROM wcf".WCF_N."_".$prefix."template template - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = template.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority DESC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - while ($row = $statement->fetchArray()) { - if (!isset($data[$row['templateName']]) || $packageID == $row['packageID']) { - $data[$row['templateName']] = $row['packageID']; - } - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateGroup.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateGroup.class.php deleted file mode 100644 index a7536fb52a..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateGroup.class.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderTemplateGroup implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $templateGroupList = new TemplateGroupList(); - $templateGroupList->sqlLimit = 0; - $templateGroupList->readObjects(); - - return $templateGroupList->getObjects(); - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateListener.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateListener.class.php deleted file mode 100644 index 5b8829d2a2..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateListener.class.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderTemplateListener implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID, $environment) = explode('-', $cacheResource['cache']); - - // get templates for current package id - $templateListenerList = new TemplateListenerList(); - $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($environment)); - // work-around during setup - if (PACKAGE_ID) $templateListenerList->getConditionBuilder()->add("template_listener.packageID IN (?)", array(PackageDependencyHandler::getDependencies())); - $templateListenerList->sqlLimit = 0; - $templateListenerList->readObjects(); - - $data = array(); - foreach ($templateListenerList->getObjects() as $templateListener) { - $data[$templateListener->templateName] = array(); - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateListenerCode.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateListenerCode.class.php deleted file mode 100644 index 397c81b0e8..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderTemplateListenerCode.class.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderTemplateListenerCode implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($packageID, $environment, $templateName) = explode('-', $cacheResource['cache']); - - // get template codes for specified template - $templateListenerList = new TemplateListenerList(); - $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($environment)); - $templateListenerList->getConditionBuilder()->add("template_listener.templateName = ?", array($templateName)); - $templateListenerList->getConditionBuilder()->add("template_listener.packageID IN (?)", array(PackageDependencyHandler::getDependencies())); - $templateListenerList->sqlLimit = 0; - $templateListenerList->readObjects(); - - $data = array(); - foreach ($templateListenerList->getObjects() as $templateListener) { - $data[$templateListener->eventName][] = $templateListener->templateCode; - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderUserGroup.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderUserGroup.class.php deleted file mode 100644 index a5f3fbb4fa..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderUserGroup.class.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderUserGroup implements ICacheBuilder { - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - $data = array('types' => array(), 'groups' => array()); - - // get all user groups - $groupList = new UserGroupList(); - $groupList->sqlOrderBy = "user_group.groupName"; - $groupList->sqlLimit = 0; - $groupList->readObjects(); - $groups = $groupList->getObjects(); - - foreach ($groups as $group) { - if (!isset($data['types'][$group->groupType])) { - $data['types'][$group->groupType] = array(); - } - - $data['types'][$group->groupType][] = $group->groupID; - $data['groups'][$group->groupID] = $group; - } - - return $data; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderUserGroupPermission.class.php b/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderUserGroupPermission.class.php deleted file mode 100644 index 81e76303f7..0000000000 --- a/wcfsetup/install/files/lib/system/cache/builder/CacheBuilderUserGroupPermission.class.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @package com.woltlab.wcf - * @subpackage system.cache.builder - * @category Community Framework - */ -class CacheBuilderUserGroupPermission implements ICacheBuilder { - protected $typeObjects = array(); - - /** - * @see wcf\system\cache\ICacheBuilder::getData() - */ - public function getData($cacheResource) { - list($cache, $packageID, $groupIDs) = explode('-', $cacheResource['cache']); - $data = array(); - - // get all options and filter options with low priority - if ($packageID == 0) { - // during the installation of the package wcf - $sql = "SELECT optionName, optionID - FROM wcf".WCF_N."_user_group_option - WHERE packageID IS NULL"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(); - } - else { - $sql = "SELECT optionName, optionID - FROM wcf".WCF_N."_user_group_option option_table - LEFT JOIN wcf".WCF_N."_package_dependency package_dependency - ON (package_dependency.dependency = option_table.packageID) - WHERE package_dependency.packageID = ? - ORDER BY package_dependency.priority ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($packageID)); - } - - $options = array(); - while ($row = $statement->fetchArray()) { - $options[$row['optionName']] = $row['optionID']; - } - - if (count($options) > 0) { - // get needed options - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs))); - $conditions->add("option_value.optionID IN (?)", array($options)); - - $sql = "SELECT option_table.optionName, option_table.optionType, option_value.optionValue - FROM wcf".WCF_N."_user_group_option_value option_value - LEFT JOIN wcf".WCF_N."_user_group_option option_table - ON (option_table.optionID = option_value.optionID) - ".$conditions; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - if (!isset($data[$row['optionName']])) { - $data[$row['optionName']] = array('type' => $row['optionType'], 'values' => array()); - } - - $data[$row['optionName']]['values'][] = $row['optionValue']; - } - - // merge values - foreach ($data as $optionName => $option) { - if (count($option['values']) == 1) { - $result = $option['values'][0]; - } - else { - $typeObj = $this->getTypeObject($option['type']); - $result = $typeObj->merge($option['values']); - } - - // unset false values - if ($result === false) { - unset($data[$optionName]); - } - else { - $data[$optionName] = $result; - } - } - } - - $data['groupIDs'] = $groupIDs; - return $data; - } - - /** - * Returns an object of the requested group option type. - * - * @param string $type - * @return wcf\system\option\group\IGroupOptionType - */ - protected function getTypeObject($type) { - if (!isset($this->typeObjects[$type])) { - $className = 'wcf\system\option\group\GroupOptionType'.ucfirst($type); - - // validate class - if (!class_exists($className)) { - throw new SystemException("unable to find class '".$className."'"); - } - if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\group\IGroupOptionType')) { - throw new SystemException("'".$className."' should implement wcf\system\option\group\IGroupOptionType"); - } - - // create instance - $this->typeObjects[$type] = new $className(); - } - - return $this->typeObjects[$type]; - } -} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php new file mode 100644 index 0000000000..53a71007de --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/CleanupAdapterCacheBuilder.class.php @@ -0,0 +1,51 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class CleanupAdapterCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID) = explode('-', $cacheResource['cache']); + $data = array( + 'adapters' => array(), + 'objectTypes' => array(), + 'packageIDs' => array() + ); + + $sql = "SELECT listener.*, package.packageDir + FROM wcf".WCF_N."_cleanup_listener listener + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = listener.packageID) + LEFT JOIN wcf".WCF_N."_package package + ON (package.packageID = listener.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + if (!is_array($data['adapters'][$row['objectType']])) $data['adapters'][$row['objectType']] = array(); + $data['adapters'][$row['objectType']][] = $row; + + if (!is_array($data['objectTypes'][$row['objectType']])) $data['objectTypes'][$row['objectType']] = array(); + $data['objectTypes'][$row['objectType']][] = $row['packageID']; + } + + $data['objectTypes'] = array_unique($data['objectTypes']); + $data['packageIDs'] = array_unique($data['packageIDs']); + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php new file mode 100644 index 0000000000..df144312b0 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/CoreObjectCacheBuilder.class.php @@ -0,0 +1,43 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class CoreObjectCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID) = explode('-', $cacheResource['cache']); + $data = array(); + + $coreObjectList = new CoreObjectList(); + $coreObjectList->getConditionBuilder()->add("core_object.packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + $coreObjectList->sqlLimit = 0; + $coreObjectList->readObjects(); + $coreObjects = $coreObjectList->getObjects(); + + foreach ($coreObjects as $coreObject) { + if (!isset($data[$coreObject->packageID])) { + $data[$coreObject->packageID] = array(); + } + + $tmp = explode('\\', $coreObject->objectName); + $className = array_pop($tmp); + $data[$coreObject->packageID][$className] = $coreObject->objectName; + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php new file mode 100644 index 0000000000..952ad05b16 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/CronjobCacheBuilder.class.php @@ -0,0 +1,40 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class CronjobCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + // get next execution time + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + + $sql = "SELECT MIN(nextExec) AS nextExec, + MIN(afterNextExec) AS afterNextExec + FROM wcf".WCF_N."_cronjob + ".$conditionBuilder->__toString(); + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditionBuilder->getParameters()); + $row = $statement->fetchArray(); + + return array( + 'afterNextExec' => $row['afterNextExec'], + 'nextExec' => $row['nextExec'] + ); + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php new file mode 100644 index 0000000000..030e237ee0 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/EventListenerCacheBuilder.class.php @@ -0,0 +1,77 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class EventListenerCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID) = explode('-', $cacheResource['cache']); + $data = array( + 'actions' => array('user' => array(), 'admin' => array()), + 'inheritedActions' => array('user' => array(), 'admin' => array()) + ); + + // get all listeners and filter options with low priority + $sql = "SELECT event_listener.* + FROM wcf".WCF_N."_event_listener event_listener + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = event_listener.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + // distinguish between inherited actions and non-inherited actions + if (!$row['inherit']) { + $data['actions'][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row; + } + else { + if (!isset($data['inheritedActions'][$row['eventClassName']])) $data['inheritedActions'][$row['eventClassName']] = array(); + $data['inheritedActions'][$row['eventClassName']][$row['eventName']][] = $row; + } + } + + // sort data by nice value and class name + foreach ($data['actions'] as $key => $listeners) { + uasort($data['actions'][$key], array(__CLASS__, 'sortListeners')); + } + + foreach ($data['inheritedActions'] as $class => $listeners) { + foreach ($listeners as $key => $val) { + uasort($data['inheritedActions'][$class][$key], array(__CLASS__, 'sortListeners')); + } + } + + return $data; + } + + /** + * Sorts the event listeners alphabetically. + */ + public static function sortListeners($listenerA, $listenerB) { + if ($listenerA['niceValue'] < $listenerB['niceValue']) { + return -1; + } + else if ($listenerA['niceValue'] > $listenerB['niceValue']) { + return 1; + } + else { + return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']); + } + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/IconCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/IconCacheBuilder.class.php new file mode 100644 index 0000000000..b1131857ab --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/IconCacheBuilder.class.php @@ -0,0 +1,91 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class IconCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID, $styleID) = explode('-', $cacheResource['cache']); + $data = array(); + + // get active package + $activePackage = new Package($packageID); + $activePackageDir = FileUtil::getRealPath(WCF_DIR.$activePackage->getDir()); + + // get package dirs + $packageDirs = array(); + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add("packageID IN (?) AND packageDir <> ''", array(PackageDependencyHandler::getDependenciesString())); + $sql = "SELECT DISTINCT packageDir + FROM wcf".WCF_N."_package package + ".$conditionBuilder->__toString()." + ORDER BY priority DESC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditionBuilder->getParameters()); + while ($row = $statement->fetchArray()) { + $packageDirs[] = FileUtil::getRealPath(WCF_DIR.$row['packageDir']); + } + $packageDirs[] = WCF_DIR; + + // get style icon path + $iconDirs = array(); + $sql = "SELECT variableValue + FROM wcf".WCF_N."_style_variable + WHERE styleID = ? + AND variableName = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($styleID, 'global.icons.location')); + $row = $statement->fetchArray(); + if (!empty($row['variableValue'])) $iconDirs[] = FileUtil::addTrailingSlash($row['variableValue']); + if (!in_array('icon/', $iconDirs)) $iconDirs[] = 'icon/'; + + // get icons + foreach ($packageDirs as $packageDir) { + $relativePackageDir = ($activePackageDir != $packageDir ? FileUtil::getRelativePath($activePackageDir, $packageDir) : ''); + + foreach ($iconDirs as $iconDir) { + $path = FileUtil::addTrailingSlash($packageDir.$iconDir); + $icons = self::getIconFiles($path); + foreach ($icons as $icon) { + $icon = str_replace($path, '', $icon); + if (!isset($data[$icon])) { + $data[$icon] = $relativePackageDir.$iconDir.$icon; + } + } + } + } + + return $data; + } + + protected static function getIconFiles($path) { + $files = array(); + if (is_dir($path)) { + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); + foreach ($iterator as $file) { + if (preg_match('/\.png$/', $file->getFilename())) { + $files[] = $file->getPathname(); + } + } + } + + return $files; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php new file mode 100644 index 0000000000..4c1b4ad433 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/LanguageCacheBuilder.class.php @@ -0,0 +1,90 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class LanguageCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $languageToPackages = array(); + $data = array( + 'codes' => array(), + 'languages' => array(), + 'packages' => array(), + 'default' => 0, + 'categories' => array() + ); + + // get language to packages + $sql = "SELECT package.languageID, package.packageID + FROM wcf".WCF_N."_language_to_package package + LEFT JOIN wcf".WCF_N."_language language + ON (language.languageID = package.languageID) + ORDER BY language.isDefault DESC, + language.languageCode ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + while ($row = $statement->fetchArray()) { + // package to languages + if (!isset($data['packages'][$row['packageID']])) { + $data['packages'][$row['packageID']] = array(); + } + $data['packages'][$row['packageID']][] = $row['languageID']; + + // language to packages + if (!isset($languageToPackages[$row['languageID']])) { + $languageToPackages[$row['languageID']] = array(); + } + $languageToPackages[$row['languageID']][] = $row['packageID']; + } + + // get languages + $sql = "SELECT * + FROM wcf".WCF_N."_language"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + while ($row = $statement->fetchArray()) { + // language data + $data['languages'][$row['languageID']] = $row; + + // language to packages + if (!isset($languageToPackages[$row['languageID']])) { + $languageToPackages[$row['languageID']] = array(); + } + $data['languages'][$row['languageID']]['packages'] = $languageToPackages[$row['languageID']]; + + // default language + if ($row['isDefault']) { + $data['default'] = $row['languageID']; + } + + // language code to language id + $data['codes'][$row['languageCode']] = $row['languageID']; + } + + // get language categories + $sql = "SELECT * + FROM wcf".WCF_N."_language_category"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + while ($row = $statement->fetchArray()) { + // package to languages + $data['categories'][$row['languageCategory']] = $row; + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php new file mode 100644 index 0000000000..013e46c49f --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/OptionCacheBuilder.class.php @@ -0,0 +1,117 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class OptionCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $information = explode('-', $cacheResource['cache']); + if (count($information) == 3) { + $type = $information[0].'_'; + $packageID = $information[2]; + } + else { + $type = ''; + $packageID = $information[1]; + } + + $data = array( + 'categories' => array(), + 'options' => array(), + 'categoryStructure' => array(), + 'optionToCategories' => array() + ); + + // option categories + // get all option categories and sort categories by priority + $sql = "SELECT categoryName, categoryID + FROM wcf".WCF_N."_".$type."option_category option_category + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = option_category.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + $optionCategories = array(); + while ($row = $statement->fetchArray()) { + $optionCategories[$row['categoryName']] = $row['categoryID']; + } + + if (count($optionCategories) > 0) { + // get needed option categories + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("categoryID IN (?)", array($optionCategories)); + + $sql = "SELECT option_category.*, package.packageDir + FROM wcf".WCF_N."_".$type."option_category option_category + LEFT JOIN wcf".WCF_N."_package package + ON (package.packageID = option_category.packageID) + ".$conditions." + ORDER BY showOrder ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $data['categories'][$row['categoryName']] = new OptionCategory(null, $row); + if (!isset($data['categoryStructure'][$row['parentCategoryName']])) { + $data['categoryStructure'][$row['parentCategoryName']] = array(); + } + + $data['categoryStructure'][$row['parentCategoryName']][] = $row['categoryName']; + } + } + + // options + // get all options and sort options by priority + $optionIDs = array(); + $sql = "SELECT optionName, optionID + FROM wcf".WCF_N."_".$type."option option_table + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = option_table.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + $optionIDs[$row['optionName']] = $row['optionID']; + } + + if (count($optionIDs) > 0) { + // get needed options + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("optionID IN (?)", array($optionIDs)); + + $sql = "SELECT * + FROM wcf".WCF_N."_".$type."option + ".$conditions." + ORDER BY showOrder ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $data['options'][$row['optionName']] = new Option(null, $row); + if (!isset($data['optionToCategories'][$row['categoryName']])) { + $data['optionToCategories'][$row['categoryName']] = array(); + } + + $data['optionToCategories'][$row['categoryName']][] = $row['optionName']; + } + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php new file mode 100644 index 0000000000..d4fe6b7499 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/PackageCacheBuilder.class.php @@ -0,0 +1,28 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class PackageCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $packageList = new PackageList(); + $packageList->sqlLimit = 0; + $packageList->readObjects(); + + return $packageList->getObjects(); + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/PackageDependency.CacheBuilderclass.php b/wcfsetup/install/files/lib/system/cache/builder/PackageDependency.CacheBuilderclass.php new file mode 100644 index 0000000000..417baa213f --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/PackageDependency.CacheBuilderclass.php @@ -0,0 +1,61 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class PackageDependencyCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID) = explode('-', $cacheResource['cache']); + $data = array( + 'dependency' => array(), + 'resolve' => array() + ); + + if ($packageID != 0) { + // general dependencies for current package id + $sql = "SELECT dependency + FROM wcf".WCF_N."_package_dependency + WHERE packageID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + $data['dependency'][] = $row['dependency']; + } + + // resolve package id by package name + $sql = "SELECT package.packageID, package.package + FROM wcf".WCF_N."_package_dependency package_dependency + LEFT JOIN wcf".WCF_N."_package package + ON (package.packageID = package_dependency.dependency) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + if (!isset($data['resolve'][$row['package']])) $data['resolve'][$row['package']] = array(); + $data['resolve'][$row['package']][] = $row['packageID']; + } + + foreach ($data['resolve'] as $package => $packageIDArray) { + if (count($packageIDArray) == 1) { + $data[$package] = array_shift($packageIDArray); + } + } + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php new file mode 100644 index 0000000000..215c218180 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/PageMenuCacheBuilder.class.php @@ -0,0 +1,63 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class PageMenuCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID) = explode('-', $cacheResource['cache']); + $data = array(); + + // get all menu items and filter menu items with low priority + $sql = "SELECT menuItem, menuItemID + FROM wcf".WCF_N."_page_menu_item menu_item + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = menu_item.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + $itemIDs = array(); + while ($row = $statement->fetchArray()) { + $itemIDs[$row['menuItem']] = $row['menuItemID']; + } + + if (count($itemIDs) > 0) { + // get needed menu items and build item tree + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("menu_item.menuItemID IN (?)", array($itemIDs)); + $conditions->add("menu_item.isDisabled = ?", array(0)); + + $sql = "SELECT menuItemID, menuItem, parentMenuItem, menuItemLink, + permissions, options, packageDir, menuPosition, className, + CASE WHEN parentPackageID <> 0 THEN parentPackageID ELSE menu_item.packageID END AS packageID + FROM wcf".WCF_N."_page_menu_item menu_item + LEFT JOIN wcf".WCF_N."_package package + ON (package.packageID = menu_item.packageID) + ".$conditions." + ORDER BY showOrder ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + $data[($row['parentMenuItem'] ? $row['parentMenuItem'] : $row['menuPosition'])][] = new PageMenuItem(null, $row); + } + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php new file mode 100644 index 0000000000..9f0b71f87b --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/SpiderCacheBuilder.class.php @@ -0,0 +1,28 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class SpiderCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $spiderList = new SpiderList(); + $spiderList->sqlOrderBy = "spider.spiderID ASC"; + $spiderList->sqlLimit = 0; + $spiderList->readObjects(); + + return $spiderList->getObjects(); + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php new file mode 100644 index 0000000000..d449c02512 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/StyleCacheBuilder.class.php @@ -0,0 +1,72 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class StyleCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $data = array( + 'default' => 0, + 'styles' => array(), + 'packages' => array() + ); + + // get all styles + $sql = "SELECT * + FROM wcf".WCF_N."_style + ORDER BY styleName ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + while ($row = $statement->fetchArray()) { + if ($row['isDefault']) $data['default'] = $row['styleID']; + $row['variables'] = array(); + + // get variable + $sql = "SELECT * + FROM wcf".WCF_N."_style_variable + WHERE styleID = ?"; + $statement2 = WCF::getDB()->prepareStatement($sql); + $statement2->execute(array($row['styleID'])); + while ($row = $statement2->fetchArray()) { + + $row['variables'][$row2['variableName']] = $row2['variableValue']; + } + + $data['styles'][$row['styleID']] = new Style(null, $row); + } + + // get style to packages + $sql = "SELECT * + FROM wcf".WCF_N."_style_to_package + ORDER BY packageID ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + while ($row = $statement->fetchArray()) { + + if (!isset($data['packages'][$row['packageID']])) { + $data['packages'][$row['packageID']] = array('default' => 0, 'disabled' => array()); + } + + if ($row['isDefault']) { + $data['packages'][$row['packageID']]['default'] = $row['styleID']; + } + $data['packages'][$row['packageID']]['disabled'][$row['styleID']] = $row['disabled']; + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php new file mode 100644 index 0000000000..8da1a1fcb7 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateCacheBuilder.class.php @@ -0,0 +1,58 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class TemplateCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $information = explode('-', $cacheResource['cache']); + if (count($information) == 3) { + $prefix = $information[0].'_'; + $packageID = $information[2]; + } + else { + $prefix = ''; + $packageID = $information[1]; + } + + $data = array(); + + // get package directory for given package id + $sql = "SELECT packageDir + FROM wcf".WCF_N."_package + WHERE packageID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + $row = $statement->fetchArray(); + + // get all templates and filter options with low priority + $sql = "SELECT templateName, template.packageID + FROM wcf".WCF_N."_".$prefix."template template + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = template.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority DESC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + while ($row = $statement->fetchArray()) { + if (!isset($data[$row['templateName']]) || $packageID == $row['packageID']) { + $data[$row['templateName']] = $row['packageID']; + } + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php new file mode 100644 index 0000000000..fb460ec16b --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateGroupCacheBuilder.class.php @@ -0,0 +1,27 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class TemplateGroupCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $templateGroupList = new TemplateGroupList(); + $templateGroupList->sqlLimit = 0; + $templateGroupList->readObjects(); + + return $templateGroupList->getObjects(); + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php new file mode 100644 index 0000000000..d3891267fb --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCacheBuilder.class.php @@ -0,0 +1,39 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class TemplateListenerCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID, $environment) = explode('-', $cacheResource['cache']); + + // get templates for current package id + $templateListenerList = new TemplateListenerList(); + $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($environment)); + // work-around during setup + if (PACKAGE_ID) $templateListenerList->getConditionBuilder()->add("template_listener.packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + $templateListenerList->sqlLimit = 0; + $templateListenerList->readObjects(); + + $data = array(); + foreach ($templateListenerList->getObjects() as $templateListener) { + $data[$templateListener->templateName] = array(); + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php new file mode 100644 index 0000000000..37ad981c06 --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/TemplateListenerCodeCacheBuilder.class.php @@ -0,0 +1,39 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class TemplateListenerCodeCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($packageID, $environment, $templateName) = explode('-', $cacheResource['cache']); + + // get template codes for specified template + $templateListenerList = new TemplateListenerList(); + $templateListenerList->getConditionBuilder()->add("template_listener.environment = ?", array($environment)); + $templateListenerList->getConditionBuilder()->add("template_listener.templateName = ?", array($templateName)); + $templateListenerList->getConditionBuilder()->add("template_listener.packageID IN (?)", array(PackageDependencyHandler::getDependencies())); + $templateListenerList->sqlLimit = 0; + $templateListenerList->readObjects(); + + $data = array(); + foreach ($templateListenerList->getObjects() as $templateListener) { + $data[$templateListener->eventName][] = $templateListener->templateCode; + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php new file mode 100644 index 0000000000..99d4dfbe5b --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupCacheBuilder.class.php @@ -0,0 +1,41 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class UserGroupCacheBuilder implements ICacheBuilder { + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + $data = array('types' => array(), 'groups' => array()); + + // get all user groups + $groupList = new UserGroupList(); + $groupList->sqlOrderBy = "user_group.groupName"; + $groupList->sqlLimit = 0; + $groupList->readObjects(); + $groups = $groupList->getObjects(); + + foreach ($groups as $group) { + if (!isset($data['types'][$group->groupType])) { + $data['types'][$group->groupType] = array(); + } + + $data['types'][$group->groupType][] = $group->groupID; + $data['groups'][$group->groupID] = $group; + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php new file mode 100644 index 0000000000..326708457e --- /dev/null +++ b/wcfsetup/install/files/lib/system/cache/builder/UserGroupPermissionCacheBuilder.class.php @@ -0,0 +1,123 @@ + + * @package com.woltlab.wcf + * @subpackage system.cache.builder + * @category Community Framework + */ +class UserGroupPermissionCacheBuilder implements ICacheBuilder { + protected $typeObjects = array(); + + /** + * @see wcf\system\cache\ICacheBuilder::getData() + */ + public function getData($cacheResource) { + list($cache, $packageID, $groupIDs) = explode('-', $cacheResource['cache']); + $data = array(); + + // get all options and filter options with low priority + if ($packageID == 0) { + // during the installation of the package wcf + $sql = "SELECT optionName, optionID + FROM wcf".WCF_N."_user_group_option + WHERE packageID IS NULL"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + } + else { + $sql = "SELECT optionName, optionID + FROM wcf".WCF_N."_user_group_option option_table + LEFT JOIN wcf".WCF_N."_package_dependency package_dependency + ON (package_dependency.dependency = option_table.packageID) + WHERE package_dependency.packageID = ? + ORDER BY package_dependency.priority ASC"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($packageID)); + } + + $options = array(); + while ($row = $statement->fetchArray()) { + $options[$row['optionName']] = $row['optionID']; + } + + if (count($options) > 0) { + // get needed options + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs))); + $conditions->add("option_value.optionID IN (?)", array($options)); + + $sql = "SELECT option_table.optionName, option_table.optionType, option_value.optionValue + FROM wcf".WCF_N."_user_group_option_value option_value + LEFT JOIN wcf".WCF_N."_user_group_option option_table + ON (option_table.optionID = option_value.optionID) + ".$conditions; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditions->getParameters()); + while ($row = $statement->fetchArray()) { + if (!isset($data[$row['optionName']])) { + $data[$row['optionName']] = array('type' => $row['optionType'], 'values' => array()); + } + + $data[$row['optionName']]['values'][] = $row['optionValue']; + } + + // merge values + foreach ($data as $optionName => $option) { + if (count($option['values']) == 1) { + $result = $option['values'][0]; + } + else { + $typeObj = $this->getTypeObject($option['type']); + $result = $typeObj->merge($option['values']); + } + + // unset false values + if ($result === false) { + unset($data[$optionName]); + } + else { + $data[$optionName] = $result; + } + } + } + + $data['groupIDs'] = $groupIDs; + return $data; + } + + /** + * Returns an object of the requested group option type. + * + * @param string $type + * @return wcf\system\option\group\IGroupOptionType + */ + protected function getTypeObject($type) { + if (!isset($this->typeObjects[$type])) { + $className = 'wcf\system\option\group\GroupOptionType'.ucfirst($type); + + // validate class + if (!class_exists($className)) { + throw new SystemException("unable to find class '".$className."'"); + } + if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\group\IGroupOptionType')) { + throw new SystemException("'".$className."' should implement wcf\system\option\group\IGroupOptionType"); + } + + // create instance + $this->typeObjects[$type] = new $className(); + } + + return $this->typeObjects[$type]; + } +}