diff --git a/js/auto_image_handling.js b/js/auto_image_handling.js index e811f1dcc8a5b3fadf9d739e069fedb3ab528b81..99821d87aa4a8197a130c386fa942b1b2f2c90a6 100644 --- a/js/auto_image_handling.js +++ b/js/auto_image_handling.js @@ -69,6 +69,7 @@ function lightbox2_init_triggers(classes, rel_type, custom_class) { var lang_pattern = new RegExp(Drupal.settings.basePath + "\\w\\w\\/"); orig_href = orig_href.replace(lang_pattern, Drupal.settings.basePath); } + var frame_href = orig_href; // Handle flickr images. if ($(child).attr("class").match("flickr-photo-img") || @@ -88,6 +89,7 @@ function lightbox2_init_triggers(classes, rel_type, custom_class) { // Image assist uses "+" signs for spaces which doesn't work for // normal links. orig_href = orig_href.replace(/\+/, " "); + frame_href = orig_href; href = orig_href; } @@ -123,6 +125,9 @@ function lightbox2_init_triggers(classes, rel_type, custom_class) { rel = rel_type + "["+ id +"]"; } } + if (lightframe) { + frame_href = orig_href + "/lightbox2"; + } } // Modify the image url. @@ -135,7 +140,7 @@ function lightbox2_init_triggers(classes, rel_type, custom_class) { $(child).attr({title: img_title}); } if (lightframe) { - href = orig_href; + href = frame_href; } if (!custom_class) { var title_link = ""; diff --git a/lightbox2.module b/lightbox2.module index fc5db49de98e74875023d5dba3c327b3ea3d4565..e3dc0a311fd78702a5b52e653d1f9a0f765888bf 100644 --- a/lightbox2.module +++ b/lightbox2.module @@ -1067,7 +1067,7 @@ function lightbox2_field_formatter_info() { $rules = _imagecache_get_presets(); } $iframe['lightframe2][original][node'] = array( - 'label' => 'Lightbox2 iframe: original->full node page', + 'label' => 'Lightbox2 iframe: original->node page', 'field types' => array('image'), ); foreach ($rules as $ruleid => $view_rule) { @@ -1261,6 +1261,8 @@ function lightbox2_theme() { */ function theme_imagefield_image_imagecache_lightbox2($view_preset, $field, $item, $node, $rel = 'lightbox') { + // Can't show current node page in a lightframe on the node page. + // Switch instead to show it in a lightbox. if ($rel == 'lightframe' && arg(0) == 'node' && arg(1) == $node->nid) { $rel = 'lightbox'; $item['lightbox_preset'] = 'original'; @@ -1313,7 +1315,7 @@ function theme_imagefield_image_imagecache_lightbox2($view_preset, $field, $item $image = theme('imagecache', $view_preset, $item['filepath'], $item['alt'], $item['title'], $attributes); } if ($item['lightbox_preset'] == 'node') { - $output = l($image, 'node/'. $node->nid, $link_attributes, NULL, NULL, FALSE, TRUE); + $output = l($image, 'node/'. $node->nid .'/lightbox2', $link_attributes, NULL, NULL, FALSE, TRUE); } else if ($item['lightbox_preset'] == 'original') { $output = l($image, file_create_url($item['filepath']), array('attributes' => $link_attributes, 'html' => TRUE)); @@ -1477,7 +1479,7 @@ function theme_lightbox2_image_ncck($field, $item, $formatter, $node, $options = 'rel' => $rel, 'title' => $title . $node_link, ); - $output = l($image, $link, array('attributes' => $link_attributes, 'html' => TRUE)); + $output = l($image, $link .'/lightbox2', array('attributes' => $link_attributes, 'html' => TRUE)); } } return $output; @@ -1526,3 +1528,127 @@ function lightbox2_imagecache_create_url($preset, $filepath) { } } +function lightbox2_preprocess_page(&$variables) { + if (arg(0) != 'node' || arg(2) != 'lightbox2') { + return; + } + // Add favicon + if (theme_get_setting('toggle_favicon')) { + drupal_set_html_head(''); + } + + global $theme; + // Populate all block regions. + $regions = system_region_list($theme); + // Load all region content assigned via blocks. + foreach (array_keys($regions) as $region) { + if ($region != 'content') { + $variables[$region] = NULL; + } + } + + // Set up layout variable. + $variables['layout'] = 'none'; + + // Set mission when viewing the frontpage. + if (drupal_is_front_page()) { + $mission = filter_xss_admin(theme_get_setting('mission')); + } + + // Construct page title + if (drupal_get_title()) { + $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal')); + } + else { + $head_title = array(variable_get('site_name', 'Drupal')); + if (variable_get('site_slogan', '')) { + $head_title[] = variable_get('site_slogan', ''); + } + } + $variables['head_title'] = implode(' | ', $head_title); + $variables['base_path'] = base_path(); + $variables['front_page'] = url(); + $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb()); + $variables['feed_icons'] = drupal_get_feeds(); + $variables['footer_message'] = filter_xss_admin(variable_get('site_footer', FALSE)); + $variables['head'] = drupal_get_html_head(); + $variables['help'] = theme('help'); + $variables['language'] = $GLOBALS['language']; + $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; + $variables['logo'] = theme_get_setting('logo'); + $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; + $variables['mission'] = isset($mission) ? $mission : ''; + $variables['primary_links'] = theme_get_setting('toggle_primary_links') ? menu_primary_links() : array(); + $variables['secondary_links'] = theme_get_setting('toggle_secondary_links') ? menu_secondary_links() : array(); + $variables['search_box'] = (theme_get_setting('toggle_search') ? drupal_get_form('search_theme_form') : ''); + $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''); + $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : ''); + $variables['css'] = drupal_add_css(); + $variables['styles'] = drupal_get_css(); + $variables['scripts'] = drupal_get_js(); + $variables['tabs'] = theme('menu_local_tasks'); + $variables['title'] = drupal_get_title(); + // Closure should be filled last. + $variables['closure'] = theme('closure'); + + if ($node = menu_get_object()) { + $variables['node'] = $node; + } + + // Compile a list of classes that are going to be applied to the body element. + // This allows advanced theming based on context (home page, node of certain type, etc.). + $body_classes = array(); + // Add a class that tells us whether we're on the front page or not. + $body_classes[] = $variables['is_front'] ? 'front' : 'not-front'; + // Add a class that tells us whether the page is viewed by an authenticated user or not. + $body_classes[] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in'; + // Add arg(0) to make it possible to theme the page depending on the current page + // type (e.g. node, admin, user, etc.). To avoid illegal characters in the class, + // we're removing everything disallowed. We are not using 'a-z' as that might leave + // in certain international characters (e.g. German umlauts). + $body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0)))); + // If on an individual node page, add the node type. + if (isset($variables['node']) && $variables['node']->type) { + $body_classes[] = 'node-type-'. form_clean_id($variables['node']->type); + } + // Add information about the number of sidebars. + if ($variables['layout'] == 'both') { + $body_classes[] = 'two-sidebars'; + } + elseif ($variables['layout'] == 'none') { + $body_classes[] = 'no-sidebars'; + } + else { + $body_classes[] = 'one-sidebar sidebar-'. $variables['layout']; + } + // Implode with spaces. + $variables['body_classes'] = implode(' ', $body_classes); + + // Build a list of suggested template files in order of specificity. One + // suggestion is made for every element of the current path, though + // numeric elements are not carried to subsequent suggestions. For example, + // http://www.example.com/node/1/edit would result in the following + // suggestions: + // + // page-node-edit.tpl.php + // page-node-1.tpl.php + // page-node.tpl.php + // page.tpl.php + $i = 0; + $suggestion = 'page'; + $suggestions = array(); + while ($arg = arg($i++)) { + $suggestions[] = $suggestion .'-'. $arg; + if (!is_numeric($arg)) { + $suggestion .= '-'. $arg; + } + } + if (drupal_is_front_page()) { + $suggestions[] = 'page-front'; + } + + if ($suggestions) { + $variables['template_files'] = $suggestions; + } +} + diff --git a/page-node-lightbox2.tpl.php b/page-node-lightbox2.tpl.php new file mode 100644 index 0000000000000000000000000000000000000000..d144bff41662fc5183b89e850c6a16bd5940e0fc --- /dev/null +++ b/page-node-lightbox2.tpl.php @@ -0,0 +1,51 @@ + + + + <?php print $head_title ?> + + + + + + + + + +
+
+ + +
+type); ?> + + +

+ + + + +
+
+ +
+ +
+ + + + +
+ +
+
+
+
+
+
+ +