'General', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => 0 ); $items['admin/user/gallery/settings/profile'] = array( 'title' => 'User Profile', 'access callback' => 'gallery_admin_access', 'access arguments' => array(array('administer users', 'administer gallery settings')), 'file' => 'gallery_settings.inc', 'file path' => drupal_get_path('module', 'gallery'), 'page callback' => 'drupal_get_form', 'page arguments' => array('_gallery_profile_settings'), 'type' => MENU_LOCAL_TASK, 'weight' => 1 ); return $items; } /** * Implementation of hook_profile_alter(). */ function gallery_profile_profile_alter(&$account) { if (isset($account->content['gallery2'])) { $profile = &$account->content['gallery2']; // Set custom title $profile['#title'] = variable_get('gallery_user_profile_title', 'Gallery2'); // Remove sync status message if (variable_get('gallery_user_profile_hide_sync', 0)) { unset($profile['user_sync']); } // Useralbum link/gallery $gallery_mode = variable_get('gallery_user_profile_gallery', array('link')); if (in_array('gallery', $gallery_mode) && gallery_user_useralbum($account->uid, FALSE)) { $profile['useralbum_gallery'] = array( '#type' => 'user_profile_item', '#title' => in_array('link', $gallery_mode) ? $profile['useralbum_link']['#value'] : t('Album: %username', array('%username' => $account->name)), '#value' => _gallery_profile_useralbum($account->uid), '#attributes' => array('class' => 'gallery_profile_useralbum') ); unset($profile['useralbum_link']); } else if (!in_array('link', $gallery_mode)) { unset($profile['useralbum_link']); } // Hide section (if no items are available) if (count($profile) < 3) { unset($fields['gallery2']); } } } /** * Implementation of hook_form_alter(). */ function gallery_profile_form_alter(&$form, $form_state, $form_id) { if ($form_id == '_gallery_user_settings') { unset($form['user']['gallery_user_profile_hide']); $form['user']['sync']['#collapsible'] = FALSE; } } /** * Function _gallery_profile_settings(). */ function _gallery_profile_settings() { $form['profile'] = array( '#type' => 'fieldset', '#title' => t('User Profile'), '#collapsible' => FALSE, '#collapsed' => FALSE ); $form['profile']['gallery_user_profile_hide'] = array( '#type' => 'checkbox', '#title' => t('Hide Gallery2 section in profiles'), '#default_value' => variable_get('gallery_user_profile_hide', 0), '#description' => t('Hide the Gallery2 section (i.e. Gallery2-Drupal Sync Status) on the user profile pages.'), ); $form['profile']['gallery_user_profile_title'] = array( '#type' => 'textfield', '#title' => t('Title of Gallery2 profile section'), '#default_value' => variable_get('gallery_user_profile_title', 'Gallery2'), '#size' => 40, '#maxlength' => 255, '#description' => t('Title of the Gallery2 section on profile pages.') ); $form['profile']['gallery_user_profile_hide_sync'] = array( '#type' => 'checkbox', '#title' => t('Hide sync status message'), '#default_value' => variable_get('gallery_user_profile_hide_sync', 0), '#description' => t('Hide \'Gallery2-Drupal Sync Status\' message in the profile.'), ); $gallery_mode = variable_get('gallery_user_profile_gallery', array('link')); $form['profile']['gallery_user_profile_gallery'] = array( '#type' => 'checkboxes', '#title' => t('Profile gallery mode'), '#default_value' => $gallery_mode, '#options' => array( 'link' => t('Show link to useralbum'), 'gallery' => t('Show (useralbum) gallery/images') ), '#description' => t('By default a link to the useralbum is shown. But you may also insert a gallery of random/recent images from the useralbum into the user profile.'), ); // Useralbum settings if (in_array('gallery', $gallery_mode)) { $form['profile'][] = _gallery_profile_useralbum_settings(); } $form['array_filter'] = array('#type' => 'value'); return system_settings_form($form); } /** * Function _gallery_profile_useralbum_settings(). */ function _gallery_profile_useralbum_settings() { require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc'); $plugin_status = gallery_plugin_status(array('imageblock', 'imageframe')); $form['useralbum'] = array( '#type' => 'fieldset', '#title' => t('Useralbum'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('The profile useralbum requires the Gallery2 Image Block plugin (!imageblock_status) and optionally the Gallery2 Image Frame plugin (!imageframe_status).', array( '!imageblock_status' => theme('gallery_plugin_status_message', $plugin_status['imageblock']), '!imageframe_status' => theme('gallery_plugin_status_message', $plugin_status['imageframe']) )) ); if ($plugin_status['imageblock'] != GALLERY_PLUGIN_ENABLED) { $form['useralbum']['#description'] .= t(' However the Image Block plugin is unavailable.'); return $form; } $form['useralbum']['gallery_user_profile_useralbum_num_cols'] = array( '#type' => 'select', '#title' => t('Number of columns'), '#default_value' => variable_get('gallery_user_profile_useralbum_num_cols', 2), '#options' => _gallery_range_array(1, 10), '#description' => t('Enter the number of columns in the useralbum.'), ); $form['useralbum']['gallery_user_profile_useralbum_num_rows'] = array( '#type' => 'select', '#title' => t('Number of rows'), '#default_value' => variable_get('gallery_user_profile_useralbum_num_rows', 2), '#options' => _gallery_range_array(1, 10), '#description' => t('Enter the number of rows in the useralbum.'), ); $form['useralbum']['gallery_user_profile_useralbum_block_block'] = array( '#type' => 'select', '#title' => 'Image types', '#default_value' => variable_get('gallery_user_profile_useralbum_block_block', 'randomImage'), '#options' => array( 'randomImage' => t('Random image'), 'recentImage' => t('Recent image') ), '#description' => 'Pick the type of images you would like to see in the useralbum.', ); $form['useralbum']['gallery_user_profile_useralbum_item_id'] = array( '#type' => 'textfield', '#title' => t('Album or Item ID'), '#default_value' => variable_get('gallery_user_profile_useralbum_item_id', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter the Gallery image or album ID or leave blank for \'Useralbum\' (default).') ); $form['useralbum']['gallery_user_profile_useralbum_block_show'] = array( '#type' => 'checkboxes', '#title' => t('Image data'), '#default_value' => variable_get('gallery_user_profile_useralbum_block_show', array()), '#options' => array( 'title' => t('Title'), 'date' => t('Date'), 'views' => t('View Count'), 'owner' => t('Item owner'), 'heading' => t('Heading') ), '#description' => t('Choose the item metadata you would like to display.'), ); $form['useralbum']['gallery_user_profile_useralbum_size_method'] = array( '#type' => 'select', '#title' => t('Image size method'), '#default_value' => variable_get('gallery_user_profile_useralbum_size_method', GALLERY_GRID_SIZE_METHOD_DEFAULT), '#options' => array( 'maxsize' => t('Max Size'), 'exactsize' => t('Exact Size'), ), '#description' => t('\'Max Size\' gives faster image downloading, but the image size may be smaller than the size defined below.
\'Exact Size\' may be slower (as a larger image is downloaded and then scaled by the browser) but the image will be guaranteed to be the size defined below. Only supported for G2.2+.'), ); $form['useralbum']['gallery_user_profile_useralbum_size'] = array( '#type' => 'textfield', '#title' => t('Image size'), '#default_value' => variable_get('gallery_user_profile_useralbum_size', GALLERY_GRID_SIZE_DEFAULT), '#size' => 10, '#maxlength' => 10, '#description' => t('Sets the size (in pixels) of the longest side of the image according to the method defined above.'), ); $imageframe_desc = ($plugin_status['imageframe'] != GALLERY_PLUGIN_ENABLED) ? t('Requires the Gallery2 Image Frame plugin (!imageframe_status).', array('!imageframe_status' => theme('gallery_plugin_status_message', $plugin_status['imageframe']))) : ''; $image_frames = gallery_get_image_frames(); $form['useralbum']['gallery_user_profile_useralbum_album_frame'] = array( '#type' => 'select', '#title' => t('Album frame'), '#default_value' => variable_get('gallery_user_profile_useralbum_album_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['useralbum']['gallery_user_profile_useralbum_item_frame'] = array( '#type' => 'select', '#title' => t('Item frame'), '#default_value' => variable_get('gallery_user_profile_useralbum_item_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['useralbum']['gallery_user_profile_useralbum_link_target'] = array( '#type' => 'textfield', '#title' => t('Link target'), '#default_value' => variable_get('gallery_user_profile_useralbum_link_target', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter a link target (e.g. \'_blank\' to open in a new window).'), ); $form['useralbum']['gallery_user_profile_useralbum_link'] = array( '#type' => 'textfield', '#title' => t('Image Link'), '#default_value' => variable_get('gallery_user_profile_useralbum_link', ''), '#size' => 60, '#maxlength' => 255, '#description' => t('By default the image has a link to the item in the Gallery. This can be overridden here (or leave empty for the default). Use \'none\' for no link, or a URL to link somewhere else instead.'), ); return $form; } /** * Function _gallery_profile_useralbum(). */ function _gallery_profile_useralbum($uid) { $num_cols = variable_get('gallery_user_profile_useralbum_num_cols', 2); $num_rows = variable_get('gallery_user_profile_useralbum_num_rows', 2); $num_images = $num_cols * $num_rows; $param_blocks_array = array_fill(0, $num_images, variable_get('gallery_user_profile_useralbum_block_block', 'randomImage')); $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : ''; $item_id = trim(variable_get('gallery_user_profile_useralbum_item_id', '')); $params['itemId'] = empty($item_id) ? ('user:'. $uid) : $item_id; $param_show_array = variable_get('gallery_user_profile_useralbum_block_show', array()); $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : ''; if (variable_get('gallery_user_profile_useralbum_size_method', GALLERY_GRID_SIZE_METHOD_DEFAULT) == 'maxsize') { $params['maxSize'] = variable_get('gallery_user_profile_useralbum_size', GALLERY_GRID_SIZE_DEFAULT); } else { $params['exactSize'] = variable_get('gallery_user_profile_useralbum_size', GALLERY_GRID_SIZE_DEFAULT); } $params['albumFrame'] = variable_get('gallery_user_profile_useralbum_album_frame', 'none'); $params['itemFrame'] = variable_get('gallery_user_profile_useralbum_item_frame', 'none'); $params['linkTarget'] = variable_get('gallery_user_profile_useralbum_link_target', ''); $params['link'] = variable_get('gallery_user_profile_useralbum_link', ''); $block = gallery_get_block($params, 'ImageBlock', array('num_cols' => $num_cols)); return $block['content']; }