Commit 9afd9e89 authored by fettesvieh's avatar fettesvieh

One major change to the URL schema

parent df25c557
......@@ -6,5 +6,5 @@
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?stm=$1 [L,QSA]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
\ No newline at end of file
......@@ -27,7 +27,7 @@ class modules
*
* @var string
*/
public $stm = '';
public $query = '';
/**
* Zerlegt u.a. die übergebenen Parameter in der URI in ihre Bestandteile
......@@ -36,41 +36,40 @@ class modules
*/
function __construct()
{
if (!empty($_GET['stm'])) {
$this->stm = $_GET['stm'];
}
$this->query = str_replace(PHP_SELF, '', htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES));
if (!empty($_GET['stm']) && strpos($_GET['stm'], 'acp/') !== false) {
if (!empty($this->query) && preg_match('/^(\/acp)/', $this->query)) {
// Definieren, dass man sich im Administrationsbereich befindet
define('IN_ADM', true);
// "acp/" entfernen
$_GET['stm'] = substr($_GET['stm'], 4, strlen($_GET['stm']));
$this->query = substr($this->query, 5);
} else {
// Definieren, dass man sich im Frontend befindet
define('IN_ACP3', true);
$this->query = substr($this->query, 1);
}
$stm = !empty($_GET['stm']) ? explode('/', $_GET['stm']) : 0;
$query = !empty($this->query) ? explode('/', $this->query) : 0;
$defaultModule = defined('IN_ADM') ? 'acp' : 'news';
$defaultPage = defined('IN_ADM') ? 'adm_list' : 'list';
$this->mod = !empty($stm[0]) ? $stm[0] : $defaultModule;
$this->page = !empty($stm[1]) ? $stm[1] : $defaultPage;
$this->mod = !empty($query[0]) ? $query[0] : $defaultModule;
$this->page = !empty($query[1]) ? $query[1] : $defaultPage;
if (!empty($_POST['cat']))
$this->params['cat'] = $_POST['cat'];
if (!empty($_POST['action']))
$this->params['action'] = $_POST['action'];
if (!empty($stm[2])) {
$c_stm = count($stm);
if (!empty($query[2])) {
$c_query = count($query);
for ($i = 2; $i < $c_stm; $i++) {
if (!empty($stm[$i])) {
if (!defined('POS') && preg_match('/^(pos_(\d+))$/', $stm[$i])) {
define('POS', substr($stm[$i], 4));
} elseif (preg_match('/^(([a-z0-9-]+)_(.+))$/', $stm[$i])) {
$pos = strpos($stm[$i], '_');
$this->params[substr($stm[$i], 0, $pos)] = substr($stm[$i], $pos + 1, strlen($stm[$i]));
for ($i = 2; $i < $c_query; $i++) {
if (!empty($query[$i])) {
if (!defined('POS') && preg_match('/^(pos_(\d+))$/', $query[$i])) {
define('POS', substr($query[$i], 4));
} elseif (preg_match('/^(([a-z0-9-]+)_(.+))$/', $query[$i])) {
$pos = strpos($query[$i], '_');
$this->params[substr($query[$i], 0, $pos)] = substr($query[$i], $pos + 1);
}
}
}
......
......@@ -17,7 +17,7 @@ require_once ACP3_ROOT . 'includes/globals.php';
// Konfiguration des ACP3 laden
require_once ACP3_ROOT . 'includes/config.php';
if (!defined('INSTALLED')) {
header('Location: installation/');
header('Location:' . ACP3_ROOT . 'installation/');
exit;
}
......@@ -26,15 +26,9 @@ function __autoload($className)
require_once ACP3_ROOT . 'includes/classes/' . $className . '.php';
}
// Klassen initialisieren
$db = new db;
$modules = new modules;
$validate = new validate;
$config = new config;
$cache = new cache;
$breadcrumb = new breadcrumb;
require_once ACP3_ROOT . 'includes/functions.php';
// Einige Konstanten definieren
define('PHP_SELF', htmlentities($_SERVER['SCRIPT_NAME']));
define('ROOT_DIR', substr(PHP_SELF, 0, strrpos(PHP_SELF, '/') + 1));
// Smarty einbinden
define('SMARTY_DIR', ACP3_ROOT . 'includes/smarty/');
......@@ -44,10 +38,6 @@ $tpl->template_dir = ACP3_ROOT . 'designs/' . CONFIG_DESIGN . '/';
$tpl->compile_dir = ACP3_ROOT . 'cache/';
// $tpl->compile_check = false;
// Einige Konstanten definieren
define('PHP_SELF', htmlentities($_SERVER['PHP_SELF']));
define('ROOT_DIR', substr(PHP_SELF, 0, strrpos(PHP_SELF, '/') + 1));
// Einige Template Variablen setzen
$tpl->assign('PHP_SELF', PHP_SELF);
$tpl->assign('REQUEST_URI', htmlentities($_SERVER['REQUEST_URI']));
......@@ -57,4 +47,14 @@ $tpl->assign('LANG', CONFIG_LANG);
$tpl->assign('PAGE_TITLE', CONFIG_TITLE);
$tpl->assign('KEYWORDS', CONFIG_META_KEYWORDS);
$tpl->assign('DESCRIPTION', CONFIG_META_DESCRIPTION);
// Klassen initialisieren
$db = new db;
$modules = new modules;
$validate = new validate;
$config = new config;
$cache = new cache;
$breadcrumb = new breadcrumb;
require_once ACP3_ROOT . 'includes/functions.php';
?>
\ No newline at end of file
......@@ -326,7 +326,7 @@ function timeZones($value)
*/
function uri($uri)
{
$pre = CONFIG_SEF == '0' ? PHP_SELF . '?stm=' : ROOT_DIR;
return $pre . $uri . (!preg_match('/\/$/', $uri) ? '/' : '');
$prefix = CONFIG_SEF == '0' ? PHP_SELF . '/' : ROOT_DIR;
return $prefix . $uri . (!preg_match('/\/$/', $uri) ? '/' : '');
}
?>
\ No newline at end of file
......@@ -96,7 +96,7 @@ function processNavbar()
case '2':
$link['href'] = uri($pages[$i]['uri']);
if (uri($modules->stm) == uri($pages[$i]['uri'])) {
if (uri($modules->query) == uri($pages[$i]['uri'])) {
$link['css'].= $selected;
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment