System update (improved blog and wiki)

This commit is contained in:
markseu 2017-02-22 21:05:46 +01:00
parent c29a0a8fe9
commit 566814bf88
3 changed files with 18 additions and 19 deletions

View file

@ -1047,28 +1047,27 @@ class YellowPageCollection extends ArrayObject
// Filter page collection by meta data // Filter page collection by meta data
function filter($key, $value, $exactMatch = true) function filter($key, $value, $exactMatch = true)
{ {
if(!empty($key)) $array = array();
$value = strreplaceu(' ', '-', strtoloweru($value));
$valueLength = strlenu($value);
$this->filterValue = "";
foreach($this->getArrayCopy() as $page)
{ {
$array = array(); if($page->isExisting($key))
$value = strreplaceu(' ', '-', strtoloweru($value));
$valueLength = strlenu($value);
foreach($this->getArrayCopy() as $page)
{ {
if($page->isExisting($key)) foreach(preg_split("/\s*,\s*/", $page->get($key)) as $pageValue)
{ {
foreach(preg_split("/,\s*/", $page->get($key)) as $pageValue) $pageValueLength = $exactMatch ? strlenu($pageValue) : $valueLength;
if($value==substru(strreplaceu(' ', '-', strtoloweru($pageValue)), 0, $pageValueLength))
{ {
$pageValueLength = $exactMatch ? strlenu($pageValue) : $valueLength; if(empty($this->filterValue)) $this->filterValue = substru($pageValue, 0, $pageValueLength);
if($value==substru(strreplaceu(' ', '-', strtoloweru($pageValue)), 0, $pageValueLength)) array_push($array, $page);
{ break;
$this->filterValue = substru($pageValue, 0, $pageValueLength);
array_push($array, $page);
}
} }
} }
} }
$this->exchangeArray($array);
} }
$this->exchangeArray($array);
return $this; return $this;
} }
@ -1105,7 +1104,7 @@ class YellowPageCollection extends ArrayObject
$location = $page->location; $location = $page->location;
$keywords = $this->yellow->toolbox->createTextKeywords($page->get("title")); $keywords = $this->yellow->toolbox->createTextKeywords($page->get("title"));
$keywords .= ",".$page->get("tag").",".$page->get("author"); $keywords .= ",".$page->get("tag").",".$page->get("author");
$tokens = array_unique(array_filter(preg_split("/,\s*/", $keywords), "strlen")); $tokens = array_unique(array_filter(preg_split("/\s*,\s*/", $keywords), "strlen"));
if(!empty($tokens)) if(!empty($tokens))
{ {
$array = array(); $array = array();
@ -1125,7 +1124,7 @@ class YellowPageCollection extends ArrayObject
} }
} }
$this->exchangeArray($array); $this->exchangeArray($array);
$this->sort("searchscore", $ascendingOrder); $this->sort("modified", false)->sort("searchscore", $ascendingOrder);
} }
return $this; return $this;
} }
@ -2015,8 +2014,8 @@ class YellowText
// Return human readable date, custom date format // Return human readable date, custom date format
function getDateFormatted($timestamp, $format) function getDateFormatted($timestamp, $format)
{ {
$dateMonths = preg_split("/,\s*/", $this->get("dateMonths")); $dateMonths = preg_split("/\s*,\s*/", $this->get("dateMonths"));
$dateWeekdays = preg_split("/,\s*/", $this->get("dateWeekdays")); $dateWeekdays = preg_split("/\s*,\s*/", $this->get("dateWeekdays"));
$month = $dateMonths[date('n', $timestamp) - 1]; $month = $dateMonths[date('n', $timestamp) - 1];
$weekday = $dateWeekdays[date('N', $timestamp) - 1]; $weekday = $dateWeekdays[date('N', $timestamp) - 1];
$format = preg_replace("/(?<!\\\)F/", addcslashes($month, 'A..Za..z'), $format); $format = preg_replace("/(?<!\\\)F/", addcslashes($month, 'A..Za..z'), $format);
@ -3272,7 +3271,7 @@ class YellowToolbox
$language = $languageDefault; $language = $languageDefault;
if(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) if(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
{ {
foreach(preg_split("/,\s*/", $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $string) foreach(preg_split("/\s*,\s*/", $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $string)
{ {
$tokens = explode(';', $string); $tokens = explode(';', $string);
if(in_array($tokens[0], $languages)) { $language = $tokens[0]; break; } if(in_array($tokens[0], $languages)) { $language = $tokens[0]; break; }