Commit 30110a87 authored by Dries's avatar Dries

- Patch #6166 by Moshe: node preview should not display links. Push the links...

- Patch #6166 by Moshe: node preview should not display links.  Push the links to the theme instead of the theme having to pull them in using node_link().

  TODO:
    1. Update theme upgrade instructions in the handbook: node_link() is gone.
    2. Remove page_link() just like we removed node_link().
parent 9574766a
......@@ -1595,15 +1595,6 @@ function link_page() {
}
}
/**
* Fetch a set of links to display after a given node.
*
* The links are gathered by calls to hook_link('node') in each module.
*/
function link_node($node, $main = 0) {
return module_invoke_all('link', 'node', $node, $main);
}
/**
* Perform end-of-request tasks.
*
......
......@@ -519,8 +519,8 @@ function theme_node($node, $teaser = FALSE, $page = FALSE) {
$output .= $node->body;
}
if ($links = link_node($node, $teaser)) {
$output .= '<div class="links">'. theme('links', $links) .'</div>';
if ($node->links) {
$output .= '<div class="links">'. theme('links', $node->links) .'</div>';
}
return $output;
......
......@@ -507,11 +507,13 @@ function node_save($node) {
* Whether to display only the teaser for the node.
* @param $page
* Whether the node is being displayed by itself as a page.
* @param $links
* Whether or not to display node links. Links are omitted for node previews.
*
* @return
* An HTML representation of the themed node.
*/
function node_view($node, $teaser = FALSE, $page = FALSE) {
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
$node = array2object($node);
// Remove the delimiter (if any) that separates the teaser from the body.
......@@ -528,6 +530,9 @@ function node_view($node, $teaser = FALSE, $page = FALSE) {
}
// Allow modules to change $node->body before viewing.
node_invoke_nodeapi($node, 'view', $teaser, $page);
if ($links) {
$node->links = module_invoke_all('link', 'node', $node, !$page);
}
return theme('node', $node, $teaser, $page);
}
......@@ -1354,13 +1359,13 @@ function node_preview($node) {
// Display a preview of the node:
if ($node->teaser && $node->teaser != $node->body) {
$output = '<h3>'. t('Preview trimmed version') .'</h3>';
$output .= node_view($node, 1);
$output .= node_view($node, 1, FALSE, 0);
$output .= '<p><em>'. t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.') .'</em></p>';
$output .= '<h3>'. t('Preview full version') .'</h3>';
$output .= node_view($node, 0);
$output .= node_view($node, 0, FALSE, 0);
}
else {
$output .= node_view($node, 0);
$output .= node_view($node, 0, FALSE, 0);
}
$output .= node_form($node);
......
......@@ -507,11 +507,13 @@ function node_save($node) {
* Whether to display only the teaser for the node.
* @param $page
* Whether the node is being displayed by itself as a page.
* @param $links
* Whether or not to display node links. Links are omitted for node previews.
*
* @return
* An HTML representation of the themed node.
*/
function node_view($node, $teaser = FALSE, $page = FALSE) {
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
$node = array2object($node);
// Remove the delimiter (if any) that separates the teaser from the body.
......@@ -528,6 +530,9 @@ function node_view($node, $teaser = FALSE, $page = FALSE) {
}
// Allow modules to change $node->body before viewing.
node_invoke_nodeapi($node, 'view', $teaser, $page);
if ($links) {
$node->links = module_invoke_all('link', 'node', $node, !$page);
}
return theme('node', $node, $teaser, $page);
}
......@@ -1354,13 +1359,13 @@ function node_preview($node) {
// Display a preview of the node:
if ($node->teaser && $node->teaser != $node->body) {
$output = '<h3>'. t('Preview trimmed version') .'</h3>';
$output .= node_view($node, 1);
$output .= node_view($node, 1, FALSE, 0);
$output .= '<p><em>'. t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.') .'</em></p>';
$output .= '<h3>'. t('Preview full version') .'</h3>';
$output .= node_view($node, 0);
$output .= node_view($node, 0, FALSE, 0);
}
else {
$output .= node_view($node, 0);
$output .= node_view($node, 0, FALSE, 0);
}
$output .= node_form($node);
......
......@@ -435,7 +435,7 @@ function poll_view(&$node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
// No 'read more' link
$node->body = $node->teaser = '';
$links = link_node($node, $main);
$links = module_invoke_all('link', 'node', $node, 0);
$links[] = l(t('older polls'), 'poll', array('title' => t('View the list of polls on this site.')));
if ($node->allowvotes && $block) {
$links[] = l(t('results'), 'node/'. $node->nid .'/results', array('title' => t('View the current poll results.')));
......
......@@ -435,7 +435,7 @@ function poll_view(&$node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
// No 'read more' link
$node->body = $node->teaser = '';
$links = link_node($node, $main);
$links = module_invoke_all('link', 'node', $node, 0);
$links[] = l(t('older polls'), 'poll', array('title' => t('View the list of polls on this site.')));
if ($node->allowvotes && $block) {
$links[] = l(t('results'), 'node/'. $node->nid .'/results', array('title' => t('View the current poll results.')));
......
......@@ -629,7 +629,6 @@ function statistics_summary($dbfield, $dbrows) {
$result = db_query_range('SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC', $dbfield, 0, $dbrows);
while ($nid = db_fetch_array($result)) {
$content = node_load(array('nid' => $nid['nid']));
$links = link_node($content, 1);
// Filter and prepare node teaser
if (node_hook($content, 'view')) {
......@@ -641,7 +640,7 @@ function statistics_summary($dbfield, $dbrows) {
$output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. $content->teaser .'</div></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $content->links) .' ]<br /><br /></td></tr>';
}
return $output;
......
......@@ -629,7 +629,6 @@ function statistics_summary($dbfield, $dbrows) {
$result = db_query_range('SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC', $dbfield, 0, $dbrows);
while ($nid = db_fetch_array($result)) {
$content = node_load(array('nid' => $nid['nid']));
$links = link_node($content, 1);
// Filter and prepare node teaser
if (node_hook($content, 'view')) {
......@@ -641,7 +640,7 @@ function statistics_summary($dbfield, $dbrows) {
$output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. $content->teaser .'</div></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $content->links) .' ]<br /><br /></td></tr>';
}
return $output;
......
#!/bin/sh
if [ $# != 2 ]; then
cat >&2 << EOH
cat >&2 << EOH
This is Drupal database prefixer.
Usage:
......
......@@ -136,8 +136,8 @@ function chameleon_node($node, $main = 0, $page = 0) {
$terms = taxonomy_link("taxonomy terms", $node);
}
if ($links = link_node($node, $main)) {
$output .= " <div class=\"links\">". theme('links', array_merge($submitted, $terms, $links)) ."</div>\n";
if ($node->links) {
$output .= " <div class=\"links\">". theme('links', array_merge($submitted, $terms, $node->links)) ."</div>\n";
}
$output .= "</div>\n";
......
......@@ -63,8 +63,8 @@ function xtemplate_node($node, $main = 0, $page = 0) {
$xtemplate->template->parse("node.taxonomy");
}
if ($links = link_node($node, $main)) {
$xtemplate->template->assign("links", theme_links($links));
if ($node->links) {
$xtemplate->template->assign("links", theme_links($node->links));
$xtemplate->template->parse("node.links");
}
......
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