Преглед на файлове

Core update (fika remix)

markseu преди 9 години
родител
ревизия
b9a0b709ed
променени са 4 файла, в които са добавени 59 реда и са изтрити 49 реда
  1. 30 6
      system/plugins/core.php
  2. 0 1
      system/plugins/markdown.php
  3. 1 1
      system/plugins/webinterface.css
  4. 28 41
      system/plugins/webinterface.php

+ 30 - 6
system/plugins/core.php

@@ -540,6 +540,30 @@ class YellowPage
 				if(!is_null($output)) break;
 			}
 		}
+		if(is_null($output))
+		{
+			if($name=="debug" && $shortcut)
+			{
+				$output = "<span class=\"".htmlspecialchars($name)."\">\n";
+				if(empty($text))
+				{
+					$serverSoftware = $this->yellow->toolbox->getServerSoftware();
+					$output .= "Yellow ".YellowCore::Version.", PHP ".PHP_VERSION.", $serverSoftware\n";
+				} else if($text == "version") {
+					foreach($this->yellow->plugins->getData() as $key=>$value)
+					{
+						$output .= htmlspecialchars("$key: $value")."<br />\n";
+					}
+				} else {
+					foreach($this->yellow->config->getData($text) as $key=>$value)
+					{
+						$output .= htmlspecialchars(ucfirst($key).": ".$value)."<br />\n";
+					}
+				}
+				if(!empty($text) && $this->parserSafeMode) $this->error(500, "Debug '$text' is not allowed in safe mode!");
+				$output .= "</span>\n";
+			}
+		}
 		if(defined("DEBUG") && DEBUG>=3 && !empty($name)) echo "YellowPage::parseContentBlock name:$name shortcut:$shortcut<br/>\n";
 		return $output;
 	}
