You are here

imagepicker.module in Image Picker 6.2

Same filename and directory in other branches
  1. 5.2 imagepicker.module
  2. 5 imagepicker.module
  3. 7 imagepicker.module

Enables permitted roles to upload images for insertion into configured nodes.

File

imagepicker.module
View source
<?php

/**
 * @file
 * Enables permitted roles to upload images for insertion into configured nodes.
 */
define('IMAGEPICKER_FILES_DIR', 'imagepicker');
define('IMAGEPICKER_THUMBS_DIR', 'thumbs');
define('IMAGEPICKER_BROWSER_DIR', 'browser');
define('IMAGEPICKER_ORIG_DIR', 'orig');
define('IMAGEPICKER_WATERMARK_DIR', 'watermarks');
define('IMAGEPICKER_ADMIN_PATH', 'admin/settings/imagepicker');
define('IMAGEPICKER_PATH', drupal_get_path('module', 'imagepicker'));
define('IMAGEPICKER_INSERT_TEMPLATE', 'imagepicker_insert_template.txt');

// Minimum PHP version for extension
define('IMAGEPICKER_UPLOAD_STATUS_MIN_PHP', '5.2.1');
define('IMAGEPICKER_UPLOAD_ID', 'UPLOAD_IDENTIFIER');

/**
 * Implementation of hook_help().
 */
function imagepicker_help($path, $arg) {
  switch ($path) {
    case 'admin/help#imagepicker':
      $output = '<p>' . t('Adds an advanced image upload form under the node body part.') . '</p>';
      return $output;
  }
}

/**
 * Implementation of hook_perm().
 */
function imagepicker_perm() {
  return array(
    'administer imagepicker',
    'use imagepicker',
    'access own imagepicker',
    'use public imagepicker',
    'create public groups',
  );
}

/**
 * Implementation of hook_init().
 */
function imagepicker_init() {
  global $user;
  if ($user->uid > 0) {
    module_load_include('inc', 'imagepicker', 'imagepicker.functions');
    module_load_include('inc', 'imagepicker', 'imagepicker.form-elements');
  }
}

/**
 * Implementation of hook_menu().
 */
