Commit 6e8aabb0 authored by profix898's avatar profix898

- task: reduce default tree depth

- task: add option to enable/disable url rewrite paths
parent b1511a14
......@@ -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);
......
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