* cache class name\r
* @var string\r
*/\r
- public $cacheClass = 'wcf\system\cache\CacheBuilderOption';\r
+ public $cacheClass = 'wcf\system\cache\builder\CacheBuilderOption';\r
\r
/**\r
* list of all option categories\r
protected function readUserOptions() {\r
// add cache resource\r
$cacheName = 'user-option-'.PACKAGE_ID;\r
- CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\CacheBuilderOption');\r
+ CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\builder\CacheBuilderOption');\r
\r
// get options\r
$this->options = CacheHandler::getInstance()->get($cacheName, 'options');\r
}
// load icon cache
- WCF::getCache()->addResource('icon-'.PACKAGE_ID.'-'.$this->styleID, WCF_DIR.'cache/cache.icon-'.PACKAGE_ID.'-'.$this->styleID.'.php', 'wcf\system\cache\CacheBuilderIcon');
+ WCF::getCache()->addResource('icon-'.PACKAGE_ID.'-'.$this->styleID, WCF_DIR.'cache/cache.icon-'.PACKAGE_ID.'-'.$this->styleID.'.php', 'wcf\system\cache\builder\CacheBuilderIcon');
$this->iconCache = WCF::getCache()->get('icon-'.PACKAGE_ID.'-'.$this->styleID);
}
*/
protected static function getUserOptionCache() {
$cacheName = 'user-option-'.PACKAGE_ID;
- CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\CacheBuilderOption');
+ CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\builder\CacheBuilderOption');
self::$userOptions = CacheHandler::getInstance()->get($cacheName, 'options');
}
*/
protected static function getCache() {
if (self::$cache === null) {
- CacheHandler::getInstance()->addResource('usergroups', WCF_DIR.'cache/cache.usergroups.php', 'wcf\system\cache\CacheBuilderUserGroup');
+ CacheHandler::getInstance()->addResource('usergroups', WCF_DIR.'cache/cache.usergroups.php', 'wcf\system\cache\builder\CacheBuilderUserGroup');
self::$cache = CacheHandler::getInstance()->get('usergroups');
}
}
* Loads the default cache resources.\r
*/\r
protected function loadDefaultCacheResources() {\r
- CacheHandler::getInstance()->addResource('languages', WCF_DIR.'cache/cache.languages.php', 'wcf\system\cache\CacheBuilderLanguage');\r
- CacheHandler::getInstance()->addResource('spiders', WCF_DIR.'cache/cache.spiders.php', 'wcf\system\cache\CacheBuilderSpider');\r
+ CacheHandler::getInstance()->addResource('languages', WCF_DIR.'cache/cache.languages.php', 'wcf\system\cache\builder\CacheBuilderLanguage');\r
+ CacheHandler::getInstance()->addResource('spiders', WCF_DIR.'cache/cache.spiders.php', 'wcf\system\builder\cache\CacheBuilderSpider');\r
if (defined('PACKAGE_ID')) {\r
- CacheHandler::getInstance()->addResource('coreObjects-'.PACKAGE_ID, WCF_DIR.'cache/cache.coreObjects-'.PACKAGE_ID.'.php', 'wcf\system\cache\CacheBuilderCoreObject');\r
+ CacheHandler::getInstance()->addResource('coreObjects-'.PACKAGE_ID, WCF_DIR.'cache/cache.coreObjects-'.PACKAGE_ID.'.php', 'wcf\system\cache\builder\CacheBuilderCoreObject');\r
}\r
}\r
\r
\r
return null;\r
}\r
-}
+}\r
*/\r
protected function loadDefaultCacheResources() {\r
parent::loadDefaultCacheResources();\r
- CacheHandler::getInstance()->addResource('packages', WCF_DIR.'cache/cache.packages.php', 'wcf\system\cache\CacheBuilderPackage');\r
+ CacheHandler::getInstance()->addResource('packages', WCF_DIR.'cache/cache.packages.php', 'wcf\system\cache\builder\CacheBuilderPackage');\r
}\r
\r
/**\r
}\r
}\r
}\r
-}
+}\r
CacheHandler::getInstance()->addResource(
'application-'.PACKAGE_ID,
WCF_DIR.'cache/cache.application-'.PACKAGE_ID.'.php',
- 'wcf\system\cache\CacheBuilderApplication'
+ 'wcf\system\cache\builder\CacheBuilderApplication'
);
$this->cache = CacheHandler::getInstance()->get('application-'.PACKAGE_ID);
}
+++ /dev/null
-<?php\r
-namespace wcf\system\cache;\r
-use wcf\data\acp\menu\item\ACPMenuItem;\r
-use wcf\system\database\util\PreparedStatementConditionBuilder;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Caches the acp menu items tree.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderACPMenu implements CacheBuilder {\r
- protected $optionCategoryStructure = array();\r
-\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- list($cache, $packageID) = explode('-', $cacheResource['cache']); \r
- $data = array();\r
-\r
- // get all menu items and filter menu items with low priority\r
- $sql = "SELECT menuItem, menuItemID\r
- FROM wcf".WCF_N."_acp_menu_item menu_item\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (menu_item.packageID = package_dependency.dependency)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- $itemIDs = array();\r
- while ($row = $statement->fetchArray()) {\r
- $itemIDs[$row['menuItem']] = $row['menuItemID'];\r
- }\r
- \r
- if (count($itemIDs) > 0) {\r
- $conditions = new PreparedStatementConditionBuilder();\r
- $conditions->add("menuItemID IN (?)", array($itemIDs));\r
- \r
- // get needed menu items and build item tree\r
- $sql = "SELECT menu_item.packageID, menuItem, parentMenuItem,\r
- menuItemLink, permissions, options, packageDir\r
- FROM wcf".WCF_N."_acp_menu_item menu_item\r
- LEFT JOIN wcf".WCF_N."_package package\r
- ON (package.packageID = menu_item.packageID)\r
- ".$conditions."\r
- ORDER BY showOrder ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute($conditions->getParameters());\r
- while ($row = $statement->fetchArray()) {\r
- if (!isset($data[$row['parentMenuItem']])) {\r
- $data[$row['parentMenuItem']] = array();\r
- }\r
- \r
- $data[$row['parentMenuItem']][] = new ACPMenuItem(null, $row);\r
- }\r
- }\r
- \r
- // get top option categories\r
- $optionCategories = $this->getTopOptionCategories($packageID);\r
- if (count($optionCategories) > 0) {\r
- if (!isset($data['wcf.acp.menu.link.option.category'])) {\r
- $data['wcf.acp.menu.link.option.category'] = array();\r
- }\r
- \r
- // get option category data\r
- $conditions = new PreparedStatementConditionBuilder();\r
- $conditions->add("categoryID IN (?)", array($optionCategories));\r
- \r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_option_category\r
- ".$conditions."\r
- ORDER BY showOrder ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute($conditions->getParameters());\r
- while ($row = $statement->fetchArray()) {\r
- $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array(\r
- 'packageID' => $packageID,\r
- 'menuItem' => 'wcf.acp.option.category.'.$row['categoryName'],\r
- 'parentMenuItem' => 'wcf.acp.menu.link.option.category',\r
- 'menuItemLink' => 'index.php?form=Option&categoryID='.$row['categoryID'],\r
- 'packageDir' => '',\r
- 'permissions' => $row['permissions'],\r
- 'options' => $row['options']\r
- ));\r
- }\r
- }\r
- \r
- return $data;\r
- }\r
- \r
- protected function getTopOptionCategories($packageID) {\r
- // get all option categories and filter categories with low priority\r
- $sql = "SELECT categoryName, categoryID \r
- FROM wcf".WCF_N."_option_category option_category\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (package_dependency.dependency = option_category.packageID)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- $optionCategories = array();\r
- while ($row = $statement->fetchArray()) {\r
- $optionCategories[$row['categoryName']] = $row['categoryID'];\r
- }\r
- \r
- $conditions = new PreparedStatementConditionBuilder();\r
- $conditions->add("categoryID IN (?)", array($optionCategories));\r
- $statementParameters = $conditions->getParameters();\r
- array_unshift($statementParameters, $packageID);\r
- \r
- $sql = "SELECT categoryID, parentCategoryName, categoryName,\r
- (\r
- SELECT COUNT(*) FROM wcf".WCF_N."_option WHERE categoryName = category.categoryName AND packageID IN (\r
- SELECT dependency FROM wcf".WCF_N."_package_dependency WHERE packageID = ?\r
- )\r
- ) AS count\r
- FROM wcf".WCF_N."_option_category category\r
- ".$conditions;\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute($statementParameters);\r
- while ($row = $statement->fetchArray()) {\r
- if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) $this->optionCategoryStructure[$row['parentCategoryName']] = array();\r
- $this->optionCategoryStructure[$row['parentCategoryName']][] = $row;\r
- }\r
- \r
- $topOptionCategories = array();\r
- foreach ($this->optionCategoryStructure[''] as $optionCategory) {\r
- $count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']);\r
- if ($count > 0) $topOptionCategories[] = $optionCategory['categoryID'];\r
- }\r
- \r
- return $topOptionCategories;\r
- }\r
- \r
- protected function countOptions($parentCategoryName) {\r
- if (!isset($this->optionCategoryStructure[$parentCategoryName])) return 0;\r
- \r
- $count = 0;\r
- foreach ($this->optionCategoryStructure[$parentCategoryName] as $optionCategory) {\r
- $count += $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']);\r
- }\r
- \r
- return $count;\r
- }\r
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache;
-use wcf\data\application\group\ApplicationGroup;
-use wcf\data\application;
-use wcf\data\package\Package;
-use wcf\data\package\PackageList;
-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
- * @category Community Framework
- */
-class CacheBuilderApplication implements CacheBuilder {
- /**
- * @see CacheBuilder::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;
-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
- * @category Community Framework
- */
-class CacheBuilderCleanupAdapter implements CacheBuilder {
- /**
- * @see CacheBuilder::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;
-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
- * @category Community Framework
- */
-class CacheBuilderCoreObject implements CacheBuilder {
- /**
- * @see CacheBuilder::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;
-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
- * @category Community Framework
- */
-class CacheBuilderCronjob implements CacheBuilder {
- /**
- * @see CacheBuilder::getData()
- */
- public function getData($cacheResource) {
- // get next execution time
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("packageID IN (?)", array(PackageDependencyHandler::getDependenciesString()));
-
- $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\r
-namespace wcf\system\cache;\r
-use wcf\system\event\listener\EventHandler;\r
-use wcf\system\WCF;\r
-use wcf\util\StringUtil;\r
-\r
-/**\r
- * Caches the event listeners.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderEventListener implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- list($cache, $packageID) = explode('-', $cacheResource['cache']); \r
- $data = array(\r
- 'actions' => array('user' => array(), 'admin' => array()),\r
- 'inheritedActions' => array('user' => array(), 'admin' => array())\r
- );\r
- \r
- // get all listeners and filter options with low priority\r
- $sql = "SELECT event_listener.*\r
- FROM wcf".WCF_N."_event_listener event_listener\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (package_dependency.dependency = event_listener.packageID)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- while ($row = $statement->fetchArray()) {\r
- // distinguish between inherited actions and non-inherited actions\r
- if (!$row['inherit']) {\r
- $data['actions'][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;\r
- }\r
- else {\r
- if (!isset($data['inheritedActions'][$row['eventClassName']])) $data['inheritedActions'][$row['eventClassName']] = array();\r
- $data['inheritedActions'][$row['eventClassName']][$row['eventName']][] = $row; \r
- }\r
- }\r
- \r
- // sort data by nice value and class name\r
- foreach ($data['actions'] as $key => $listeners) {\r
- uasort($data['actions'][$key], array(__CLASS__, 'sortListeners'));\r
- }\r
- \r
- foreach ($data['inheritedActions'] as $class => $listeners) {\r
- foreach ($listeners as $key => $val) {\r
- uasort($data['inheritedActions'][$class][$key], array(__CLASS__, 'sortListeners'));\r
- }\r
- }\r
- \r
- return $data;\r
- }\r
- \r
- /**\r
- * Sorts the event listeners alphabetically.\r
- */\r
- public static function sortListeners($listenerA, $listenerB) {\r
- if ($listenerA['niceValue'] < $listenerB['niceValue']) {\r
- return -1;\r
- }\r
- else if ($listenerA['niceValue'] > $listenerB['niceValue']) {\r
- return 1;\r
- }\r
- else {\r
- return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']);\r
- } \r
- }\r
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache;
-use wcf\data\package\Package;
-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
- * @category Community Framework
- */
-class CacheBuilderIcon implements CacheBuilder {
- /**
- * @see CacheBuilder::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\r
-namespace wcf\system\cache;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Caches languages, language to packages relation, package to languages relation\r
- * and the id of the default language. \r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderLanguage implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $languageToPackages = array();\r
- $data = array(\r
- 'codes' => array(),\r
- 'languages' => array(), \r
- 'packages' => array(),\r
- 'default' => 0,\r
- 'categories' => array()\r
- );\r
- \r
- // get language to packages\r
- $sql = "SELECT package.languageID, package.packageID\r
- FROM wcf".WCF_N."_language_to_package package\r
- LEFT JOIN wcf".WCF_N."_language language\r
- ON (language.languageID = package.languageID)\r
- ORDER BY language.isDefault DESC,\r
- language.languageCode ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute();\r
- while ($row = $statement->fetchArray()) {\r
- // package to languages\r
- if (!isset($data['packages'][$row['packageID']])) {\r
- $data['packages'][$row['packageID']] = array();\r
- }\r
- $data['packages'][$row['packageID']][] = $row['languageID'];\r
- \r
- // language to packages\r
- if (!isset($languageToPackages[$row['languageID']])) {\r
- $languageToPackages[$row['languageID']] = array();\r
- }\r
- $languageToPackages[$row['languageID']][] = $row['packageID'];\r
- }\r
- \r
- // get languages\r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_language";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute();\r
- while ($row = $statement->fetchArray()) {\r
- // language data\r
- $data['languages'][$row['languageID']] = $row;\r
- \r
- // language to packages\r
- if (!isset($languageToPackages[$row['languageID']])) {\r
- $languageToPackages[$row['languageID']] = array();\r
- }\r
- $data['languages'][$row['languageID']]['packages'] = $languageToPackages[$row['languageID']];\r
- \r
- // default language\r
- if ($row['isDefault']) {\r
- $data['default'] = $row['languageID'];\r
- }\r
- \r
- // language code to language id\r
- $data['codes'][$row['languageCode']] = $row['languageID'];\r
- }\r
- \r
- // get language categories\r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_language_category";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute();\r
- while ($row = $statement->fetchArray()) {\r
- // package to languages\r
- $data['categories'][$row['languageCategory']] = $row;\r
- }\r
-\r
- return $data;\r
- }\r
-}
+++ /dev/null
-<?php\r
-namespace wcf\system\cache;\r
-use wcf\data\option\category\OptionCategory;\r
-use wcf\data\option\Option;\r
-use wcf\system\database\util\PreparedStatementConditionBuilder;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Caches the options and option categories\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderOption implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $information = explode('-', $cacheResource['cache']);\r
- if (count($information) == 3) {\r
- $type = $information[0].'_';\r
- $packageID = $information[2];\r
- }\r
- else {\r
- $type = '';\r
- $packageID = $information[1];\r
- }\r
- \r
- $data = array(\r
- 'categories' => array(),\r
- 'options' => array(),\r
- 'categoryStructure' => array(),\r
- 'optionToCategories' => array()\r
- );\r
-\r
- // option categories\r
- // get all option categories and sort categories by priority\r
- $sql = "SELECT categoryName, categoryID \r
- FROM wcf".WCF_N."_".$type."option_category option_category\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (package_dependency.dependency = option_category.packageID)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- $optionCategories = array();\r
- while ($row = $statement->fetchArray()) {\r
- $optionCategories[$row['categoryName']] = $row['categoryID'];\r
- }\r
- \r
- if (count($optionCategories) > 0) {\r
- // get needed option categories\r
- $conditions = new PreparedStatementConditionBuilder();\r
- $conditions->add("categoryID IN (?)", array($optionCategories));\r
- \r
- $sql = "SELECT option_category.*, package.packageDir\r
- FROM wcf".WCF_N."_".$type."option_category option_category\r
- LEFT JOIN wcf".WCF_N."_package package\r
- ON (package.packageID = option_category.packageID)\r
- ".$conditions."\r
- ORDER BY showOrder ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute($conditions->getParameters());\r
- while ($row = $statement->fetchArray()) {\r
- $data['categories'][$row['categoryName']] = new OptionCategory(null, $row);\r
- if (!isset($data['categoryStructure'][$row['parentCategoryName']])) {\r
- $data['categoryStructure'][$row['parentCategoryName']] = array();\r
- }\r
- \r
- $data['categoryStructure'][$row['parentCategoryName']][] = $row['categoryName'];\r
- }\r
- }\r
- \r
- // options\r
- // get all options and sort options by priority\r
- $optionIDs = array();\r
- $sql = "SELECT optionName, optionID \r
- FROM wcf".WCF_N."_".$type."option option_table\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (package_dependency.dependency = option_table.packageID)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- while ($row = $statement->fetchArray()) {\r
- $optionIDs[$row['optionName']] = $row['optionID'];\r
- }\r
- \r
- if (count($optionIDs) > 0) {\r
- // get needed options\r
- $conditions = new PreparedStatementConditionBuilder();\r
- $conditions->add("optionID IN (?)", array($optionIDs));\r
- \r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_".$type."option\r
- ".$conditions."\r
- ORDER BY showOrder ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute($conditions->getParameters());\r
- while ($row = $statement->fetchArray()) {\r
- $data['options'][$row['optionName']] = new Option(null, $row);\r
- if (!isset($data['optionToCategories'][$row['categoryName']])) {\r
- $data['optionToCategories'][$row['categoryName']] = array();\r
- }\r
- \r
- $data['optionToCategories'][$row['categoryName']][] = $row['optionName'];\r
- }\r
- }\r
- \r
- return $data;\r
- }\r
-}
+++ /dev/null
-<?php\r
-namespace wcf\system\cache;\r
-use wcf\data\package\PackageList;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Caches all registered packages.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderPackage implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $packageList = new PackageList();\r
- $packageList->sqlLimit = 0;\r
- $packageList->readObjects();\r
- \r
- return $packageList->getObjects();\r
- }\r
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache;
-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
- * @category Community Framework
- */
-class CacheBuilderPackageDependency implements CacheBuilder {
- /**
- * @see CacheBuilder::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;
-use wcf\data\page\menu\item\PageMenuItem;
-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
- * @category Community Framework
- */
-class CacheBuilderPageMenu implements CacheBuilder {
- /**
- * @see CacheBuilder::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\r
-namespace wcf\system\cache;\r
-use wcf\data\spider\SpiderList;\r
-\r
-/**\r
- * Caches the list of search engine spiders.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderSpider implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $spiderList = new SpiderList();\r
- $spiderList->sqlOrderBy = "spider.spiderID ASC";\r
- $spiderList->sqlLimit = 0;\r
- $spiderList->readObjects();\r
- \r
- return $spiderList->getObjects();\r
- }\r
-}
+++ /dev/null
-<?php\r
-namespace wcf\system\cache;\r
-use wcf\data\style\Style;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Caches the styles and style variables.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderStyle implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $data = array('default' => 0, 'styles' => array(), 'packages' => array());\r
- \r
- // get all styles\r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_style\r
- ORDER BY styleName ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute();\r
- while ($row = $statement->fetchArray()) {\r
- if ($row['isDefault']) $data['default'] = $row['styleID'];\r
- $row['variables'] = array();\r
- \r
- // get variable\r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_style_variable\r
- WHERE styleID = ?";\r
- $statement2 = WCF::getDB()->prepareStatement($sql);\r
- $statement2->execute(array($row['styleID']));\r
- while ($row = $statement2->fetchArray()) {\r
- \r
- $row['variables'][$row2['variableName']] = $row2['variableValue'];\r
- }\r
- \r
- $data['styles'][$row['styleID']] = new Style(null, $row);\r
- }\r
- \r
- // get style to packages\r
- $sql = "SELECT *\r
- FROM wcf".WCF_N."_style_to_package\r
- ORDER BY packageID ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute();\r
- while ($row = $statement->fetchArray()) {\r
- \r
- if (!isset($data['packages'][$row['packageID']])) {\r
- $data['packages'][$row['packageID']] = array('default' => 0, 'disabled' => array());\r
- }\r
- \r
- if ($row['isDefault']) {\r
- $data['packages'][$row['packageID']]['default'] = $row['styleID'];\r
- }\r
- $data['packages'][$row['packageID']]['disabled'][$row['styleID']] = $row['disabled'];\r
- }\r
- \r
- return $data;\r
- }\r
-}
+++ /dev/null
-<?php\r
-namespace wcf\system\cache;\r
-use wcf\system\WCF;\r
-\r
-/**\r
- * Caches the structure of templates.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderTemplate implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $information = explode('-', $cacheResource['cache']);\r
- if (count($information) == 3) {\r
- $prefix = $information[0].'_';\r
- $packageID = $information[2];\r
- }\r
- else {\r
- $prefix = '';\r
- $packageID = $information[1];\r
- }\r
- \r
- $data = array();\r
- \r
- // get package directory for given package id\r
- $sql = "SELECT packageDir\r
- FROM wcf".WCF_N."_package\r
- WHERE packageID = ?";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- $row = $statement->fetchArray();\r
- \r
- // get all templates and filter options with low priority\r
- $sql = "SELECT templateName, template.packageID \r
- FROM wcf".WCF_N."_".$prefix."template template\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (package_dependency.dependency = template.packageID)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority DESC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- while ($row = $statement->fetchArray()) {\r
- if (!isset($data[$row['templateName']]) || $packageID == $row['packageID']) {\r
- $data[$row['templateName']] = $row['packageID'];\r
- }\r
- }\r
- \r
- return $data;\r
- }\r
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache;
-use wcf\data\template\group\TemplateGroupList;
-
-/**
- * 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
- * @category Community Framework
- */
-class CacheBuilderTemplateGroup implements CacheBuilder {
- /**
- * @see CacheBuilder::getData()
- */
- public function getData($cacheResource) {
- $templateGroupList = new TemplateGroupList();
- $templateGroupList->sqlLimit = 0;
- $templateGroupList->readObjects();
-
- return $templateGroupList->getObjects();
- }
-}
+++ /dev/null
-<?php
-namespace wcf\system\cache;
-use wcf\data\template\listener\TemplateListenerList;
-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
- * @category Community Framework
- */
-class CacheBuilderTemplateListener implements CacheBuilder {
- /**
- * @see CacheBuilder::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;
-use wcf\data\template\listener\TemplateListenerList;
-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
- * @category Community Framework
- */
-class CacheBuilderTemplateListenerCode implements CacheBuilder {
- /**
- * @see CacheBuilder::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\r
-namespace wcf\system\cache;\r
-use wcf\data\user\group\UserGroupList;\r
-\r
-/**\r
- * Caches all user groups.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderUserGroup implements CacheBuilder {\r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- $data = array('types' => array(), 'groups' => array());\r
-\r
- // get all user groups\r
- $groupList = new UserGroupList();\r
- $groupList->sqlOrderBy = "user_group.groupName";\r
- $groupList->sqlLimit = 0;\r
- $groupList->readObjects();\r
- $groups = $groupList->getObjects();\r
- \r
- foreach ($groups as $group) {\r
- if (!isset($data['types'][$group->groupType])) {\r
- $data['types'][$group->groupType] = array();\r
- }\r
- \r
- $data['types'][$group->groupType][] = $group->groupID;\r
- $data['groups'][$group->groupID] = $group;\r
- }\r
- \r
- return $data;\r
- }\r
-}
+++ /dev/null
-<?php\r
-namespace wcf\system\cache;\r
-use wcf\system\database\util\PreparedStatementConditionBuilder;\r
-use wcf\system\exception\SystemException;\r
-use wcf\system\WCF;\r
-use wcf\util\ClassUtil;\r
-\r
-/**\r
- * Caches the merged group options of a group combination.\r
- * \r
- * @author Marcel Werk\r
- * @copyright 2001-2011 WoltLab GmbH\r
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
- * @package com.woltlab.wcf\r
- * @subpackage system.cache\r
- * @category Community Framework\r
- */\r
-class CacheBuilderUserGroupPermission implements CacheBuilder {\r
- protected $typeObjects = array();\r
- \r
- /**\r
- * @see CacheBuilder::getData()\r
- */\r
- public function getData($cacheResource) {\r
- list($cache, $packageID, $groupIDs) = explode('-', $cacheResource['cache']);\r
- $data = array();\r
- \r
- // get all options and filter options with low priority\r
- if ($packageID == 0) {\r
- // during the installation of the package wcf\r
- $sql = "SELECT optionName, optionID \r
- FROM wcf".WCF_N."_user_group_option\r
- WHERE packageID IS NULL";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute();\r
- }\r
- else {\r
- $sql = "SELECT optionName, optionID \r
- FROM wcf".WCF_N."_user_group_option option_table\r
- LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
- ON (package_dependency.dependency = option_table.packageID)\r
- WHERE package_dependency.packageID = ?\r
- ORDER BY package_dependency.priority ASC";\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute(array($packageID));\r
- }\r
- \r
- $options = array();\r
- while ($row = $statement->fetchArray()) {\r
- $options[$row['optionName']] = $row['optionID'];\r
- }\r
- \r
- if (count($options) > 0) {\r
- // get needed options\r
- $conditions = new PreparedStatementConditionBuilder();\r
- $conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs)));\r
- $conditions->add("option_value.optionID IN (?)", array($options));\r
- \r
- $sql = "SELECT option_table.optionName, option_table.optionType, option_value.optionValue\r
- FROM wcf".WCF_N."_user_group_option_value option_value\r
- LEFT JOIN wcf".WCF_N."_user_group_option option_table\r
- ON (option_table.optionID = option_value.optionID)\r
- ".$conditions;\r
- $statement = WCF::getDB()->prepareStatement($sql);\r
- $statement->execute($conditions->getParameters());\r
- while ($row = $statement->fetchArray()) {\r
- if (!isset($data[$row['optionName']])) {\r
- $data[$row['optionName']] = array('type' => $row['optionType'], 'values' => array());\r
- }\r
- \r
- $data[$row['optionName']]['values'][] = $row['optionValue'];\r
- }\r
- \r
- // merge values\r
- foreach ($data as $optionName => $option) {\r
- if (count($option['values']) == 1) {\r
- $result = $option['values'][0];\r
- }\r
- else {\r
- $typeObj = $this->getTypeObject($option['type']);\r
- $result = $typeObj->merge($option['values']);\r
- }\r
- \r
- // unset false values\r
- if ($result === false) {\r
- unset($data[$optionName]);\r
- }\r
- else {\r
- $data[$optionName] = $result;\r
- }\r
- }\r
- }\r
- \r
- $data['groupIDs'] = $groupIDs;\r
- return $data;\r
- }\r
- \r
- /**\r
- * Returns an object of the requested group option type.\r
- * \r
- * @param string $type\r
- * @return GroupOptionType\r
- */\r
- protected function getTypeObject($type) {\r
- if (!isset($this->typeObjects[$type])) {\r
- $className = 'wcf\system\option\group\GroupOptionType'.ucfirst($type);\r
- \r
- // validate class\r
- if (!class_exists($className)) {\r
- throw new SystemException("unable to find class '".$className."'", 11001);\r
- }\r
- if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\group\GroupOptionType')) {\r
- throw new SystemException("'".$className."' should implement GroupOptionType");\r
- }\r
- \r
- // create instance\r
- $this->typeObjects[$type] = new $className();\r
- }\r
- \r
- return $this->typeObjects[$type];\r
- }\r
-}
--- /dev/null
+<?php\r
+namespace wcf\system\cache\builder;\r
+use wcf\data\acp\menu\item\ACPMenuItem;\r
+use wcf\system\database\util\PreparedStatementConditionBuilder;\r
+use wcf\system\WCF;\r
+\r
+/**\r
+ * Caches the acp menu items tree.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderACPMenu implements CacheBuilder {\r
+ protected $optionCategoryStructure = array();\r
+\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ list($cache, $packageID) = explode('-', $cacheResource['cache']); \r
+ $data = array();\r
+\r
+ // get all menu items and filter menu items with low priority\r
+ $sql = "SELECT menuItem, menuItemID\r
+ FROM wcf".WCF_N."_acp_menu_item menu_item\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (menu_item.packageID = package_dependency.dependency)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ $itemIDs = array();\r
+ while ($row = $statement->fetchArray()) {\r
+ $itemIDs[$row['menuItem']] = $row['menuItemID'];\r
+ }\r
+ \r
+ if (count($itemIDs) > 0) {\r
+ $conditions = new PreparedStatementConditionBuilder();\r
+ $conditions->add("menuItemID IN (?)", array($itemIDs));\r
+ \r
+ // get needed menu items and build item tree\r
+ $sql = "SELECT menu_item.packageID, menuItem, parentMenuItem,\r
+ menuItemLink, permissions, options, packageDir\r
+ FROM wcf".WCF_N."_acp_menu_item menu_item\r
+ LEFT JOIN wcf".WCF_N."_package package\r
+ ON (package.packageID = menu_item.packageID)\r
+ ".$conditions."\r
+ ORDER BY showOrder ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute($conditions->getParameters());\r
+ while ($row = $statement->fetchArray()) {\r
+ if (!isset($data[$row['parentMenuItem']])) {\r
+ $data[$row['parentMenuItem']] = array();\r
+ }\r
+ \r
+ $data[$row['parentMenuItem']][] = new ACPMenuItem(null, $row);\r
+ }\r
+ }\r
+ \r
+ // get top option categories\r
+ $optionCategories = $this->getTopOptionCategories($packageID);\r
+ if (count($optionCategories) > 0) {\r
+ if (!isset($data['wcf.acp.menu.link.option.category'])) {\r
+ $data['wcf.acp.menu.link.option.category'] = array();\r
+ }\r
+ \r
+ // get option category data\r
+ $conditions = new PreparedStatementConditionBuilder();\r
+ $conditions->add("categoryID IN (?)", array($optionCategories));\r
+ \r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_option_category\r
+ ".$conditions."\r
+ ORDER BY showOrder ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute($conditions->getParameters());\r
+ while ($row = $statement->fetchArray()) {\r
+ $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array(\r
+ 'packageID' => $packageID,\r
+ 'menuItem' => 'wcf.acp.option.category.'.$row['categoryName'],\r
+ 'parentMenuItem' => 'wcf.acp.menu.link.option.category',\r
+ 'menuItemLink' => 'index.php?form=Option&categoryID='.$row['categoryID'],\r
+ 'packageDir' => '',\r
+ 'permissions' => $row['permissions'],\r
+ 'options' => $row['options']\r
+ ));\r
+ }\r
+ }\r
+ \r
+ return $data;\r
+ }\r
+ \r
+ protected function getTopOptionCategories($packageID) {\r
+ // get all option categories and filter categories with low priority\r
+ $sql = "SELECT categoryName, categoryID \r
+ FROM wcf".WCF_N."_option_category option_category\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (package_dependency.dependency = option_category.packageID)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ $optionCategories = array();\r
+ while ($row = $statement->fetchArray()) {\r
+ $optionCategories[$row['categoryName']] = $row['categoryID'];\r
+ }\r
+ \r
+ $conditions = new PreparedStatementConditionBuilder();\r
+ $conditions->add("categoryID IN (?)", array($optionCategories));\r
+ $statementParameters = $conditions->getParameters();\r
+ array_unshift($statementParameters, $packageID);\r
+ \r
+ $sql = "SELECT categoryID, parentCategoryName, categoryName,\r
+ (\r
+ SELECT COUNT(*) FROM wcf".WCF_N."_option WHERE categoryName = category.categoryName AND packageID IN (\r
+ SELECT dependency FROM wcf".WCF_N."_package_dependency WHERE packageID = ?\r
+ )\r
+ ) AS count\r
+ FROM wcf".WCF_N."_option_category category\r
+ ".$conditions;\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute($statementParameters);\r
+ while ($row = $statement->fetchArray()) {\r
+ if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) $this->optionCategoryStructure[$row['parentCategoryName']] = array();\r
+ $this->optionCategoryStructure[$row['parentCategoryName']][] = $row;\r
+ }\r
+ \r
+ $topOptionCategories = array();\r
+ foreach ($this->optionCategoryStructure[''] as $optionCategory) {\r
+ $count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']);\r
+ if ($count > 0) $topOptionCategories[] = $optionCategory['categoryID'];\r
+ }\r
+ \r
+ return $topOptionCategories;\r
+ }\r
+ \r
+ protected function countOptions($parentCategoryName) {\r
+ if (!isset($this->optionCategoryStructure[$parentCategoryName])) return 0;\r
+ \r
+ $count = 0;\r
+ foreach ($this->optionCategoryStructure[$parentCategoryName] as $optionCategory) {\r
+ $count += $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']);\r
+ }\r
+ \r
+ return $count;\r
+ }\r
+}\r
--- /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\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
+ * @category Community Framework
+ */
+class CacheBuilderApplication implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\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
+ * @category Community Framework
+ */
+class CacheBuilderCleanupAdapter implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\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
+ * @category Community Framework
+ */
+class CacheBuilderCoreObject implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\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
+ * @category Community Framework
+ */
+class CacheBuilderCronjob implements CacheBuilder {
+ /**
+ * @see CacheBuilder::getData()
+ */
+ public function getData($cacheResource) {
+ // get next execution time
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->add("packageID IN (?)", array(PackageDependencyHandler::getDependenciesString()));
+
+ $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\r
+namespace wcf\system\cache\builder;\r
+use wcf\system\event\listener\EventHandler;\r
+use wcf\system\WCF;\r
+use wcf\util\StringUtil;\r
+\r
+/**\r
+ * Caches the event listeners.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderEventListener implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ list($cache, $packageID) = explode('-', $cacheResource['cache']); \r
+ $data = array(\r
+ 'actions' => array('user' => array(), 'admin' => array()),\r
+ 'inheritedActions' => array('user' => array(), 'admin' => array())\r
+ );\r
+ \r
+ // get all listeners and filter options with low priority\r
+ $sql = "SELECT event_listener.*\r
+ FROM wcf".WCF_N."_event_listener event_listener\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (package_dependency.dependency = event_listener.packageID)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ while ($row = $statement->fetchArray()) {\r
+ // distinguish between inherited actions and non-inherited actions\r
+ if (!$row['inherit']) {\r
+ $data['actions'][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;\r
+ }\r
+ else {\r
+ if (!isset($data['inheritedActions'][$row['eventClassName']])) $data['inheritedActions'][$row['eventClassName']] = array();\r
+ $data['inheritedActions'][$row['eventClassName']][$row['eventName']][] = $row; \r
+ }\r
+ }\r
+ \r
+ // sort data by nice value and class name\r
+ foreach ($data['actions'] as $key => $listeners) {\r
+ uasort($data['actions'][$key], array(__CLASS__, 'sortListeners'));\r
+ }\r
+ \r
+ foreach ($data['inheritedActions'] as $class => $listeners) {\r
+ foreach ($listeners as $key => $val) {\r
+ uasort($data['inheritedActions'][$class][$key], array(__CLASS__, 'sortListeners'));\r
+ }\r
+ }\r
+ \r
+ return $data;\r
+ }\r
+ \r
+ /**\r
+ * Sorts the event listeners alphabetically.\r
+ */\r
+ public static function sortListeners($listenerA, $listenerB) {\r
+ if ($listenerA['niceValue'] < $listenerB['niceValue']) {\r
+ return -1;\r
+ }\r
+ else if ($listenerA['niceValue'] > $listenerB['niceValue']) {\r
+ return 1;\r
+ }\r
+ else {\r
+ return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']);\r
+ } \r
+ }\r
+}\r
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\package\Package;
+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
+ * @category Community Framework
+ */
+class CacheBuilderIcon implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\r
+namespace wcf\system\cache\builder;\r
+use wcf\system\WCF;\r
+\r
+/**\r
+ * Caches languages, language to packages relation, package to languages relation\r
+ * and the id of the default language. \r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderLanguage implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $languageToPackages = array();\r
+ $data = array(\r
+ 'codes' => array(),\r
+ 'languages' => array(), \r
+ 'packages' => array(),\r
+ 'default' => 0,\r
+ 'categories' => array()\r
+ );\r
+ \r
+ // get language to packages\r
+ $sql = "SELECT package.languageID, package.packageID\r
+ FROM wcf".WCF_N."_language_to_package package\r
+ LEFT JOIN wcf".WCF_N."_language language\r
+ ON (language.languageID = package.languageID)\r
+ ORDER BY language.isDefault DESC,\r
+ language.languageCode ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute();\r
+ while ($row = $statement->fetchArray()) {\r
+ // package to languages\r
+ if (!isset($data['packages'][$row['packageID']])) {\r
+ $data['packages'][$row['packageID']] = array();\r
+ }\r
+ $data['packages'][$row['packageID']][] = $row['languageID'];\r
+ \r
+ // language to packages\r
+ if (!isset($languageToPackages[$row['languageID']])) {\r
+ $languageToPackages[$row['languageID']] = array();\r
+ }\r
+ $languageToPackages[$row['languageID']][] = $row['packageID'];\r
+ }\r
+ \r
+ // get languages\r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_language";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute();\r
+ while ($row = $statement->fetchArray()) {\r
+ // language data\r
+ $data['languages'][$row['languageID']] = $row;\r
+ \r
+ // language to packages\r
+ if (!isset($languageToPackages[$row['languageID']])) {\r
+ $languageToPackages[$row['languageID']] = array();\r
+ }\r
+ $data['languages'][$row['languageID']]['packages'] = $languageToPackages[$row['languageID']];\r
+ \r
+ // default language\r
+ if ($row['isDefault']) {\r
+ $data['default'] = $row['languageID'];\r
+ }\r
+ \r
+ // language code to language id\r
+ $data['codes'][$row['languageCode']] = $row['languageID'];\r
+ }\r
+ \r
+ // get language categories\r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_language_category";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute();\r
+ while ($row = $statement->fetchArray()) {\r
+ // package to languages\r
+ $data['categories'][$row['languageCategory']] = $row;\r
+ }\r
+\r
+ return $data;\r
+ }\r
+}\r
--- /dev/null
+<?php\r
+namespace wcf\system\cache\builder;\r
+use wcf\data\option\category\OptionCategory;\r
+use wcf\data\option\Option;\r
+use wcf\system\database\util\PreparedStatementConditionBuilder;\r
+use wcf\system\WCF;\r
+\r
+/**\r
+ * Caches the options and option categories\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderOption implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $information = explode('-', $cacheResource['cache']);\r
+ if (count($information) == 3) {\r
+ $type = $information[0].'_';\r
+ $packageID = $information[2];\r
+ }\r
+ else {\r
+ $type = '';\r
+ $packageID = $information[1];\r
+ }\r
+ \r
+ $data = array(\r
+ 'categories' => array(),\r
+ 'options' => array(),\r
+ 'categoryStructure' => array(),\r
+ 'optionToCategories' => array()\r
+ );\r
+\r
+ // option categories\r
+ // get all option categories and sort categories by priority\r
+ $sql = "SELECT categoryName, categoryID \r
+ FROM wcf".WCF_N."_".$type."option_category option_category\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (package_dependency.dependency = option_category.packageID)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ $optionCategories = array();\r
+ while ($row = $statement->fetchArray()) {\r
+ $optionCategories[$row['categoryName']] = $row['categoryID'];\r
+ }\r
+ \r
+ if (count($optionCategories) > 0) {\r
+ // get needed option categories\r
+ $conditions = new PreparedStatementConditionBuilder();\r
+ $conditions->add("categoryID IN (?)", array($optionCategories));\r
+ \r
+ $sql = "SELECT option_category.*, package.packageDir\r
+ FROM wcf".WCF_N."_".$type."option_category option_category\r
+ LEFT JOIN wcf".WCF_N."_package package\r
+ ON (package.packageID = option_category.packageID)\r
+ ".$conditions."\r
+ ORDER BY showOrder ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute($conditions->getParameters());\r
+ while ($row = $statement->fetchArray()) {\r
+ $data['categories'][$row['categoryName']] = new OptionCategory(null, $row);\r
+ if (!isset($data['categoryStructure'][$row['parentCategoryName']])) {\r
+ $data['categoryStructure'][$row['parentCategoryName']] = array();\r
+ }\r
+ \r
+ $data['categoryStructure'][$row['parentCategoryName']][] = $row['categoryName'];\r
+ }\r
+ }\r
+ \r
+ // options\r
+ // get all options and sort options by priority\r
+ $optionIDs = array();\r
+ $sql = "SELECT optionName, optionID \r
+ FROM wcf".WCF_N."_".$type."option option_table\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (package_dependency.dependency = option_table.packageID)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ while ($row = $statement->fetchArray()) {\r
+ $optionIDs[$row['optionName']] = $row['optionID'];\r
+ }\r
+ \r
+ if (count($optionIDs) > 0) {\r
+ // get needed options\r
+ $conditions = new PreparedStatementConditionBuilder();\r
+ $conditions->add("optionID IN (?)", array($optionIDs));\r
+ \r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_".$type."option\r
+ ".$conditions."\r
+ ORDER BY showOrder ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute($conditions->getParameters());\r
+ while ($row = $statement->fetchArray()) {\r
+ $data['options'][$row['optionName']] = new Option(null, $row);\r
+ if (!isset($data['optionToCategories'][$row['categoryName']])) {\r
+ $data['optionToCategories'][$row['categoryName']] = array();\r
+ }\r
+ \r
+ $data['optionToCategories'][$row['categoryName']][] = $row['optionName'];\r
+ }\r
+ }\r
+ \r
+ return $data;\r
+ }\r
+}\r
--- /dev/null
+<?php\r
+namespace wcf\system\cache\builder;\r
+use wcf\data\package\PackageList;\r
+use wcf\system\WCF;\r
+\r
+/**\r
+ * Caches all registered packages.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderPackage implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $packageList = new PackageList();\r
+ $packageList->sqlLimit = 0;\r
+ $packageList->readObjects();\r
+ \r
+ return $packageList->getObjects();\r
+ }\r
+}\r
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+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
+ * @category Community Framework
+ */
+class CacheBuilderPackageDependency implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\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
+ * @category Community Framework
+ */
+class CacheBuilderPageMenu implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\r
+namespace wcf\system\cache\builder;\r
+use wcf\data\spider\SpiderList;\r
+\r
+/**\r
+ * Caches the list of search engine spiders.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderSpider implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $spiderList = new SpiderList();\r
+ $spiderList->sqlOrderBy = "spider.spiderID ASC";\r
+ $spiderList->sqlLimit = 0;\r
+ $spiderList->readObjects();\r
+ \r
+ return $spiderList->getObjects();\r
+ }\r
+}\r
--- /dev/null
+<?php\r
+namespace wcf\system\cache\builder;\r
+use wcf\data\style\Style;\r
+use wcf\system\WCF;\r
+\r
+/**\r
+ * Caches the styles and style variables.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderStyle implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $data = array('default' => 0, 'styles' => array(), 'packages' => array());\r
+ \r
+ // get all styles\r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_style\r
+ ORDER BY styleName ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute();\r
+ while ($row = $statement->fetchArray()) {\r
+ if ($row['isDefault']) $data['default'] = $row['styleID'];\r
+ $row['variables'] = array();\r
+ \r
+ // get variable\r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_style_variable\r
+ WHERE styleID = ?";\r
+ $statement2 = WCF::getDB()->prepareStatement($sql);\r
+ $statement2->execute(array($row['styleID']));\r
+ while ($row = $statement2->fetchArray()) {\r
+ \r
+ $row['variables'][$row2['variableName']] = $row2['variableValue'];\r
+ }\r
+ \r
+ $data['styles'][$row['styleID']] = new Style(null, $row);\r
+ }\r
+ \r
+ // get style to packages\r
+ $sql = "SELECT *\r
+ FROM wcf".WCF_N."_style_to_package\r
+ ORDER BY packageID ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute();\r
+ while ($row = $statement->fetchArray()) {\r
+ \r
+ if (!isset($data['packages'][$row['packageID']])) {\r
+ $data['packages'][$row['packageID']] = array('default' => 0, 'disabled' => array());\r
+ }\r
+ \r
+ if ($row['isDefault']) {\r
+ $data['packages'][$row['packageID']]['default'] = $row['styleID'];\r
+ }\r
+ $data['packages'][$row['packageID']]['disabled'][$row['styleID']] = $row['disabled'];\r
+ }\r
+ \r
+ return $data;\r
+ }\r
+}\r
--- /dev/null
+<?php\r
+namespace wcf\system\cache\builder;\r
+use wcf\system\WCF;\r
+\r
+/**\r
+ * Caches the structure of templates.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderTemplate implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $information = explode('-', $cacheResource['cache']);\r
+ if (count($information) == 3) {\r
+ $prefix = $information[0].'_';\r
+ $packageID = $information[2];\r
+ }\r
+ else {\r
+ $prefix = '';\r
+ $packageID = $information[1];\r
+ }\r
+ \r
+ $data = array();\r
+ \r
+ // get package directory for given package id\r
+ $sql = "SELECT packageDir\r
+ FROM wcf".WCF_N."_package\r
+ WHERE packageID = ?";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ $row = $statement->fetchArray();\r
+ \r
+ // get all templates and filter options with low priority\r
+ $sql = "SELECT templateName, template.packageID \r
+ FROM wcf".WCF_N."_".$prefix."template template\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (package_dependency.dependency = template.packageID)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority DESC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ while ($row = $statement->fetchArray()) {\r
+ if (!isset($data[$row['templateName']]) || $packageID == $row['packageID']) {\r
+ $data[$row['templateName']] = $row['packageID'];\r
+ }\r
+ }\r
+ \r
+ return $data;\r
+ }\r
+}\r
--- /dev/null
+<?php
+namespace wcf\system\cache\builder;
+use wcf\data\template\group\TemplateGroupList;
+
+/**
+ * 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
+ * @category Community Framework
+ */
+class CacheBuilderTemplateGroup implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\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
+ * @category Community Framework
+ */
+class CacheBuilderTemplateListener implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\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
+ * @category Community Framework
+ */
+class CacheBuilderTemplateListenerCode implements CacheBuilder {
+ /**
+ * @see CacheBuilder::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\r
+namespace wcf\system\cache\builder;\r
+use wcf\data\user\group\UserGroupList;\r
+\r
+/**\r
+ * Caches all user groups.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderUserGroup implements CacheBuilder {\r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ $data = array('types' => array(), 'groups' => array());\r
+\r
+ // get all user groups\r
+ $groupList = new UserGroupList();\r
+ $groupList->sqlOrderBy = "user_group.groupName";\r
+ $groupList->sqlLimit = 0;\r
+ $groupList->readObjects();\r
+ $groups = $groupList->getObjects();\r
+ \r
+ foreach ($groups as $group) {\r
+ if (!isset($data['types'][$group->groupType])) {\r
+ $data['types'][$group->groupType] = array();\r
+ }\r
+ \r
+ $data['types'][$group->groupType][] = $group->groupID;\r
+ $data['groups'][$group->groupID] = $group;\r
+ }\r
+ \r
+ return $data;\r
+ }\r
+}\r
--- /dev/null
+<?php\r
+namespace wcf\system\cache\builder;\r
+use wcf\system\database\util\PreparedStatementConditionBuilder;\r
+use wcf\system\exception\SystemException;\r
+use wcf\system\WCF;\r
+use wcf\util\ClassUtil;\r
+\r
+/**\r
+ * Caches the merged group options of a group combination.\r
+ * \r
+ * @author Marcel Werk\r
+ * @copyright 2001-2011 WoltLab GmbH\r
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>\r
+ * @package com.woltlab.wcf\r
+ * @subpackage system.cache\r
+ * @category Community Framework\r
+ */\r
+class CacheBuilderUserGroupPermission implements CacheBuilder {\r
+ protected $typeObjects = array();\r
+ \r
+ /**\r
+ * @see CacheBuilder::getData()\r
+ */\r
+ public function getData($cacheResource) {\r
+ list($cache, $packageID, $groupIDs) = explode('-', $cacheResource['cache']);\r
+ $data = array();\r
+ \r
+ // get all options and filter options with low priority\r
+ if ($packageID == 0) {\r
+ // during the installation of the package wcf\r
+ $sql = "SELECT optionName, optionID \r
+ FROM wcf".WCF_N."_user_group_option\r
+ WHERE packageID IS NULL";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute();\r
+ }\r
+ else {\r
+ $sql = "SELECT optionName, optionID \r
+ FROM wcf".WCF_N."_user_group_option option_table\r
+ LEFT JOIN wcf".WCF_N."_package_dependency package_dependency\r
+ ON (package_dependency.dependency = option_table.packageID)\r
+ WHERE package_dependency.packageID = ?\r
+ ORDER BY package_dependency.priority ASC";\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute(array($packageID));\r
+ }\r
+ \r
+ $options = array();\r
+ while ($row = $statement->fetchArray()) {\r
+ $options[$row['optionName']] = $row['optionID'];\r
+ }\r
+ \r
+ if (count($options) > 0) {\r
+ // get needed options\r
+ $conditions = new PreparedStatementConditionBuilder();\r
+ $conditions->add("option_value.groupID IN (?)", array(explode(',', $groupIDs)));\r
+ $conditions->add("option_value.optionID IN (?)", array($options));\r
+ \r
+ $sql = "SELECT option_table.optionName, option_table.optionType, option_value.optionValue\r
+ FROM wcf".WCF_N."_user_group_option_value option_value\r
+ LEFT JOIN wcf".WCF_N."_user_group_option option_table\r
+ ON (option_table.optionID = option_value.optionID)\r
+ ".$conditions;\r
+ $statement = WCF::getDB()->prepareStatement($sql);\r
+ $statement->execute($conditions->getParameters());\r
+ while ($row = $statement->fetchArray()) {\r
+ if (!isset($data[$row['optionName']])) {\r
+ $data[$row['optionName']] = array('type' => $row['optionType'], 'values' => array());\r
+ }\r
+ \r
+ $data[$row['optionName']]['values'][] = $row['optionValue'];\r
+ }\r
+ \r
+ // merge values\r
+ foreach ($data as $optionName => $option) {\r
+ if (count($option['values']) == 1) {\r
+ $result = $option['values'][0];\r
+ }\r
+ else {\r
+ $typeObj = $this->getTypeObject($option['type']);\r
+ $result = $typeObj->merge($option['values']);\r
+ }\r
+ \r
+ // unset false values\r
+ if ($result === false) {\r
+ unset($data[$optionName]);\r
+ }\r
+ else {\r
+ $data[$optionName] = $result;\r
+ }\r
+ }\r
+ }\r
+ \r
+ $data['groupIDs'] = $groupIDs;\r
+ return $data;\r
+ }\r
+ \r
+ /**\r
+ * Returns an object of the requested group option type.\r
+ * \r
+ * @param string $type\r
+ * @return GroupOptionType\r
+ */\r
+ protected function getTypeObject($type) {\r
+ if (!isset($this->typeObjects[$type])) {\r
+ $className = 'wcf\system\option\group\GroupOptionType'.ucfirst($type);\r
+ \r
+ // validate class\r
+ if (!class_exists($className)) {\r
+ throw new SystemException("unable to find class '".$className."'", 11001);\r
+ }\r
+ if (!ClassUtil::isInstanceOf($className, 'wcf\system\option\group\GroupOptionType')) {\r
+ throw new SystemException("'".$className."' should implement GroupOptionType");\r
+ }\r
+ \r
+ // create instance\r
+ $this->typeObjects[$type] = new $className();\r
+ }\r
+ \r
+ return $this->typeObjects[$type];\r
+ }\r
+}\r
CacheHandler::getInstance()->addResource(
'cleanupAdapter-'.PACKAGE_ID,
WCF_DIR.'cache/cache.cleanupAdapter.php',
- 'wcf\system\cache\CacheBuilderCleanupAdapter'
+ 'wcf\system\cache\builder\CacheBuilderCleanupAdapter'
);
$this->cache = CacheHandler::getInstance()->get('cleanupAdapter');
*/
protected static function getCache() {
$cacheName = 'cronjobs-'.PACKAGE_ID;
- CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\CacheBuilderCronjob');
+ CacheHandler::getInstance()->addResource($cacheName, WCF_DIR.'cache/cache.'.$cacheName.'.php', 'wcf\system\cache\builder\CacheBuilderCronjob');
return CacheHandler::getInstance()->get($cacheName);
}
* Loads all registered actions of the active package.\r
*/\r
protected function loadActions() {\r
- CacheHandler::getInstance()->addResource('eventListener-'.PACKAGE_ID, WCF_DIR.'cache/cache.eventListener-'.PACKAGE_ID.'.php', 'wcf\system\cache\CacheBuilderEventListener');\r
+ CacheHandler::getInstance()->addResource('eventListener-'.PACKAGE_ID, WCF_DIR.'cache/cache.eventListener-'.PACKAGE_ID.'.php', 'wcf\system\cache\builder\CacheBuilderEventListener');\r
$cache = CacheHandler::getInstance()->get('eventListener-'.PACKAGE_ID);\r
if (isset($cache['actions'])) $this->actions = $cache['actions'];\r
if (isset($cache['inheritedActions'])) $this->inheritedActions = $cache['inheritedActions'];\r
public static function generateKey($className, $eventName) {\r
return $eventName.'@'.$className;\r
}\r
-}
+}\r
CacheHandler::getInstance()->addResource(
'languages',
WCF_DIR.'cache/cache.languages.php',
- 'wcf\system\cache\CacheBuilderLanguage'
+ 'wcf\system\cache\builder\CacheBuilderLanguage'
);
self::$cache = CacheHandler::getInstance()->get('languages');
return;\r
}\r
\r
- CacheHandler::getInstance()->addResource('menu-'.PACKAGE_ID, WCF_DIR.'cache/cache.menu-'.PACKAGE_ID.'.php', 'wcf\system\cache\CacheBuilderACPMenu');\r
+ CacheHandler::getInstance()->addResource('menu-'.PACKAGE_ID, WCF_DIR.'cache/cache.menu-'.PACKAGE_ID.'.php', 'wcf\system\cache\builder\CacheBuilderACPMenu');\r
$this->menuItems = CacheHandler::getInstance()->get('menu-'.PACKAGE_ID);\r
}\r
-}
+}\r
parent::loadCache();\r
\r
// get cache\r
- CacheHandler::getInstance()->addResource('pageMenu-'.PACKAGE_ID, WCF_DIR.'cache/cache.pageMenu-'.PACKAGE_ID.'.php', 'wcf\system\cache\CacheBuilderPageMenu');\r
+ CacheHandler::getInstance()->addResource('pageMenu-'.PACKAGE_ID, WCF_DIR.'cache/cache.pageMenu-'.PACKAGE_ID.'.php', 'wcf\system\cache\builder\CacheBuilderPageMenu');\r
$this->menuItems = CacheHandler::getInstance()->get('pageMenu-'.PACKAGE_ID);\r
}\r
\r
\r
return $item->getProvider()->isVisible();\r
}\r
-}
+}\r
CacheHandler::getInstance()->addResource(
'packageDependencies-'.PACKAGE_ID,
WCF_DIR.'cache/cache.packageDependencies-'.PACKAGE_ID.'.php',
- 'wcf\system\cache\CacheBuilderPackageDependency'
+ 'wcf\system\cache\builder\CacheBuilderPackageDependency'
);
self::$packageDependencyCache = CacheHandler::getInstance()->get('packageDependencies-'.PACKAGE_ID);
CacheHandler::getInstance()->addResource(
'groups-'.PACKAGE_ID.'-'.$groups,
WCF_DIR.'cache/cache.groups-'.PACKAGE_ID.'-'.$groupsFileName.'.php',
- 'wcf\system\cache\CacheBuilderUserGroupPermission'
+ 'wcf\system\cache\builder\CacheBuilderUserGroupPermission'
);
// get group data from cache
*/
protected function init() {
// load cache
- CacheHandler::getInstance()->addResource('styles', WCF_DIR.'cache/cache.styles.php', 'wcf\system\cache\CacheBuilderStyle');
+ CacheHandler::getInstance()->addResource('styles', WCF_DIR.'cache/cache.styles.php', 'wcf\system\cache\builder\CacheBuilderStyle');
$this->cache = CacheHandler::getInstance()->get('styles');
}
* Loads cached template group information.
*/
protected function loadTemplateGroupCache() {
- CacheHandler::getInstance()->addResource('templateGroups', WCF_DIR.'cache/cache.templateGroups.php', 'wcf\system\cache\CacheBuilderTemplateGroup');
+ CacheHandler::getInstance()->addResource('templateGroups', WCF_DIR.'cache/cache.templateGroups.php', 'wcf\system\cache\builder\CacheBuilderTemplateGroup');
$this->templateGroupCache = CacheHandler::getInstance()->get('templateGroups');
}
CacheHandler::getInstance()->addResource(
$cacheName,
WCF_DIR.'cache/cache.'.$cacheName.'.php',
- 'wcf\system\cache\CacheBuilderTemplateListener'
+ 'wcf\system\cache\builder\CacheBuilderTemplateListener'
);
$this->templateListeners = CacheHandler::getInstance()->get($cacheName);
CacheHandler::getInstance()->addResource(
$cacheName,
WCF_DIR.'cache/templateListener/'.$cacheName.'.php',
- 'wcf\system\cache\CacheBuilderTemplateListenerCode'
+ 'wcf\system\cache\builder\CacheBuilderTemplateListenerCode'
);
$this->templateListeners[$templateName] = CacheHandler::getInstance()->get($cacheName);