Commit adefaf3d authored by profix898's avatar profix898
Browse files

- task: complete update to D6 (block handling, page context, etc.) + various bugfixes

parent 6539308d
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
* Implementation of hook_install(). * Implementation of hook_install().
*/ */
function gallery_install() { function gallery_install() {
drupal_set_message(t(''));
} }
/** /**
...@@ -78,7 +77,7 @@ function gallery_update_1() { ...@@ -78,7 +77,7 @@ function gallery_update_1() {
* Implementation of hook_update_N(). * Implementation of hook_update_N().
* (initial update to Drupal 6) * (initial update to Drupal 6)
*/ */
function gallery_update_6001() { function gallery_update_6000() {
$delta = 0; $delta = 0;
$new = $migrate = array(); $new = $migrate = array();
// Image block settings // Image block settings
...@@ -87,7 +86,7 @@ function gallery_update_6001() { ...@@ -87,7 +86,7 @@ function gallery_update_6001() {
$delta++; $delta++;
$new += array( $new += array(
'gallery_block_'. $delta .'_type' => 'imageblock', 'gallery_block_'. $delta .'_type' => 'imageblock',
'gallery_block_'. $delta .'_imageblock_num_cols' => 1, 'gallery_block_'. $delta .'_imageblock_num_cols' => 1
); );
$migrate += array( $migrate += array(
'gallery_block_image_'. $i .'_blockid' => 'gallery_block_'. $delta .'_blockid', 'gallery_block_image_'. $i .'_blockid' => 'gallery_block_'. $delta .'_blockid',
...@@ -100,8 +99,9 @@ function gallery_update_6001() { ...@@ -100,8 +99,9 @@ function gallery_update_6001() {
'gallery_block_image_'. $i .'_album_frame' => 'gallery_block_'. $delta .'_imageblock_album_frame', 'gallery_block_image_'. $i .'_album_frame' => 'gallery_block_'. $delta .'_imageblock_album_frame',
'gallery_block_image_'. $i .'_item_frame' => 'gallery_block_'. $delta .'_imageblock_item_frame', 'gallery_block_image_'. $i .'_item_frame' => 'gallery_block_'. $delta .'_imageblock_item_frame',
'gallery_block_image_'. $i .'_link_target' => 'gallery_block_'. $delta .'_imageblock_link_target', 'gallery_block_image_'. $i .'_link_target' => 'gallery_block_'. $delta .'_imageblock_link_target',
'gallery_block_image_'. $i .'_link' => 'gallery_block_'. $delta .'_imageblock_link', 'gallery_block_image_'. $i .'_link' => 'gallery_block_'. $delta .'_imageblock_link'
); );
$ret[] = update_sql("UPDATE {blocks} SET delta = 'block-%d' WHERE module = 'gallery' AND delta = 'image-%d'", $delta, $i);
} }
// Grid block settings // Grid block settings
$gridblock_num = variable_get('gallery_block_grid_num', 1); $gridblock_num = variable_get('gallery_block_grid_num', 1);
...@@ -120,25 +120,22 @@ function gallery_update_6001() { ...@@ -120,25 +120,22 @@ function gallery_update_6001() {
'gallery_block_grid_'. $i .'_album_frame' => 'gallery_block_'. $delta .'_imageblock_album_frame', 'gallery_block_grid_'. $i .'_album_frame' => 'gallery_block_'. $delta .'_imageblock_album_frame',
'gallery_block_grid_'. $i .'_item_frame' => 'gallery_block_'. $delta .'_imageblock_item_frame', 'gallery_block_grid_'. $i .'_item_frame' => 'gallery_block_'. $delta .'_imageblock_item_frame',
'gallery_block_grid_'. $i .'_link_target' => 'gallery_block_'. $delta .'_imageblock_link_target', 'gallery_block_grid_'. $i .'_link_target' => 'gallery_block_'. $delta .'_imageblock_link_target',
'gallery_block_grid_'. $i .'_link' => 'gallery_block_'. $delta .'_imageblock_link', 'gallery_block_grid_'. $i .'_link' => 'gallery_block_'. $delta .'_imageblock_link'
); );
$ret[] = update_sql("UPDATE {blocks} SET delta = 'block-%d' WHERE module = 'gallery' AND delta = 'grid-%d'", $delta, $i);
} }
$new['gallery_block_num'] = $delta; $new['gallery_block_num'] = $delta;
// Array containing obsolete variables // Array containing obsolete variables
$obsolete = array('gallery_page_callback', 'gallery_block_image_num', 'gallery_block_grid_num'); $obsolete = array('gallery_page_callback', 'gallery_block_image_num', 'gallery_block_grid_num');
// Update variables
$ret = gallery_update_variables($migrate, $obsolete);
// Add new variables // Add new variables
foreach ($new as $name => $value) { foreach ($new as $name => $value) {
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $value); db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $value);
} }
// Update variables
$ret = gallery_update_variables($migrate, $obsolete);
// Update the blocks
$ret[] = update_sql("UPDATE {blocks} SET delta = 'image-0' WHERE module = 'gallery' AND delta = 0");
$ret[] = update_sql("UPDATE {blocks} SET delta = 'navigation' WHERE module = 'gallery' AND delta = 1");
$ret[] = update_sql("UPDATE {blocks} SET delta = 'grid-0' WHERE module = 'gallery' AND delta = 2");
cache_clear_all('variables', 'cache'); cache_clear_all('variables', 'cache');
menu_rebuild(); menu_rebuild();
......
...@@ -357,8 +357,8 @@ function gallery_elements() { ...@@ -357,8 +357,8 @@ function gallery_elements() {
* (add image link underneath textareas) * (add image link underneath textareas)
*/ */
function gallery_g2image_textarea($element) { function gallery_g2image_textarea($element) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_g2image.inc'); require_once(drupal_get_path('module', 'gallery') .'/gallery_g2image.inc');
if (_gallery_g2image_page_match() && !strstr($_GET['q'], 'gallery') if (_gallery_g2image_page_match() && !strstr($_GET['q'], 'gallery')
&& (variable_get('gallery_g2image_mode', 'disabled') == 'standalone') && (variable_get('gallery_g2image_mode', 'disabled') == 'standalone')
&& (user_access('access standalone g2image'))) { && (user_access('access standalone g2image'))) {
gallery_g2image_add_js(); gallery_g2image_add_js();
...@@ -395,12 +395,12 @@ function gallery_page() { ...@@ -395,12 +395,12 @@ function gallery_page() {
if ($result && !$result['isDone']) { if ($result && !$result['isDone']) {
// Allow modules to alter the page // Allow modules to alter the page
drupal_alter('gallery_page', $result, array()); drupal_alter('gallery_page', $result, array());
// Add css/js for this page // Add css/js/meta for this page
gallery_set_head($result['headHtml'], TRUE); gallery_set_head($result['headHtml'], TRUE);
// Add pathbar. See http://gallery.menalto.com/node/33447 // Add pathbar. See http://gallery.menalto.com/node/33447
if (isset($result['themeData'])) { if (isset($result['themeData'])) {
$breadcrumb = array(l(t('Home'), '')); $breadcrumb = array(l(t('Home'), ''));
// Some themes (eg hybrid) do not set $result['themeData']['parents'] // Some themes (e.g. hybrid) do not set $result['themeData']['parents']
if ($result['themeData']['parents']) { if ($result['themeData']['parents']) {
foreach ($result['themeData']['parents'] as $parent) { foreach ($result['themeData']['parents'] as $parent) {
$parent_title = $parent['title']; $parent_title = $parent['title'];
...@@ -418,6 +418,8 @@ function gallery_page() { ...@@ -418,6 +418,8 @@ function gallery_page() {
} }
} }
drupal_set_breadcrumb($breadcrumb); drupal_set_breadcrumb($breadcrumb);
// store G2 page context
gallery_context($result['themeData'], TRUE);
} }
// Hack to get the admin sidebar // Hack to get the admin sidebar
if (variable_get('gallery_move_admin_sidebar_to_block', 0)) { if (variable_get('gallery_move_admin_sidebar_to_block', 0)) {
......
...@@ -71,7 +71,7 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) { ...@@ -71,7 +71,7 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
$init_err_msg = t('Unable to initialize embedded Gallery. You need to <a href="@link"> configure your embedded Gallery</a>.', $init_err_msg = t('Unable to initialize embedded Gallery. You need to <a href="@link"> configure your embedded Gallery</a>.',
array('@link' => url('admin/settings/gallery/install'))); array('@link' => url('admin/settings/gallery/install')));
if ((!$gallery_valid) || (!is_readable($embed_path))) { if (!$gallery_valid || !is_readable($embed_path)) {
if ($report_error) { if ($report_error) {
gallery_error($init_err_msg); gallery_error($init_err_msg);
} }
...@@ -105,24 +105,21 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) { ...@@ -105,24 +105,21 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
} }
// Allow modules to alter the init parameters // Allow modules to alter the init parameters
drupal_alter('gallery_init', $params); drupal_alter('gallery_init', $params, array());
// Initialize Gallery2 // Initialize Gallery2
include_once($embed_path); include_once($embed_path);
$ret = GalleryEmbed::init($params); $ret = GalleryEmbed::init($params);
if ($ret) { if ($ret) {
if ($ret->getErrorCode() & ERROR_PLUGIN_VERSION_MISMATCH) { if ($report_error) {
if ($report_error) { if ($ret->getErrorCode() & ERROR_PLUGIN_VERSION_MISMATCH) {
gallery_error($vars ? t('Embedding API version is incompatible.') : $init_err_msg, $ret, TRUE); gallery_error($vars ? t('Embedding API version is incompatible.') : $init_err_msg, $ret, TRUE);
} }
return FALSE; else {
}
else {
if ($report_error) {
gallery_error($init_err_msg, $ret, TRUE); gallery_error($init_err_msg, $ret, TRUE);
} }
return FALSE;
} }
return FALSE;
} }
// Check if initialization was successful // Check if initialization was successful
...@@ -147,11 +144,10 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) { ...@@ -147,11 +144,10 @@ function _gallery_init($full = FALSE, $vars = NULL, $report_error = TRUE) {
// Set theme for embedded gallery // Set theme for embedded gallery
if ((!$full || !$ready['half']) && isset($params['themeId'])) { if ((!$full || !$ready['half']) && isset($params['themeId'])) {
// TODO: G2.3 $ret = GalleryEmbed::setThemeForRequest($params['themeId']);
/*$ret = GalleryEmbed::setThemeForRequest($g2_theme);
if ($ret && $report_error) { if ($ret && $report_error) {
gallery_error(t('Error settings embedded theme (%theme).', array('%theme' => $g2_theme))); gallery_error(t('Error settings embedded theme (%theme).', array('%theme' => $params['themeId'])));
}*/ }
} }
// Allow other modules to perform post-init tasks // Allow other modules to perform post-init tasks
module_invoke_all('gallery_init', $full); module_invoke_all('gallery_init', $full);
...@@ -218,7 +214,7 @@ function gallery_get_language($user) { ...@@ -218,7 +214,7 @@ function gallery_get_language($user) {
// Convert certain lang codes, e.g. 'esl/spa es' => 'es' or 'fr-ca' => 'fr' // Convert certain lang codes, e.g. 'esl/spa es' => 'es' or 'fr-ca' => 'fr'
$lang = preg_replace(array('/([\w\/]+) ([a-z]{2,3})/i', '/([a-z]{2,3})-(\w+)/i'), array('${2}', '${1}'), $lang); $lang = preg_replace(array('/([\w\/]+) ([a-z]{2,3})/i', '/([a-z]{2,3})-(\w+)/i'), array('${2}', '${1}'), $lang);
return $language->language; return $lang;
} }
/** /**
...@@ -507,6 +503,42 @@ function gallery_set_javascript($javascript) { ...@@ -507,6 +503,42 @@ function gallery_set_javascript($javascript) {
} }
} }
/**
* Function gallery_context().
* (store and/or access the context of the current gallery page)
*/
function gallery_context(&$params, $setcontext = FALSE) {
static $context_cache = NULL;
if ($setcontext) {
// store new context
$context_cache = (isset($params) && count($params)) ? $params : array();
gallery_debug($context_cache, t('Context cache'));
}
else if (isset($context_cache)) {
// get context parameters
if (isset($params)) {
// return requested context parameters
$params = is_array($params) ? $params : array($params);
foreach($params as $param) {
if (!isset($context_cache[$param])) {
return FALSE;
}
$context[$param] = $context_cache[$param];
}
$params = $context;
}
else {
// return all stored context parameters
$params = $context_cache;
}
return TRUE;
}
return FALSE;
}
/** /**
* Function gallery_get_blocks(). * Function gallery_get_blocks().
*/ */
...@@ -614,11 +646,9 @@ function _gallery_htmlcharsdecode($string) { ...@@ -614,11 +646,9 @@ function _gallery_htmlcharsdecode($string) {
return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
} }
/* /* --------------------------------------------------------------------------
* --------------------------------------------------------------------------
* Error, Debug and Status Functions * Error, Debug and Status Functions
* -------------------------------------------------------------------------- * -------------------------------------------------------------------------- */
*/
/** /**
* Function gallery_error(). * Function gallery_error().
......
...@@ -52,19 +52,39 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -52,19 +52,39 @@ function _gallery_block($op = 'list', $delta = 0, $edit = array()) {
*/ */
function _gallery_block_map($refresh = FALSE) { function _gallery_block_map($refresh = FALSE) {
// Get block map from cache (or rebuild map) // Get block map from cache (or rebuild map)
$cache = cache_get('gallery:blocksmap', 'cache'); $cache = cache_get('gallery:blockmap', 'cache');
if (!$cache || $refresh) { if (!$cache || $refresh) {
// Rebuild block map
$block_map = array(); $block_map = array();
$g2_blocks = gallery_get_blocks(); $g2_blocks = gallery_get_blocks();
foreach ($g2_blocks as $plugin => $blocks) { foreach ($g2_blocks as $plugin => $blocks) {
foreach (array_keys($blocks) as $block) { foreach (array_keys($blocks) as $block) {
switch ($block) {
// Blocks with no required parameter
case 'AlbumSelect':
case 'AlbumTree':
case 'ShowCart':
case 'LanguageSelector':
case 'MembersSummary':
case 'QuotasSummary':
case 'RssBlock':
$params = array();
break;
// Parameter defaults to 'item'
// (required by 'ViewComments', 'AddComment', 'ItemInfo', 'ItemLinks',
// 'PeerList', 'CustomFields', 'ExifInfo', 'KeywordLinks', 'Rating', ...)
default:
$params = array('item');
}
//
$block_map[strtolower($block)] = array( $block_map[strtolower($block)] = array(
'plugin' => $plugin, 'plugin' => $plugin,
'block' => $block 'block' => $block,
'params' => $params
); );
} }
} }
cache_set('gallery:blocksmap', $block_map, 'cache', CACHE_PERMANENT); cache_set('gallery:blockmap', $block_map, 'cache', CACHE_PERMANENT);
} }
else { else {
$block_map = $cache->data; $block_map = $cache->data;
...@@ -96,19 +116,25 @@ function _gallery_block_block($delta) { ...@@ -96,19 +116,25 @@ function _gallery_block_block($delta) {
$block_type = variable_get('gallery_block_'. $delta .'_type', 'imageblock'); $block_type = variable_get('gallery_block_'. $delta .'_type', 'imageblock');
$plugin = $block_map[$block_type]['plugin']; $plugin = $block_map[$block_type]['plugin'];
$plugin_block = $block_map[$block_type]['block']; $plugin_block = $block_map[$block_type]['block'];
$params = $block_map[$block_type]['params'];
// // ImageBlock needs special handling
if ($plugin_block == 'ImageBlock') { if ($plugin_block == 'ImageBlock') {
return _gallery_block_image_block($delta, $plugin, $plugin_block); return _gallery_block_image_block($delta, $plugin, $plugin_block);
} }
// // Check for required parameters
$params = array(); if (!gallery_context($params)) {
return FALSE;
}
// Add custom parameters
$g2_blocks = gallery_get_blocks(); $g2_blocks = gallery_get_blocks();
foreach ($g2_blocks[$plugin][$plugin_block]['vars'] as $parameter => $options) { if (isset($g2_blocks[$plugin][$plugin_block]['vars'])) {
$block = strtolower($plugin_block .'_'. $parameter); foreach ($g2_blocks[$plugin][$plugin_block]['vars'] as $parameter => $options) {
$element = 'gallery_block_'. $delta .'_'. $block; $block = strtolower($plugin_block .'_'. $parameter);
$params[$parameter] = variable_get($element, $options['default']); $element = 'gallery_block_'. $delta .'_'. $block;
$params[$parameter] = variable_get($element, $options['default']);
}
} }
return _gallery_block_get_block($plugin, $plugin_block, $params); return _gallery_block_get_block($plugin, $plugin_block, $params);
...@@ -151,9 +177,8 @@ function _gallery_block_image_block($delta, $plugin, $plugin_block) { ...@@ -151,9 +177,8 @@ function _gallery_block_image_block($delta, $plugin, $plugin_block) {
* Function _gallery_block_get_block(). * Function _gallery_block_get_block().
*/ */
function _gallery_block_get_block($plugin, $plugin_block, $params, $extra = array()) { function _gallery_block_get_block($plugin, $plugin_block, $params, $extra = array()) {
// // Handle useralbum feature (for ImageBlocks)
if ($plugin_block == 'ImageBlock') { if ($plugin_block == 'ImageBlock') {
// Handle useralbum feature
if (preg_match('/user(:([\d]+))?/i', $params['itemId'], $param_uid)) { if (preg_match('/user(:([\d]+))?/i', $params['itemId'], $param_uid)) {
require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc'); require_once(drupal_get_path('module', 'gallery') .'/gallery_user.inc');
$params['itemId'] = gallery_user_useralbum(isset($param_uid[2]) ? $param_uid[2] : NULL, FALSE); $params['itemId'] = gallery_user_useralbum(isset($param_uid[2]) ? $param_uid[2] : NULL, FALSE);
...@@ -162,7 +187,7 @@ function _gallery_block_get_block($plugin, $plugin_block, $params, $extra = arra ...@@ -162,7 +187,7 @@ function _gallery_block_get_block($plugin, $plugin_block, $params, $extra = arra
unset($params['itemId']); unset($params['itemId']);
} }
} }
gallery_debug($params, t('Block parameters')); gallery_debug($params, t('Block parameters'));
// Get the block from G2 // Get the block from G2
list($ret, $content, $head) = GalleryEmbed::getBlock($plugin, $plugin_block, $params); list($ret, $content, $head) = GalleryEmbed::getBlock($plugin, $plugin_block, $params);
...@@ -170,19 +195,24 @@ function _gallery_block_get_block($plugin, $plugin_block, $params, $extra = arra ...@@ -170,19 +195,24 @@ function _gallery_block_get_block($plugin, $plugin_block, $params, $extra = arra
gallery_error(t('Error trying to get block.'), $ret); gallery_error(t('Error trying to get block.'), $ret);
return array(); return array();
} }
$content = trim($content);
// Allow other modules to alter the block output // Allow other modules to alter the block output
drupal_alter('gallery_block', $content, array('params' => $params, 'extra' => $extra)); drupal_alter('gallery_block', $content, array('params' => $params, 'extra' => $extra));
// Format the block content // Format the block content
$block = array(); $block = array();
if ($content) { if (!empty($content)) {
$block['subject'] = t('Gallery'); $block['subject'] = t('Gallery');
if (isset($extra['num_cols'])) { $block['content'] = $content;
$class = isset($extra['class']) ? $extra['class'] : 'gallery-grid-block'; //
$block['content'] = theme('gallery_block_grid_block', $content, $extra['num_cols'], $class); if ($plugin_block == 'ImageBlock') {
} if (isset($extra['num_cols'])) {
else { $class = isset($extra['class']) ? $extra['class'] : 'gallery-grid-block';
$class = isset($extra['class']) ? $extra['class'] : 'g2image_centered'; $block['content'] = theme('gallery_block_grid_block', $content, $extra['num_cols'], $class);
$block['content'] = theme('gallery_block_image_block', $content, $class); }
else {
$class = isset($extra['class']) ? $extra['class'] : 'g2image_centered';
$block['content'] = theme('gallery_block_image_block', $content, $class);
}
} }
// Add css/js to the page // Add css/js to the page
if ($head) { if ($head) {
......
...@@ -76,7 +76,7 @@ function _gallery_block_admin_block($delta) { ...@@ -76,7 +76,7 @@ function _gallery_block_admin_block($delta) {
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('%block settings', array('%block' => $plugin_block)), '#title' => t('%block settings', array('%block' => $plugin_block)),
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#collapsed' => FALSE, '#collapsed' => FALSE
); );
$form[$block_type][] = $param_form; $form[$block_type][] = $param_form;
} }
...@@ -297,6 +297,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo ...@@ -297,6 +297,7 @@ function _gallery_block_admin_imageblock($delta, $plugin, $plugin_block, $g2_blo
*/ */
function _gallery_block_admin_update($form, &$form_state) { function _gallery_block_admin_update($form, &$form_state) {
_gallery_block_admin_save(0, $form_state['values']); _gallery_block_admin_save(0, $form_state['values']);
db_query("UPDATE {blocks} SET title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']);
} }
/** /**
......
...@@ -122,11 +122,12 @@ function gallery_filter_process($text) { ...@@ -122,11 +122,12 @@ function gallery_filter_process($text) {
gallery_error(t('Error trying to get image block.'), $ret); gallery_error(t('Error trying to get image block.'), $ret);
continue; continue;
} }
if ($content) { $content = trim($content);
if (!empty($content)) {
$params['class'] = 'giImageBlock'. ($params['class'] ? ' '. $params['class'] : ''); $params['class'] = 'giImageBlock'. ($params['class'] ? ' '. $params['class'] : '');
$content = '<div class ="'. $params['class'] .'">'. $content .'</div>';
// Allow other modules to alter the filter output // Allow other modules to alter the filter output
drupal_alter('gallery_filter', $content, array('params' => $params)); drupal_alter('gallery_filter', $content, array('params' => $params));
$content = '<div class ="'. $params['class'] .'">'. $content .'</div>';
} }
// Replace G2 filter tag with image block html (or at least remove filter tag) // Replace G2 filter tag with image block html (or at least remove filter tag)
$text = str_replace($match[0], $content, $text); $text = str_replace($match[0], $content, $text);
......
...@@ -57,7 +57,7 @@ function _gallery_install_status_report($install_status) { ...@@ -57,7 +57,7 @@ function _gallery_install_status_report($install_status) {
foreach ($install_status as $step => $status) { foreach ($install_status as $step => $status) {
// Find the combination of status and severity of the plugin // Find the combination of status and severity of the plugin
$severity = ($status['status'] <= 0) ? $status['severity'] : GALLERY_SEVERITY_SUCCESS; $severity = ($status['status'] <= 0) ? $status['severity'] : GALLERY_SEVERITY_SUCCESS;
if (!$status['status']) { if (!$status['status'] && $severity == GALLERY_SEVERITY_ERROR) {
$error = TRUE; $error = TRUE;
} }
$row = array(); $row = array();
...@@ -150,29 +150,31 @@ function _gallery_install_status($form_state) { ...@@ -150,29 +150,31 @@ function _gallery_install_status($form_state) {
// Step 3: Drupal Modules and Gallery2 Plugins check // Step 3: Drupal Modules and Gallery2 Plugins check
$form += _gallery_install_plugins($install_status); $form += _gallery_install_plugins($install_status);
// Step 4: Clean URL configuration // Step 4: Clean URL configuration
_gallery_install_urlrewrite_check($install_status); _gallery_install_urlrewrite_check($install_status);
if (_gallery_install_urlrewrite($public_path, $htaccess_path, TRUE)) { if (gallery_single_plugin_status('rewrite') == GALLERY_PLUGIN_ENABLED) {
$form['urlrewrite'] = array( if (_gallery_install_urlrewrite($public_path, $htaccess_path, TRUE)) {
'#type' => 'fieldset', $form['urlrewrite'] = array(
'#title' => t('Clean URLs / URL Rewrite settings'), '#type' => 'fieldset',
'#collapsible' => TRUE, '#title' => t('Clean URLs / URL Rewrite settings'),
'#collapsed' => TRUE, '#collapsible' => TRUE,
'#description' => t('Overview of your URL Rewrite settings as specified during install.') '#collapsed' => TRUE,
'#description' => t('Overview of your URL Rewrite settings as specified during install.')
);
$form['urlrewrite']['htaccess_public_path'] = array(
'#title' => t('Public path to your .htaccess file'),
'#type' => 'item',
'#value' => $public_path
); );
$form['urlrewrite']['htaccess_public_path'] = array( $form['urlrewrite']['htaccess_filesystem_path'] = array(
'#title' => t('Public path to your .htaccess file'), '#title' => t('Filesystem path to your .htaccess file'),
'#type' => 'item', '#type' => 'item',
'#value' => $public_path '#value' => $htaccess_path
); );
$form['urlrewrite']['htaccess_filesystem_path'] = array( }
'#title' => t('Filesystem path to your .htaccess file'),
'#type' => 'item',
'#value' => $htaccess_path
);
} }
// Step 5: User Synchronization // Step 5: User Synchronization
$install_status['usersync']['status'] = TRUE; $install_status['usersync']['status'] = TRUE;
$install_status['usersync']['info'] = t('Your initial user synchronization has been completed already.<br /> If you $install_status['usersync']['info'] = t('Your initial user synchronization has been completed already.<br /> If you
...@@ -1123,6 +1125,10 @@ function _gallery_install_urlrewrite(&$public_path, &$htaccess_path, $load_confi ...@@ -1123,6 +1125,10 @@ function _gallery_install_urlrewrite(&$public_path, &$htaccess_path, $load_confi
list($ret, $rewrite_api) = GalleryCoreApi::newFactoryInstance('RewriteApi'); list($ret, $rewrite_api) = GalleryCoreApi::newFactoryInstance('RewriteApi');
if ($ret || !isset($rewrite_api)) { if ($ret || !isset($rewrite_api)) {
gallery_error(t('Error trying to create URL Rewrite plugin instance.'), $ret); gallery_error(t('Error trying to create URL Rewrite plugin instance.'), $ret);
if (!$ret) {
drupal_set_message(t('URL Rewrite plugin could not be instantiated.
Please check its configuration in standalone Gallery2.'), 'error');
}
return FALSE; return FALSE;
} }
...@@ -1144,7 +1150,7 @@ function _gallery_install_urlrewrite(&$public_path, &$htaccess_path, $load_confi ...@@ -1144,7 +1150,7 @@ function _gallery_install_urlrewrite(&$public_path, &$htaccess_path, $load_confi
$htaccess_path = $params['embeddedHtaccess']; $htaccess_path = $params['embeddedHtaccess'];
} }
} }
// Check for trailing slash // Check for trailing slash