From 0ec7fc45006c490345b7d3ea51872dce15d52108 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sat, 13 Jan 2024 13:43:54 -0500 Subject: [PATCH] fix some stuff --- lib/phast/client/scripts/controls/Alert.js | 5 ++++- lib/phast/server/Sorting/QuickSort.inc.php | 18 +++++++++++++++--- lib/phast/server/System.inc.php | 7 +++++++ lib/phast/server/UUID.inc.php | 18 ++++++++++++++++++ .../WebControls/AdditionalDetailWidget.inc.php | 2 +- lib/phast/server/WebPageMessage.inc.php | 4 +++- 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/lib/phast/client/scripts/controls/Alert.js b/lib/phast/client/scripts/controls/Alert.js index 1cc67c7..8527842 100644 --- a/lib/phast/client/scripts/controls/Alert.js +++ b/lib/phast/client/scripts/controls/Alert.js @@ -137,7 +137,10 @@ window.addEventListener("load", function() var items = document.getElementsByClassName("uwt-alert"); for (var i = 0; i < items.length; i++) { - items[i].style.right = "-2000px"; + if (!System.ClassList.Contains(items[i], "uwt-alert-sticky")) + { + items[i].style.right = "-2000px"; + } } }, 5000); diff --git a/lib/phast/server/Sorting/QuickSort.inc.php b/lib/phast/server/Sorting/QuickSort.inc.php index 11bcb05..ac0aa1c 100644 --- a/lib/phast/server/Sorting/QuickSort.inc.php +++ b/lib/phast/server/Sorting/QuickSort.inc.php @@ -39,10 +39,10 @@ class QuickSort $pivot=$arr[($leftIndex+$rightIndex)/2]; while ($leftIndex <= $rightIndex) - { - while ($arr[$leftIndex] < $pivot) + { + while ($predicate($arr[$leftIndex], $pivot) < 0) $leftIndex++; - while ($arr[$rightIndex] > $pivot) + while ($predicate($arr[$rightIndex], $pivot) > 0) $rightIndex--; if ($predicate($arr[$leftIndex], $arr[$rightIndex]) <= 0) { $tmp = $arr[$leftIndex]; @@ -74,6 +74,18 @@ class QuickSort return $array; } + + public function Sort_By($arr, $key_f) { + $values = array_map($key_f, $arr); + asort($values); + $sorted_arr = array(); + + foreach ($values as $idx => $value) { + $sorted_arr[] = $arr[$idx]; + } + + return $sorted_arr; + } } ?> \ No newline at end of file diff --git a/lib/phast/server/System.inc.php b/lib/phast/server/System.inc.php index c640d1c..57a698a 100644 --- a/lib/phast/server/System.inc.php +++ b/lib/phast/server/System.inc.php @@ -827,6 +827,7 @@ { // FIXME : find the "best match" for the given route $qs = new QuickSort(); + /* $sortedPages = $qs->Sort($actualPages, function($left, $right) { $leftStr = System::__ReplaceAny($left->FileName, "{", "}" , "?"); @@ -834,6 +835,12 @@ $val = strlen($leftStr) < strlen($rightStr); return $val; }); + */ + $sortedPages = $qs->Sort_By($actualPages, function($item) + { + $val = System::__ReplaceAny($item->FileName, "{", "}" , "?"); + return strlen($val); + }); $actualPage = $actualPages[count($actualPages) - 1]; if ($actualPage->FileName !== null) { diff --git a/lib/phast/server/UUID.inc.php b/lib/phast/server/UUID.inc.php index b13b764..746b9f0 100644 --- a/lib/phast/server/UUID.inc.php +++ b/lib/phast/server/UUID.inc.php @@ -372,6 +372,24 @@ $guidChars .= "}"; return $guidChars; } + public function __toStringFormat($includeDashes = false, $prefix = "{", $suffix = "}") + { + $guidChars = $prefix; + $guidChars .= UUID::HexsToChars($this->_a >> 24, $this->_a >> 16); + $guidChars .= UUID::HexsToChars($this->_a >> 8, $this->_a); + if ($includeDashes) $guidChars .= '-'; + $guidChars .= UUID::HexsToChars($this->_b >> 8, $this->_b); + if ($includeDashes) $guidChars .= '-'; + $guidChars .= UUID::HexsToChars($this->_c >> 8, $this->_c); + if ($includeDashes) $guidChars .= '-'; + $guidChars .= UUID::HexsToChars($this->_d, $this->_e); + if ($includeDashes) $guidChars .= '-'; + $guidChars .= UUID::HexsToChars($this->_f, $this->_g); + $guidChars .= UUID::HexsToChars($this->_h, $this->_i); + $guidChars .= UUID::HexsToChars($this->_j, $this->_k); + $guidChars .= $suffix; + return $guidChars; + } private static function format($input) { diff --git a/lib/phast/server/WebControls/AdditionalDetailWidget.inc.php b/lib/phast/server/WebControls/AdditionalDetailWidget.inc.php index b67e1db..94f17b9 100644 --- a/lib/phast/server/WebControls/AdditionalDetailWidget.inc.php +++ b/lib/phast/server/WebControls/AdditionalDetailWidget.inc.php @@ -128,7 +128,7 @@ } else { - echo ("" . $this->Text . ""); + echo ("" . $this->Text . ""); } } diff --git a/lib/phast/server/WebPageMessage.inc.php b/lib/phast/server/WebPageMessage.inc.php index 38865aa..42884e6 100644 --- a/lib/phast/server/WebPageMessage.inc.php +++ b/lib/phast/server/WebPageMessage.inc.php @@ -12,11 +12,13 @@ class WebPageMessage { public $Message; + public $Title; public $Severity; - public function __construct($message, $severity = WebPageMessageSeverity::None) + public function __construct($message, $title = "", $severity = WebPageMessageSeverity::None) { $this->Message = $message; + $this->Title = $title; $this->Severity = $severity; } }