mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
#2774 - Functions in tag cloud widget out of place
This commit is contained in:
parent
2bcbb8ee7d
commit
fe9afc2e36
@ -64,11 +64,11 @@ class TagCloudWidget extends Widget {
|
|||||||
if($allTags) {
|
if($allTags) {
|
||||||
//TODO: move some or all of the sorts to the database for more efficiency
|
//TODO: move some or all of the sorts to the database for more efficiency
|
||||||
if($this->Limit > 0){
|
if($this->Limit > 0){
|
||||||
uasort($allTags, "column_sort_by_popularity"); //sort by popularity
|
uasort($allTags, array($this, "column_sort_by_popularity")); //sort by popularity
|
||||||
$allTags = array_slice($allTags, 0, $this->Limit);
|
$allTags = array_slice($allTags, 0, $this->Limit);
|
||||||
}
|
}
|
||||||
if($this->Sortby == "alphabet"){
|
if($this->Sortby == "alphabet"){
|
||||||
natksort($allTags);
|
$this->natksort($allTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sizes = array();
|
$sizes = array();
|
||||||
@ -123,15 +123,14 @@ class TagCloudWidget extends Widget {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to compare 2 Vars to work out the results.
|
* Helper method to compare 2 Vars to work out the results.
|
||||||
* @param mixed
|
* @param mixed
|
||||||
* @param mixed
|
* @param mixed
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function column_sort_by_popularity($a, $b){
|
private function column_sort_by_popularity($a, $b){
|
||||||
if($a == $b) {
|
if($a == $b) {
|
||||||
$result = 0;
|
$result = 0;
|
||||||
}
|
}
|
||||||
@ -139,9 +138,9 @@ function column_sort_by_popularity($a, $b){
|
|||||||
$result = $b - $a;
|
$result = $b - $a;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function natksort(&$aToBeSorted) {
|
private function natksort(&$aToBeSorted) {
|
||||||
$aResult = array();
|
$aResult = array();
|
||||||
$aKeys = array_keys($aToBeSorted);
|
$aKeys = array_keys($aToBeSorted);
|
||||||
natcasesort($aKeys);
|
natcasesort($aKeys);
|
||||||
@ -151,6 +150,9 @@ function natksort(&$aToBeSorted) {
|
|||||||
$aToBeSorted = $aResult;
|
$aToBeSorted = $aResult;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user