commit b771f518497c5ccc1a5997a1ba73fac538c85ea9
parent 686f7a52b2410165be67257eb26fbcdc2d17735c
Author: markseu <mark2011@mayberg.se>
Date: Sun, 5 Oct 2014 23:23:59 +0200
Hello multi language mode (approved for all audiences)
Diffstat:
2 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
@@ -1,4 +1,4 @@
-Yellow 0.4.2
+Yellow 0.4.3
============
Yellow is for people who make websites. [Visit website](http://datenstrom.se/yellow).
diff --git a/system/core/core.php b/system/core/core.php
@@ -5,7 +5,7 @@
// Yellow main class
class Yellow
{
- const Version = "0.4.2";
+ const Version = "0.4.3";
var $page; //current page
var $pages; //pages from file system
var $config; //configuration
@@ -810,8 +810,8 @@ class YellowPageCollection extends ArrayObject
{
$pagination = $this->yellow->config->get("contentPagination");
$location = $this->yellow->page->getLocation();
- $locationArgs = $this->yellow->toolbox->getLocationArgs($pagination,
- $pageNumber>1 ? "$pagination:$pageNumber" : "$pagination:");
+ $locationArgs = $this->yellow->toolbox->getLocationArgsNew(
+ $pageNumber>1 ? "$pagination:$pageNumber" : "$pagination:", $pagination);
}
return $location.$locationArgs;
}
@@ -887,22 +887,10 @@ class YellowPages
}
// Return page collection with top-level navigation
- function top($showInvisible = false, $showLanguages = false)
+ function top($showInvisible = false)
{
- $rootLocation = $showLanguages ? "" : $this->getRootLocation($this->yellow->page->location);
- $pages = $this->findChildren($rootLocation, $showInvisible);
- if($showLanguages)
- {
- $this->scanChildren($rootLocation);
- foreach($this->pages[$rootLocation] as $page)
- {
- if($home = $this->find(substru($page->location, 4)))
- {
- if($home->isVisible() || $showInvisible) $pages->append($home);
- }
- }
- }
- return $pages;
+ $rootLocation = $this->getRootLocation($this->yellow->page->location);
+ return $this->findChildren($rootLocation, $showInvisible);
}
// Return page collection with path ancestry
@@ -919,6 +907,23 @@ class YellowPages
return $pages;
}
+ // Return page collection with multiple languages
+ function translation($location, $absoluteLocation = false, $showInvisible = false)
+ {
+ $pages = new YellowPageCollection($this->yellow);
+ if($absoluteLocation) $location = substru($location, strlenu($this->yellow->page->base));
+ $postfix = substru($location, strlenu($this->getRootLocation($location)) - 4);
+ $this->scanChildren("");
+ foreach($this->pages[""] as $page)
+ {
+ if($content = $this->find(substru($page->location, 4).$postfix))
+ {
+ if($content->isVisible() || $showInvisible) $pages->append($content);
+ }
+ }
+ return $pages;
+ }
+
// Return empty page collection
function create()
{
@@ -1222,6 +1227,12 @@ class YellowText
return ($this->isText($key, $language)) ? $this->text[$language][$key] : "[$key]";
}
+ // Return text string for specific language, HTML encoded
+ function getTextHtml($key, $language)
+ {
+ return htmlspecialchars($this->getText($key, $language));
+ }
+
// Return text string
function get($key)
{
@@ -1351,7 +1362,14 @@ class YellowToolbox
}
// Return location arguments from current HTTP request
- function getLocationArgs($pagination, $arg = "")
+ function getLocationArgs()
+ {
+ if(preg_match("/^(.*?\/)([^\/]+:.*)$/", $this->getLocation(), $matches)) $locationArgs = $matches[2];
+ return $locationArgs;
+ }
+
+ // Return location arguments from current HTTP request, modify an argument
+ function getLocationArgsNew($arg, $pagination)
{
preg_match("/^(.*?):(.*)$/", $arg, $args);
if(preg_match("/^(.*?\/)([^\/]+:.*)$/", $this->getLocation(), $matches))