mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 45e32c5ed434cd414433e4f93fae384e5c8fddfa
parent f4f9a6eef4b823fce23be88ef61d28b4948a1709
Author: markseu <mark2011@mayberg.se>
Date:   Mon, 16 Dec 2019 09:10:36 +0100

Updated API

Diffstat:
Msystem/extensions/command.php | 5++---
Msystem/extensions/core.php | 24++++++++++--------------
Msystem/settings/system.ini | 3+--
3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/system/extensions/command.php b/system/extensions/command.php @@ -4,7 +4,7 @@ // This file may be used and distributed under the terms of the public license. class YellowCommand { - const VERSION = "0.8.8"; + const VERSION = "0.8.9"; const TYPE = "feature"; const PRIORITY = "3"; public $yellow; //access to API @@ -225,7 +225,6 @@ class YellowCommand { // Analyse locations with arguments public function analyseLocations($scheme, $address, $base, $rawData) { - $pagination = $this->yellow->system->get("coreContentPagination"); preg_match_all("/<(.*?)href=\"([^\"]+)\"(.*?)>/i", $rawData, $matches); foreach ($matches[2] as $match) { $location = rawurldecode($match); @@ -238,7 +237,7 @@ class YellowCommand { if (substru($location, 0, strlenu($base))!=$base) continue; $location = substru($location, strlenu($base)); if (!$this->yellow->toolbox->isLocationArgs($location)) continue; - if (!$this->yellow->toolbox->isLocationArgsPagination($location, $pagination)) { + if (!$this->yellow->toolbox->isLocationArgsPagination($location)) { $location = rtrim($location, "/")."/"; if (is_null($this->locationsArgs[$location])) { $this->locationsArgs[$location] = $location; diff --git a/system/extensions/core.php b/system/extensions/core.php @@ -41,6 +41,7 @@ class YellowCore { $this->system->setDefault("coreStaticErrorFile", "404.html"); $this->system->setDefault("coreStaticDir", "public/"); $this->system->setDefault("coreCacheDir", "cache/"); + $this->system->setDefault("coreTrashDir", "system/trash/"); $this->system->setDefault("coreServerUrl", "auto"); $this->system->setDefault("coreServerTimezone", "UTC"); $this->system->setDefault("coreSafeMode", "0"); @@ -58,12 +59,10 @@ class YellowCore { $this->system->setDefault("coreLayoutDir", "system/layouts/"); $this->system->setDefault("coreResourceDir", "system/resources/"); $this->system->setDefault("coreSettingDir", "system/settings/"); - $this->system->setDefault("coreTrashDir", "system/trash/"); $this->system->setDefault("coreContentDir", "content/"); $this->system->setDefault("coreContentRootDir", "default/"); $this->system->setDefault("coreContentHomeDir", "home/"); $this->system->setDefault("coreContentSharedDir", "shared/"); - $this->system->setDefault("coreContentPagination", "page"); $this->system->setDefault("coreContentDefaultFile", "page.md"); $this->system->setDefault("coreContentExtension", ".md"); $this->system->setDefault("coreDownloadExtension", ".download"); @@ -349,7 +348,7 @@ class YellowCore { // Return request location public function getRequestLocationArgsClean() { - return $this->toolbox->getLocationArgsClean($this->system->get("coreContentPagination")); + return $this->toolbox->getLocationArgsClean(); } // Return request language @@ -1075,8 +1074,7 @@ class YellowPageCollection extends ArrayObject { public function pagination($limit, $reverse = true) { $this->paginationNumber = 1; $this->paginationCount = ceil($this->count() / $limit); - $pagination = $this->yellow->system->get("coreContentPagination"); - if (isset($_REQUEST[$pagination])) $this->paginationNumber = intval($_REQUEST[$pagination]); + if (isset($_REQUEST["page"])) $this->paginationNumber = intval($_REQUEST["page"]); if ($this->paginationNumber>$this->paginationCount) $this->paginationNumber = 0; if ($this->paginationNumber>=1) { $array = $this->getArrayCopy(); @@ -1099,10 +1097,8 @@ class YellowPageCollection extends ArrayObject { // Return location for a page in pagination public function getPaginationLocation($absoluteLocation = true, $pageNumber = 1) { if ($pageNumber>=1 && $pageNumber<=$this->paginationCount) { - $pagination = $this->yellow->system->get("coreContentPagination"); $location = $this->yellow->page->getLocation($absoluteLocation); - $locationArgs = $this->yellow->toolbox->getLocationArgsNew( - $pageNumber>1 ? "$pagination:$pageNumber" : "$pagination:", $pagination); + $locationArgs = $this->yellow->toolbox->getLocationArgsNew($pageNumber>1 ? "page:$pageNumber" : "page:"); } return $location.$locationArgs; } @@ -2248,7 +2244,7 @@ class YellowToolbox { } // Return location arguments from current HTTP request, modify existing arguments - public function getLocationArgsNew($arg, $pagination) { + public function getLocationArgsNew($arg) { $separator = $this->getLocationArgsSeparator(); preg_match("/^(.*?):(.*)$/", $arg, $args); foreach (explode("/", $_SERVER["LOCATION_ARGS"]) as $token) { @@ -2268,13 +2264,13 @@ class YellowToolbox { } if (!empty($locationArgs)) { $locationArgs = $this->normaliseArgs($locationArgs, false, false); - if (!$this->isLocationArgsPagination($locationArgs, $pagination)) $locationArgs .= "/"; + if (!$this->isLocationArgsPagination($locationArgs)) $locationArgs .= "/"; } return $locationArgs; } // Return location arguments from current HTTP request, convert form parameters - public function getLocationArgsClean($pagination) { + public function getLocationArgsClean() { foreach (array_merge($_GET, $_POST) as $key=>$value) { if (!empty($key) && !strempty($value)) { if (!empty($locationArgs)) $locationArgs .= "/"; @@ -2285,7 +2281,7 @@ class YellowToolbox { } if (!empty($locationArgs)) { $locationArgs = $this->normaliseArgs($locationArgs, false, false); - if (!$this->isLocationArgsPagination($locationArgs, $pagination)) $locationArgs .= "/"; + if (!$this->isLocationArgsPagination($locationArgs)) $locationArgs .= "/"; } return $locationArgs; } @@ -2303,9 +2299,9 @@ class YellowToolbox { } // Check if there are pagination arguments in current HTTP request - public function isLocationArgsPagination($location, $pagination) { + public function isLocationArgsPagination($location) { $separator = $this->getLocationArgsSeparator(); - return preg_match("/^(.*\/)?$pagination$separator.*$/", $location); + return preg_match("/^(.*\/)?page$separator.*$/", $location); } // Check if script location is requested diff --git a/system/settings/system.ini b/system/settings/system.ini @@ -18,6 +18,7 @@ CoreStaticDefaultFile: index.html CoreStaticErrorFile: 404.html CoreStaticDir: public/ CoreCacheDir: cache/ +CoreTrashDir: system/trash/ CoreServerUrl: auto CoreServerTimezone: UTC CoreSafeMode: 0 @@ -35,12 +36,10 @@ CoreExtensionDir: system/extensions/ CoreLayoutDir: system/layouts/ CoreResourceDir: system/resources/ CoreSettingDir: system/settings/ -CoreTrashDir: system/trash/ CoreContentDir: content/ CoreContentRootDir: default/ CoreContentHomeDir: home/ CoreContentSharedDir: shared/ -CoreContentPagination: page CoreContentDefaultFile: page.md CoreContentExtension: .md CoreDownloadExtension: .download