uid == arg(1))); if ($may_cache) { $items[] = array('path' => 'gallery', 'title' => t('gallery'), 'callback' => 'gallery_page', 'access' => user_access('access content'), 'type' => MENU_NORMAL_ITEM); $items[] = array( 'path' => 'admin/user/gallery', 'title' => t('gallery'), 'callback' => 'gallery_users', 'access' => user_access('administer users'), 'type' => MENU_LOCAL_TASK); } else { // Add head info here so that it is included once only per page (almost) gallery_set_html_head(gallery_css_include()); } return $items; } /** * Implementation of hook_help */ function gallery_help($section) { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_help.inc'); return _gallery_help($section); } /** * Implementation of hook_settings */ function gallery_settings() { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_settings.inc'); return _gallery_settings(); } /** * Implementation of hook_user */ function gallery_user($op, &$edit, &$user, $category = NULL) { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_user.inc'); switch ($op) { case 'login': /* _gallery_init() will try to create the user, if necessary */ list ($success, $ret) = _gallery_init(); if (!$success) { gallery_error(t('Unable to log in to Gallery'), $ret); return; } break; case 'logout': if (variable_get('gallery_valid', 0)) { $embedPath = variable_get('gallery_dir', './gallery2/') . 'embed.php'; require_once($embedPath); $ret = GalleryEmbed::logout(); break; } case 'view': return gallery_view_user($user); case 'insert': return gallery_insert_user($edit, $user); case 'update': return gallery_update_user($edit, $user); case 'delete': return gallery_delete_user($user); } } /** * Gallery Users Page - view a set of users */ function gallery_users() { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_user.inc'); return _gallery_users(); } /** * implementation of hook_search */ function gallery_search($op = 'search', $keys = null) { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_search.inc'); return _gallery_search($op, $keys); } /** * Implementation of hook_search_item to override how to display the item */ function gallery_search_page($results) { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_search.inc'); return _gallery_search_page($results); } /** * Implementation of hook_filter */ function gallery_filter($op, $delta = 0, $format = -1, $text = '') { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_filter.inc'); switch ($op) { case 'list' : return array (0 => t('Gallery2 filter')); case 'description' : return t('Allow users to easily reference Gallery2 items from nodes.'); case 'process' : return gallery_filter_process($text); case 'no cache': return !variable_get('gallery_filter_can_cache', 1); default : return $text; } } /** * Implementation of hook_filter_tips */ function gallery_filter_tips($delta = 0, $format = -1, $long = false) { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_help.inc'); if ($long) { return gallery_filter_long_tip_translated(); } else { return gallery_filter_short_tip_translated(); } } /** * Implementation of hook_perm(). */ function gallery_perm() { return array('access standalone g2image'); } /** * Implementation of hook_elements() - from img_assist */ function gallery_elements() { $type['textarea'] = array('#process' => array('gallery_g2image_textarea' => array())); return $type; } /* * Add image link underneath textareas */ function gallery_g2image_textarea($element) { $path = drupal_get_path('module', 'gallery'); require_once($path . '/gallery_g2image.inc'); if (_gallery_g2image_page_match() && !strstr($_GET['q'], 'gallery') && (variable_get('gallery_g2image_mode', 'disabled') == 'standalone') && (user_access('access standalone g2image'))) { gallery_g2image_add_js(); $output = theme('gallery_g2image_textarea_link', $element, $link); $element['#suffix'] .= $output; } return $element; } /** * Implementation of hook_block * * - gallery navigation block (recommended) * - gallery imageblock (random, most viewed, etc) */ function gallery_block($op = 'list', $delta = 0, $edit = array()) { // Modified typeMap to use current Gallery2 naming $typeMap = array('none' => t('None'), 'randomImage' => t('Random Image'), 'recentImage' => t('Newest Image'), 'viewedImage' => t('Most Viewed Image'), 'randomAlbum' => t('Random Album'), 'recentAlbum' => t('Newest Album'), 'viewedAlbum' => t('Most Viewed Album'), 'dailyImage' => t('Picture of the Day'), 'weeklyImage' => t('Picture of the Week'), 'monthlyImage' => t('Picture of the Month'), 'dailyAlbum' => t('Album of the Day'), 'weeklyAlbum' => t('Album of the Week'), 'monthlyAlbum' => t('Album of the Month')); switch ($op) { case 'list': $blocks[0]['info'] = t('Gallery Block'); $blocks[1]['info'] = t('Gallery Navigation'); return $blocks; case 'view': list ($success, $ret) = _gallery_init(true); if (!$success) { $err_msg = t('Unable to initialize embedded Gallery. You need to configure your embedded Gallery.', array('%link' => url('admin/settings/gallery'))); gallery_error($err_msg, $ret); return; } switch ($delta) { // 0 = Image Block case 0: // Allow for multiple image types $param_blocks_array = variable_get('gallery_block_block', array('randomImage')); $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : ""; $param_show_array = variable_get('gallery_block_show', array()); $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : ""; $params['maxSize'] = variable_get('gallery_maxsize', 160); // Add frames and link target using g2_filter code from MichelleC $params['albumFrame'] = variable_get('gallery_album_frame', 'none');; $params['itemFrame'] = variable_get('gallery_item_frame', 'none');; $params['linkTarget'] = variable_get('gallery_link_target', '');; $block = array(); list($ret, $content, $head) = GalleryEmbed::getImageBlock($params); if ($ret) { gallery_error(t('Unable to get Gallery image block'), $ret); return; } else { if ($content) { // If more than one image type selected then default the subject to 'Gallery' // Also fixes typo in v1.9 -- block => blocks if (count(variable_get('gallery_block_block', 'randomImage')) > 1) { $block['subject'] = t('Gallery'); } else { $block['subject'] = $typeMap[$params['blocks']]; } // TODO: This should not be hardcoded, but included in the CSS. $block['content'] = '
' . $content . '
'; } } if ($head) { gallery_set_html_head($head); } break; // 1 = Navigation Block case 1: if (arg(0) == 'gallery') { GalleryCapabilities::set('showSidebarBlocks', false); $result = GalleryEmbed::handleRequest(); if (isset($result['sidebarBlocksHtml']) && !empty($result['sidebarBlocksHtml'])) { $block['subject'] = t('Gallery Navigation'); $block['content'] = '
' . join('', $result['sidebarBlocksHtml']) . '
'; } } break; } $ret = GalleryEmbed::done(); if ($ret) { gallery_error(t('Unable to complete Gallery request'), $ret); return; } return $block; } } /** * Main gallery display page */ function gallery_page() { list ($success, $ret) = _gallery_init(true); if (!$success) { gallery_error(t('Unable to initialize embedded Gallery'), $ret); $err_msg = t('Unable to initialize embedded Gallery. You need to configure your embedded Gallery.', array('%link' => url('admin/settings/gallery'))); return $err_msg; } /* Pass any excess path info to G2 - NEEDED??? */ // $path = substr($_GET['q'], 7 /* length of 'gallery/' */); /* if (!empty($path)) { $_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path'] = $path; }*/ // Turn off sidebar and pathbar GalleryCapabilities::set('showSidebarBlocks', false); $result = GalleryEmbed::handleRequest(); if (!$result['isDone']) { list($title, $css, $javascript) = GalleryEmbed::parseHead($result['headHtml']); if (!empty($javascript)) { gallery_set_html_head(implode("\n", $javascript)); } gallery_set_html_head(implode("\n", $css)); // Add Gallery head. FIX - this will be included twice on a gallery page. Has to be // included here as it is after the G2 .css files and so can override them. gallery_set_html_head(gallery_css_include(), false); drupal_set_title($title); // Add pathbar. See http://gallery.menalto.com/node/33447 if (isset($result['themeData'])) { $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator(); $breadcrumb = array(l(t('Home'), '')); foreach ($result['themeData']['parents'] as $parent) { $parent_title = $parent['title']; // Simple strip of bbcode (italics) $parent_title = str_replace("[i]", "", $parent_title); $parent_title = str_replace("[/i]", "", $parent_title); $breadcrumb[] = ''.$parent_title.""; } drupal_set_breadcrumb($breadcrumb); } return $result['bodyHtml']; } } ?>