mikuli.cz

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

commit f07c724591d276bd63bc06c0cdbcd125049b230f
parent 1b4f600ee286739504220ad9a1d0894066e8b5e1
Author: markseu <mark2011@mayberg.se>
Date:   Thu, 30 Jun 2016 17:51:56 +0200

System update (detect file system)

Diffstat:
Msystem/plugins/core.php | 65+++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/system/plugins/core.php b/system/plugins/core.php @@ -2009,12 +2009,44 @@ class YellowLookup // Load file system information function load() { - list($pathRoot, $pathHome) = $this->getContentInformation(); + list($pathRoot, $pathHome) = $this->detectFileSystem(); $this->yellow->config->set("contentRootDir", $pathRoot); $this->yellow->config->set("contentHomeDir", $pathHome); date_default_timezone_set($this->yellow->config->get("serverTime")); } + // Detect file system + function detectFileSystem() + { + $path = $this->yellow->config->get("contentDir"); + $pathRoot = $this->yellow->config->get("contentRootDir"); + $pathHome = $this->yellow->config->get("contentHomeDir"); + if(!$this->yellow->config->get("multiLanguageMode")) $pathRoot = ""; + if(!empty($pathRoot)) + { + $token = $root = rtrim($pathRoot, '/'); + foreach($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry) + { + if(empty($firstRoot)) { $firstRoot = $token = $entry; } + if($this->normaliseName($entry) == $root) { $token = $entry; break; } + } + $pathRoot = $this->normaliseName($token)."/"; + $path .= "$firstRoot/"; + } + if(!empty($pathHome)) + { + $token = $home = rtrim($pathHome, '/'); + foreach($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry) + { + if(empty($firstHome)) { $firstHome = $token = $entry; } + if($this->normaliseName($entry) == $home) { $token = $entry; break; } + } + $pathHome = $this->normaliseName($token)."/"; + if(count($this->yellow->toolbox->getDirectoryEntries($path.$token, "/.*/", true, true, false))) $invalid = true; + } + return array($pathRoot, $invalid ? "invalid" : $pathHome); + } + // Return root locations function findRootLocations($includePath = true) { @@ -2305,37 +2337,6 @@ class YellowLookup return $url; } - // Return content information - function getContentInformation() - { - $path = $this->yellow->config->get("contentDir"); - $pathRoot = $this->yellow->config->get("contentRootDir"); - $pathHome = $this->yellow->config->get("contentHomeDir"); - if(!$this->yellow->config->get("multiLanguageMode")) $pathRoot = ""; - if(!empty($pathRoot)) - { - $token = $root = rtrim($pathRoot, '/'); - foreach($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry) - { - if(empty($firstRoot)) { $firstRoot = $token = $entry; } - if($this->normaliseName($entry) == $root) { $token = $entry; break; } - } - $pathRoot = $this->normaliseName($token)."/"; - $path .= "$firstRoot/"; - } - if(!empty($pathHome)) - { - $token = $home = rtrim($pathHome, '/'); - foreach($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry) - { - if(empty($firstHome)) { $firstHome = $token = $entry; } - if($this->normaliseName($entry) == $home) { $token = $entry; break; } - } - $pathHome = $this->normaliseName($token)."/"; - } - return array($pathRoot, $pathHome); - } - // Return directory location function getDirectoryLocation($location) {