mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
MINOR: comment improvements and fixes
This commit is contained in:
parent
cb0ca458e3
commit
3f50a8e36c
@ -52,17 +52,17 @@ class TagCloudWidget extends Widget {
|
||||
|
||||
if($entries) {
|
||||
foreach($entries as $entry) {
|
||||
$theseTags = split(" *, *", trim($entry->Tags));
|
||||
$theseTags = split(" *, *", strtolower(trim($entry->Tags)));
|
||||
foreach($theseTags as $tag) {
|
||||
if($tag != "") {
|
||||
$allTags[$tag] = isset($allTags[$tag]) ? $allTags[$tag] + 1 : 1; //getting the count into key => value map
|
||||
$max = ($allTags[$tag] > $max) ? $allTags[$tag] : $max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($allTags) {
|
||||
|
||||
//TODO: move some or all of the sorts to the database for more efficiency
|
||||
|
||||
if($this->Limit > 0){
|
||||
uasort($allTags, "column_sort_by_popularity"); //sort by popularity
|
||||
$allTags = array_slice($allTags, 0, $this->Limit);
|
||||
@ -112,7 +112,6 @@ class TagCloudWidget extends Widget {
|
||||
"Link" => $blogHolder->Link() . 'tag/' . urlencode($tag)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$output = new DataObjectSet();
|
||||
@ -126,15 +125,19 @@ class TagCloudWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to compare 2 Vars to work out the results.
|
||||
* @param mixed
|
||||
* @param mixed
|
||||
* @return int
|
||||
*/
|
||||
function column_sort_by_popularity($a, $b){
|
||||
|
||||
if($a == $b) {
|
||||
$result = 0;
|
||||
}
|
||||
else {
|
||||
$result = $b - $a;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user