summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThilo Wawrzik2007-10-10 15:30:50 (GMT)
committerThilo Wawrzik2007-10-10 15:30:50 (GMT)
commit6e8aabb075b1930b2ee52f5b2b42f07598d149d2 (patch)
treea1ec9d3878993ac27806aa30c1ff2b84a85df9f0
parentb1511a1464023df72a3c2da35b116f479b182319 (diff)
- task: reduce default tree depth5.x-2.0-beta4
- task: add option to enable/disable url rewrite paths
-rw-r--r--gallery_menu/gallery_menu.module26
1 files changed, 20 insertions, 6 deletions
diff --git a/gallery_menu/gallery_menu.module b/gallery_menu/gallery_menu.module
index c64a222..ac24105 100644
--- a/gallery_menu/gallery_menu.module
+++ b/gallery_menu/gallery_menu.module
@@ -62,17 +62,20 @@ function gallery_menu_disable() {
* Function gallery_menu_page().
*/
function gallery_menu_page() {
+ // Remove trailing slash from the G2 path
if (!empty($_GET['g2_path'])) {
$_GET['g2_path'] = rtrim($_GET['g2_path'], '/');
}
+ // Trigger the usual request handling
$result = gallery_page(TRUE);
+ // Generate the path to set the active menu item
if (isset($result['themeData']['item'])) {
$id = $result['themeData']['item']['id'];
if ($result['themeData']['item']['entityType'] != 'GalleryAlbumItem') {
$id = $result['themeData']['item']['parentId'];
}
$url_generator =& $GLOBALS['gallery']->getUrlGenerator();
- if (isset($url_generator->_shortUrls)) {
+ if (isset($url_generator->_shortUrls) && variable_get('gallery_menu_rewrite', 0)) {
$path = _gallery_menu_album_path($id);
}
else {
@@ -118,7 +121,7 @@ function gallery_menu_build_menu() {
$items = unserialize($cache->data);
}
else {
- $depth = variable_get('gallery_menu_depth', 0);
+ $depth = variable_get('gallery_menu_depth', 5);
$tree = gallery_album_tree(NULL, $depth ? $depth : NULL);
if (count($tree)) {
_gallery_menu_traverse($tree, $items);
@@ -139,7 +142,7 @@ function _gallery_menu_traverse(&$tree, &$items) {
$item = array();
// Check for URL Rewrite being available
$url_generator =& $GLOBALS['gallery']->getUrlGenerator();
- if (isset($url_generator->_shortUrls)) {
+ if (isset($url_generator->_shortUrls) && variable_get('gallery_menu_rewrite', 0)) {
$item['path'] = _gallery_menu_album_path($id);
}
else {
@@ -181,10 +184,21 @@ function _gallery_menu_settings() {
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
+ $url_generator =& $GLOBALS['gallery']->getUrlGenerator();
+ $form['menu']['gallery_menu_rewrite'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable URL Rewrite mode'),
+ '#default_value' => variable_get('gallery_menu_rewrite', 0),
+ '#description' => t('By default gallery menu paths look like \'gallery/album_id/subalbum_id\'. However if URL Rewrite
+ plugin is enabled in G2 you can force the module to use the same paths as generated by G2 internally
+ (i.e. \'gallery/v/album/subalbum\').'),
+ '#disabled' => !isset($url_generator->_shortUrls)
+ );
$form['menu']['gallery_menu_depth'] = array(
'#type' => 'textfield',
'#title' => t('Depth of Gallery albums'),
- '#default_value' => variable_get('gallery_menu_depth', 0),
+ '#size' => 10,
+ '#default_value' => variable_get('gallery_menu_depth', 5),
'#description' => 'Depth of album hierarchy to include (\'0\' for infinite).'
);
@@ -196,7 +210,7 @@ function _gallery_menu_settings() {
'#collapsed' => TRUE
);
$form['menu']['items'][] = _gallery_menu_settings_table();
-
+
$form['#submit']['_gallery_menu_settings_submit'] = array();
$form['#submit']['system_settings_form_submit'] = array();
return system_settings_form($form);
@@ -217,7 +231,7 @@ function _gallery_menu_settings_table() {
return array();
}
- $depth = variable_get('gallery_menu_depth', 0);
+ $depth = variable_get('gallery_menu_depth', 5);
$tree = gallery_album_tree(NULL, $depth ? $depth : NULL);
$form = _gallery_menu_settings_traverse($tree);