mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-04 15:47:33 +02:00
Starting edit mode using mypage?edit
instead of /edit/mypage
This commit is contained in:
@@ -7,7 +7,8 @@ function init() {
|
||||
// into $appPath example: '/slim-wiki'
|
||||
// and $requestPathArray example: array('myfolder', 'mypage')
|
||||
|
||||
$uriPathArray = explode("/", parse_url($_SERVER['REQUEST_URI'])['path']);
|
||||
$uriParts = parse_url($_SERVER['REQUEST_URI']);
|
||||
$uriPathArray = explode("/", $uriParts['path']);
|
||||
$scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME']));
|
||||
|
||||
$basePathArray = array();
|
||||
@@ -36,7 +37,7 @@ function init() {
|
||||
|
||||
require_once __DIR__ . '/server/logic/Main.php';
|
||||
|
||||
Main::get()->dispatch($baseUrl, $basePath, $requestPathArray);
|
||||
Main::get()->dispatch($baseUrl, $basePath, $requestPathArray, $uriParts['query']);
|
||||
}
|
||||
|
||||
init();
|
||||
|
@@ -46,7 +46,7 @@
|
||||
if ($item['active']) {
|
||||
echo $item['name'];
|
||||
} else {
|
||||
?><a href="<?php echo $data['basePath'] . ($data['isEditMode'] ? 'edit/' : '') . $item['path']; ?>"><?php echo $item['name']; ?></a><?php
|
||||
?><a href="<?php echo $data['basePath'] . $item['path'] . ($data['isEditMode'] ? '?edit' : ''); ?>"><?php echo $item['name']; ?></a><?php
|
||||
}
|
||||
$isFirst = false;
|
||||
}
|
||||
|
@@ -21,14 +21,15 @@ class Main {
|
||||
}
|
||||
|
||||
// Parameters:
|
||||
// - $baseUrl: E.g. 'http://localhost/slim-wiki/'
|
||||
// - $baseUrl: E.g. 'http://localhost/slim-wiki/?edit'
|
||||
// - $basePath: E.g. '/slim-wiki/'
|
||||
// - $requestPathArray: E.g. array('myfolder', 'mypage')
|
||||
public function dispatch($baseUrl, $basePath, $requestPathArray) {
|
||||
// - $requestQuery: E.g. 'edit'
|
||||
public function dispatch($baseUrl, $basePath, $requestPathArray, $requestQuery) {
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$this->handlePost($requestPathArray);
|
||||
} else {
|
||||
$this->handleGet($baseUrl, $basePath, $requestPathArray);
|
||||
$this->handleGet($baseUrl, $basePath, $requestPathArray, $requestQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +72,8 @@ class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private function handleGet($baseUrl, $basePath, $requestPathArray) {
|
||||
$isEditMode = isset($requestPathArray[0]) && $requestPathArray[0] == 'edit';
|
||||
if ($isEditMode) {
|
||||
array_shift($requestPathArray);
|
||||
}
|
||||
private function handleGet($baseUrl, $basePath, $requestPathArray, $requestQuery) {
|
||||
$isEditMode = $requestQuery == 'edit';
|
||||
|
||||
$articleFilename = $this->getArticleFilename($requestPathArray);
|
||||
if ($articleFilename == null) {
|
||||
|
Reference in New Issue
Block a user