I have noticed that the tags in the current beta are being displayed in alphabetical order, and I have thought that it would be more practical and better if every time random tags are being displayed when a page is loaded.
Here is my getAllTags() function.
Code: Select all
function getAllTags($search = null, $limit = false)
{
global $DB;
$tags = array();
// Hack: LIKE is case sensitive under PostgreSQL
switch ($DB['type']) {
case 'pgsql':
$like = 'ILIKE';
break;
default:
$like = 'LIKE';
break;
}
$query = sprintf("
SELECT
tagging_id, tagging_name
FROM
%sfaqtags
%s
ORDER BY tagging_name",
SQLPREFIX,
(isset($search) && ($search != '') ? "WHERE tagging_name ".$like." '".$search."%'" : '')
);
$i = 0;
$result = $this->db->query($query);
//changes start here
if ($result) {
while ($row = $this->db->fetch_object($result)) {
$allTags[$row->tagging_id] = $row->tagging_name;
}
}
$numberOfItems = $limit ? PMF_TAGS_CLOUD_RESULT_SET_SIZE : $this->db->num_rows($result);
if ($numberOfItems < count($allTags)) {
for ($n = 0; $n<$numberOfItems; $n++) {
$valid = false;
while (!$valid) {
$rand = rand(1, count($allTags) + 1);
if (!isset($soFar[$rand])) {
if (isset($allTags[$rand])) {
$valid = true;
$soFar[$rand] = '';
$tags[$rand] = $allTags[$rand];
}
}
}
}
}
else {
$tags = $allTags;
}
return $tags;
}