1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-05 08:07:35 +02:00

Starting edit mode using mypage?edit instead of /edit/mypage

This commit is contained in:
til-schneider
2015-12-22 22:35:30 +01:00
parent 9597efe4dc
commit df95ea7f8e
3 changed files with 10 additions and 11 deletions

View File

@@ -7,7 +7,8 @@ function init() {
// into $appPath example: '/slim-wiki' // into $appPath example: '/slim-wiki'
// and $requestPathArray example: array('myfolder', 'mypage') // 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'])); $scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME']));
$basePathArray = array(); $basePathArray = array();
@@ -36,7 +37,7 @@ function init() {
require_once __DIR__ . '/server/logic/Main.php'; require_once __DIR__ . '/server/logic/Main.php';
Main::get()->dispatch($baseUrl, $basePath, $requestPathArray); Main::get()->dispatch($baseUrl, $basePath, $requestPathArray, $uriParts['query']);
} }
init(); init();

View File

@@ -46,7 +46,7 @@
if ($item['active']) { if ($item['active']) {
echo $item['name']; echo $item['name'];
} else { } 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; $isFirst = false;
} }

View File

@@ -21,14 +21,15 @@ class Main {
} }
// Parameters: // Parameters:
// - $baseUrl: E.g. 'http://localhost/slim-wiki/' // - $baseUrl: E.g. 'http://localhost/slim-wiki/?edit'
// - $basePath: E.g. '/slim-wiki/' // - $basePath: E.g. '/slim-wiki/'
// - $requestPathArray: E.g. array('myfolder', 'mypage') // - $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') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->handlePost($requestPathArray); $this->handlePost($requestPathArray);
} else { } else {
$this->handleGet($baseUrl, $basePath, $requestPathArray); $this->handleGet($baseUrl, $basePath, $requestPathArray, $requestQuery);
} }
} }
@@ -71,11 +72,8 @@ class Main {
} }
} }
private function handleGet($baseUrl, $basePath, $requestPathArray) { private function handleGet($baseUrl, $basePath, $requestPathArray, $requestQuery) {
$isEditMode = isset($requestPathArray[0]) && $requestPathArray[0] == 'edit'; $isEditMode = $requestQuery == 'edit';
if ($isEditMode) {
array_shift($requestPathArray);
}
$articleFilename = $this->getArticleFilename($requestPathArray); $articleFilename = $this->getArticleFilename($requestPathArray);
if ($articleFilename == null) { if ($articleFilename == null) {