You are here

function photos_edit_sort_album_page in Album Photos 7.3

Grid drag and drop album sorting.

1 string reference to 'photos_edit_sort_album_page'
photos_menu in ./photos.module
Implements hook_menu().

File

inc/photos.edit.inc, line 358
Handles uploading and editing images.

Code

function photos_edit_sort_album_page($account) {
  $output = '';
  $uid = $account->uid;
  drupal_add_library('system', 'ui');
  drupal_add_library('system', 'ui.draggable');
  drupal_add_library('system', 'ui.sortable');
  drupal_add_js(array(
    'photos' => array(
      'uid' => $uid,
    ),
  ), 'setting');
  drupal_add_js(array(
    'photos' => array(
      'sort' => 'albums',
    ),
  ), 'setting');
  $albums = _photos_edit_page_albums($uid);
  $count = count($albums);

  //  $output .= t('Limit') . ': ' . l(100, 'node/' . $nid . '/photos-sort', array('query' => array('limit' => 100)));
  //  $output .= ' - ' . l(500, 'node/' . $nid . '/photos-sort', array('query' => array('limit' => 500)));
  $default_message = t('%album_count albums to re-arrange.', array(
    '%album_count' => $count,
  ));
  $output .= '<div id="photos-sort-message">' . $default_message . ' ' . '<span id="photos-sort-updates"></span></div>';
  $output .= '<ul id="photos-sortable">';

  // watchdog('photos', 'albums: <pre>' . print_r($albums, 1) . '</pre>');
  foreach ($albums as $album) {
    $item = array();
    $title = $album['title'];
    $cover = file_load($album['fid']);

    // @todo set photos_sort_style variable for custom image style settings.
    $style_name = variable_get('photos_thumb_size', 'thumbnail');
    $output .= '<li id="photos_' . $album['nid'] . '" class="photos-sort-grid ui-state-default">';
    $output .= theme('image_style', array(
      'style_name' => $style_name,
      'path' => $cover->uri,
      'alt' => $title,
      'title' => $title,
    ));
    $output .= '</li>';
  }
  $output .= '</ul>';

  //$page_title = t('Re-arrange Photos: @title', array('@title' => $node->title));

  //drupal_set_title($page_title, PASS_THROUGH);
  return $output;
}