- Patch #18260 by Ber, m3averck et al: allow overriding of links returned by modules
parent
be7bb9be9b
commit
1b291a2917
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.'))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.'))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,21 +29,24 @@ 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))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return 'taxonomy/term/'. $term->tid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
|
|
|
@ -29,21 +29,24 @@ 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))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return 'taxonomy/term/'. $term->tid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue