Commit eebfd4f9 authored by kiz_0987's avatar kiz_0987
Browse files

#81559 - Fixed g2image config.php permissions check.

Better drupal .htaccess location guess for URL Rewrite
Fixed URL rewrite auto config (hopefully) to correctly save new .htaccess file.
parent e615ab2b
......@@ -123,17 +123,17 @@ function _gallery_settings() {
// Image Block settings
$typeMap = array(
'randomImage' => t('Random image'),
'recentImage' => t('Recent image'),
'viewedImage' => t('Viewed image'),
'randomAlbum' => t('Random album'),
'recentAlbum' => t('Recent album'),
'viewedAlbum' => t('Viewed album'),
'dailyImage' => t('Daily image'),
'weeklyImage' => t('Weekly image'),
'monthlyImage' => t('Monthly image'),
'dailyAlbum' => t('Daily album'),
'weeklyAlbum' => t('Weekly album'),
'randomImage' => t('Random image'),
'recentImage' => t('Recent image'),
'viewedImage' => t('Viewed image'),
'randomAlbum' => t('Random album'),
'recentAlbum' => t('Recent album'),
'viewedAlbum' => t('Viewed album'),
'dailyImage' => t('Daily image'),
'weeklyImage' => t('Weekly image'),
'monthlyImage' => t('Monthly image'),
'dailyAlbum' => t('Daily album'),
'weeklyAlbum' => t('Weekly album'),
'monthlyAlbum' => t('Monthly album'),
);
......@@ -144,7 +144,7 @@ function _gallery_settings() {
'owner' => t('Item owner'),
'heading' => t('Heading'),
'fullSize' => t('Full Size'),
);
);
$form['block'] = _gallery_block_settings($typeMap , $paramMap);
$form['grid'] = _gallery_grid_block_settings($typeMap , $paramMap);
......@@ -378,23 +378,23 @@ function _gallery_filter_settings($typeMap , $paramMap) {
'#description' => '',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
//we don't include specificItem, since it can be selected automatically if n=1
$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].'),
);
$form['filter']['gallery_filter_default_block_type'] = array(
'#type' => 'select',
'#title' => t('Image Block Type'),
'#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'),
'#options' => $typeMap,
'#description' => t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'),
);
//we don't include specificItem, since it can be selected automatically if n=1
$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].'),
);
$form['filter']['gallery_filter_default_block_type'] = array(
'#type' => 'select',
'#title' => t('Image Block Type'),
'#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'),
'#options' => $typeMap,
'#description' => t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'),
);
$form['filter']['gallery_filter_can_cache'] = array(
......@@ -403,50 +403,50 @@ function _gallery_filter_settings($typeMap , $paramMap) {
'#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 <a href="%link">admin/filters</a> and re-save the image formats that use gallery filter.', array('%link' => url('admin/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.'),
);
//////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
//then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
$form['filter']['gallery_filter_default_show'] = array(
'#type' => 'checkboxes',
'#title' => t('Default Image Block Settings'),
'#default_value' => variable_get('gallery_filter_default_show', array('none')),
'#options' => $paramMap,
'#description' => t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'),
$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.'),
);
//////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
//then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
$form['filter']['gallery_filter_default_show'] = array(
'#type' => 'checkboxes',
'#title' => t('Default Image Block Settings'),
'#default_value' => variable_get('gallery_filter_default_show', array('none')),
'#options' => $paramMap,
'#description' => t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'),
);
$form['filter']['gallery_filter_default_size'] = array(
'#type' => 'textfield',
'#title' => t('Default thumbnail size'),
'#default_value' => variable_get("gallery_filter_default_size", "150"),
'#size' => 10,
'#maxlength' => 10,
$form['filter']['gallery_filter_default_size'] = array(
'#type' => 'textfield',
'#title' => t('Default thumbnail size'),
'#default_value' => variable_get("gallery_filter_default_size", "150"),
'#size' => 10,
'#maxlength' => 10,
'#description' => t('If no size is specified when calling the filter, this size will be used. If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
);
$form['filter']['gallery_filter_default_album_frame'] = array(
'#type' => 'textfield',
'#title' => t('Default album frame'),
'#default_value' => variable_get('gallery_filter_default_album_frame', 'none'),
'#size' => 20,
'#maxlength' => 20,
'#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame. '),
$form['filter']['gallery_filter_default_album_frame'] = array(
'#type' => 'textfield',
'#title' => t('Default album frame'),
'#default_value' => variable_get('gallery_filter_default_album_frame', 'none'),
'#size' => 20,
'#maxlength' => 20,
'#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame. '),
);
$form['filter']['gallery_filter_default_item_frame'] = array(
'#type' => 'textfield',
'#title' => t('Default item frame'),
'#default_value' => variable_get('gallery_filter_default_item_frame', 'none'),
'#size' => 20,
'#maxlength' => 20,
'#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame.'),
$form['filter']['gallery_filter_default_item_frame'] = array(
'#type' => 'textfield',
'#title' => t('Default item frame'),
'#default_value' => variable_get('gallery_filter_default_item_frame', 'none'),
'#size' => 20,
'#maxlength' => 20,
'#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame.'),
);
$form['filter']['gallery_filter_default_link_target'] = array(
......@@ -457,14 +457,14 @@ function _gallery_filter_settings($typeMap , $paramMap) {
'#maxlength' => 20,
'#description' => t('Enter a link target (eg "_blank", "_new").'),
);
$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_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.)'),
);
return $form['filter'];
}
......@@ -606,13 +606,13 @@ function _gallery_g2image_settings() {
'#description' => $description
);
$form['g2image']['gallery_g2image_regex'] = array(
'#type' => 'textfield',
'#title' => t('Image Types Regular Expression'),
'#default_value' => variable_get('gallery_g2image_regex', '@(jpg|jpeg|png|gif|bmp|svg|mov|mpg|mpeg)$@i'),
'#size' => 50,
'#maxlength' => 50,
'#description' => t('Images with these file extensions will be displayed in g2image'),
$form['g2image']['gallery_g2image_regex'] = array(
'#type' => 'textfield',
'#title' => t('Image Types Regular Expression'),
'#default_value' => variable_get('gallery_g2image_regex', '@(jpg|jpeg|png|gif|bmp|svg|mov|mpg|mpeg)$@i'),
'#size' => 50,
'#maxlength' => 50,
'#description' => t('Images with these file extensions will be displayed in g2image'),
);
$form['g2image']['gallery_g2image_sortby'] = array(
......@@ -683,13 +683,13 @@ function _gallery_g2image_settings() {
'#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'),
$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'),
);
// Fix - G2 prefix
......@@ -913,14 +913,10 @@ function _gallery_configure_url_rewrite() {
// Find the public path to drupal from the base_url
global $base_url;
$http = 'http' . (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] == 'on' ? 's' : '' : '');
$public_path = str_replace($http . '://' . $_SERVER['HTTP_HOST'],'', $base_url);
$public_path = str_replace($http . '://' . $_SERVER['HTTP_HOST'],'', $base_url) . '/';
// Find the path to drupal. Will this always work?
// FIX NEEDED: This will fail if the module is installed in the sites/XXX/modules dir.
// Probably not a big deal for 99% of people.
$drupal_root = dirname(__FILE__);
$gallery_path = drupal_get_path('module', 'gallery');
$htaccess_path = str_replace($gallery_path, '', $drupal_root);
$htaccess_path = realpath(".") . '/';
$title = t('Gallery2 URL Rewrite Module Auto-Configuration:');
$results['urlrewrite']['title'] = $title;
......@@ -960,18 +956,18 @@ function _gallery_configure_url_rewrite() {
// Save the G2 rewrite Values
list ($ret, $code, $err) = $rewriteApi->saveEmbedConfig($params);
if ( $code > 0 ) {
if ($code != REWRITE_STATUS_OK) {
list ($ret, $errstr) = $err;
$errstr = $code." - ".$errstr;
$results['urlrewrite']['error'] = true;
$results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error') . '<pre>' . $errstr . '</pre>';
$results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error:') . '<pre>' . $errstr . '</pre>';
$num_errors++;
}
$results['urlrewrite']['success'] = true;
} else {
$results['urlrewrite']['success'] = true;
}
} else {
$results['urlrewrite']['error'] = true;
$results['urlrewrite']['notice'] = t('The .htaccess file in your defined Drupal directory (%dir) is not writable. Please CHMOD it to 644 (or 666 if 644 does not work).', array('%dir' => $htaccess_path));
$results['urlrewrite']['notice'] = t('The .htaccess file in your defined Drupal directory (%dir) is not writable. Please CHMOD it to 644 (or 666 if 644 does not work).', array('%dir' => $htaccess_path));
$num_errors++;
}
}
......@@ -998,7 +994,8 @@ function _gallery_g2image_settings_form_validate(&$form_values) {
}
$title = 'Gallery2 Image Assist (g2image) Status:';
// Note that file_check_directory uses &$path and will strip the trailing '/'
if (!file_check_directory($path)) {
$filename = $path . '/config.php';
if (is_writable($filename) == false && !file_check_directory($path)) {
$results['gallery_g2image']['title'] = $title;
$results['gallery_g2image']['warning'] = true;
$results['gallery_g2image']['notice'] = 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' => '&lt;drupal_path&gt;'.$path));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment