summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-05-18 14:58:57 +0000
committerDries Buytaert <dries@buytaert.net>2006-05-18 14:58:57 +0000
commit1b291a2917a1c18194c54fce8bf0fd895db98019 (patch)
treea46473123aeb5709f8cc6f07e685fc84df90bf06
parentbe7bb9be9bb41c83795fa8d7fa119ce4025f2de0 (diff)
downloadbrdo-1b291a2917a1c18194c54fce8bf0fd895db98019.tar.gz
brdo-1b291a2917a1c18194c54fce8bf0fd895db98019.tar.bz2
- Patch #18260 by Ber, m3averck et al: allow overriding of links returned by modules
-rw-r--r--includes/menu.inc29
-rw-r--r--includes/theme.inc27
-rw-r--r--modules/aggregator.module17
-rw-r--r--modules/aggregator/aggregator.module17
-rw-r--r--modules/blog.module6
-rw-r--r--modules/blog/blog.module6
-rw-r--r--modules/book.module13
-rw-r--r--modules/book/book.module13
-rw-r--r--modules/comment.module74
-rw-r--r--modules/comment/comment.module74
-rw-r--r--modules/forum.module9
-rw-r--r--modules/forum/forum.module9
-rw-r--r--modules/node.module11
-rw-r--r--modules/node/node.module11
-rw-r--r--modules/statistics.module2
-rw-r--r--modules/statistics/statistics.module2
-rw-r--r--modules/taxonomy.module21
-rw-r--r--modules/taxonomy/taxonomy.module21
-rw-r--r--modules/upload.module7
-rw-r--r--modules/upload/upload.module7
20 files changed, 296 insertions, 80 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index b1d1bdb51..92a1325d8 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -703,16 +703,30 @@ function theme_menu_item_link($item, $link_item) {
*
* @param $mid
* The menu item id to render.
+ * @param $theme
+ * Whether to return a themed link or the link as an array
*/
-function menu_item_link($mid) {
+function menu_item_link($mid, $theme = TRUE) {
$item = menu_get_item($mid);
$link_item = $item;
+ $link = '';
while ($link_item['type'] & MENU_LINKS_TO_PARENT) {
$link_item = menu_get_item($link_item['pid']);
}
- return theme('menu_item_link', $item, $link_item);
+ if ($theme) {
+ $link = theme('menu_item_link', $item, $link_item);
+ }
+ else {
+ $link = array(
+ '#title' => $item['title'],
+ '#href' => $link_item['path'],
+ '#attributes' => isset($item['description']) ? array('title' => $item['description']) : array()
+ );
+ }
+
+ return $link;
}
/**
@@ -806,7 +820,7 @@ function theme_menu_local_task($mid, $active, $primary) {
* @param $pid
* The parent menu ID from which to search for children. Defaults to the
* menu_primary_menu setting.
- * @return An array containing the themed links as the values. The keys of
+ * @return A nested array of links and their properties. The keys of
* the array contain some extra encoded information about the results.
* The format of the key is {level}-{num}{-active}.
* level is the depth within the menu tree of this list.
@@ -842,18 +856,21 @@ function menu_primary_links($start_level = 1, $pid = 0) {
if ($pid && is_array($menu['visible'][$pid]) && isset($menu['visible'][$pid]['children'])) {
$count = 1;
foreach ($menu['visible'][$pid]['children'] as $cid) {
- $index = "$start_level-$count";
+ $index = "$start_level-$count-$pid";
if (menu_in_active_trail_in_submenu($cid, $pid)) {
$index .= "-active";
}
- $links[$index] = menu_item_link($cid);
+ $links[$index] = menu_item_link($cid, FALSE);
$count++;
}
}
// Special case - provide link to admin/menu if primary links is empty.
if (empty($links) && $start_level == 1 && $pid == variable_get('menu_primary_menu', 0)) {
- $links['1-1'] = l(t('edit primary links'),'admin/menu');
+ $links['1-1'] = array(
+ '#title' => t('edit primary links'),
+ '#href' => 'admin/menu'
+ );
}
return $links;
diff --git a/includes/theme.inc b/includes/theme.inc
index 19e0f4b71..89f388dce 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -486,17 +486,36 @@ function theme_status_messages() {
* Return a themed set of links.
*
* @param $links
- * An array of links to be themed.
+ * A keyed array of links to be themed.
* @param $delimiter
* A string used to separate the links.
* @return
* A string containing the themed links.
*/
function theme_links($links, $delimiter = ' | ') {
- if (!is_array($links)) {
- return '';
+ $output = array();
+
+ if (is_array($links)) {
+ foreach ($links as $key => $link) {
+ //Automatically add a class to each link and convert all _ to - for XHTML compliance
+ if (isset($link['#attributes']) && isset($link['#attributes']['class'])) {
+ $link['#attributes']['class'] .= ' '. str_replace('_', '-', $key);
+ }
+ else {
+ $link['#attributes']['class'] = str_replace('_', '-', $key);
+ }
+
+ if ($link['#href']) {
+ $output[] = l($link['#title'], $link['#href'], $link['#attributes'], $link['#query'], $link['#fragment']);
+ }
+ else if ($link['#title']) {
+ //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
+ $output[] = '<span'. drupal_attributes($link['#attributes']) .'>'. $link['#title'] .'</span>';
+ }
+ }
}
- return implode($delimiter, $links);
+
+ return implode($delimiter, $output);
}
/**
diff --git a/modules/aggregator.module b/modules/aggregator.module
index 21ea91e06..da6b17fe7 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -1145,7 +1145,13 @@ function aggregator_page_sources() {
}
}
$output .= theme('item_list', $list);
- $output .= '<div class="links">'. theme('links', array(l(t('more'), 'aggregator/sources/'. $feed->fid))) ."</div>\n";
+
+ $link['sources'] = array(
+ '#title' => t('more'),
+ '#href' => 'aggregator/sources/'. $feed->fid
+ );
+
+ $output .= '<div class="links">'. theme('links', $link) ."</div>\n";
}
$output .= theme('xml_icon', url('aggregator/opml'));
$output .= '</div>';
@@ -1245,8 +1251,15 @@ function aggregator_page_categories() {
}
$output .= theme('item_list', $list);
}
- $output .= '<div class="links">'. theme('links', array(l(t('more'), 'aggregator/categories/'. $category->cid))) ."</div>\n";
+
+ $link['categories'] = array(
+ '#title' => t('more'),
+ '#href' => 'aggregator/categories/'. $category->cid
+ );
+
+ $output .= '<div class="links">'. theme('links', $link) ."</div>\n";
}
+
$output .= '</div>';
return $output;
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 21ea91e06..da6b17fe7 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -1145,7 +1145,13 @@ function aggregator_page_sources() {
}
}
$output .= theme('item_list', $list);
- $output .= '<div class="links">'. theme('links', array(l(t('more'), 'aggregator/sources/'. $feed->fid))) ."</div>\n";
+
+ $link['sources'] = array(
+ '#title' => t('more'),
+ '#href' => 'aggregator/sources/'. $feed->fid
+ );
+
+ $output .= '<div class="links">'. theme('links', $link) ."</div>\n";
}
$output .= theme('xml_icon', url('aggregator/opml'));
$output .= '</div>';
@@ -1245,8 +1251,15 @@ function aggregator_page_categories() {
}
$output .= theme('item_list', $list);
}
- $output .= '<div class="links">'. theme('links', array(l(t('more'), 'aggregator/categories/'. $category->cid))) ."</div>\n";
+
+ $link['categories'] = array(
+ '#title' => t('more'),
+ '#href' => 'aggregator/categories/'. $category->cid
+ );
+
+ $output .= '<div class="links">'. theme('links', $link) ."</div>\n";
}
+
$output .= '</div>';
return $output;
diff --git a/modules/blog.module b/modules/blog.module
index d1246f31c..01c5fa557 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -249,7 +249,11 @@ function blog_link($type, $node = 0, $main = 0) {
if ($type == 'node' && $node->type == 'blog') {
if (arg(0) != 'blog' || arg(1) != $node->uid) {
- $links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
+ $links['blog_usernames_blog'] = array(
+ '#title' => t("%username's blog", array('%username' => $node->name)),
+ '#href' => "blog/$node->uid",
+ '#attributes' => array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name)))
+ );
}
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index d1246f31c..01c5fa557 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -249,7 +249,11 @@ function blog_link($type, $node = 0, $main = 0) {
if ($type == 'node' && $node->type == 'blog') {
if (arg(0) != 'blog' || arg(1) != $node->uid) {
- $links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
+ $links['blog_usernames_blog'] = array(
+ '#title' => t("%username's blog", array('%username' => $node->name)),
+ '#href' => "blog/$node->uid",
+ '#attributes' => array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name)))
+ );
}
}
diff --git a/modules/book.module b/modules/book.module
index 8af126911..fb61ac070 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -58,12 +58,17 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == 'node' && isset($node->parent)) {
if (!$main) {
if (book_access('create', $node)) {
- $links[] = l(t('add child page'), "node/add/book/parent/$node->nid");
+ $links['book_add_child'] = array(
+ '#title' => t('add child page'),
+ '#href' => "node/add/book/parent/$node->nid"
+ );
}
if (user_access('see printer-friendly version')) {
- $links[] = l(t('printer-friendly version'),
- 'book/export/html/'. $node->nid,
- array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')));
+ $links['book_printer'] = array(
+ '#title' => t('printer-friendly version'),
+ '#href' => 'book/export/html/'. $node->nid,
+ '#attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
+ );
}
}
}
diff --git a/modules/book/book.module b/modules/book/book.module
index 8af126911..fb61ac070 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -58,12 +58,17 @@ function book_link($type, $node = 0, $main = 0) {
if ($type == 'node' && isset($node->parent)) {
if (!$main) {
if (book_access('create', $node)) {
- $links[] = l(t('add child page'), "node/add/book/parent/$node->nid");
+ $links['book_add_child'] = array(
+ '#title' => t('add child page'),
+ '#href' => "node/add/book/parent/$node->nid"
+ );
}
if (user_access('see printer-friendly version')) {
- $links[] = l(t('printer-friendly version'),
- 'book/export/html/'. $node->nid,
- array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')));
+ $links['book_printer'] = array(
+ '#title' => t('printer-friendly version'),
+ '#href' => 'book/export/html/'. $node->nid,
+ '#attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
+ );
}
}
}
diff --git a/modules/comment.module b/modules/comment.module
index bcea6844e..5d8eeaee1 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -195,19 +195,34 @@ function comment_link($type, $node = 0, $main = 0) {
$new = comment_num_new($node->nid);
if ($all) {
- $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
+ $links['comment_comments'] = array(
+ '#title' => format_plural($all, '1 comment', '%count comments'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Jump to the first comment of this posting.')),
+ '#fragment' => 'comment'
+ );
if ($new) {
- $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
+ $links['comment_new_comments'] = array(
+ '#title' => format_plural($new, '1 new comment', '%count new comments'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Jump to the first new comment of this posting.')),
+ '#fragment' => 'new'
+ );
}
}
else {
if ($node->comment == COMMENT_NODE_READ_WRITE) {
if (user_access('post comments')) {
- $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')), NULL, 'comment_form');
+ $links['comment_add'] = array(
+ '#title' => t('add new comment'),
+ '#href' => "comment/reply/$node->nid",
+ '#attributes' => array('title' => t('Add a new comment to this page.')),
+ '#fragment' => 'comment_form'
+ );
}
else {
- $links[] = theme('comment_post_forbidden', $node->nid);
+ $links['comment_forbidden']['#title'] = theme('comment_post_forbidden', $node->nid);
}
}
}
@@ -220,11 +235,16 @@ function comment_link($type, $node = 0, $main = 0) {
if ($node->comment == COMMENT_NODE_READ_WRITE) {
if (user_access('post comments')) {
if (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
- $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment_form');
+ $links['comment_add'] = array(
+ '#title' => t('add new comment'),
+ '#href' => "comment/reply/$node->nid",
+ '#attributes' => array('title' => t('Share your thoughts and opinions related to this posting.')),
+ '#fragment' => 'comment_form'
+ );
}
}
else {
- $links[] = theme('comment_post_forbidden', $node->nid);
+ $links['comment_forbidden']['#title'] = theme('comment_post_forbidden', $node->nid);
}
}
}
@@ -670,23 +690,42 @@ function comment_links($comment, $return = 1) {
// If we are viewing just this comment, we link back to the node.
if ($return) {
- $links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid");
+ $links['comment_parent'] = array(
+ '#title' => t('parent'),
+ '#href' => comment_node_url(),
+ '#fragment' => "comment-$comment->cid"
+ );
}
if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
if (user_access('administer comments') && user_access('post comments')) {
- $links[] = l(t('delete'), "comment/delete/$comment->cid");
- $links[] = l(t('edit'), "comment/edit/$comment->cid");
- $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
+ $links['comment_delete'] = array(
+ '#title' => t('delete'),
+ '#href' => "comment/delete/$comment->cid"
+ );
+ $links['comment_edit'] = array(
+ '#title' => t('edit'),
+ '#href' => "comment/edit/$comment->cid"
+ );
+ $links['comment_reply'] = array(
+ '#title' => t('reply'),
+ '#href' => "comment/reply/$comment->nid/$comment->cid"
+ );
}
else if (user_access('post comments')) {
if (comment_access('edit', $comment)) {
- $links[] = l(t('edit'), "comment/edit/$comment->cid");
+ $links['comment_edit'] = array(
+ '#title' => t('edit'),
+ '#href' => "comment/edit/$comment->cid"
+ );
}
- $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
+ $links['comment_reply'] = array(
+ '#title' => t('reply'),
+ '#href' => "comment/reply/$comment->nid/$comment->cid"
+ );
}
else {
- $links[] = theme('comment_post_forbidden', $comment->nid);
+ $links['comment_forbidden']['#title'] = theme('comment_post_forbidden', $comment->nid);
}
}
@@ -724,7 +763,14 @@ function comment_render($node, $cid = 0) {
if ($comment = db_fetch_object($result)) {
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- $output .= theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 1));
+ $links = module_invoke_all('link', 'comment', $comment, 1);
+
+ foreach (module_implements('link_alter') as $module) {
+ $function = $module .'_link_alter';
+ $function($node, $links);
+ }
+
+ $output .= theme('comment_view', $comment, $links);
}
}
else {
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index bcea6844e..5d8eeaee1 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -195,19 +195,34 @@ function comment_link($type, $node = 0, $main = 0) {
$new = comment_num_new($node->nid);
if ($all) {
- $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
+ $links['comment_comments'] = array(
+ '#title' => format_plural($all, '1 comment', '%count comments'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Jump to the first comment of this posting.')),
+ '#fragment' => 'comment'
+ );
if ($new) {
- $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
+ $links['comment_new_comments'] = array(
+ '#title' => format_plural($new, '1 new comment', '%count new comments'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Jump to the first new comment of this posting.')),
+ '#fragment' => 'new'
+ );
}
}
else {
if ($node->comment == COMMENT_NODE_READ_WRITE) {
if (user_access('post comments')) {
- $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')), NULL, 'comment_form');
+ $links['comment_add'] = array(
+ '#title' => t('add new comment'),
+ '#href' => "comment/reply/$node->nid",
+ '#attributes' => array('title' => t('Add a new comment to this page.')),
+ '#fragment' => 'comment_form'
+ );
}
else {
- $links[] = theme('comment_post_forbidden', $node->nid);
+ $links['comment_forbidden']['#title'] = theme('comment_post_forbidden', $node->nid);
}
}
}
@@ -220,11 +235,16 @@ function comment_link($type, $node = 0, $main = 0) {
if ($node->comment == COMMENT_NODE_READ_WRITE) {
if (user_access('post comments')) {
if (variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
- $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment_form');
+ $links['comment_add'] = array(
+ '#title' => t('add new comment'),
+ '#href' => "comment/reply/$node->nid",
+ '#attributes' => array('title' => t('Share your thoughts and opinions related to this posting.')),
+ '#fragment' => 'comment_form'
+ );
}
}
else {
- $links[] = theme('comment_post_forbidden', $node->nid);
+ $links['comment_forbidden']['#title'] = theme('comment_post_forbidden', $node->nid);
}
}
}
@@ -670,23 +690,42 @@ function comment_links($comment, $return = 1) {
// If we are viewing just this comment, we link back to the node.
if ($return) {
- $links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid");
+ $links['comment_parent'] = array(
+ '#title' => t('parent'),
+ '#href' => comment_node_url(),
+ '#fragment' => "comment-$comment->cid"
+ );
}
if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
if (user_access('administer comments') && user_access('post comments')) {
- $links[] = l(t('delete'), "comment/delete/$comment->cid");
- $links[] = l(t('edit'), "comment/edit/$comment->cid");
- $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
+ $links['comment_delete'] = array(
+ '#title' => t('delete'),
+ '#href' => "comment/delete/$comment->cid"
+ );
+ $links['comment_edit'] = array(
+ '#title' => t('edit'),
+ '#href' => "comment/edit/$comment->cid"
+ );
+ $links['comment_reply'] = array(
+ '#title' => t('reply'),
+ '#href' => "comment/reply/$comment->nid/$comment->cid"
+ );
}
else if (user_access('post comments')) {
if (comment_access('edit', $comment)) {
- $links[] = l(t('edit'), "comment/edit/$comment->cid");
+ $links['comment_edit'] = array(
+ '#title' => t('edit'),
+ '#href' => "comment/edit/$comment->cid"
+ );
}
- $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
+ $links['comment_reply'] = array(
+ '#title' => t('reply'),
+ '#href' => "comment/reply/$comment->nid/$comment->cid"
+ );
}
else {
- $links[] = theme('comment_post_forbidden', $comment->nid);
+ $links['comment_forbidden']['#title'] = theme('comment_post_forbidden', $comment->nid);
}
}
@@ -724,7 +763,14 @@ function comment_render($node, $cid = 0) {
if ($comment = db_fetch_object($result)) {
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
- $output .= theme('comment_view', $comment, module_invoke_all('link', 'comment', $comment, 1));
+ $links = module_invoke_all('link', 'comment', $comment, 1);
+
+ foreach (module_implements('link_alter') as $module) {
+ $function = $module .'_link_alter';
+ $function($node, $links);
+ }
+
+ $output .= theme('comment_view', $comment, $links);
}
}
else {
diff --git a/modules/forum.module b/modules/forum.module
index 6a27f6855..922df1eb0 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -635,8 +635,13 @@ function _forum_parent_select($tid, $title, $child_type) {
return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE);
}
-function forum_term_path($term) {
- return 'forum/'. $term->tid;
+function forum_link_alter(&$node, &$links) {
+ foreach ($links AS $module => $link) {
+ if (strstr($module, 'taxonomy_term')) {
+ // Link back to the forum and not the taxonomy term page
+ $links[$module]['#href'] = str_replace('taxonomy/term', 'forum', $link['#href']);
+ }
+ }
}
/**
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 6a27f6855..922df1eb0 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -635,8 +635,13 @@ function _forum_parent_select($tid, $title, $child_type) {
return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE);
}
-function forum_term_path($term) {
- return 'forum/'. $term->tid;
+function forum_link_alter(&$node, &$links) {
+ foreach ($links AS $module => $link) {
+ if (strstr($module, 'taxonomy_term')) {
+ // Link back to the forum and not the taxonomy term page
+ $links[$module]['#href'] = str_replace('taxonomy/term', 'forum', $link['#href']);
+ }
+ }
}
/**
diff --git a/modules/node.module b/modules/node.module
index fb8bd7035..3eb21d638 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -536,6 +536,11 @@ function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
node_invoke_nodeapi($node, 'view', $teaser, $page);
if ($links) {
$node->links = module_invoke_all('link', 'node', $node, !$page);
+
+ foreach (module_implements('link_alter') AS $module) {
+ $function = $module .'_link_alter';
+ $function($node, $node->links);
+ }
}
// unset unused $node part so that a bad theme can not open a security hole
if ($teaser) {
@@ -810,7 +815,11 @@ function node_link($type, $node = 0, $main = 0) {
}
if ($main == 1 && $node->teaser && $node->readmore) {
- $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
+ $links['node_read_more'] = array(
+ '#title' => t('read more'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Read the rest of this posting.'))
+ );
}
}
diff --git a/modules/node/node.module b/modules/node/node.module
index fb8bd7035..3eb21d638 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -536,6 +536,11 @@ function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
node_invoke_nodeapi($node, 'view', $teaser, $page);
if ($links) {
$node->links = module_invoke_all('link', 'node', $node, !$page);
+
+ foreach (module_implements('link_alter') AS $module) {
+ $function = $module .'_link_alter';
+ $function($node, $node->links);
+ }
}
// unset unused $node part so that a bad theme can not open a security hole
if ($teaser) {
@@ -810,7 +815,11 @@ function node_link($type, $node = 0, $main = 0) {
}
if ($main == 1 && $node->teaser && $node->readmore) {
- $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
+ $links['node_read_more'] = array(
+ '#title' => t('read more'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Read the rest of this posting.'))
+ );
}
}
diff --git a/modules/statistics.module b/modules/statistics.module
index f6510221e..67dfa7645 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -99,7 +99,7 @@ function statistics_link($type, $node = 0, $main = 0) {
if ($type != 'comment' && user_access('view post access counter')) {
$statistics = statistics_get($node->nid);
if ($statistics) {
- $links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
+ $links['statistics_counter']['#title'] = format_plural($statistics['totalcount'], '1 read', '%count reads');
}
}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index f6510221e..67dfa7645 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -99,7 +99,7 @@ function statistics_link($type, $node = 0, $main = 0) {
if ($type != 'comment' && user_access('view post access counter')) {
$statistics = statistics_get($node->nid);
if ($statistics) {
- $links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
+ $links['statistics_counter']['#title'] = format_plural($statistics['totalcount'], '1 read', '%count reads');
}
}
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index 29ccd3ae0..d917c7511 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -29,19 +29,22 @@ function taxonomy_link($type, $node = NULL) {
$links = array();
if (array_key_exists('taxonomy', $node)) {
foreach ($node->taxonomy as $term) {
- $links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
+ $links['taxonomy_term_'. $term->tid] = array(
+ '#title' => $term->name,
+ '#href' => 'taxonomy/term/'. $term->tid,
+ '#attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))
+ );
}
}
- return $links;
- }
-}
-function taxonomy_term_path($term) {
- $vocabulary = taxonomy_get_vocabulary($term->vid);
- if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
- return $path;
+ // We call this hook again because some modules and themes call taxonomy_link('taxonomy terms') directly
+ foreach (module_implements('link_alter') AS $module) {
+ $function = $module .'_link_alter';
+ $function($node, $links);
+ }
+
+ return $links;
}
- return 'taxonomy/term/'. $term->tid;
}
/**
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 29ccd3ae0..d917c7511 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -29,19 +29,22 @@ function taxonomy_link($type, $node = NULL) {
$links = array();
if (array_key_exists('taxonomy', $node)) {
foreach ($node->taxonomy as $term) {
- $links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
+ $links['taxonomy_term_'. $term->tid] = array(
+ '#title' => $term->name,
+ '#href' => 'taxonomy/term/'. $term->tid,
+ '#attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))
+ );
}
}
- return $links;
- }
-}
-function taxonomy_term_path($term) {
- $vocabulary = taxonomy_get_vocabulary($term->vid);
- if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
- return $path;
+ // We call this hook again because some modules and themes call taxonomy_link('taxonomy terms') directly
+ foreach (module_implements('link_alter') AS $module) {
+ $function = $module .'_link_alter';
+ $function($node, $links);
+ }
+
+ return $links;
}
- return 'taxonomy/term/'. $term->tid;
}
/**
diff --git a/modules/upload.module b/modules/upload.module
index c575d1d79..ca01ac700 100644
--- a/modules/upload.module
+++ b/modules/upload.module
@@ -53,7 +53,12 @@ function upload_link($type, $node = 0, $main = 0) {
}
}
if ($num_files) {
- $links[] = l(format_plural($num_files, '1 attachment', '%count attachments'), "node/$node->nid", array('title' => t('Read full article to view attachments.')), NULL, 'attachments');
+ $links['upload_attachments'] = array(
+ '#title' => format_plural($num_files, '1 attachment', '%count attachments'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Read full article to view attachments.')),
+ '#fragment' => 'attachments'
+ );
}
}
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index c575d1d79..ca01ac700 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -53,7 +53,12 @@ function upload_link($type, $node = 0, $main = 0) {
}
}
if ($num_files) {
- $links[] = l(format_plural($num_files, '1 attachment', '%count attachments'), "node/$node->nid", array('title' => t('Read full article to view attachments.')), NULL, 'attachments');
+ $links['upload_attachments'] = array(
+ '#title' => format_plural($num_files, '1 attachment', '%count attachments'),
+ '#href' => "node/$node->nid",
+ '#attributes' => array('title' => t('Read full article to view attachments.')),
+ '#fragment' => 'attachments'
+ );
}
}