1 installer.pages.inc installer_browser_get_sort_widget($sort_options, $current_order, $current_sort)

Returns a themed sort widget for the filters.

File

core/modules/installer/installer.pages.inc, line 893
Page callbacks used by the Installer browse pages.

Code

function installer_browser_get_sort_widget($sort_options, $current_order, $current_sort) {
  $sort_list = array();
  $sort_list[] = array('data' => t('Sort by:'), 'class' => array('sort-header'));
  $current_path = backdrop_get_path_alias($_GET['q']);

  foreach ($sort_options as $sort_option) {
    $classes = array();
    $query = array(
      'order' => $sort_option['method'],
      'sort' => $sort_option['default_sort'],
    );

    // If the sort option is currently active, handle it differently.
    if ($current_order == $sort_option['method']) {
      $classes[] = 'sort-active';
      $classes[] = 'sort-' . $current_sort;

      // Set the direction of the sort link to the opposite of what it currently
      // is.
      if ($current_sort == $query['sort']) {
        if ($query['sort'] == 'desc') {
          $query['sort'] = 'asc';
        }
        else {
          $query['sort'] = 'desc';
        }
      }
    }
    else {
      $classes[] = 'sort-inactive';
    }

    $sort_list[] = array(
      'data' => l($sort_option['label'], $current_path, array('query' => $query)),
      'class' => $classes,
    );
  }

  return theme('item_list', array(
    'items' => $sort_list,
    'type' => 'ul',
    'attributes' => array('class' => array('installer-browser-sort-list', 'clearfix'))
  ));
}