summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStella Power2008-06-06 16:19:25 (GMT)
committer Stella Power2008-06-06 16:19:25 (GMT)
commitca79f67ca313dac27113169c70cee8e17728407b (patch)
tree22be15c08fcd4edf1c75db97c50cf7570b7415d9
parentef1efb802b1dbcd035e1d8037b43ce02f35eaa15 (diff)
#141867 - added ability to open node page without sidebars in an iframe.
-rw-r--r--js/auto_image_handling.js7
-rw-r--r--lightbox2.module132
-rw-r--r--page-node-lightbox2.tpl.php51
3 files changed, 186 insertions, 4 deletions
diff --git a/js/auto_image_handling.js b/js/auto_image_handling.js
index e811f1d..99821d8 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 fc5db49..e3dc0a3 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('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
+ }
+
+ 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 0000000..d144bff
--- /dev/null
+++ b/page-node-lightbox2.tpl.php
@@ -0,0 +1,51 @@
+<?php
+// $Id$
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
+ <head>
+ <title><?php print $head_title ?></title>
+ <?php print $head ?>
+ <?php print $styles ?>
+ <?php print $scripts ?>
+ <!--[if lt IE 7]>
+ <?php print phptemplate_get_ie_styles(); ?>
+ <![endif]-->
+ </head>
+ <body>
+
+<!-- Layout -->
+
+ <div id="wrapper">
+ <div id="container" class="clear-block">
+
+
+ <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
+<?php phptemplate_comment_wrapper(NULL, $node->type); ?>
+
+<?php if ($page == 0): ?>
+ <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
+<?php endif; ?>
+
+ <?php print $content ?>
+
+ <div class="clear-block clear">
+ <div class="meta">
+ <?php if ($taxonomy): ?>
+ <div class="terms"><?php print $terms ?></div>
+ <?php endif;?>
+ </div>
+
+ <?php if ($links): ?>
+ <div class="links"><?php print $links; ?></div>
+ <?php endif; ?>
+ </div>
+
+</div>
+</div>
+</div>
+</div>
+</div> <!-- close container -->
+</div> <!-- close wrapper -->
+</body>
+</html>