@@ -1934,14 +1958,14 @@ class YellowLookup
 			}
 			if(!$directory)
 			{
-				$fileFolder = $tokens[$i-1].$fileExtension;
 				if(!empty($tokens[$i]))
 				{
 					$token = $tokens[$i].$fileExtension;
+					$fileFolder = $tokens[$i-1].$fileExtension;
 					if($token==$fileDefault || $token==$fileFolder) $invalid = true;
 					$path .= $this->findFileDirectory($path, $token, true, false, $found, $invalid);
 				} else {
-					$path .= $this->findFileDefault($path, $fileDefault, $fileFolder);
+					$path .= $this->findFileDefault($path, $fileDefault, $fileExtension, false);
 				}
 				if(defined("DEBUG") && DEBUG>=2)
 				{
@@ -1970,11 +1994,12 @@ class YellowLookup
 	}
 	
 	// Return default file in directory
-	function findFileDefault($path, $fileDefault, $fileFolder)
+	function findFileDefault($path, $fileDefault, $fileExtension, $includePath = true)
 	{
 		$token = $fileDefault;
 		if(!is_file($path."/".$fileDefault))
 		{
+			$fileFolder = $this->normaliseName(basename($path)).$fileExtension;
 			$regex = "/^[\d\-\_\.]*($fileDefault|$fileFolder)$/";
 			foreach($this->yellow->toolbox->getDirectoryEntries($path, $regex, true, false, false) as $entry)
 			{
@@ -1982,7 +2007,7 @@ class YellowLookup
 				if($this->normaliseName($entry) == $fileFolder) { $token = $entry; break; }
 			}
 		}
-		return $token;
+		return $includePath ? "$path/$token" : $token;
 	}
 	
 	// Return children from location
@@ -1996,8 +2021,7 @@ class YellowLookup
 			$path = $this->findFileFromLocation($location, true);
 			foreach($this->yellow->toolbox->getDirectoryEntries($path, "/.*/", true, true, false) as $entry)
 			{
-				$fileFolder = $this->normaliseName($entry).$fileExtension;
-				$token = $this->findFileDefault($path.$entry, $fileDefault, $fileFolder);
+				$token = $this->findFileDefault($path.$entry, $fileDefault, $fileExtension, false);
 				array_push($fileNames, $path.$entry."/".$token);
 			}
 			if(!$this->isRootLocation($location))

+ 0 - 1
system/plugins/markdown.php

@@ -35,7 +35,6 @@ class YellowMarkdownParser extends MarkdownExtraParser
 		$this->page = $page;
 		$this->idAttributes = array();
 		$this->no_markup = $page->parserSafeMode;
-		$this->no_entities = $page->parserSafeMode;
 		$this->url_filter_func = function($url) use ($yellow, $page)
 		{
 			return $yellow->lookup->normaliseLocation($url, $page->base, $page->location,

+ 1 - 1
system/plugins/webinterface.css

@@ -96,7 +96,7 @@
 #yellow-pane-login input { width:15em; box-sizing:border-box; }
 #yellow-pane-login .yellow-btn { width:15em; margin:1em 1em 0.5em 0; }
 #yellow-pane-edit { }
-#yellow-pane-edit h1 { margin:0 0 10px 0; font-size:1.5em; }
+#yellow-pane-edit h1 { margin:0 0 10px 0; font-size:1.5em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
 #yellow-pane-edit-page { padding:5px; outline:none; resize:none; }
 #yellow-pane-edit-buttons { margin-top:5px; }
 #yellow-pane-edit-buttons input { margin-right:10px; }

+ 28 - 41
system/plugins/webinterface.php

@@ -83,27 +83,6 @@ class YellowWebinterface
 			if(substru($text, 0, 2)=="- ") $editText = trim(substru($text, 2));
 			$output = "<a href=\"".$page->get("pageEdit")."\">".htmlspecialchars($editText)."</a>";
 		}
-		if($name=="debug" && $shortcut)
-		{
-			$output = "<div class=\"".htmlspecialchars($name)."\">\n";
-			if(empty($text))
-			{
-				$serverSoftware = $this->yellow->toolbox->getServerSoftware();
-				$output .= "Yellow ".YellowCore::Version.", PHP ".PHP_VERSION.", $serverSoftware\n";
-			} else if($text == "version") {
-				foreach($this->yellow->plugins->getData() as $key=>$value)
-				{
-					$output .= htmlspecialchars("$key: $value")."<br />\n";
-				}
-			} else {
-				foreach($this->yellow->config->getData($text) as $key=>$value)
-				{
-					$output .= htmlspecialchars(ucfirst($key).": ".$value)."<br />\n";
-				}
-			}
-			if(!empty($text) && $page->parserSafeMode) $page->error(500, "Debug '$text' is not allowed in safe mode!");
-			$output .= "</div>\n";
-		}
 		return $output;
 	}
 	
@@ -470,26 +449,29 @@ class YellowWebinterface
 		$page = new YellowPage($this->yellow);
 		$page->setRequestInformation($serverScheme, $serverName, $base, $location, $fileName);
 		$page->parseData($rawData, false, 0);
-		$page->fileName = $this->yellow->lookup->findFileFromTitle(
-			$page->get($this->yellow->config->get("webinterfaceMetaFilePrefix")), $page->get("title"), $fileName,
-			$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
-		$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
-		if($this->yellow->pages->find($page->location))
-		{
-			preg_match("/^(.*?)(\d*)$/", $page->get("title"), $matches);
-			$titleText = $matches[1];
-			$titleNumber = $matches[2];
-			if(strempty($titleNumber)) { $titleNumber = 2; $titleText = $titleText.' '; }
-			for(; $titleNumber<=999; ++$titleNumber)
+		if($this->yellow->lookup->isFileLocation($location) || is_file($fileName))
+		{
+			$page->fileName = $this->yellow->lookup->findFileFromTitle(
+				$page->get($this->yellow->config->get("webinterfaceMetaFilePrefix")), $page->get("title"), $fileName,
+				$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
+			$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
+			if($this->yellow->pages->find($page->location))
 			{
-				$page->rawData = $this->updateDataTitle($rawData, $titleText.$titleNumber);
-				$page->fileName = $this->yellow->lookup->findFileFromTitle(
-					$page->get($this->yellow->config->get("webinterfaceMetaFilePrefix")), $titleText.$titleNumber, $fileName,
-					$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
-				$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
-				if(!$this->yellow->pages->find($page->location)) { $ok = true; break; }
+				preg_match("/^(.*?)(\d*)$/", $page->get("title"), $matches);
+				$titleText = $matches[1];
+				$titleNumber = $matches[2];
+				if(strempty($titleNumber)) { $titleNumber = 2; $titleText = $titleText.' '; }
+				for(; $titleNumber<=999; ++$titleNumber)
+				{
+					$page->rawData = $this->updateDataTitle($rawData, $titleText.$titleNumber);
+					$page->fileName = $this->yellow->lookup->findFileFromTitle(
+						$page->get($this->yellow->config->get("webinterfaceMetaFilePrefix")), $titleText.$titleNumber, $fileName,
+						$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
+					$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
+					if(!$this->yellow->pages->find($page->location)) { $ok = true; break; }
+				}
+				if(!$ok) $page->error(500, "Page '".$page->get("title")."' can not be created!");
 			}
-			if(!$ok) $page->error(500, "Page '".$page->get("title")."' can not be created!");
 		}
 		if(!$this->getUserPermission($page->location, $page->fileName)) $page->error(500, "Page '".$page->get("title")."' is not allowed!");
 		return $page;
@@ -514,9 +496,14 @@ class YellowWebinterface
 					$page->get($prefix), $page->get("title"), $fileName,
 					$this->yellow->config->get("contentDefaultFile"), $this->yellow->config->get("contentExtension"));
 				$page->location = $this->yellow->lookup->findLocationFromFile($page->fileName);
-				if($pageSource->location!=$page->location && $this->yellow->pages->find($page->location))
+				if($pageSource->location != $page->location)
 				{
-					$page->error(500, "Page '".$page->get("title")."' already exists!");
+					if(!$this->yellow->lookup->isFileLocation($page->location))
+					{
+						$page->error(500, "Page '".$page->get("title")."' is not allowed!");
+					} else if($this->yellow->pages->find($page->location)) {
+						$page->error(500, "Page '".$page->get("title")."' already exists!");
+					}
 				}
 			}
 		}