Skip to content

Commit

Permalink
Refactored code, wee faster sort
Browse files Browse the repository at this point in the history
Co-Authored-By: wunderfeyd <7998283+wunderfeyd@users.noreply.github.com>
  • Loading branch information
markseuffert and wunderfeyd committed Apr 23, 2024
1 parent 9ef0ce3 commit dedd517
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions system/extensions/update-available.ini
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions system/extensions/yellow-extension.ini
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions system/workers/core.php
Expand Up @@ -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
Expand Down Expand Up @@ -3656,14 +3656,14 @@ public function similar($page): YellowPageCollection {
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);
Expand Down

0 comments on commit dedd517

Please sign in to comment.