'fieldset', '#title' => t('Status'), '#description' => gallery_format_status($status, ''), '#collapsible' => FALSE, '#collapsed' => FALSE, ); // Theme Settings $form['theme'] = array( '#type' => 'fieldset', '#title' => t('Theme settings'), '#description' => '', '#collapsible' => TRUE, '#collapsed' => TRUE, ); $themes = system_theme_data(); ksort($themes); $options = array('default' => t('System default')); foreach ($themes as $theme) { $options[$theme->name] = drupal_ucfirst($theme->name); } $form['theme']['gallery_page_theme'] = array( '#type' => 'select', '#title' => t('Gallery page theme'), '#default_value' => variable_get('gallery_page_theme', 'default'), '#options' => $options, '#description' => t('Drupal theme to be used for all gallery pages (gallery/*).'), ); // Gallery Block Settings $form['blocks'] = array( '#type' => 'fieldset', '#title' => t('Gallery block settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('You can now have multiple image blocks and grid blocks. Use these settings to determine the number of available blocks.
Warning: If you decrease the number of blocks, always the last block (with the highest ID) will be removed.'), ); $form['blocks']['gallery_block_image_num'] = array( '#type' => 'textfield', '#title' => t('Number of image blocks'), '#default_value' => variable_get('gallery_block_image_num', 1), '#size' => 10, '#maxlength' => 10, '#description' => t('Select how many image blocks should be available.'), ); $form['blocks']['gallery_block_grid_num'] = array( '#type' => 'textfield', '#title' => t('Number of grid image blocks'), '#default_value' => variable_get('gallery_block_grid_num', 1), '#size' => 10, '#maxlength' => 10, '#description' => t('Select how many grid image blocks should be available.'), ); // Gallery2 Sidebar Settings $form['sidebar'] = array( '#type' => 'fieldset', '#title' => t('Sidebar settings'), '#description' => '', '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['sidebar']['gallery_move_sidebar_to_block'] = array( '#type' => 'checkbox', '#title' => t('Move Gallery2 sidebar to Drupal Gallery Navigation block'), '#default_value' => variable_get('gallery_move_sidebar_to_block', 1), '#description' => t('When selected, the Gallery2 sidebar will be moved into the Drupal "Gallery Navigation" block. This typically allows for a much cleaner embedded gallery and is generally recommended. Note that you will need to enable the Gallery Navigation block.'), ); $form['sidebar']['gallery_move_admin_sidebar_to_block'] = array( '#type' => 'checkbox', '#title' => t('Move Gallery2 Admin sidebar to Drupal Gallery Navigation block'), '#default_value' => variable_get('gallery_move_admin_sidebar_to_block', 0), '#description' => t('When selected, the Gallery2 Admin sidebar will be moved into the Drupal "Gallery Navigation" block. This is not normally recommended since the Admin Sitebar is very long and the formatting does not always fit with the rest of the block (but cannot be changed in the current Gallery2 versions).'), '#disabled' => !variable_get('gallery_move_sidebar_to_block', 1), ); // Gallery2 Google Sitemap Settings $gallery2_sitemap_status = gallery_single_plugin_status('sitemap'); $gallery2_sitemap_status_str = theme('gallery_plugin_status_message', $gallery2_sitemap_status); $gsitemap_status = module_exists('gsitemap'); $gsitemap_status_str = theme('gallery_module_status_message', $gsitemap_status); $desc = t('Allows the Gallery2 Google (XML) sitemap to be merged with the Drupal one so that only one URL needs to be supplied to Google (or other search site). Requires the Drupal gsitemap module (!gsitemap_status) and the Gallery2 sitemap module (!gallery2_sitemap_status) to be installed/activated.', array( '!gsitemap_status' => $gsitemap_status_str, '!gallery2_sitemap_status' => $gallery2_sitemap_status_str, ) ); $form['sitemap'] = array( '#type' => 'fieldset', '#title' => t('Google (XML) sitemap settings'), '#description' => '', '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => $desc, ); $form['sitemap']['gallery_enable_sitemap'] = array( '#type' => 'checkbox', '#title' => t('Enable merge of Gallery2 sitemap with Drupal sitemap'), '#default_value' => variable_get('gallery_enable_sitemap', 1), '#disabled' => !($gsitemap_status && ($gallery2_sitemap_status == GALLERY_PLUGIN_ENABLED)), ); // Error logging / Debug Settings $form['error'] = array( '#type' => 'fieldset', '#title' => t('Error logging / Debug settings'), '#description' => '', '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['error']['gallery_error_mode'] = array( '#type' => 'checkboxes', '#title' => t('Error logging'), '#default_value' => variable_get('gallery_error_mode', array(GALLERY_ERROR_WATCHDOG)), '#options' => array(GALLERY_ERROR_WATCHDOG => t('Watchdog'), GALLERY_ERROR_BROWSER => t('Output to the browser'), GALLERY_ERROR_VERBOSE => t('Verbose error messages')), '#description' => t('Choose where errors are displayed and how detailed they are.'), ); $form['error']['gallery_report'] = array( '#type' => 'checkbox', '#title' => t('Enable bug report assistant'), '#default_value' => variable_get('gallery_report', 1), '#description' => t('In case of errors the module can automatically assemble useful data (system info and debug traces) to help you with detailed bug reports. Only available to users with \'administer site configuration\' permission.') ); $form['error']['gallery_debug'] = array( '#type' => 'checkbox', '#title' => t('Enable debug mode'), '#default_value' => variable_get('gallery_debug', 0), '#description' => t('Print out debug variables and verbose error messages. Only visible to users with \'administer site configuration\' permission.') ); // Relevant links $form['links'] = array( '#type' => 'fieldset', '#title' => t('Links to the most relevant Drupal & Gallery2 pages'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); // Drupal links $desc = ''; $form['links']['drupal'] = array( '#type' => 'fieldset', '#title' => t('Links to Drupal paths'), '#description' => t($desc, array( '@gallery-users' => url('admin/user/gallery'), '@gallery-report' => url('admin/settings/gallery/report/download'))), '#collapsible' => FALSE, '#collapsed' => FALSE, ); // Gallery2 links $desc = ''; $g2_uri = variable_get('gallery_embed_uri', '?q=gallery'); $form['links']['gallery'] = array( '#type' => 'fieldset', '#title' => t('Links to Gallery2 Site Admin sections'), '#description' => t($desc, array( '@g2-modules' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminModules', '@g2-themes' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminThemes&g2_mode=defaults', '@g2-rewrite' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=rewrite.AdminRewrite&g2_mode=setup', '@g2-cookie' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminCore')), '#collapsible' => FALSE, '#collapsed' => FALSE, ); $form['#validate']['_gallery_settings_general_validate'] = array(); $form['#submit']['_gallery_settings_general_submit'] = array(); $form['#submit']['system_settings_form_submit'] = array(); return system_settings_form($form); } /** * Function _gallery_settings_general_validate(). */ function _gallery_settings_general_validate($form_id, $form_values) { if (!is_numeric($form_values['gallery_block_image_num']) || $form_values['gallery_block_image_num'] < 1) { form_set_error('gallery_block_image_num', t('Number of image blocks must be a positiv integer greater zero.')); } if (!is_numeric($form_values['gallery_block_grid_num']) || $form_values['gallery_block_grid_num'] < 1) { form_set_error('gallery_block_grid_num', t('Number of grid blocks must be a positiv integer greater zero.')); } } /** * Function _gallery_settings_general_submit(). */ function _gallery_settings_general_submit($form_id, $form_values) { if ($form_values['gallery_enable_sitemap'] != variable_get('gallery_enable_sitemap', 0)) { drupal_set_message('The Google (XML) sitemap setting has been updated, but the new sitemap may not be generated immediately (controlled by gsitemap).'); } } /** * Function _gallery_settings_block_image(). */ function _gallery_settings_block_image($delta) { $plugin_status = gallery_plugin_status(array('imageblock', 'imageframe')); $imageblock_desc = t('The Gallery Image Block 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) { $g2_uri = variable_get('gallery_embed_uri', '?q=gallery'); $g2_plugins_page = (variable_get('gallery_valid', 0)) ? t('Gallery2 Plugins', array('@g2_plugins' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminModules')) : t('Gallery2 Site Admin -> Plugins'); $g2_imageblock_desc = t(' However the Image Block plugin is unavailable, so this block is not available and the settings are disabled. To use this block please go to the !g2_plugins page and install/activate the Image Block plugin.', array( '!g2_plugins' => $g2_plugins_page)); $imageblock_desc .= $g2_imageblock_desc; } $form['#description'] = $imageblock_desc; $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(); _gallery_block_options($type_map, $param_map); if (variable_get('gallery_block_image_num', 1) > 1) { $form['gallery_block_image_'. $delta .'_blockid'] = array( '#type' => 'textfield', '#title' => t('Block Identifier [Block @id]', array('@id' => $delta+1)), '#default_value' => variable_get('gallery_block_image_'. $delta .'_blockid', ''), '#size' => 25, '#maxlength' => 30, '#description' => t('A short identifier to distinguish blocks of the same type. (Blocks are numbered by default)'), ); } if ($plugin_status['imageblock'] == GALLERY_PLUGIN_ENABLED) { $numimages = variable_get('gallery_block_image_'. $delta .'_num_images', 3); $form['gallery_block_image_'. $delta .'_num_images'] = array( '#type' => 'select', '#title' => t('Number of images in block'), '#default_value' => $numimages, '#options' => _gallery_range_array(1, 20), '#description' => t('Choose the number of images to appear. You will need to submit the form if you have increased the number in order to choose the image types.'), ); $gallery_block_block = variable_get('gallery_block_image_'. $delta .'_block_block', array('randomImage')); $form['gallery_block_image_'. $delta .'_block_block'] = array( '#type' => 'fieldset', '#title' => t('Image types'), '#collapsible' => FALSE, '#collapsed' => FALSE, '#tree' => TRUE, '#description' => t('Pick the type of images you would like to see. You can select the same type more than once.'), ); for ($i=0; $i<$numimages; $i++) { $form['gallery_block_image_'. $delta .'_block_block'][$i] = array( '#type' => 'select', '#title' => '', '#default_value' => $gallery_block_block[$i], '#options' => array_merge(array('none' => t('None')), $type_map), ); } $form['gallery_block_image_'. $delta .'_item_id'] = array( '#type' => 'textfield', '#title' => t('Album or Item ID'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_item_id', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter the Gallery image or album ID (or blank). If an album or item ID is specified, random images will only be selected from that album and its sub-albums. If %user is specified, items will be taken from the visitor\'s useralbum (if possible).') ); $form['gallery_block_image_'. $delta .'_block_show'] = array( '#type' => 'checkboxes', '#title' => t('Image data'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_block_show', array('title', 'heading')), '#options' => $param_map, '#description' => t('Choose the item metadata you would like to display.'), ); $form['gallery_block_image_'. $delta .'_size_method'] = array( '#type' => 'select', '#title' => t('Image size method'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_size_method', GALLERY_IMAGEBLOCK_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['gallery_block_image_'. $delta .'_size'] = array( '#type' => 'textfield', '#title' => t('Image size'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_size', GALLERY_IMAGEBLOCK_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.'), ); $form['gallery_block_image_'. $delta .'_album_frame'] = array( '#type' => 'select', '#title' => t('Album frame'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_album_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['gallery_block_image_'. $delta .'_item_frame'] = array( '#type' => 'select', '#title' => t('Item frame'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_item_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['gallery_block_image_'. $delta .'_link_target'] = array( '#type' => 'textfield', '#title' => t('Link target'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_link_target', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter a link target (e.g. \'_blank\' to open in a new window).'), ); $form['gallery_block_image_'. $delta .'_link'] = array( '#type' => 'textfield', '#title' => t('Image Link'), '#default_value' => variable_get('gallery_block_image_'. $delta .'_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_settings_block_grid(). */ function _gallery_settings_block_grid($delta) { $plugin_status = gallery_plugin_status(array('imageblock', 'imageframe')); $gridblock_desc = t('The Gallery Grid Block 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) { $g2_uri = variable_get('gallery_embed_uri', '?q=gallery'); $g2_plugins_page = (variable_get('gallery_valid', 0)) ? t('Gallery2 Plugins', array('@g2_plugins' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminModules')) : t('Gallery2 Site Admin -> Plugins'); $g2_imageblock_desc = t(' However the Image Block plugin is unavailable, so this block is not available and the settings are disabled. To use this block please go to the !g2_plugins page and install/activate the Image Block plugin.', array('!g2_plugins' => $g2_plugins_page)); $gridblock_desc .= $g2_imageblock_desc; } $form['#description'] = $gridblock_desc; $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(); _gallery_block_options($type_map, $param_map); if (variable_get('gallery_block_grid_num', 1) > 1) { $form['gallery_block_grid_'. $delta .'_blockid'] = array( '#type' => 'textfield', '#title' => t('Block Identifier [Block @id]', array('@id' => $delta+1)), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_blockid', ''), '#size' => 25, '#maxlength' => 30, '#description' => t('A short identifier to distinguish blocks of the same type. (Blocks are numbered by default)'), ); } if ($plugin_status['imageblock'] == GALLERY_PLUGIN_ENABLED) { $form['gallery_block_grid_'. $delta .'_num_cols'] = array( '#type' => 'select', '#title' => t('Number of columns'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_num_cols', 2), '#options' => _gallery_range_array(1, 5), '#description' => t('Enter the number of columns in the grid.'), ); $form['gallery_block_grid_'. $delta .'_num_rows'] = array( '#type' => 'select', '#title' => t('Number of rows'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_num_rows', 2), '#options' => _gallery_range_array(1, 5), '#description' => t('Enter the number of rows in the grid.'), ); $form['gallery_block_grid_'. $delta .'_block_block'] = array( '#type' => 'select', '#title' => 'Image types', '#default_value' => variable_get('gallery_block_grid_'. $delta .'_block_block', 'randomImage'), '#options' => $type_map, '#description' => 'Pick the type of images you would like to see in the grid.', ); $form['gallery_block_grid_'. $delta .'_item_id'] = array( '#type' => 'textfield', '#title' => t('Album or Item ID'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_item_id', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter the Gallery image or album ID (or blank). If an album or item ID is specified, random images will only be selected from that album and its sub-albums. If %user is specified, items will be taken from the visitor\'s useralbum (if possible).') ); $form['gallery_block_grid_'. $delta .'_block_show'] = array( '#type' => 'checkboxes', '#title' => t('Image data'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_block_show', array()), '#options' => $param_map, '#description' => t('Choose the item metadata you would like to display.'), ); $form['gallery_block_grid_'. $delta .'_size_method'] = array( '#type' => 'select', '#title' => t('Image size method'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_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['gallery_block_grid_'. $delta .'_size'] = array( '#type' => 'textfield', '#title' => t('Image size'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_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.'), ); $form['gallery_block_grid_'. $delta .'_album_frame'] = array( '#type' => 'select', '#title' => t('Album frame'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_album_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['gallery_block_grid_'. $delta .'_item_frame'] = array( '#type' => 'select', '#title' => t('Item frame'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_item_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['gallery_block_grid_'. $delta .'_link_target'] = array( '#type' => 'textfield', '#title' => t('Link target'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_link_target', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter a link target (e.g. \'_blank\' to open in a new window).'), ); $form['gallery_block_grid_'. $delta .'_link'] = array( '#type' => 'textfield', '#title' => t('Image Link'), '#default_value' => variable_get('gallery_block_grid_'. $delta .'_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_settings_block_save(). */ function _gallery_settings_block_save($delta, $form_values) { // Validate variable values if (isset($form_values['gallery_block_image_'. $delta .'_size'])) { if (!is_numeric($form_values['gallery_block_image_'. $delta .'_size']) || $form_values['gallery_block_image_'. $delta .'_size'] < 10) { $form_values['gallery_block_image_'. $delta .'_size'] = 10; drupal_set_message(t('Image size must be a number greater than ten pixels. (The value has been updated to \'10\' for your convenience.)'), 'error'); } } if (isset($form_values['gallery_block_grid_'. $delta .'_size'])) { if (!is_numeric($form_values['gallery_block_grid_'. $delta .'_size']) || $form_values['gallery_block_grid_'. $delta .'_size'] < 10) { $form_values['gallery_block_grid_'. $delta .'_size'] = 10; drupal_set_message(t('Image size must be a number greater than ten pixels. (The value has been updated to \'10\' for your convenience.)'), 'error'); } } // Save variables foreach ($form_values as $key => $value) { if (strpos($key, 'gallery_block_') == 0) { if (is_array($value) && isset($form_values['array_filter'])) { $value = array_keys(array_filter($value)); } variable_set($key, $value); } } } /** * Function _gallery_settings_filter(). */ function _gallery_settings_filter() { require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc'); $plugin_status = gallery_plugin_status(array('imageblock', 'imageframe')); $desc = t('Note that changing the defaults here will change the all the gallery filter images on the site, not just new images. '); $desc .= t('The Gallery Filter 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) { $g2_uri = variable_get('gallery_embed_uri', '?q=gallery'); $g2_plugins_page = (variable_get('gallery_valid', 0)) ? t('Gallery2 Plugins', array('@g2_plugins' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminModules')) : t('Gallery2 Site Admin -> Plugins'); $desc .= t(' However the Image Block plugin is unavailable, so the Gallery Filter is not available and the settings are disabled. To use the filter please go to the !g2_plugins page and install/activate the Image Block plugin.', array('!g2_plugins' => $g2_plugins_page)); } $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']))) : ''; $form['filter'] = array( '#type' => 'fieldset', '#title' => t('Gallery Filter settings'), '#collapsible' => FALSE, '#collapsed' => FALSE, '#description' => $desc, ); $image_frames = gallery_get_image_frames(); _gallery_block_options($type_map, $param_map); if ($plugin_status['imageblock'] == GALLERY_PLUGIN_ENABLED) { $form['filter']['gallery_filter_prefix'] = array( '#type' => 'textfield', '#title' => t('Filter prefix'), '#default_value' => variable_get('gallery_filter_prefix', 'G2'), '#size' => 10, '#maxlength' => 10, '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999]. Be careful when changing this as any pages using the previous prefix will not be changed and so will not be filtered correctly.'), ); $form['filter']['gallery_filter_default_block_type'] = array( '#type' => 'select', '#title' => t('Default image type'), '#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'), '#options' => $type_map, '#description' => t('Pick the default type of image you would like to use.'), ); $form['filter']['gallery_filter_can_cache'] = array( '#type' => 'checkbox', '#title' => t('Cache gallery filter pages'), '#default_value' => variable_get('gallery_filter_can_cache', 1), '#description' => t('By default the gallery filter output is cached by Drupal to speed up page loading. However, it will not cache the css class info for the frames. The best approach is the make sure that the sidebar image block and the gallery filter images use the same frames. If you are unable to do this you will have to deselect this option to force Drupal not to cache the pages, or else your frames will not appear. If you change this option you will need to go to admin/settings/filters and re-save the image formats that use gallery filter.', array('@link' => url('admin/settings/filters'))), ); $form['filter']['gallery_filter_n_images'] = array( '#type' => 'textfield', '#title' => t('Default number of images'), '#default_value' => variable_get('gallery_filter_n_images', 1), '#size' => 3, '#maxlength' => 3, '#description' => t('How many images you want the default block to show. Best to keep at 1 and use the n parameter.'), ); $form['filter']['gallery_filter_default_show'] = array( '#type' => 'checkboxes', '#title' => t('Default image data'), '#default_value' => variable_get('gallery_filter_default_show', array('none')), '#options' => $param_map, '#description' => t('Choose the item metadata you would like to display by default. This will change all instances where show parameter was not specified.'), ); // parse gallery_filter.css and extract classes $css = implode('', file(drupal_get_path('module', 'gallery') .'/gallery_filter.css')); preg_match_all('/div.giImageBlock.(\w+) {/', $css, $matches); if (count($matches[1])) { $classes = array(); foreach ($matches[1] as $class) { $classes[$class] = $class; } $form['filter']['gallery_filter_default_div_class'] = array( '#type' => 'select', '#title' => t('Default class'), '#default_value' => variable_get('gallery_filter_default_div_class', 'nowrap'), '#options' => $classes, ); } else { $form['filter']['gallery_filter_default_div_class'] = array( '#type' => 'textfield', '#title' => t('Default class'), '#default_value' => variable_get('gallery_filter_default_div_class', 'nowrap'), '#size' => 20, '#maxlength' => 20, '#description' => t('left, right, or nowrap. (See gallery_filter.css to add more or modify these.)'), ); } $form['filter']['gallery_filter_default_maxsize'] = array( '#type' => 'textfield', '#title' => t('Default \'Max Size\' thumbnail size'), '#default_value' => variable_get('gallery_filter_default_maxsize', GALLERY_FILTER_MAXSIZE_DEFAULT), '#size' => 10, '#maxlength' => 10, ); $form['filter']['gallery_filter_default_exactsize'] = array( '#type' => 'textfield', '#title' => t('Default \'Exact Size\' thumbnail size'), '#default_value' => variable_get('gallery_filter_default_exactsize', GALLERY_FILTER_EXACTSIZE_DEFAULT), '#size' => 10, '#maxlength' => 10, '#description' => t('If no size is specified when calling the filter, one of these sizes (and implied method) will be used.
\'Max Size\' gives faster image downloading, but the image size may be smaller than the size defined.
\'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. Only supported for G2.2+. Only fill in one size box (not both) to set the default method.'), ); $form['filter']['gallery_filter_default_album_frame'] = array( '#type' => 'select', '#title' => t('Default album frame'), '#default_value' => variable_get('gallery_filter_default_album_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['filter']['gallery_filter_default_item_frame'] = array( '#type' => 'select', '#title' => t('Default item frame'), '#default_value' => variable_get('gallery_filter_default_item_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['filter']['gallery_filter_default_link_target'] = array( '#type' => 'textfield', '#title' => t('Default link target'), '#default_value' => variable_get('gallery_filter_default_link_target', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter a link target (e.g. "_blank", "_new").'), ); $form['filter']['gallery_filter_default_link'] = array( '#type' => 'textfield', '#title' => t('Default Image Link'), '#default_value' => variable_get('gallery_filter_default_link', ''), '#size' => 20, '#maxlength' => 20, '#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.'), ); } // Include both #submit handlers so that the default system submit // is also called to save all the variables. $form['#submit']['_gallery_settings_filter_submit'] = array(); $form['#submit']['system_settings_form_submit'] = array(); return system_settings_form($form); } /** * Function _gallery_settings_filter_validate(). */ function _gallery_settings_filter_validate($form_id, $form_values) { // Only validate if a setting was returned if (isset($form_values['gallery_filter_default_maxsize'])) { if ((strlen($form_values['gallery_filter_default_maxsize']) > 0) && (strlen($form_values['gallery_filter_default_exactsize']) > 0)) { form_set_error('gallery_filter_default_maxsize', t('You must set either the Max Size or the Exact Size, not both.')); } elseif ((strlen($form_values['gallery_filter_default_maxsize']) == 0) && (strlen($form_values['gallery_filter_default_exactsize']) == 0)) { form_set_error('gallery_filter_default_maxsize', t('You must set either the Max Size or the Exact Size.')); } if ((strlen($form_values['gallery_filter_default_maxsize']) > 0) && (!is_numeric($form_values['gallery_filter_default_maxsize']) || $form_values['gallery_filter_default_maxsize'] < 1)) { form_set_error('gallery_filter_default_maxsize', t('Max Size must be a number greater than zero.')); } if ((strlen($form_values['gallery_filter_default_exactsize']) > 0) && (!is_numeric($form_values['gallery_filter_default_exactsize']) || $form_values['gallery_filter_default_exactsize'] < 1)) { form_set_error('gallery_filter_default_exactsize', t('Exact Size must be a number greater than zero.')); } if ((strlen($form_values['gallery_filter_n_images']) > 0) && (!is_numeric($form_values['gallery_filter_n_images']) || $form_values['gallery_filter_n_images'] < 1)) { form_set_error('gallery_filter_n_images', t('Number of images must be a number greater than zero.')); } } } /** * Function _gallery_settings_filter_submit(). */ function _gallery_settings_filter_submit($form_id, $form_values) { // The default values have changed, so the pages containing the gallery filter need // to be updated (or else it would only occur on an edit), so empty the filter cache. // Find out which formats are using the gallery filter $result = db_query("SELECT format FROM {filters} WHERE module = 'gallery'"); while ($format = db_fetch_object($result)) { cache_clear_all($format->format .':', 'cache_filter', TRUE); } drupal_set_message('The gallery filter cache has been cleared so that the new defaults apply.'); } /** * Function _gallery_settings_g2image(). */ function _gallery_settings_g2image() { $plugin_status = gallery_plugin_status(array('imageblock')); $desc = t('G2Image requires the Gallery2 Image Block plugin (!imageblock_status) and the g2image application to be installed.', array('!imageblock_status' => theme('gallery_plugin_status_message', $plugin_status['imageblock']))); if ($plugin_status['imageblock'] != GALLERY_PLUGIN_ENABLED) { $g2_uri = variable_get('gallery_embed_uri', '?q=gallery'); $g2_plugins_page = (variable_get('gallery_valid', 0)) ? t('Gallery2 Plugins', array('@g2_plugins' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminModules')) : t('Gallery2 Site Admin -> Plugins'); $desc .= t(' However the Image Block plugin is unavailable, so G2Image is not available and the settings are disabled. To use G2Image please go to the !g2_plugins page and install/activate the Image Block plugin.', array( '!g2_plugins' => $g2_plugins_page)); } $form['g2image'] = array( '#type' => 'fieldset', '#title' => t('Gallery Image Assist (G2Image) settings'), '#collapsible' => FALSE, '#collapsed' => FALSE, '#description' => $desc, ); if ($plugin_status['imageblock'] == GALLERY_PLUGIN_ENABLED) { $form['g2image']['gallery_g2image_mode'] = array( '#type' => 'select', '#title' => t('Mode'), '#default_value' => variable_get('gallery_g2image_mode', 'disabled'), '#options' => array( 'disabled' => t('Disabled'), 'standalone' => t('Standalone'), 'tinymce' => t('TinyMCE'), ), '#description' => t('Determines the mode of operation. For anything other than \'Disabled\' the g2image application has to be installed. See the INSTALL.txt instructions. In \'Standalone\' mode a button will be visible under textfields to launch the g2image window. In \'TinyMCE\' mode the g2image button can be used in the TinyMCE toolbar. Note that the TinyMCE version will NOT work wih Safari - use the standalone version instead.'), ); $options = array( t('Show on every page except the listed pages.'), t('Show on only the listed pages.') ); $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')); $form['g2image']['gallery_g2image_only_listed_pages'] = array( '#type' => 'radios', '#title' => t('Show g2image link on specific pages (Standalone mode only)'), '#default_value' => variable_get('gallery_g2image_only_listed_pages', 1), '#options' => $options, ); $form['g2image']['gallery_g2image_std_pages'] = array( '#type' => 'textarea', '#title' => t('Pages (Standalone mode only)'), '#default_value' => variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages')), '#description' => $description ); $form['g2image']['gallery_g2image_sortby'] = array( '#type' => 'select', '#title' => t('Default Sort Order'), '#default_value' => variable_get('gallery_g2image_sortby', 'title_asc'), '#options' => array( 'title_asc' => t('Gallery2 Title (A-z)'), 'title_desc' => t('Gallery2 Title (z-A)'), 'name_asc' => t('Filename (A-z)'), 'name_desc' => t('Filename (z-A)'), 'mtime_desc' => t('Last Modification (newest first)'), 'mtime_asc' => t('Last Modification (oldest first)'), ), '#description' => t('Determines the default sorting order.'), ); $form['g2image']['gallery_g2image_images_per_page'] = array( '#type' => 'select', '#title' => t('Default Number of images per page'), '#default_value' => variable_get('gallery_g2image_images_per_page', 20), '#options' => array(10 => 10, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 60 => 60), '#description' => t('Choose the default number of images per page.'), ); $form['g2image']['gallery_g2image_display_filenames'] = array( '#type' => 'select', '#title' => t('Default Display Options'), '#default_value' => variable_get('gallery_g2image_display_filenames', 'thumbnails'), '#options' => array( 'thumbnails' => t('Thumbnails only'), 'filenames' => t('Thumbnails with title and filename'), ), '#description' => t('Choose the default display option for images.'), ); $form['g2image']['gallery_g2image_default_action'] = array( '#type' => 'select', '#title' => t('Default Action'), '#default_value' => variable_get('gallery_g2image_default_action', 'drupal_g2_filter'), '#options' => array( 'drupal_g2_filter' => t('Gallery Filter ID'), 'thumbnail_image' => t('Thumbnail with link to image'), 'thumbnail_album' => t('Thumbnail with link to parent album'), 'thumbnail_custom_url' => t('Thumbnail with link to custom URL'), 'thumbnail_only' => t('Thumbnail only'), 'link_image' => t('Text link to image'), 'link_parent' => t('Text link to parent album'), ), '#description' => t('Choose the default method of inserting the image info.'), ); $form['g2image']['gallery_g2image_custom_url'] = array( '#type' => 'textfield', '#title' => t('Default custom url'), '#default_value' => variable_get('gallery_g2image_custom_url', 'http://'), '#size' => 50, '#maxlength' => 50, '#description' => t('The default custom url. Used with \'Thumbnail with link to custom URL\' action setting'), ); $gallery_g2image_custom_class = variable_get('gallery_g2image_custom_class', array()); $css_options = array( 'none' => t('None'), 'g2image_normal' => t('Normal'), 'g2image_float_left' => t('Float Left'), 'g2image_float_right' => t('Float Right'), 'g2image_centered' => t('Centered'), ); $add_css_options = array(); foreach ($gallery_g2image_custom_class as $key => $value) { if ($value) { $add_css_options[$value] = $value; } } $css_options = array_merge($css_options, $add_css_options); $form['g2image']['gallery_g2image_default_alignment'] = array( '#type' => 'select', '#title' => t('Default Alignment'), '#default_value' => variable_get('gallery_g2image_default_alignment', 'none'), '#options' => $css_options, '#description' => t('Choose the default alignment of images.'), ); $form['g2image']['gallery_g2image_custom_class'] = array('#tree' => TRUE); for ($i=1; $i<=4; $i++) { $form['g2image']['gallery_g2image_custom_class'][$i] = array( '#type' => 'textfield', '#title' => t('Custom Class @index', array('@index' => $i)), '#default_value' => $gallery_g2image_custom_class[$i], '#size' => 20, '#maxlength' => 50, ); } $form['g2image']['gallery_g2image_custom_class'][$i-1]['#description'] = t('Additional css classes to be available for selection (must be defined in .css file).'); $form['g2image']['gallery_g2image_class_mode'] = array( '#type' => 'select', '#title' => t('Alignment Class Insertion Point'), '#default_value' => variable_get('gallery_g2image_class_mode', 'img'), '#options' => array( 'img' => t(''), 'div' => t('
'), ), '#description' => t('Determines where the alignment class will be inserted. If you choose \'<div class=...><img ...>\', you will have to manually delete any <div> tags manually after deleting images from the TinyMCE window.'), ); } $form['#validate']['_gallery_g2image_settings_validate'] = array(); return system_settings_form($form); } /** * Function _gallery_settings_search(). */ function _gallery_settings_search() { require_once(drupal_get_path('module', 'gallery') .'/gallery_block.inc'); $plugin_status = gallery_plugin_status(array('imageblock', 'imageframe', 'search')); $search_desc = t('The Gallery Search requires the Gallery2 Search plugin (!search_status) and optionally the Gallery2 Image Block plugin (!imageblock_status) and Gallery2 Image Frame plugin (!imageframe_status).', array( '!search_status' => theme('gallery_plugin_status_message', $plugin_status['search']), '!imageblock_status' => theme('gallery_plugin_status_message', $plugin_status['imageblock']), '!imageframe_status' => theme('gallery_plugin_status_message', $plugin_status['imageframe']), ) ); $g2_uri = variable_get('gallery_embed_uri', '?q=gallery'); $g2_plugins_page = (variable_get('gallery_valid', 0)) ? t('Gallery2 Plugins', array('@g2_plugins' => $g2_uri .'&g2_view=core.SiteAdmin&g2_subView=core.AdminModules')) : t('Gallery2 Site Admin -> Plugins'); $thumbs_desc = ''; if ($plugin_status['search'] != GALLERY_PLUGIN_ENABLED) { $search_desc .= t(' However the Search plugin is unavailable, so the search is not available and these settings are disabled. To use the search feature please go to the !g2_plugins page and install/activate the Image Block plugin.', array('!g2_plugins' => $g2_plugins_page)); } if ($plugin_status['imageblock'] != GALLERY_PLUGIN_ENABLED) { $thumbs_desc = t('To display search results with thumbnail images requires the Gallery2 Image Block plugin (!imageblock_status) and optionally the and 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']), ) ); $thumbs_desc .= t(' However the Image Block plugin is unavailable, so the thumbnails are not available and these settings are disabled. To use this feature please go to the !g2_plugins page and install/activate the Image Block plugin.', array('!g2_plugins' => $g2_plugins_page)); } $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']))) : ''; $form['search'] = array( '#type' => 'fieldset', '#title' => t('Search settings'), '#collapsible' => FALSE, '#collapsed' => FALSE, '#description' => $search_desc, ); $image_frames = gallery_get_image_frames(); _gallery_block_options($type_map, $param_map); if ($plugin_status['search'] == GALLERY_PLUGIN_ENABLED) { $form['search']['gallery_search_advanced'] = array( '#type' => 'checkbox', '#title' => t('Display advanced search options'), '#default_value' => variable_get('gallery_search_advanced', 1), '#description' => t('Adds options to the search form to select which Gallery fields to search in.'), ); $form['search']['gallery_search_num_per_row'] = array( '#type' => 'select', '#title' => t('Number of search results per table row'), '#default_value' => variable_get('gallery_search_num_per_row', 3), '#options' => _gallery_range_array(1, 5), '#description' => t('Select the number of search results per row in the paged table.'), ); $form['search']['gallery_search_rows_per_pager'] = array( '#type' => 'select', '#title' => t('Number of rows per page'), '#default_value' => variable_get('gallery_search_rows_per_pager', 4), '#options' => _gallery_range_array(1, 10), '#description' => t('Select the number of rows in the paged table.'), ); $form['search']['thumbs'] = array( '#type' => 'fieldset', '#title' => t('Search thumbnail settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#description' => $thumbs_desc, ); if ($plugin_status['imageblock'] == GALLERY_PLUGIN_ENABLED) { $form['search']['thumbs']['gallery_search_show_thumbs'] = array( '#type' => 'checkbox', '#title' => t('Display thumbnails'), '#default_value' => variable_get('gallery_search_show_thumbs', 1), '#description' => t('Display thumbnail images for the search results.'), ); $form['search']['thumbs']['gallery_search_block_show'] = array( '#type' => 'checkboxes', '#title' => t('Image data'), '#default_value' => variable_get('gallery_search_block_show', array('title' => t('Title'))), '#options' => $param_map, '#description' => t('Choose the item metadata you would like to display.'), ); $form['search']['thumbs']['gallery_search_size_method'] = array( '#type' => 'select', '#title' => t('Image size method'), '#default_value' => variable_get('gallery_search_size_method', GALLERY_SEARCH_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['search']['thumbs']['gallery_search_size'] = array( '#type' => 'textfield', '#title' => t('Image size'), '#default_value' => variable_get('gallery_search_size', GALLERY_SEARCH_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.'), ); $form['search']['thumbs']['gallery_search_album_frame'] = array( '#type' => 'select', '#title' => t('Album frame'), '#default_value' => variable_get('gallery_search_album_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['search']['thumbs']['gallery_search_item_frame'] = array( '#type' => 'select', '#title' => t('Item frame'), '#default_value' => variable_get('gallery_search_item_frame', 'none'), '#options' => $image_frames, '#description' => $imageframe_desc, ); $form['search']['thumbs']['gallery_search_link_target'] = array( '#type' => 'textfield', '#title' => t('Link target'), '#default_value' => variable_get('gallery_search_link_target', ''), '#size' => 20, '#maxlength' => 20, '#description' => t('Enter a link target (e.g. "_blank", "_new").'), ); $form['search']['thumbs']['gallery_search_default_link'] = array( '#type' => 'textfield', '#title' => t('Image Link'), '#default_value' => variable_get('gallery_search_default_link', ''), '#size' => 20, '#maxlength' => 20, '#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 system_settings_form($form); } /** * Function _gallery_settings_search_validate(). */ function _gallery_settings_search_validate($form_id, $form_values) { if (isset($form_values['gallery_search_size']) && (!is_numeric($form_values['gallery_search_size']) || $form_values['gallery_search_size'] < 1)) { form_set_error('gallery_search_size', t('Image size must be a number greater than zero.')); } } /** * Function _gallery_g2image_settings_validate(). * (saves the G2Image config file) */ function _gallery_g2image_settings_validate($form_id, $form_values) { switch ($form_values['gallery_g2image_mode']) { case 'tinymce': $mode = t('TinyMCE'); $path = drupal_get_path('module', 'tinymce'); $path .= '/tinymce/jscripts/tiny_mce/plugins/g2image'; break; case 'standalone': $mode = t('Standalone'); $path = drupal_get_path('module', 'gallery'); $path .= '/g2image'; break; default: return; } // Note that file_check_directory uses &$path and will strip the trailing '/' $filename = $path .'/config.php'; if (is_writable($filename) == FALSE && !file_check_directory($path)) { form_set_error('', t('G2Image does not seem to be installed for @mode mode in the required directory (@dir), or the directory is not writable. Please see the INSTALL.txt for instructions.', array('@mode' => $mode, '@dir' => '/'. $path))); return; } $cr = "\n"; $g2ic_gallery2_path = str_replace('\\', '/', variable_get('gallery_dir', './gallery2/')); $g2ic_use_full_path = (substr($g2ic_gallery2_path, 0, 1) == '/' || substr($g2ic_gallery2_path, $_SERVER['DOCUMENT_ROOT']) !== FALSE) ? 'TRUE' : 'FALSE'; $form_values['gallery_g2image_custom_url'] = check_url($form_values['gallery_g2image_custom_url']); $g2ic_display_filenames = ($form_values['gallery_g2image_display_filenames'] == 'filenames') ? 'TRUE' : 'FALSE'; $g2ic_custom_class = array(); foreach ($form_values['gallery_g2image_custom_class'] as $key => $value) { $g2ic_custom_class[$key] = ($value) ? $value : 'not_used'; } $g2ic_custom_class_1 = ($form_values['gallery_g2image_custom_class_1']) ? $form_values['gallery_g2image_custom_class_1'] : 'not_used'; $g2ic_custom_class_2 = ($form_values['gallery_g2image_custom_class_2']) ? $form_values['gallery_g2image_custom_class_2'] : 'not_used'; $g2ic_custom_class_3 = ($form_values['gallery_g2image_custom_class_3']) ? $form_values['gallery_g2image_custom_class_3'] : 'not_used'; $g2ic_custom_class_4 = ($form_values['gallery_g2image_custom_class_4']) ? $form_values['gallery_g2image_custom_class_4'] : 'not_used'; $content = ''. $cr; $filename = $path .'/config.php'; if (is_writable($filename) == FALSE) { form_set_error('', t('Could not write to G2Image config file. Please check the permissions for @filename.', array('@filename' => $filename))); return; } $handle = fopen($filename, "w"); if (fwrite($handle, $content) === FALSE) { form_set_error('', t('Could not write to G2Image config file. Please check the permissions for @filename.', array('@filename' => $filename))); return; } else { drupal_set_message(t('G2Image configuration file successfully created.')); } fclose($handle); } /** * Function _gallery_range_array(). * (create an associative range array * like array($min=>$min, ..., $max=>$max)) */ function _gallery_range_array($min, $max) { $range_array = array(); for ($i=$min; $i<=$max; $i++) { $range_array[$i] = $i; } return $range_array; } /** * Function _gallery_php_mem_check(). * (check the amount of PHP memory) */ function _gallery_php_mem_check($min_memory = 24) { $mem_limit = trim(ini_get('memory_limit')); $mem_limit_bytes = parse_size($mem_limit); if (empty($mem_limit)) { return array( 'status' => TRUE, 'info' => t('There is no memory limit restricting your PHP installation.'), ); } elseif (($mem_limit_bytes / (1024 * 1024)) < $min_memory) { return array( 'status' => FALSE, 'info' => t('Your PHP is configured to limit the memory to @mem_limit (memory_limit parameter in php.ini). You must raise this limit to at least @min_mem_limitM for proper embedded Gallery2 operation.', array( '@mem_limit' => $mem_limit, '@min_mem_limit' => $min_memory, ) ) ); } else { return array( 'status' => TRUE, 'info' => t('Your PHP is configured to limit the memory to @mem_limit (memory_limit parameter in php.ini). This should be fine for embedded Gallery2 operation.', array( '@mem_limit' => $mem_limit, ) ) ); } } /** * Function gallery_wanted_plugin_info(). */ function gallery_wanted_plugin_info() { return array( 'imageblock' => array( 'title' => 'Image Block', 'info' => t('Allows images to be included in the Drupal sidebar or in nodes.'), 'severity' => GALLERY_SEVERITY_ERROR, 'status' => gallery_single_plugin_status('imageblock'), ), 'imageframe' => array( 'title' => 'ImageFrame', 'info' => t('Provides a variety of frames around the images.'), 'severity' => GALLERY_SEVERITY_WARNING, 'status' => gallery_single_plugin_status('imageframe'), ), 'search' => array( 'title' => 'Search', 'info' => t('Allow the Drupal search to also search the Gallery.'), 'severity' => GALLERY_SEVERITY_WARNING, 'status' => gallery_single_plugin_status('search'), ), 'rewrite' => array( 'title' => 'URL Rewrite', 'info' => t('Allow short URLs (clean URLs).'), 'severity' => GALLERY_SEVERITY_ADVISE, 'status' => gallery_single_plugin_status('rewrite'), ), ); } /** * Function gallery_unwanted_plugin_info(). */ function gallery_unwanted_plugin_info() { return array( 'register' => array( 'title' => 'Registration', 'info' => t('All user registration must take place via Drupal to ensure that the users are synchronized between Drupal and Gallery2. This plugin would allow a user to register only in Gallery2 and not in Drupal and so should not be used.'), 'severity' => GALLERY_SEVERITY_WARNING, 'status' => gallery_single_plugin_status('register'), ), ); } /** * Function gallery_wanted_module_info(). */ function gallery_wanted_module_info() { return array( 'gsitemap' => array( 'title' => 'Google Sitemap', 'status' => module_exists('gsitemap'), 'severity' => GALLERY_SEVERITY_ADVISE, 'info' => t('Allows the Drupal and Gallery2 Google Sitemaps to be merged which allows for a single sitemap to be sent to Google (and other web search sites).'), ), 'profile' => array( 'title' => 'Profile', 'status' => module_exists('profile'), 'severity' => GALLERY_SEVERITY_ADVISE, 'info' => t('Allows support of the \'Full Name\' field in Gallery2.'), ), ); } /** * Function gallery_plugin_set_status(). */ function gallery_plugin_set_status($plugin_names) { $plugins_status = gallery_plugin_status($plugin_names); $plugin_info = gallery_wanted_plugin_info(); // Generate array containing module status $status = array(); foreach ($plugins_status as $plugin => $plugin_status) { if ($plugin_status == GALLERY_PLUGIN_ENABLED) { $status[$plugin] = ''; } else { $status[$plugin]['title'] = t('Gallery2 plugin \'@plugin\' is not available', array('@plugin' => isset($plugin_info[$plugin]) ? $plugin_info[$plugin]['title'] : drupal_ucfirst($plugin))); $status[$plugin]['severity'] = isset($plugin_info[$plugin]['severity']) ? $plugin_info[$plugin]['severity'] : GALLERY_SEVERITY_WARNING; $status[$plugin]['url'] = url('admin/settings/gallery/install', NULL, $plugin); } } gallery_set_status($status); } /** * Function gallery_format_status(). */ function gallery_format_status($status = array(), $title = 'Gallery message(s):') { $message = $title .'
    '; if (count($status)) { foreach ($status as $item) { $message .= '
  • '; $message .= empty($item['url']) ? t($item['title']) : ''. t($item['title']) .''; $message .= (isset($item['info']) && !empty($item['info'])) ? (': '. t($item['info'])) : ''; $message .= isset($item['severity']) ? (' ['. theme('gallery_severity_message', $item['severity']) .']') : ''; $message .= '
  • '; } } else { $message = t('Status not available'); } $message .= '
'; return $message; } /** * Theme function : theme_gallery_module_status_message(). */ function theme_gallery_module_status_message($status) { if ($status) { return ''. t('enabled') .''; } else { return ''. t('disabled') .''; } } /** * Theme function : theme_gallery_severity_message(). */ function theme_gallery_severity_message($severity = NULL) { switch ($severity) { case GALLERY_SEVERITY_SUCCESS: return ''. t('OK') .''; case GALLERY_SEVERITY_ERROR: return ''. t('Error') .''; case GALLERY_SEVERITY_WARNING: return ''. t('Warning') .''; case GALLERY_SEVERITY_ADVISE: return ''. t('Advisory') .''; case GALLERY_SEVERITY_UNKNOWN: return ''. t('Unknown') .''; default: } } /** * Theme function : theme_gallery_plugin_status_message(). */ function theme_gallery_plugin_status_message($status, $invert = FALSE) { if ($invert) { $enabled_class = 'admin-disabled'; $disabled_class = 'admin-enabled'; } else { $enabled_class = 'admin-enabled'; $disabled_class = 'admin-disabled'; } $unknown_class = 'admin-disabled'; switch ($status) { case GALLERY_PLUGIN_ENABLED: return ''. t('activated') .''; case GALLERY_PLUGIN_DISABLED: return ''. t('disabled') .''; case GALLERY_PLUGIN_NOT_ACTIVE: return ''. t('deactivated') .''; case GALLERY_PLUGIN_NOT_INSTALLED: return ''. t('not installed') .''; case GALLERY_PLUGIN_MISSING: return ''. t('missing') .''; case GALLERY_PLUGIN_STATUS_UNKNOWN: default: return ''. t('unknown') .''; } } /** * Theme function : theme_gallery_severity_status_message(). */ function theme_gallery_severity_status_message($severity, $status, $full_msg = FALSE, $invert = FALSE) { // In some cases (e.g. unwanted plugins) it makes sense to return the full 2 part message // even on a success, but in most cases a simple "OK" is sufficient. if ($full_msg) { return theme('gallery_severity_message', $severity) .' ('. theme('gallery_plugin_status_message', $module['status'], $invert) .')'; } switch ($severity) { case GALLERY_SEVERITY_SUCCESS: return theme('gallery_severity_message', $severity); default: return theme('gallery_severity_message', $severity) .' ('. theme('gallery_plugin_status_message', $module['status'], $invert) .')'; } }