You are here

function _photos_order_link in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 photos.module \_photos_order_link()

Limit and sort by links.

6 calls to _photos_order_link()
photos_album_page in inc/photos.album.inc
Album view.
photos_page_image in inc/photos.page.inc
Latest images page.
photos_share in inc/photos.page.inc
Share photos.
photos_sub_album_page in inc/photos.album.inc
Sub album view.
_photos_edit_page_album in inc/photos.edit.inc
Album image management page.

... See full list

File

./photos.module, line 2425
Implementation of photos.module.

Code

function _photos_order_link($arg, $count = 0, $link = 0, $limit = 0) {
  $field = array(
    'weight' => t('By weight'),
    'timestamp' => t('By time'),
    'comments' => t('By comments'),
    'visits' => t('By visits'),
    'filesize' => t('By filesize'),
  );
  if ($limit) {
    $query = _photos_pager_get_query();
    $links['limit'] = '';
    if (!is_array($limit)) {
      $limit = array(
        5,
        10,
        20,
        30,
        40,
        50,
      );
    }
    $limit_query = $query;
    foreach ($limit as $tt) {
      $limit_query['limit'] = $tt;
      $sort = array(
        'query' => $limit_query,
        'attributes' => array(
          'class' => array(
            isset($_GET['limit']) && $_GET['limit'] == $tt ? 'orderac' : NULL,
          ),
          'rel' => 'nofollow',
        ),
      );
      $links['limit'] .= l($tt, $_GET['q'], $sort);
    }
  }
  $links['count'] = $count;
  $links['link'] = $link ? $link : NULL;
  $links['sort'] = l(t('Default'), $arg, array(
    'attributes' => array(
      'rel' => 'nofollow',
    ),
  ));
  foreach ($field as $key => $t) {
    if (!isset($_GET['field']) || $_GET['field'] != $key) {
      $sort = 'desc';
      $class = 'photos_order_desc';
    }
    elseif ($_GET['sort'] == 'desc') {
      $sort = 'asc';
      $class = 'photos_order_desc orderac';
    }
    else {
      $sort = 'desc';
      $class = 'photos_order_asc orderac';
    }
    $field_query = array(
      'sort' => $sort,
      'field' => $key,
    );
    if (isset($_GET['limit'])) {
      $field_query['limit'] = check_plain($_GET['limit']);
    }
    $links['sort'] .= l($t, $_GET['q'], array(
      'query' => $field_query,
      'attributes' => array(
        'class' => array(
          $class,
        ),
        'rel' => 'nofollow',
      ),
    ));
  }
  return theme('photos_albumlinks', array(
    'links' => $links,
  ));
}