function imagepicker_menu() {
  $items = array();
  $items['imagepicker'] = array(
    'title' => 'Image picker',
    'page callback' => 'imagepicker_box',
    'access callback' => 'imagepicker_access_use',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.upload.inc',
  );
  $items['imagepicker/upload'] = array(
    'title' => 'Upload',
    'access callback' => 'imagepicker_access_use',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 0,
  );
  $items['imagepicker/browse'] = array(
    'title' => 'Browse',
    'page callback' => 'imagepicker_box',
    'access callback' => 'imagepicker_access_use',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );
  $items['imagepicker/browse_public'] = array(
    'title' => 'Browse Public',
    'page callback' => 'imagepicker_box',
    'access callback' => 'imagepicker_access_use_public',
    'type' => MENU_LOCAL_TASK,
    'weight' => 3,
  );
  $items['imagepicker/groups'] = array(
    'title' => 'Groups',
    'page callback' => 'imagepicker_box',
    'access callback' => 'imagepicker_access_use_group',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.group.inc',
    'weight' => 4,
  );
  $items['imagepicker/browse/%imagepicker_id'] = array(
    'title' => 'Browse',
    'page callback' => 'imagepicker_box',
    'access callback' => 'imagepicker_access_use',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );
  $items['imagepicker/edit/%imagepicker_id'] = array(
    'title' => 'Edit image',
    'page callback' => 'imagepicker_box',
    'access callback' => 'imagepicker_access_use',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.edit.inc',
  );
  $items['imagepicker/image/%imagepicker_id'] = array(
    'title' => 'Imagepicker',
    'page callback' => 'imagepicker_box',
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
  );
  $items['imagepicker/image/%imagepicker_id/%'] = array(
    'title' => 'Imagepicker',
    'page callback' => 'imagepicker_box',
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
  );

  // uploadprogress callback
  $items['imagepicker/progress'] = array(
    'page callback' => 'imagepicker_uploadprogress_callback',
    'access arguments' => array(
      TRUE,
    ),
    'type' => MENU_CALLBACK,
  );

  // admin settings
  $items[IMAGEPICKER_ADMIN_PATH] = array(
    'title' => 'Imagepicker',
    'description' => 'Imagepicker settings and administration.',
    'page callback' => 'imagepicker_settings_page',
    'access callback' => 'imagepicker_access_admin',
    'type' => MENU_NORMAL_ITEM,
    'file' => 'imagepicker.admin.inc',
    'weight' => 0,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/general'] = array(
    'title' => 'General',
    'description' => 'Imagepicker settings.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_settings_page',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -10,
  );

  // admin groups and images
  $items[IMAGEPICKER_ADMIN_PATH . '/groups'] = array(
    'title' => 'Groups',
    'description' => 'Show user groups.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -8,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/groups/users'] = array(
    'title' => 'Users',
    'description' => 'Show user groups.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -10,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/groups/stats'] = array(
    'title' => 'Stats',
    'description' => 'Show user group stats.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -8,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/groups/user/%imagepicker_id'] = array(
    'title' => 'Groups',
    'description' => 'Show user groups.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -7,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/groups/user/%imagepicker_id/stats'] = array(
    'title' => 'Stats',
    'description' => 'Show user stats.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -8,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/groups/autocomplete'] = array(
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_group_search_autocomplete',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.admin.inc',
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/stats'] = array(
    'title' => 'Stats All',
    'description' => 'Show user statistics.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -7,
  );

  // admin images
  $items[IMAGEPICKER_ADMIN_PATH . '/images'] = array(
    'title' => 'Images',
    'description' => 'Show user images.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -9,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/browse_all'] = array(
    'title' => 'Browse All',
    'description' => 'Browse user images.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -9,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/list_all'] = array(
    'title' => 'List All',
    'description' => 'List user images.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -8,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/users'] = array(
    'title' => 'Users',
    'description' => 'List users.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -10,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/user/%imagepicker_id/browse'] = array(
    'title' => 'Browse',
    'description' => 'Browse user images.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -4,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/user/%imagepicker_id/browseadmin'] = array(
    'title' => 'List',
    'description' => 'List user images.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -3,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/user/%imagepicker_id/upload'] = array(
    'title' => 'Upload',
    'description' => 'Browse user images.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -6,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/user/%imagepicker_id/stats'] = array(
    'title' => 'Stats',
    'description' => 'Browse user images.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -2,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/user/%imagepicker_id/groups'] = array(
    'title' => 'Groups',
    'description' => 'List user groups.',
    'access callback' => 'imagepicker_access_admin_group',
    'page callback' => 'imagepicker_admin_images',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -1,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/images/autocomplete'] = array(
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_user_autocomplete',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.admin.inc',
  );

  // admin validation
  $items[IMAGEPICKER_ADMIN_PATH . '/convert'] = array(
    'title' => 'Validate Files',
    'description' => 'Validate and convert Imagepicker Files.',
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'imagepicker_convert_form',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -7,
  );

  // Import
  $items[IMAGEPICKER_ADMIN_PATH . '/import'] = array(
    'title' => 'Import',
    'description' => 'Manage bulk imports.',
    'page callback' => 'imagepicker_admin_import',
    'access callback' => 'imagepicker_access_import',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -8,
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/import/autocomplete'] = array(
    'access callback' => 'imagepicker_access_import',
    'page callback' => 'imagepicker_user_autocomplete',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.admin.inc',
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/import/user/%imagepicker_id'] = array(
    'title' => 'Import',
    'description' => 'Import files.',
    'access callback' => 'imagepicker_access_import',
    'page callback' => 'imagepicker_admin_import',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.admin.inc',
    'weight' => -3,
  );

  // multitask
  $items[IMAGEPICKER_ADMIN_PATH . '/multitask/%/%/%'] = array(
    'title' => 'Bulk Operations',
    'page callback' => 'imagepicker_multitask',
    'page arguments' => array(
      4,
      5,
      6,
    ),
    'access callback' => 'imagepicker_access_admin',
    'type' => MENU_CALLBACK,
  );

  // orphans
  $items[IMAGEPICKER_ADMIN_PATH . '/orphans'] = array(
    'title' => 'Orphaned images',
    'description' => 'Manage orphaned images.',
    'page callback' => 'imagepicker_admin_orphans',
    'access callback' => 'imagepicker_access_admin',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.admin.inc',
  );
  $items[IMAGEPICKER_ADMIN_PATH . '/orphans/autocomplete'] = array(
    'access callback' => 'imagepicker_access_admin',
    'page callback' => 'imagepicker_user_autocomplete',
    'type' => MENU_CALLBACK,
    'file' => 'imagepicker.admin.inc',
  );

  // My imagepicker
  $items['user/%imagepicker_uid/imagepicker'] = array(
    'title' => 'My imagepicker',
    'description' => 'Manage your imagepicker files.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'imagepicker_access_user_pages',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => 0,
  );
  $items['user/%imagepicker_uid/imagepicker/upload'] = array(
    'title' => 'Upload',
    'description' => 'Upload images.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
    ),
    'access callback' => 'imagepicker_access_user_pages',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -9,
  );
  $items['user/%imagepicker_uid/imagepicker/images/browse'] = array(
    'title' => 'Browse',
    'description' => 'Browse your imagepicker files.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
      4,
      5,
    ),
    'access callback' => 'imagepicker_access_user_pages',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -7,
  );
  $items['user/%imagepicker_uid/imagepicker/images/browseadmin'] = array(
    'title' => 'List',
    'description' => 'List your imagepicker files.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
      4,
      5,
    ),
    'access callback' => 'imagepicker_access_user_pages',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -6,
  );

  // groups
  $items['user/%imagepicker_uid/imagepicker/images/browse_public'] = array(
    'title' => 'Browse Public',
    'description' => 'Browse public imagepicker files.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
      4,
      5,
    ),
    'access callback' => 'imagepicker_access_user_public',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -5,
  );
  $items['user/%imagepicker_uid/imagepicker/groups/browse'] = array(
    'title' => 'Groups',
    'description' => 'Manage your imagepicker groups.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
      4,
      5,
    ),
    'access callback' => 'imagepicker_access_user_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -4,
  );
  $items['user/%imagepicker_uid/imagepicker/stats'] = array(
    'title' => 'Stats',
    'description' => 'View your imagepicker statistics.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
    ),
    'access callback' => 'imagepicker_access_user_groups',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -3,
  );
  $items['user/%imagepicker_uid/imagepicker/config'] = array(
    'title' => 'Config',
    'description' => 'Administer user configuration.',
    'page callback' => 'imagepicker_user_page',
    'page arguments' => array(
      1,
      3,
    ),
    'access callback' => 'imagepicker_access_user_config',
    'type' => MENU_LOCAL_TASK,
    'file' => 'imagepicker.user.inc',
    'weight' => -2,
  );

  // multitask
  $items['user/%imagepicker_uid/imagepicker/multitask/%/%/%'] = array(
    'title' => 'Bulk Operations',
    'page callback' => 'imagepicker_multitask',
    'page arguments' => array(
      4,
      5,
      6,
    ),
    'access callback' => 'imagepicker_access_user_pages',
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * menu placeholder functions
 */
function imagepicker_id_load($arg) {
  return is_numeric($arg) ? $arg : FALSE;
}
function imagepicker_uid_load($arg) {
  global $user;
  return is_numeric($arg) && $user->uid == $arg ? $arg : FALSE;
}

/**
 * Menu access callback functions.
 */
function imagepicker_access_import() {
  if (variable_get('imagepicker_import_enabled', 0) && user_access('administer imagepicker')) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_user_pages() {
  if (variable_get('imagepicker_account_enabled', 1) && user_access('access own imagepicker')) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_user_config() {
  if (variable_get('imagepicker_account_enabled', 1) && user_access('access own imagepicker') && variable_get('imagepicker_user_config_enable', 1)) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_user_groups() {
  if (variable_get('imagepicker_account_enabled', 1) && user_access('access own imagepicker') && variable_get('imagepicker_groups_enabled', 1)) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_user_public() {
  if (variable_get('imagepicker_account_enabled', 1) && user_access('access own imagepicker') && variable_get('imagepicker_groups_enabled', 1) && user_access('use public imagepicker') && variable_get('imagepicker_public_enabled', 1)) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_admin_group() {
  if (variable_get('imagepicker_groups_enabled', 1) && user_access('administer imagepicker')) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_admin() {
  if (user_access('administer imagepicker')) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_use() {
  if (user_access('use imagepicker')) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_use_public() {
  if (user_access('use public imagepicker') && variable_get('imagepicker_public_enabled', 1)) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_access_use_group() {
  if (user_access('use imagepicker') && variable_get('imagepicker_groups_enabled', 1)) {
    return TRUE;
  }
  return FALSE;
}

/**
 * Implementation of hook_block().
 */
function imagepicker_block($op = 'list', $delta = 0, $edit = array()) {
  if (variable_get('imagepicker_galleryblocks_enabled', 0) && module_exists('colorbox')) {
    $howmany = variable_get('imagepicker_galleryblocks_howmany', 1);
    switch ($op) {
      case 'list':
        for ($i = 1; $i <= $howmany; $i++) {
          if (variable_get('imagepicker_galleryblocks_enable_' . $i, 0)) {
            $blocks[$i]['info'] = t('Imagepicker Gallery block !i', array(
              '!i' => $i,
            ));
            $blocks[$i]['cache'] = BLOCK_NO_CACHE;
          }
        }
        return $blocks;
      case 'configure':
        $form = imagepicker_block_form($delta);
        return $form;
      case 'save':
        imagepicker_block_form_submit($delta, $edit);
        return;
      case 'view':
        $block = array(
          'subject' => variable_get('imagepicker_galleryblocks_title_' . $delta, t('Gallery !i', array(
            '!i' => $delta,
          ))),
          'content' => imagepicker_display_block($delta),
        );
        return $block;
      case 'cache':
        return BLOCK_NO_CACHE;
    }
  }
}

/**
 * Function to display the contents of a block.
 */
function imagepicker_display_block($i) {

  // fetch all the images for the group
  $boxtype = 'colorbox';
  $gid = variable_get('imagepicker_galleryblocks_group_' . $i, '');
  $clickon = variable_get('imagepicker_galleryblocks_link_' . $i, t('Photo Gallery !i', array(
    '!i' => $i,
  )));
  $textarea = variable_get('imagepicker_galleryblocks_text_' . $i, '');
  $group = imagepicker_get_user_group($gid);
  $gal = $group->group_name;
  $sql = "SELECT DISTINCT i.img_id, i.uid, i.img_name, i.img_title, img_description\n  FROM {imagepicker} AS i JOIN {users} AS n USING (uid),\n  {imagepicker_user_groups} AS u JOIN {imagepicker_group_images} AS g USING (gid)\n  WHERE g.img_id=i.img_id AND u.group_name = '{$gal}'";
  $result = db_query($sql);
  $ct = 0;
  $content = "";
  $class = '';
  while ($img = db_fetch_object($result)) {
    $name = $img->img_name;
    $t = $img->img_title;
    $d = $img->img_description;
    $title = $d ? $d : $t;
    if (variable_get('file_downloads', '1') == 2) {
      $full = imagepicker_get_image_path($img, 'full', array(
        'uid' => $img->uid,
      ));
    }
    else {
      $full = file_directory_path() . DIRECTORY_SEPARATOR . IMAGEPICKER_FILES_DIR . DIRECTORY_SEPARATOR . $img->uid . DIRECTORY_SEPARATOR . $name;
    }
    if ($ct) {
      $class = "js-hide";
      $content .= l($name, $full, array(
        'html' => $ct ? FALSE : TRUE,
        'attributes' => array(
          'class' => "{$boxtype} {$class}",
          'rel' => $gal,
          'title' => $title,
        ),
      ));
    }
    else {

      // first one is visible
      $link = l($clickon, $full, array(
        'html' => $ct ? FALSE : TRUE,
        'attributes' => array(
          'class' => "{$boxtype} {$class}",
          'rel' => $gal,
          'title' => $title,
        ),
      ));
      if ($textarea && preg_match("/\\[link\\]/", $textarea)) {
        $content .= preg_replace("/\\[link\\]/", $link, $textarea);
      }
      else {
        $content .= $textarea . $link;
      }
    }
    $ct++;
  }
  return theme('imagepicker_display_block', $content);
}

// the block form
function imagepicker_block_form($i) {
  $groups = imagepicker_get_all_groups();
  $form['imagepicker_galleryblocks_link_' . $i] = array(
    '#type' => 'textfield',
    '#title' => t('Link text for Gallery Block !i', array(
      '!i' => $i,
    )),
    '#default_value' => variable_get('imagepicker_galleryblocks_link_' . $i, t('Photo Gallery !i', array(
      '!i' => $i,
    ))),
    '#required' => TRUE,
    '#description' => t('Set the link text for this block. Can contain html.'),
    '#maxlength' => 255,
  );
  $form['imagepicker_galleryblocks_group_' . $i] = array(
    '#type' => 'select',
    '#title' => t('Select a group for this block'),
    '#default_value' => variable_get('imagepicker_galleryblocks_group_' . $i, ''),
    '#options' => $groups,
  );
  $form['imagepicker_galleryblocks_text_' . $i] = array(
    '#type' => 'textarea',
    '#title' => t('Block text'),
    '#default_value' => variable_get('imagepicker_galleryblocks_text_' . $i, ''),
    '#required' => FALSE,
    '#description' => t("You can add some text to the block. To include the link in the text use the token '[link]' "),
  );
  $form['imagepicker_galleryblocks_enable_' . $i] = array(
    '#type' => 'value',
    '#value' => 1,
  );
  $form['imagepicker_galleryblocks_grouptot'] = array(
    '#type' => 'value',
    '#value' => count($groups),
  );
  return $form;
}
function imagepicker_block_form_submit($i, $edit) {

  // clean out any existing ones
  variable_del('imagepicker_galleryblocks_link_' . $i);
  variable_del('imagepicker_galleryblocks_text_' . $i);
  variable_del('imagepicker_galleryblocks_group_' . $i);
  variable_del('imagepicker_galleryblocks_enable_' . $i);
  if ($edit['imagepicker_galleryblocks_enable_' . $i] && !empty($edit['imagepicker_galleryblocks_link_' . $i]) && $edit['imagepicker_galleryblocks_grouptot']) {
    variable_set('imagepicker_galleryblocks_link_' . $i, $edit['imagepicker_galleryblocks_link_' . $i]);
    variable_set('imagepicker_galleryblocks_text_' . $i, check_markup($edit['imagepicker_galleryblocks_text_' . $i]));
    variable_set('imagepicker_galleryblocks_group_' . $i, $edit['imagepicker_galleryblocks_group_' . $i]);
    variable_set('imagepicker_galleryblocks_enable_' . $i, $edit['imagepicker_galleryblocks_enable_' . $i]);
  }
}

/**
 * Implementation of hook_form_alter().
 */
function imagepicker_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  $node_type = FALSE;
  $comment = FALSE;
  $block = FALSE;
  $weight = 1;
  if (isset($form['#node'])) {
    $node = $form['#node'];
    $node_types = node_get_types('names');
    $node_type = in_array($node->type, variable_get('imagepicker_node_types_enabled', array_keys($node_types)), TRUE);
  }
  elseif (module_exists('comment') && variable_get('imagepicker_comment_enabled', 0) && preg_match('/comment_form$/i', $form_id)) {
    $comment = TRUE;
    $weight = 1;
  }
  elseif (($form_id == 'block_add_block_form' || $form_id == 'block_admin_configure') && variable_get('imagepicker_blocks_enabled', 0)) {
    $block = TRUE;
    $weight = 1;
  }
  if (user_access('use imagepicker')) {
    $width = variable_get('imagepicker_advanced_iframe_width', "100%");
    if (isset($user->imagepicker_advanced_iframe_width) && $user->imagepicker_advanced_iframe_width) {
      $width = $user->imagepicker_advanced_iframe_width;
    }
    if (!preg_match("/%\$/", $width)) {
      $width .= 'px';
    }
    $height = variable_get('imagepicker_advanced_iframe_height', 500);
    if (isset($user->imagepicker_advanced_iframe_height) && $user->imagepicker_advanced_iframe_height) {
      $height = $user->imagepicker_advanced_iframe_height;
    }
    $border = variable_get('imagepicker_advanced_iframe_border', "0");
    if (isset($user->imagepicker_advanced_iframe_border)) {
      $border = $user->imagepicker_advanced_iframe_border;
    }
    if (imagepicker_get_thickbox_perms()) {
      $iurl = l(t('Run imagepicker'), 'imagepicker');
    }
    elseif (imagepicker_get_colorbox_perms()) {
      $iurl = l(t('Run imagepicker'), 'imagepicker', array(
        'query' => array(
          'width' => $width,
          'height' => $height,
          'iframe' => 'true',
        ),
        'attributes' => array(
          'class' => 'colorbox-load',
        ),
      ));
    }
    else {
      $iurl = '<iframe id="imagepicker" style="width: ' . $width . '; height: ' . $height . 'px; border: ' . $border . ';" src="' . url('imagepicker') . '">Imagepicker requires iframe support.</iframe>';
    }
    if ($node_type && preg_match('/node_form$/i', $form_id) || $comment) {
      $form['body_field']['body_filter']['imagepicker_file_upload'] = array(
        '#type' => 'fieldset',
        '#title' => t('Image picker'),
        '#collapsible' => 1,
        '#collapsed' => variable_get('imagepicker_advanced_collapsed', 0),
        '#weight' => $weight,
      );
      $form['body_field']['body_filter']['#weight'] = 2;
      $form['body_field']['body_filter']['imagepicker_file_upload']['mpframe'] = array(
        '#type' => 'markup',
        '#value' => '<div id="imgp_tb">' . $iurl . '</div>',
      );
      $form['body_field']['#prefix'] = '<a name="body_hash"></a>' . $form['body_field']['#prefix'];
    }
    elseif ($block) {
      $form['block_settings']['imagepicker_file_upload'] = array(
        '#type' => 'fieldset',
        '#title' => t('Image picker'),
        '#collapsible' => TRUE,
        '#collapsed' => isset($user->imagepicker_advanced_collapsed) ? $user->imagepicker_advanced_collapsed : variable_get('imagepicker_advanced_collapsed', 0),
        '#weight' => $weight,
      );
      $form['block_settings']['imagepicker_file_upload']['mpframe'] = array(
        '#type' => 'markup',
        '#value' => '<div id="imgp_tb">' . $iurl . '</div>',
      );
      $form['block_settings']['#prefix'] = '<a name="body_hash"></a>' . $form['block_settings']['#prefix'];
    }
  }
}
function imagepicker_get_thickbox_perms() {
  global $user;
  if (module_exists('thickbox') && isset($user->imagepicker_advanced_thickbox) && $user->imagepicker_advanced_thickbox && variable_get('imagepicker_advanced_thickbox', 0) || module_exists('thickbox') && !isset($user->imagepicker_advanced_thickbox) && variable_get('imagepicker_advanced_thickbox', 0)) {
    return TRUE;
  }
  return FALSE;
}
function imagepicker_get_colorbox_perms() {
  global $user;
  if (module_exists('colorbox') && isset($user->imagepicker_advanced_colorbox) && $user->imagepicker_advanced_colorbox && variable_get('imagepicker_advanced_colorbox', 0) && variable_get('colorbox_load', 0) || module_exists('colorbox') && !isset($user->imagepicker_advanced_colorbox) && variable_get('imagepicker_advanced_colorbox', 0) && variable_get('colorbox_load', 0)) {
    return TRUE;
  }
  return FALSE;
}

/**
 * get all for a group
 */
function imagepicker_get_user_group($gid, $obj = TRUE) {
  $result = db_query("SELECT * FROM {imagepicker_user_groups} WHERE gid = %d", array(
    $gid,
  ));
  if ($obj) {
    return db_fetch_object($result);
  }
  return db_fetch_array($result);
}

// for blocks
function imagepicker_get_all_groups($override = NULL) {
  $public = FALSE;
  if ($override == NULL) {
    $public = variable_get('imagepicker_galleryblocks_public', 0);
  }
  else {
    $public = $override;
  }
  $data = FALSE;
  $sql = "SELECT gid, group_name FROM {imagepicker_user_groups}";
  if ($public) {
    $sql .= " WHERE public=1";
  }
  $result = db_query($sql);
  while ($row = db_fetch_array($result)) {
    $result2 = db_query("SELECT count(DISTINCT gi.img_id) AS ct FROM {imagepicker_group_images} gi, {imagepicker_user_groups} g WHERE g.gid = gi.gid AND g.gid = %d", array(
      $row['gid'],
    ));
    $row2 = db_fetch_array($result2);
    $totcount = $row2['ct'];
    $data[$row['gid']] = $row['group_name'] . ' - ' . format_plural($totcount, '1 image', '@count images');
  }
  return $data;
}

/**
 * Implementation of hook_file_download().
 */
function imagepicker_file_download($filepath) {
  $imgbasedir = imagepicker_get_files_directory(TRUE);
  $file = $imgbasedir . DIRECTORY_SEPARATOR . $filepath;
  if (file_exists($file) & is_file($file)) {

    // There is a file, and it's in our directory structure. So send it.
    $mimetype = file_get_mimetype($filepath);
    return array(
      'Content-type:' . $mimetype,
    );
  }
  else {
    $path_parts = explode('/', $filepath);
    if ($path_parts[0] == IMAGEPICKER_FILES_DIR) {

      // The file is allegedly in our directory, but doesn't exist.
      return -1;
    }
  }

  // Not our file; let someone else decide.
  return NULL;
}

/**
 * some common utilities
 */
function imagepicker_get_path($url = FALSE, $userdir = FALSE) {
  global $base_url;
  $dirsep = !$url ? DIRECTORY_SEPARATOR : '/';
  if (!$url) {
    $path = imagepicker_get_files_directory() . $dirsep;
  }
  else {
    if (variable_get('imagepicker_use_full_url', 0)) {
      $path = $base_url;
    }
    else {
      $path = base_path();
      $path = preg_replace("/\\/\$/", "", $path);
    }
    $path .= $dirsep . file_directory_path() . $dirsep . IMAGEPICKER_FILES_DIR . $dirsep;
  }
  if ($userdir) {
    $path .= imagepicker_get_userpath($userdir, $dirsep);
  }
  return $path;
}
function imagepicker_get_userpath($userdir, $dirsep = '/') {
  global $user;
  $path = '';

  // old or new
  $fstype = variable_get('imagepicker_fstype', '');
  if ($fstype == 'alpha') {
    $username = !is_array($userdir) ? $user->name : $userdir['name'];
    $firstletter = drupal_strtolower(drupal_substr($username, 0, 1));
    $firstletter = preg_match('/^[a-z]$/', $firstletter) ? $firstletter : 'others';
    $path .= $firstletter . $dirsep . $username . $dirsep;
  }
  else {
    $useruid = !is_array($userdir) ? $user->uid : $userdir['uid'];
    $path .= $useruid . $dirsep;
  }
  return $path;
}
function imagepicker_get_image_path($img, $type = 'browser', $public = FALSE, $preset = FALSE) {
  $userdir = is_array($public) ? $public : TRUE;
  $imgbasedir = imagepicker_get_path(FALSE, $userdir);
  $found = FALSE;

  // $img is object or array
  if (is_object($img)) {
    $img_name = $img->img_name;
  }
  else {
    $img_name = $img['img_name'];
  }
  switch ($type) {
    case 'browser':
      if (file_exists($imgbasedir . IMAGEPICKER_BROWSER_DIR . DIRECTORY_SEPARATOR . $img_name)) {
        $suffix = IMAGEPICKER_BROWSER_DIR;
        $found = TRUE;
      }
      elseif (file_exists($imgbasedir . IMAGEPICKER_THUMBS_DIR . DIRECTORY_SEPARATOR . $img_name)) {
        $suffix = IMAGEPICKER_THUMBS_DIR;
        $found = TRUE;
      }
      break;
    case 'full':
      if (file_exists($imgbasedir . $img_name)) {
        $suffix = NULL;
        $found = TRUE;
      }
      break;
    case 'thumb':
    default:
      if (file_exists($imgbasedir . IMAGEPICKER_THUMBS_DIR . DIRECTORY_SEPARATOR . $img_name)) {
        $suffix = IMAGEPICKER_THUMBS_DIR;
        $found = TRUE;
      }
      elseif (file_exists($imgbasedir . IMAGEPICKER_BROWSER_DIR . DIRECTORY_SEPARATOR . $img_name)) {
        $suffix = IMAGEPICKER_BROWSER_DIR;
        $found = TRUE;
      }
      break;
    case 'watermarks':
      if (file_exists($imgbasedir . $img_name)) {
        $suffix = IMAGEPICKER_WATERMARK_DIR;
        $found = TRUE;
      }
      break;
    case 'orig':
      if (file_exists($imgbasedir . $img_name)) {
        $suffix = IMAGEPICKER_ORIG_DIR;
        $found = TRUE;
      }
      break;
  }
  if ($found) {
    if ($suffix) {
      if (variable_get('imagepicker_use_full_url', 0) || variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
        if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset && $suffix == IMAGEPICKER_THUMBS_DIR) {
          $imgpath = imagecache_create_url('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $suffix . '/' . $img_name);
        }
        else {
          $imgpath = file_create_url(IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $suffix . '/' . $img_name);
        }
      }
      else {
        if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset && $suffix == IMAGEPICKER_THUMBS_DIR) {
          $imgpath = base_path() . imagecache_create_path('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $suffix . '/' . $img_name);
        }
        else {
          $imgpath = imagepicker_get_path(TRUE, $userdir) . $suffix . '/' . $img_name;
        }
      }
    }
    else {
      if (variable_get('imagepicker_use_full_url', 0) || variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
        if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset) {
          $imgpath = imagecache_create_url('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $img_name);
        }
        else {
          $imgpath = file_create_url(IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $img_name);
        }
      }
      else {
        if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0) && $preset) {
          $imgpath = base_path() . imagecache_create_path('__PRESET__', IMAGEPICKER_FILES_DIR . '/' . imagepicker_get_userpath($userdir) . $img_name);
        }
        else {
          $imgpath = imagepicker_get_path(TRUE, $userdir) . $img_name;
        }
      }
    }
  }
  return $imgpath ? $imgpath : '';
}
function imagepicker_get_files_directory($system_only = FALSE) {
  $drupal_path = file_directory_path();
  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
    $drupaldir = $drupal_path;
  }
  else {
    $drupaldir = str_replace('/', DIRECTORY_SEPARATOR, getcwd()) . DIRECTORY_SEPARATOR . $drupal_path;
  }
  if ($system_only) {
    return $drupaldir;
  }
  $dir = $drupaldir . DIRECTORY_SEPARATOR . IMAGEPICKER_FILES_DIR;
  return $dir;
}

/**
 * Themimg functions for imagepicker.
 */

/**
 * theme registry
 */
function imagepicker_theme() {
  return array(
    'imagepicker' => array(
      'arguments' => array(
        'content' => NULL,
      ),
      'template' => 'imagepicker',
    ),
    'imagepicker_iframe' => array(
      'arguments' => array(
        'content' => NULL,
        'img' => NULL,
        'public' => NULL,
      ),
    ),
    'imagepicker_list' => array(
      'arguments' => array(
        'header' => array(),
        'rows' => array(),
        'max' => 50,
        'message' => "",
        'pref' => "",
        'suff' => "",
        'label' => "",
      ),
    ),
    'imagepicker_stats' => array(
      'arguments' => array(
        'header' => array(),
        'rows' => array(),
        'pref' => "",
        'suff' => "",
        'label' => "",
      ),
    ),
    'imagepicker_browser' => array(
      'arguments' => array(
        'content' => array(),
        'forms' => array(),
        'message' => "",
        'help' => "",
        'label' => "",
      ),
    ),
    'imagepicker_fullpage' => array(
      'arguments' => array(
        'image' => array(),
        'source' => "",
        'link' => 1,
      ),
    ),
    'imagepicker_quota_message' => array(
      'arguments' => array(
        'message1' => "",
        'message2' => "",
        'form' => array(),
        'label' => "",
        'help' => "",
      ),
    ),
    'imagepicker_view' => array(
      'arguments' => array(
        'img' => array(),
        'imgpath' => "",
        'info' => array(),
        'exifinfo' => array(),
      ),
    ),
    'imagepicker_image_edit_header' => array(
      'arguments' => array(
        'image' => array(),
        'source' => "",
      ),
    ),
    'imagepicker_quota' => array(
      'arguments' => array(
        'form' => array(),
        'message' => "",
        'label' => "",
      ),
    ),
    'imagepicker_user_config' => array(
      'arguments' => array(
        'form' => array(),
        'label' => "",
        'help' => "",
        'message1' => "",
        'message2' => "",
      ),
    ),
    'imagepicker_user_view' => array(
      'arguments' => array(
        'view' => "",
        'form1' => array(),
        'form2' => array(),
        'form3' => array(),
      ),
    ),
    'imagepicker_admin_view' => array(
      'arguments' => array(
        'view' => "",
        'form1' => array(),
        'form2' => array(),
        'form3' => array(),
      ),
    ),
    'imagepicker_insert' => array(
      'arguments' => array(
        'img' => NULL,
        'public' => NULL,
        'form1' => array(),
        'form2' => array(),
      ),
    ),
    'imagepicker_upload_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_user_image_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_user_config_admin_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_admin_image_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_user_search_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_group_search_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_quota_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_edit_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_groups_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_group_delete_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_image_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_groups_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_public_groups_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_group_images_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_order_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_public_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_search_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_copy_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_settings_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_admin_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_browse_admin' => array(
      'arguments' => array(
        'forms' => '',
        'message' => '',
        'pref' => '',
        'suff' => '',
        'label' => '',
      ),
    ),
    'imagepicker_multitask_delete_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_multitask_groups_form' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
    'imagepicker_import_form' => array(
      'arguments' => array(
        'form' => NULL,
      ),
    ),
    'imagepicker_import_dir_form' => array(
      'arguments' => array(
        'form' => NULL,
      ),
    ),
    'imagepicker_admin_orphans_form' => array(
      'arguments' => array(
        'form' => NULL,
      ),
    ),
    'imagepicker_display_block' => array(
      'arguments' => array(
        'content' => '',
      ),
    ),
  );
}

// preprocess for imagepicker.tpl.php
function template_preprocess_imagepicker(&$variables) {
  global $language;
  if (module_exists('admin_menu')) {
    admin_menu_suppress();
  }
  $variables['head_title'] = drupal_get_title() ? strip_tags(drupal_get_title()) : variable_get('site_name', 'Drupal');
  $variables['styles'] = drupal_get_css();
  $variables['scripts'] = drupal_get_js();

  // fix jquery version thing in the iframe
  if (module_exists('jquery_update')) {
    jquery_update_preprocess_page($variables);
  }
  $variables['tabs'] = theme('menu_local_tasks');
  $variables['messages'] = imagepicker_strip_messages(theme('status_messages'));
  $variables['language'] = $language;
}

// set up the iframe
function theme_imagepicker_iframe($content, $img = '', $public = FALSE) {
  drupal_add_css(IMAGEPICKER_PATH . '/imagepicker.css');
  if ($img) {
    global $user;
    $presetfilelink = '';
    $presetthumblink = '';
    if (module_exists('imagecache') && variable_get('imagepicker_imagecache_enable', 0)) {
      $presetfilelink = imagepicker_get_image_path($img, 'full', $public ? array(
        'name' => $img['name'],
        'uid' => $img['uid'],
      ) : FALSE, TRUE);
      $presetthumblink = imagepicker_get_image_path($img, 'thumb', $public ? array(
        'name' => $img['name'],
        'uid' => $img['uid'],
      ) : FALSE, TRUE);
    }
    $info = image_get_info(imagepicker_get_path(FALSE, TRUE) . $img['img_name']);
    $thumbinfo = image_get_info(imagepicker_get_path(FALSE, TRUE) . IMAGEPICKER_THUMBS_DIR . '/' . $img['img_name']);
    $img_title = $img['img_title'];
    $settings = array(
      'imagepicker_iframe' => array(
        'imgpImageAlt' => $img_title ? $img_title : t('Image'),
        'imgpImageTitle' => $img_title ? htmlspecialchars_decode($img_title, ENT_QUOTES) : '',
        'imgpImageDesc' => preg_replace("/(\n|\r)/", '', nl2br($img['img_description'])),
        'imgpFileLink' => imagepicker_get_image_path($img, 'full', $public ? array(
          'name' => $img['name'],
          'uid' => $img['uid'],
        ) : FALSE),
        'imgpPresetFileLink' => $presetfilelink,
        'imgpThumbLink' => imagepicker_get_image_path($img, 'thumb', $public ? array(
          'name' => $img['name'],
          'uid' => $img['uid'],
        ) : FALSE),
        'imgpPresetThumbLink' => $presetthumblink,
        'imgpPageLink' => url('imagepicker/image/' . $img['img_id']),
        'imgpTemplate' => imagepicker_get_insert_template(),
        'imgpWidth' => $info['width'],
        'imgpHeight' => $info['height'],
        'imgpThumbWidth' => $thumbinfo['width'],
        'imgpThumbHeight' => $thumbinfo['height'],
        'isFCKeditor' => module_exists('fckeditor') ? 'yes' : 'no',
        'isWysiwyg' => module_exists('wysiwyg') ? 'yes' : 'no',
        'use_cssbox' => variable_get('imagepicker_use_cssbox', 0) && !isset($user->imagepicker_use_cssbox) ? 1 : variable_get('imagepicker_use_cssbox', 0) && isset($user->imagepicker_use_cssbox) && $user->imagepicker_use_cssbox ? 1 : 0,
        'use_relbox' => variable_get('imagepicker_use_relbox', 0) && !isset($user->imagepicker_use_relbox) ? 1 : variable_get('imagepicker_use_relbox', 0) && isset($user->imagepicker_use_relbox) && $user->imagepicker_use_relbox ? 1 : 0,
        'use_linkbox' => variable_get('imagepicker_use_linkbox', 0) && !isset($user->imagepicker_use_linkbox) ? 1 : variable_get('imagepicker_use_linkbox', 0) && isset($user->imagepicker_use_linkbox) && $user->imagepicker_use_linkbox ? 1 : 0,
        'insert_image_title' => variable_get('imagepicker_insert_image_title', 0) && !isset($user->imagepicker_insert_image_title) ? 1 : isset($user->imagepicker_insert_image_title) && $user->imagepicker_insert_image_title ? 1 : 0,
        'default_align_show' => variable_get('imagepicker_default_align_show', 1) && !isset($user->imagepicker_default_align_show) ? 1 : variable_get('imagepicker_default_align_show', 1) && isset($user->imagepicker_default_align_show) && $user->imagepicker_default_align_show ? 1 : 0,
        'default_fleft' => isset($user->imagepicker_default_fleft) ? $user->imagepicker_default_fleft : variable_get('imagepicker_default_fleft', 'style="float: left"'),
        'default_fright' => isset($user->imagepicker_default_fright) ? $user->imagepicker_default_fright : variable_get('imagepicker_default_fright', 'style="float: right"'),
        'lightbox2_enable' => module_exists('lightbox2') && variable_get('imagepicker_lightbox2_enable', 0),
        'lightbox2_insert' => isset($user->imagepicker_lightbox2_insert) ? $user->imagepicker_lightbox2_insert : variable_get('imagepicker_lightbox2_insert', 'lightbox'),
        'thickbox_enable' => module_exists('thickbox') && variable_get('imagepicker_thickbox_enable', 0),
        'colorbox_enable' => module_exists('colorbox') && variable_get('imagepicker_colorbox_enable', 0),
        'colorbox_iframe' => imagepicker_get_colorbox_perms(),
      ),
    );
    drupal_add_js($settings, 'setting');
    drupal_add_js(IMAGEPICKER_PATH . '/imagepicker_iframe.js');
  }
  return $content;
}
function theme_imagepicker_list($header, $rows, $max, $message = "", $pref = "", $suff = "", $label = "", $cols = 1) {
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';
  if ($rows) {
    $pager = theme('pager', NULL, $max);
    if ($pager) {
      $rows[] = array(
        array(
          'data' => $pager,
          'colspan' => $cols,
        ),
      );
    }
    $output .= $pref . theme('table', $header, $rows) . $suff;
  }
  else {
    $output .= '<div class="messages">' . $message . '</div>';
  }
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_stats($header, $rows, $pref = "", $suff = "", $label = "") {
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';
  $output .= $pref . theme('table', $header, $rows) . $suff;
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_browser($content, $forms = '', $message = '', $help = '', $label = '') {
  $rows = $content[0];
  $max = $content[1];
  $cols = $content[2];
  $pref1 = $content[3][0];
  $pref2 = $content[3][1];
  $suff1 = $content[4][0];
  $suff2 = $content[4][1];
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';

  // forms
  if ($forms) {
    $output .= $forms['browse_search'];
    $output .= $forms['browse_groups'];
    $output .= $forms['browse_public'];
    $output .= $forms['browse_public_groups'];
    $output .= $forms['browse_order'];
  }
  if ($rows) {

    // help message
    if ($help) {
      $output .= '<div class="imgp_help">' . $help . '</div>';
    }
    $pager = theme('pager', NULL, $max);
    $output .= $pref1;
    $ct = 0;
    foreach ($rows as $row) {
      $tooltip = $row['img_name'] . ': ' . $row['img_title'] . ' ' . $row['img_description'];
      $imglink = '<img src="' . $row['imgpath'] . '" alt="' . $row['img_title'] . '" title="' . $tooltip . '" />';
      $output .= $pref2 . l($imglink, $row['imgurl'] . $row['img_id'], array(
        'html' => TRUE,
      )) . $suff2;
      $ct++;
      if ($cols > 0 && $ct >= $cols) {
        $output .= $suff1 . $pref1;
        $ct = 0;
      }
    }
    $output .= $suff1 . $pager;
  }
  else {
    $output .= '<div class="messages">' . $message . '</div>';
  }
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_fullpage($image, $source, $link) {
  $output = '<div id="imgp_page"><div id="imgp_page_img">';
  $output .= '<a href="' . $source . '" alt="' . $image['img_title'] . '" target="_blank">';
  $output .= '<img src="' . $source . '" alt="' . $image['img_title'] . '" /></a></div>';
  $output .= $image['img_description'] ? '<div>' . nl2br($image['img_description']) . '</div>' : '';
  $output .= $link ? '<div><a href="#" onclick="history.back()">' . t('Return to page') . '</a></div>' : '';
  $output .= '</div>';
  return $output;
}
function theme_imagepicker_quota_message($message1, $message2, $form, $label, $help) {
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';
  $output .= $message1 ? '<div class="messages">' . $message1 . '</div>' : '';
  $output .= $help ? '<div class="imgp_help">' . $help . '</div>' : '';
  $output .= $form;
  $output .= $message2 ? '<div class="messages">' . $message2 . '</div>' : '';
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_view($img, $imgpath, $info, $exifinfo = '') {
  $output = '<div id="imgp_img_view">';
  $output .= $img['img_title'] ? '<div id="imgp_img_view_title">' . $img['img_title'] . '</div>' : '';
  $output .= '<img id="imgp_img_view_img" src="' . $imgpath . '" alt="' . $img['img_title'] . '" title="' . $img['img_name'] . '" />';
  $output .= $img['img_description'] ? '<div id="imgp_img_view_desc">' . nl2br($img['img_description']) . '</div>' : '';
  $output .= '<div>';
  $output .= t('Width') . ": " . $info['width'] . "&nbsp;&nbsp;&nbsp;";
  $output .= t('Height') . ": " . $info['height'] . "&nbsp;&nbsp;&nbsp;";
  $output .= t('Type') . ": " . $info['extension'] . "&nbsp;&nbsp;&nbsp;";
  $output .= t('Size') . ": " . $info['file_size'] . '</div>';
  if ($exifinfo) {
    $output .= '<a id="imgp_trig">' . t('Show/Hide Exif Info') . '</a>';
    $output .= '<div id="imgp_targ" >';
    if (is_array($exifinfo)) {

      // using php function exif_read_data().
      foreach ($exifinfo as $key => $section) {
        $header = array(
          array(
            'data' => drupal_ucfirst(drupal_strtolower($key)),
            'colspan' => 2,
          ),
        );
        $rows = array();
        foreach ($section as $name => $val) {
          if ($key == 'COMMENT') {
            $a = explode(':', $val);
            $rows[] = array(
              $a[0] . ':',
              $a[1],
            );
          }
          else {
            $rows[] = array(
              $name . ': ',
              $val,
            );
          }
        }
        $output .= theme('table', $header, $rows);
        unset($header);
        unset($rows);
      }
      $output .= '</div>';
    }
    else {

      // from an external source eg exiftool
      $output .= '<pre>';
      $output .= check_plain($exifinfo);
      $output .= '</pre>';
      $output .= '</div>';
    }
  }
  $output .= '</div>';
  return $output;
}
function theme_imagepicker_image_edit_header($image, $source) {
  $output = '<div class="imgp_help">' . t('Edit image details') . '</div>';
  $output .= '<div id="imgp_img_holder"><img src="' . $source . '" alt="' . $image['img_title'] . '" /></div>';
  return $output;
}
function theme_imagepicker_quota($form, $message, $label) {
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';
  $output .= $message ? '<div class="messages">' . $message . '</div>' : '';
  $output .= $form;
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_user_config($form, $label = '', $help = '', $message1 = '', $message2 = '') {
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';
  $output .= $help ? '<div class="imgp_help">' . $help . '</div>' : '';
  $output .= $message1 ? '<div class="messages">' . $message1 . '</div>' : '';
  $output .= $form;
  $output .= $message2 ? '<div class="messages">' . $message2 . '</div>' : '';
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_user_view($view, $form1 = '', $form2 = '', $form3 = '') {
  $output = "";
  $output .= $view;
  $output .= '<br />';
  $output .= $form1 ? $form1 : '';
  $output .= '<br />';
  $output .= $form2 ? $form2 : '';
  $output .= $form3 ? $form3 : '';
  return $output;
}
function theme_imagepicker_admin_view($view, $form1 = '', $form2 = '', $form3 = '') {
  $output = "";
  $output .= $view;
  $output .= '<br />';
  $output .= $form1 ? $form1 : '';
  $output .= '<br />';
  $output .= $form2 ? $form2 : '';
  $output .= $form3 ? $form3 : '';
  return $output;
}
function theme_imagepicker_insert($img = '', $public = FALSE, $form1 = '', $form2 = '') {
  $output = "";
  if ($img) {
    $imgpath = imagepicker_get_image_path($img, 'browser', $public ? array(
      'name' => $img['name'],
      'uid' => $img['uid'],
    ) : FALSE);
    $output .= '<div class="imgp_help">' . t('Choose the settings you want, place the cursor in the Body box above and Insert image.') . '</div>';
    if ($img['img_title']) {
      $output .= '<div id="imgp_img_holder_title">' . $img['img_title'] . '</div>';
    }
    if ($img['img_description']) {
      $output .= '<div id="imgp_img_holder_description">' . nl2br($img['img_description']) . '</div>';
    }
    $output .= '<div id="imgp_img_holder">';
    $output .= '<img id="imgp_img" src="' . $imgpath . '" alt="' . $img['img_title'] . '" title="' . $img['img_name'] . '" />';
    $output .= '</div>';
    $output .= $form1;
    $output .= $form2;
  }
  return $output;
}
function theme_imagepicker_upload_form($form) {
  $output = '';
  $max_uploads = variable_get('imagepicker_max_uploads', 1);
  $max_filesize = ini_get('upload_max_filesize');
  $form['maxmsg']['#value'] = '<div class="messages">' . t('Browse your computer for up to !c, Max %max Total', array(
    '!c' => format_plural($max_uploads, '1 Image', '@count Images'),
    '%max' => $max_filesize,
  )) . '</div>';
  for ($ct = 1; $ct <= $max_uploads; $ct++) {
    $form['file_upload_' . $ct]['#prefix'] = "<div id='imagepicker_upload_link_wrapper_{$ct}'>";
    $form['description_' . $ct]['#suffix'] = '</div>';
    if (isset($form['link_' . $ct])) {
      $form['link_' . $ct]['#value'] = "<div class='imagepicker_upload_link' id='imagepicker_upload_link_{$ct}' style='display:none'>" . l(t('Upload another'), '', array(
        'attributes' => array(
          'onClick' => "Drupal.imagepicker_upload_link_click({$ct}); return false;",
        ),
      )) . '</div>';
    }
  }
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_user_image_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_user_config_admin_form($form) {
  $output = '';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_align']['#prefix'] = '<div class="imgp_img_options">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_align']['#suffix'] = '</div>';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_show']['#prefix'] = '<div class="imgp_img_options">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_show']['#suffix'] = '</div>';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_link']['#prefix'] = '<div class="imgp_img_options">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_link']['#suffix'] = '</div>';
  $form['imagepicker_insert_defaults']['imagepicker_insert_image_title']['#prefix'] = '<div id="imgp_insert_image_title">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_image_title']['#suffix'] = '</div>';
  $form['imagepicker_watermark']['imagepicker_watermark_image']['#prefix'] = '<div class="container-inline">';
  $form['imagepicker_watermark']['imagepicker_watermark_image_delete']['#suffix'] = '</div>';
  $form['submit']['#prefix'] = '<div class="container-inline">';
  $form['reset']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_admin_image_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_user_search_form($form) {
  $output = '';
  $form['imagepicker_currentuser']['#prefix'] = '<div id="imgp_users_form" class="container-inline">';
  $form['imagepicker_user_search_submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_group_search_form($form) {
  $output = '';
  $form['imagepicker_currentgroup']['#prefix'] = '<div id="imgp_groups_form" class="container-inline">';
  $form['imagepicker_group_search_submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_quota_form($form) {
  $output = '';
  $form['imagepicker_quota']['#prefix'] = '<div id="imgp_quota_form" class="container-inline">';
  $form['submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_edit_form($form) {
  $output = '';
  $form['title']['#prefix'] = '<div id="imgp_edit_form">';
  $form['description']['#suffix'] = '</div>';
  $form['submit']['#prefix'] = '<div id="imgp_controls">';
  $form['cancel']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_groups_form($form) {
  $output = '';
  $form['groupsave']['group_public_roles']['#prefix'] = '<div id="wrap-group-public-roles">';
  $form['groupsave']['group_public_roles']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_group_delete_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_image_form($form) {
  $output = '';
  $form['align']['#prefix'] = '<div class="imgp_img_options">';
  $form['align']['#suffix'] = '</div>';
  $form['show']['#prefix'] = '<div class="imgp_img_options">';
  $form['show']['#suffix'] = '</div>';
  $form['link']['#prefix'] = '<div class="imgp_img_options">';
  $form['link']['#suffix'] = '</div>';
  $form['desc']['#prefix'] = '<div id="imgp_desc_control">';
  $form['desc']['#suffix'] = '</div>';
  $form['insert']['#prefix'] = '<div id="imgp_controls">';
  $form['delete']['#suffix'] = '</div>';
  if (isset($form['presets_show'])) {
    $form['presets_show']['#prefix'] = '<div id="imgp_presets_control"><div id="imgp_presets_show_control">';
    $form['presets_show']['#suffix'] = '</div>';
    $form['presets_link']['#prefix'] = '<div id="imgp_presets_link_control">';
    $form['presets_link']['#suffix'] = '</div></div>';
  }
  if (isset($form['relbox'])) {
    $form['relbox']['#prefix'] = '<div id="imgp_relbox_control"><div id="imgp_relbox_show_control">';
    $form['relbox']['#suffix'] = '</div>';
    $form['linkhide']['#prefix'] = '<div id="imgp_relbox_link_control">';
    $form['linkhide']['#suffix'] = '</div></div>';
  }
  if (isset($form['linkbox'])) {
    $form['linkbox']['#prefix'] = '<div id="imgp_linkbox_control">';
    $form['linkbox']['#suffix'] = '</div>';
  }
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_groups_form($form) {
  $output = '';
  $form['gid']['#prefix'] = '<div id="imgp_groups_form" class="container-inline">';
  $form['submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_public_groups_form($form) {
  $output = '';
  $form['gid']['#prefix'] = '<div id="imgp_groups_form" class="container-inline">';
  $form['submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_group_images_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_order_form($form) {
  $output = '';
  $form['imagepicker_browser_order']['#prefix'] = '<div id="imgp_order_form" class="container-inline">';
  $form['submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_public_form($form) {
  $output = '';
  $form['imagepicker_browse_public']['#prefix'] = '<div id="imgp_browse_form" class="container-inline">';
  $form['submit']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_search_form($form) {
  $output = '';
  $form['imagepicker_browser_search']['#prefix'] = '<div id="imgp_search_form" class="container-inline">';
  $form['reset']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_copy_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_settings_form($form) {
  $output = '';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_align']['#prefix'] = '<div class="imgp_img_options">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_align']['#suffix'] = '</div>';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_show']['#prefix'] = '<div class="imgp_img_options">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_show']['#suffix'] = '</div>';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_link']['#prefix'] = '<div class="imgp_img_options">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_defaults_link']['#suffix'] = '</div>';
  $form['imagepicker_insert_defaults']['imagepicker_insert_image_title']['#prefix'] = '<div id="imgp_insert_image_title">';
  $form['imagepicker_insert_defaults']['imagepicker_insert_image_title']['#suffix'] = '</div>';
  $jshide = $form['imagepicker_import']['imagepicker_import_enabled']['#default_value'] ? '' : ' class="js-hide"';
  $form['imagepicker_import']['imagepicker_import_delete']['#prefix'] = '<div id="wrap-imagepicker-import"' . $jshide . '>';
  $form['imagepicker_import']['imagepicker_import_max']['#suffix'] = '</div>';
  $jshide = $form['imagepicker_blocks']['imagepicker_galleryblocks_enabled']['#default_value'] ? '' : ' class="js-hide"';
  $form['imagepicker_blocks']['imagepicker_galleryblocks_howmany']['#prefix'] = '<div id="wrap-imagepicker-blocks"' . $jshide . '>';
  $form['imagepicker_blocks']['close']['#suffix'] = '</div>';
  $jshide = $form['imagepicker_groups']['imagepicker_groups_enabled']['#default_value'] ? '' : ' class="js-hide"';
  $form['imagepicker_groups']['imagepicker_public_enabled']['#prefix'] = '<div id="wrap-imagepicker-groups"' . $jshide . '>';
  $form['imagepicker_groups']['imagepicker_groups_in_upload_enabled']['#suffix'] = '</div>';
  $jshide = $form['imagepicker_progress']['imagepicker_upload_progress_enabled']['#default_value'] ? '' : ' class="js-hide"';
  $form['imagepicker_progress']['imagepicker_upload_progress_delay']['#prefix'] = '<div id="wrap-imagepicker-upload-progress"' . $jshide . '>';
  if (version_compare(phpversion(), IMAGEPICKER_UPLOAD_STATUS_MIN_PHP) >= 0 && extension_loaded('uploadprogress')) {
    $form['imagepicker_progress']['imagepicker_uploadprogress']['#suffix'] = '</div>';
  }
  else {
    $form['imagepicker_progress']['imagepicker_upload_progress_message']['#suffix'] = '</div>';
  }
  $jshide = $form['imagepicker_quotas']['imagepicker_quota_byrole']['#default_value'] ? '' : ' class="js-hide"';
  $form['imagepicker_quotas']['imagepicker_quota_role']['#prefix'] = '<div id="wrap-imagepicker-quota-role"' . $jshide . '>';
  $form['imagepicker_quotas']['imagepicker_quota_role']['#suffix'] = '</div>';
  $jshide = $form['imagepicker_watermark']['imagepicker_watermark_enable']['#default_value'] ? '' : ' class="js-hide"';
  $form['imagepicker_watermark']['imagepicker_watermark_image']['#prefix'] = '<div id="wrap-imagepicker-watermark"' . $jshide . '>';
  $form['imagepicker_watermark']['imagepicker_watermark_scale']['#suffix'] = '</div>';
  $form['imagepicker_settings']['imagepicker_admin_message']['#prefix'] = '<div class="messages">';
  $form['imagepicker_settings']['imagepicker_admin_message']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_admin_form($form) {
  $src = $form['options']['src']['#value'];
  $cols = $form['options']['cols']['#value'];
  $public = $form['options']['public']['#value'];
  $form['options']['#prefix'] = '<div class="container-inline">';
  $form['options']['#suffix'] = '</div>';

  // tablesort
  if ($public && $src == 'admin') {
    $header = array(
      theme('table_select_header_cell'),
      array(
        'data' => t('Name'),
        'field' => 'i.img_name',
      ),
      array(
        'data' => t('Title'),
        'field' => 'i.img_title',
      ),
      t('Description'),
      array(
        'data' => t('User'),
        'field' => 'n.name',
      ),
      array(
        'data' => t('Date'),
        'field' => 'i.img_date',
      ),
      array(
        'data' => t('Actions'),
        'colspan' => 2,
      ),
    );
  }
  else {
    $header = array(
      theme('table_select_header_cell'),
      array(
        'data' => t('Name'),
        'field' => 'i.img_name',
      ),
      array(
        'data' => t('Title'),
        'field' => 'i.img_title',
      ),
      t('Description'),
      array(
        'data' => t('Date'),
        'field' => 'i.img_date',
      ),
      array(
        'data' => t('Actions'),
        'colspan' => 2,
      ),
    );
  }
  $output = drupal_render($form['options']);
  if (isset($form['img_name']) && is_array($form['img_name'])) {
    foreach (element_children($form['img_name']) as $key) {
      if ($public && $src == 'admin') {
        $rows[] = array(
          drupal_render($form['images'][$key]),
          drupal_render($form['img_name'][$key]),
          drupal_render($form['img_title'][$key]),
          drupal_render($form['img_desc'][$key]),
          drupal_render($form['img_list'][$key]),
          drupal_render($form['img_date'][$key]),
          drupal_render($form['img_edit'][$key]),
          drupal_render($form['img_delete'][$key]),
        );
      }
      else {
        $rows[] = array(
          drupal_render($form['images'][$key]),
          drupal_render($form['img_name'][$key]),
          drupal_render($form['img_title'][$key]),
          drupal_render($form['img_desc'][$key]),
          drupal_render($form['img_date'][$key]),
          drupal_render($form['img_edit'][$key]),
          drupal_render($form['img_delete'][$key]),
        );
      }
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('No images available.'),
        'colspan' => $cols,
      ),
    );
  }
  if ($form['pager']['#value']) {
    $pager = drupal_render($form['pager']);
    $rows[] = array(
      array(
        'data' => $pager,
        'colspan' => $cols + 1,
      ),
    );
  }
  $output .= theme('table', $header, $rows);
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_browse_admin($forms = '', $message = "", $pref = "", $suff = "", $label = "") {
  $output = $label ? '<fieldset><legend>' . $label . '</legend>' : '';
  if ($forms) {
    $output .= $pref;
    $output .= $forms['browse_search'];
    $output .= $forms['browse_groups'];
    $output .= $forms['browse_public'];
    $output .= $forms['browse_public_groups'];
    $output .= $forms['browse_admin'];
    $output .= $suff;
  }
  else {
    $output .= '<div class="messages">' . $message . '</div>';
  }
  $output .= $label ? '</fieldset>' : '';
  return $output;
}
function theme_imagepicker_multitask_delete_form($form) {
  $output = '';
  $count = $form['countnids']['#value'];
  $output .= '<p>' . t('You have selected %c to be deleted', array(
    '%c' => format_plural($count, '1 image', '@count images'),
  )) . '</p>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_multitask_groups_form($form) {
  $output = '';
  $count = $form['countnids']['#value'];
  $output .= '<p>' . t('You have selected %c to be grouped', array(
    '%c' => format_plural($count, '1 image', '@count images'),
  )) . '</p>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_import_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_import_dir_form($form) {
  $output = '';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_admin_orphans_form($form) {
  $output = '';
  $form['msg']['#prefix'] = '<div class="messages">';
  $form['msg']['#suffix'] = '</div>';
  $output .= drupal_render($form);
  return $output;
}
function theme_imagepicker_display_block($content) {
  $output = '';
  $output .= '<div class="imgp_display_block">' . $content . '</div>';
  return $output;
}

Functions

Namesort descending Description
imagepicker_access_admin
imagepicker_access_admin_group
imagepicker_access_import Menu access callback functions.
imagepicker_access_use
imagepicker_access_user_config
imagepicker_access_user_groups
imagepicker_access_user_pages
imagepicker_access_user_public
imagepicker_access_use_group
imagepicker_access_use_public
imagepicker_block Implementation of hook_block().
imagepicker_block_form
imagepicker_block_form_submit
imagepicker_display_block Function to display the contents of a block.
imagepicker_file_download Implementation of hook_file_download().
imagepicker_form_alter Implementation of hook_form_alter().
imagepicker_get_all_groups
imagepicker_get_colorbox_perms
imagepicker_get_files_directory
imagepicker_get_image_path
imagepicker_get_path some common utilities
imagepicker_get_thickbox_perms
imagepicker_get_userpath
imagepicker_get_user_group get all for a group
imagepicker_help Implementation of hook_help().
imagepicker_id_load menu placeholder functions
imagepicker_init Implementation of hook_init().
imagepicker_menu Implementation of hook_menu().
imagepicker_perm Implementation of hook_perm().
imagepicker_theme theme registry
imagepicker_uid_load
template_preprocess_imagepicker
theme_imagepicker_admin_image_form
theme_imagepicker_admin_orphans_form
theme_imagepicker_admin_view
theme_imagepicker_browser
theme_imagepicker_browse_admin
theme_imagepicker_browse_admin_form
theme_imagepicker_browse_groups_form
theme_imagepicker_browse_order_form
theme_imagepicker_browse_public_form
theme_imagepicker_browse_public_groups_form
theme_imagepicker_browse_search_form
theme_imagepicker_copy_form
theme_imagepicker_display_block
theme_imagepicker_edit_form
theme_imagepicker_fullpage
theme_imagepicker_groups_form
theme_imagepicker_group_delete_form
theme_imagepicker_group_images_form
theme_imagepicker_group_search_form
theme_imagepicker_iframe
theme_imagepicker_image_edit_header
theme_imagepicker_image_form
theme_imagepicker_import_dir_form
theme_imagepicker_import_form
theme_imagepicker_insert
theme_imagepicker_list
theme_imagepicker_multitask_delete_form
theme_imagepicker_multitask_groups_form
theme_imagepicker_quota
theme_imagepicker_quota_form
theme_imagepicker_quota_message
theme_imagepicker_settings_form
theme_imagepicker_stats
theme_imagepicker_upload_form
theme_imagepicker_user_config
theme_imagepicker_user_config_admin_form
theme_imagepicker_user_image_form
theme_imagepicker_user_search_form
theme_imagepicker_user_view
theme_imagepicker_view

Constants