You are here

function img_assist_thumbs in Image Assist 5.3

Same name and namespace in other branches
  1. 5 img_assist.module \img_assist_thumbs()
  2. 5.2 img_assist.module \img_assist_thumbs()
  3. 6.2 img_assist.module \img_assist_thumbs()
  4. 6 img_assist.module \img_assist_thumbs()

Load the thumbnail display pane.

Grabs all images from image.module and loads the thumbnails.

Related topics

1 string reference to 'img_assist_thumbs'
img_assist_menu in ./img_assist.module
Implementation of hook_menu().

File

./img_assist.module, line 756
Image Assist module

Code

function img_assist_thumbs() {
  global $user;
  if (module_exists('image')) {
    $browse = arg(2);
    if ($browse == 'myimages') {
      $myimagesonly = TRUE;
      $tid = 0;
    }
    elseif ($browse == 'allimages') {
      $myimagesonly = FALSE;
      $tid = 0;
    }
    else {
      $myimagesonly = FALSE;
      $tid = $browse;
    }
    $output = '<div align="center">';

    // Show by term id.
    if ($tid) {

      // For this term, show all published images and the user's unpublished images.
      if (user_access('access all images')) {
        $query = "SELECT n.nid FROM {node} n, {term_node} t WHERE t.nid=n.nid AND n.type='image' AND t.tid = %d AND (n.uid = %d OR n.status = 1) ORDER BY n.sticky DESC, n.created DESC";
        $params = array(
          $tid,
          $user->uid,
        );
      }
      else {
        $query = "SELECT n.nid FROM {node} n, {term_node} t WHERE t.nid=n.nid AND n.type='image' AND t.tid = %d AND n.uid = %d ORDER BY n.sticky DESC, n.created DESC";
        $params = array(
          $tid,
          $user->uid,
        );
      }
    }
    else {

      // Show all published images and the user's unpublished images.
      if (user_access('access all images') && !$myimagesonly) {
        $query = "SELECT n.nid FROM {node} n WHERE n.type='image' AND (n.uid = %d OR n.status = 1) ORDER BY n.sticky DESC, n.created DESC";
        $params = array(
          $user->uid,
        );
      }
      else {
        $query = "SELECT n.nid FROM {node} n WHERE n.type='image' AND n.uid= %d ORDER BY n.sticky DESC, n.created DESC";
        $params = array(
          $user->uid,
        );
      }
    }
    $num_rows = FALSE;
    $show_amount = variable_get('img_assist_preview_count', 10);
    $result = pager_query($query, $show_amount, $element = 0, $count_query = NULL, $params);
    while ($row = db_fetch_object($result)) {
      $node = node_load(array(
        'nid' => $row->nid,
      ));
      $image = img_assist_display($node, IMAGE_THUMBNAIL);
      $output .= l($image, 'img_assist/properties/' . $node->nid, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE) . "\n";
      $num_rows = TRUE;
    }
    if (!$num_rows) {
      $output .= t('No images were found. Please upload a new image or browse images by a different category.');
    }
    $output .= theme('pager', NULL, $show_amount);
    $output .= '</div>';
  }
  else {
    $output = t('The Image module must be enabled to use Image assist.');
  }
  echo theme('img_assist_page', $output, array(
    'id' => 'img_assist_thumbs',
    'onload' => 'parent.initThumbs();',
    'class' => 'img_assist',
  ));
  exit;
}