CacheHandler::getInstance()->clear(WCF_DIR.'cache', 'cache.option.php');
// reset options.inc.php files
- $sql = "SELECT package, packageID, packageDir
- FROM wcf".WCF_N."_package
- WHERE isApplication = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(1));
- while ($row = $statement->fetchArray()) {
- if ($row['package'] == 'com.woltlab.wcf') $packageDir = WCF_DIR;
- else $packageDir = FileUtil::getRealPath(WCF_DIR.$row['packageDir']);
- $filename = FileUtil::addTrailingSlash($packageDir).self::FILENAME;
- if (file_exists($filename)) {
- if (!@touch($filename, 1)) {
- if (!@unlink($filename)) {
- self::rebuildFile($filename, $row['packageID']);
- }
- }
- }
- }
+ self::rebuild();
}
/**
* Rebuilds the option file.
- *
- * @param string $filename
- * @param integer $packageID
*/
- public static function rebuildFile($filename, $packageID) {
+ public static function rebuild() {
$buffer = '';
// file header
$buffer .= "<?php\n/**\n* generated at ".gmdate('r')."\n*/\n";
// get all options
- $options = Option::getOptions($packageID);
+ $options = Option::getOptions();
foreach ($options as $optionName => $option) {
$buffer .= "if (!defined('".$optionName."')) define('".$optionName."', ".(($option->optionType == 'boolean' || $option->optionType == 'integer') ? intval($option->optionValue) : "'".addcslashes($option->optionValue, "'\\")."'").");\n";
}
unset($options);
// file footer
- $buffer .= "?>";
+ $buffer .= "\n";
// open file
- $file = new File($filename);
+ $file = new File(WCF_DIR.'options.inc.php');
// write buffer
$file->write($buffer);
- unset($buffer);
// close file
$file->close();
}
/**
- * Includes the options file.
- * If the option file doesn't exist, the rebuild of it is started.
- *
- * @param string $filename
+ * Loads the options file, automatically created if not exists.
*/
- protected function loadOptions($filename = null, $packageID = 1) {
- if ($filename === null) $filename = WCF_DIR.'options.inc.php';
+ protected function loadOptions() {
+ $filename = WCF_DIR.'options.inc.php';
// create options file if doesn't exist
if (!file_exists($filename) || filemtime($filename) <= 1) {
- \wcf\data\option\OptionEditor::rebuildFile($filename, $packageID);
+ \wcf\data\option\OptionEditor::rebuild();
}
require_once($filename);
}
throw new SystemException('Unable to load configuration for '.$package->package);
}
- // load options
- $this->loadOptions($packageDir.'options.inc.php', $application->packageID);
-
// start application if not within ACP
if (!class_exists('wcf\system\WCFACP', false)) {
// add template path and abbreviation
// delete categories
$sql = "DELETE FROM wcf".WCF_N."_".$this->tableName."_category
WHERE categoryName = ?
- AND packageID = ?";
+ AND packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($categories as $category) {
<?php
namespace wcf\system\request;
+use wcf\util\HeaderUtil;
+
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\SystemException;
use wcf\system\SingletonFactory;
$routeData = RouteHandler::getInstance()->getRouteData();
$controller = $routeData['controller'];
+ /*
+ * @todo redirect to landing page once page menu items support controller based URLs (see https://github.com/WoltLab/WCF/issues/998)
+ *
+ if (RouteHandler::getInstance()->isDefaultController()) {
+ HeaderUtil::redirect(..., true);
+ exit;
+ }
+ */
+
// validate class name
if (!preg_match('~^[a-z0-9_]+$~i', $controller)) {
throw new SystemException("Illegal class name '".$controller."'");
if (isset($this->parameterOptions[$schemaPart])) {
// default value is provided
if ($this->parameterOptions[$schemaPart]['default'] !== null) {
+ if ($schemaPart == 'controller') {
+ $data['isDefaultController'] = true;
+ }
+
$data[$schemaPart] = $this->parameterOptions[$schemaPart]['default'];
continue;
}
}
}
+ if (!isset($data['isDefaultController'])) {
+ $data['isDefaultController'] = true;
+ }
+
$this->routeData = $data;
// adds route controller if given
*/
protected static $secure = null;
+ /**
+ * true, if default controller is used (support for custom landing page)
+ * @var boolean
+ */
+ protected $isDefaultController = false;
+
/**
* list of available routes
* @var array<wcf\system\request\Route>
/**
* Adds default routes.
+ *
+ * @todo add support for custom default controllers (see https://github.com/WoltLab/WCF/issues/1000)
*/
protected function addDefaultRoutes() {
$acpRoute = new Route('ACP_default', true);
if ($route->matches($pathInfo)) {
$this->routeData = $route->getRouteData();
+
+ $this->isDefaultController = $this->routeData['isDefaultController'];
+ unset($this->routeData['isDefaultController']);
+
$this->registerRouteData();
return true;
}
return false;
}
+ /**
+ * Returns true, if route uses default controller.
+ *
+ * @return boolean
+ */
+ public function isDefaultController() {
+ return $this->isDefaultController;
+ }
+
/**
* Returns parsed route data
*