Refactored code, wee faster sort
Co-Authored-By: wunderfeyd <7998283+wunderfeyd@users.noreply.github.com>
This commit is contained in:
parent
9ef0ce3fb5
commit
dedd5179b1
|
@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
|
|||
system/themes/copenhagen.png: copenhagen.png, create
|
||||
|
||||
Extension: Core
|
||||
Version: 0.9.5
|
||||
Version: 0.9.6
|
||||
Description: Core functionality of your website.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-23 10:16:44
|
||||
Published: 2024-04-23 21:35:24
|
||||
Status: available
|
||||
system/workers/core.php: core.php, create, update
|
||||
system/extensions/core.php: coreupdate.txt, update
|
||||
|
@ -602,14 +602,14 @@ Status: available
|
|||
system/workers/private.php: private.php, create, update
|
||||
|
||||
Extension: Publish
|
||||
Version: 0.9.3
|
||||
Version: 0.9.4
|
||||
Description: Make and publish extensions.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-publish/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-publish
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-10 10:20:07
|
||||
Published: 2024-04-23 22:01:41
|
||||
Status: available
|
||||
system/workers/publish.php: publish.php, create, update
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# Datenstrom Yellow extension settings
|
||||
|
||||
Extension: Core
|
||||
Version: 0.9.5
|
||||
Version: 0.9.6
|
||||
Description: Core functionality of your website.
|
||||
Developer: Anna Svensson
|
||||
Tag: feature
|
||||
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
|
||||
DocumentationUrl: https://github.com/annaesvensson/yellow-core
|
||||
DocumentationLanguage: en, de, sv
|
||||
Published: 2024-04-23 10:16:44
|
||||
Published: 2024-04-23 21:35:24
|
||||
Status: available
|
||||
system/workers/core.php: core.php, create, update
|
||||
system/extensions/core.php: coreupdate.txt, update
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Core extension, https://github.com/annaesvensson/yellow-core
|
||||
|
||||
class YellowCore {
|
||||
const VERSION = "0.9.5";
|
||||
const VERSION = "0.9.6";
|
||||
const RELEASE = "0.9";
|
||||
public $content; // content files
|
||||
public $media; // media files
|
||||
|
@ -3656,14 +3656,14 @@ class YellowPageCollection extends ArrayObject {
|
|||
public function sort($key, $ascendingOrder = true): YellowPageCollection {
|
||||
$array = $this->getArrayCopy();
|
||||
$sortIndex = 0;
|
||||
$sortKeys = array();
|
||||
foreach ($array as $page) {
|
||||
$page->set("sortIndex", ++$sortIndex);
|
||||
$sortKeys[$page->location] = $page->get($key)." ".++$sortIndex;
|
||||
}
|
||||
$callback = function ($a, $b) use ($key, $ascendingOrder) {
|
||||
$result = $ascendingOrder ?
|
||||
strnatcasecmp($a->get($key), $b->get($key)) :
|
||||
strnatcasecmp($b->get($key), $a->get($key));
|
||||
return $result==0 ? $a->get("sortIndex") - $b->get("sortIndex") : $result;
|
||||
$callback = function ($a, $b) use ($sortKeys, $ascendingOrder) {
|
||||
return $ascendingOrder ?
|
||||
strnatcasecmp($sortKeys[$a->location], $sortKeys[$b->location]) :
|
||||
strnatcasecmp($sortKeys[$b->location], $sortKeys[$a->location]);
|
||||
};
|
||||
usort($array, $callback);
|
||||
$this->exchangeArray($array);
|
||||
|
|
Loading…
Reference in a new issue