You are here

function tagadelic_sort_tags in Tagadelic 7

Same name and namespace in other branches
  1. 5 tagadelic.module \tagadelic_sort_tags()
  2. 6 tagadelic.module \tagadelic_sort_tags()

API function to order a set of tags.

@todo If you feel like making this more modular, please send me patches.

3 calls to tagadelic_sort_tags()
tagadelic_block_view in ./tagadelic.module
Implements hook_block_view().
tagadelic_page_chunk in ./tagadelic.module
Menu callback renders a tagadelic page.
tagadelic_page_list in ./tagadelic.module
Menu callback renders a tagadelic page with listed items: each vocabulary.

File

./tagadelic.module, line 278

Code

function tagadelic_sort_tags($tags) {
  list($sort, $order) = explode(',', variable_get('tagadelic_sort_order', 'title,asc'));
  switch ($sort) {
    case 'title':
      usort($tags, "_tagadelic_sort_by_title");
      break;
    case 'weight':
      usort($tags, "_tagadelic_sort_by_weight");
      break;
    case 'random':
      shuffle($tags);
      break;
  }
  if ($order == 'desc') {
    $tags = array_reverse($tags);
  }
  return $tags;
}