--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\acp\menu\item\ACPMenuItem;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches the acp menu items tree.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\application\group\ApplicationGroup;
+use wcf\data\application;
+use wcf\data\package\Package;
+use wcf\data\package\PackageList;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches applications.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\acp\menu\item\ACPMenuItem;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches the acp menu items tree.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\application\group\ApplicationGroup;
-use wcf\data\application;
-use wcf\data\package\Package;
-use wcf\data\package\PackageList;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches applications.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches cleanup adapters.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\data\core\object\CoreObjectList;
-use wcf\system\package\PackageDependencyHandler;
-
-/**
- * Caches the core objects.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\package\PackageDependencyHandler;
-use wcf\system\WCF;
-
-/**
- * Caches cronjob information.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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']
- );
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\event\listener\EventHandler;
-use wcf\system\WCF;
-use wcf\util\StringUtil;
-
-/**
- * Caches the event listeners.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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']);
- }
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\package\Package;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\package\PackageDependencyHandler;
-use wcf\system\WCF;
-use wcf\util\FileUtil;
-
-/**
- * Caches the paths of icons.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches languages, language to packages relation, package to languages relation
- * and the id of the default language.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\option\category\OptionCategory;
-use wcf\data\option\Option;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches the options and option categories
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\package\PackageList;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches all registered packages.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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();
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches the dependencies of a package.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\page\menu\item\PageMenuItem;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches the page menu items.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\spider\SpiderList;
-use wcf\system\cache\ICacheBuilder;
-
-/**
- * Caches the list of search engine spiders.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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();
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\style\Style;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches the styles and style variables.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\WCF;
-
-/**
- * Caches the structure of templates.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\template\group\TemplateGroupList;
-use wcf\system\cache\ICacheBuilder;
-
-/**
- * Caches template groups.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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();
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\template\listener\TemplateListenerList;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\package\PackageDependencyHandler;
-
-/**
- * Caches template listener information.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\template\listener\TemplateListenerList;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\package\PackageDependencyHandler;
-
-/**
- * Caches template listener code.
- *
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\data\user\group\UserGroupList;
-use wcf\system\cache\ICacheBuilder;
-
-/**
- * Caches all user groups.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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;
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache\builder;
-use wcf\system\cache\ICacheBuilder;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\exception\SystemException;
-use wcf\system\WCF;
-use wcf\util\ClassUtil;
-
-/**
- * Caches the merged group options of a group combination.
- *
- * @author Marcel Werk
- * @copyright 2001-2011 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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];
- }
-}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches cleanup adapters.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\data\core\object\CoreObjectList;
+use wcf\system\package\PackageDependencyHandler;
+
+/**
+ * Caches the core objects.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\package\PackageDependencyHandler;
+use wcf\system\WCF;
+
+/**
+ * Caches cronjob information.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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']
+ );
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\event\listener\EventHandler;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Caches the event listeners.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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']);
+ }
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\package\Package;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\package\PackageDependencyHandler;
+use wcf\system\WCF;
+use wcf\util\FileUtil;
+
+/**
+ * Caches the paths of icons.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches languages, language to packages relation, package to languages relation
+ * and the id of the default language.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\option\category\OptionCategory;
+use wcf\data\option\Option;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches the options and option categories
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\package\PackageList;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches all registered packages.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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();
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches the dependencies of a package.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\page\menu\item\PageMenuItem;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches the page menu items.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\spider\SpiderList;
+use wcf\system\cache\ICacheBuilder;
+
+/**
+ * Caches the list of search engine spiders.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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();
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\style\Style;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches the styles and style variables.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\WCF;
+
+/**
+ * Caches the structure of templates.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\template\group\TemplateGroupList;
+use wcf\system\cache\ICacheBuilder;
+
+/**
+ * Caches template groups.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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();
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\template\listener\TemplateListenerList;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\package\PackageDependencyHandler;
+
+/**
+ * Caches template listener information.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\template\listener\TemplateListenerList;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\package\PackageDependencyHandler;
+
+/**
+ * Caches template listener code.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\user\group\UserGroupList;
+use wcf\system\cache\ICacheBuilder;
+
+/**
+ * Caches all user groups.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\system\cache\ICacheBuilder;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\exception\SystemException;
+use wcf\system\WCF;
+use wcf\util\ClassUtil;
+
+/**
+ * Caches the merged group options of a group combination.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2011 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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];
+ }
+}