uid, FALSE)) { $profile['useralbum_gallery'] = array( 'title' => in_array('link', $gallery_mode) ? $profile['useralbum_link']['value'] : t('Album: %username', array('%username' => $account->name)), 'value' => _gallery_profile_useralbum($account->uid), '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 (empty($profile)) { unset($fields[$title]); } } } /** * Implementation of hook_form_alter(). */ function gallery_profile_form_alter($form_id, &$form) { if ($form_id == '_gallery_user_settings') { $form['user']['profile']['#collapsed'] = TRUE; $form['user']['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['user']['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['user']['profile']['gallery_user_profile_gallery'] = array( '#type' => 'checkboxes', '#title' => t('Useralbum 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.'), ); $form['array_filter'] = array('#type' => 'value'); // Useralbum settings if (in_array('gallery', $gallery_mode)) { $form['user']['profile'][] = _gallery_profile_useralbum_settings(); } } } /** * 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; } _gallery_block_options($type_map, $param_map); $type_map = array( 'randomImage' => t('Random image'), 'recentImage' => t('Recent image') ); $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, 5), '#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, 5), '#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' => $type_map, '#description' => 'Pick the type of images you would like to see in the useralbum.', ); $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' => $param_map, '#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_list_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) : ''; $params['itemId'] = 'user:'. $uid; $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']; }