Commit dc5843bd authored by Dries's avatar Dries

- Patch #111347 by Steven: refactor url() and l().

parent e57b926e
......@@ -303,7 +303,7 @@ function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response
extract(parse_url(urldecode($_REQUEST['edit']['destination'])));
}
$url = url($path, $query, $fragment, TRUE);
$url = url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => TRUE));
// Before the redirect, allow modules to react to the end of the page request.
module_invoke_all('exit', $url);
......@@ -663,7 +663,7 @@ function locale_initialize() {
* - !variable, which indicates that the text should be inserted as-is. This is
* useful for inserting variables into things like e-mail.
* @code
* $message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", NULL, NULL, TRUE)));
* $message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", array('absolute' => TRUE))));
* @endcode
*
* - @variable, which indicates that the text should be run through check_plain,
......@@ -1120,25 +1120,39 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
* @param $path
* The Drupal path being linked to, such as "admin/content/node", or an existing URL
* like "http://drupal.org/".
* @param $query
* A query string to append to the link or URL.
* @param $fragment
* A fragment identifier (named anchor) to append to the link. If an existing
* URL with a fragment identifier is used, it will be replaced. Note, do not
* include the '#'.
* @param $absolute
* Whether to force the output to be an absolute link (beginning with http:).
* Useful for links that will be displayed outside the site, such as in an
* RSS feed.
* @param $options
* An associative array of additional options, with the following keys:
* 'query'
* A query string to append to the link, or an array of query key/value
* properties.
* 'fragment'
* A fragment identifier (or named anchor) to append to the link.
* Do not include the '#' character.
* 'absolute' (default FALSE)
* Whether to force the output to be an absolute link (beginning with
* http:). Useful for links that will be displayed outside the site, such
* as in an RSS feed.
* 'alias' (default FALSE)
* Whether the given path is an alias already.
* @return
* a string containing a URL to the given path.
*
* When creating links in modules, consider whether l() could be a better
* alternative than url().
*/
function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
if (isset($fragment)) {
$fragment = '#'. $fragment;
function url($path = NULL, $options = array()) {
// Merge in defaults
$options += array(
'fragment' => '',
'query' => '',
'absolute' => FALSE,
'alias' => FALSE,
);
if ($options['fragment']) {
$options['fragment'] = '#'. $options['fragment'];
}
if (is_array($options['query'])) {
$options['query'] = drupal_query_string_encode($options['query']);
}
// Return an external link if $path contains an allowed absolute URL.
......@@ -1148,16 +1162,16 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
// Split off the fragment
if (strpos($path, '#') !== FALSE) {
list($path, $old_fragment) = explode('#', $path, 2);
if (isset($old_fragment) && !isset($fragment)) {
$fragment = '#'. $old_fragment;
if (isset($old_fragment) && !$options['fragment']) {
$options['fragment'] = '#'. $old_fragment;
}
}
// Append the query
if (isset($query)) {
$path .= (strpos($path, '?') !== FALSE ? '&' : '?') . $query;
if ($options['query']) {
$path .= (strpos($path, '?') !== FALSE ? '&' : '?') . $options['query'];
}
// Reassemble
return $path . $fragment;
return $path . $options['fragment'];
}
global $base_url;
......@@ -1176,35 +1190,37 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
$clean_url = (bool)variable_get('clean_url', '0');
}
$base = ($absolute ? $base_url . '/' : base_path());
$base = $options['absolute'] ? $base_url . '/' : base_path();
// The special path '<front>' links to the default front page.
if (!empty($path) && $path != '<front>') {
$path = drupal_get_path_alias($path);
if (!$options['alias']) {
$path = drupal_get_path_alias($path);
}
$path = drupal_urlencode($path);
if (!$clean_url) {
if (isset($query)) {
return $base . $script .'?q='. $path .'&'. $query . $fragment;
if ($options['query']) {
return $base . $script .'?q='. $path .'&'. $options['query'] . $options['fragment'];
}
else {
return $base . $script .'?q='. $path . $fragment;
return $base . $script .'?q='. $path . $options['fragment'];
}
}
else {
if (isset($query)) {
return $base . $path .'?'. $query . $fragment;
if ($options['query']) {
return $base . $path .'?'. $options['query'] . $options['fragment'];
}
else {
return $base . $path . $fragment;
return $base . $path . $options['fragment'];
}
}
}
else {
if (isset($query)) {
return $base . $script .'?'. $query . $fragment;
if ($options['query']) {
return $base . $script .'?'. $options['query'] . $options['fragment'];
}
else {
return $base . $fragment;
return $base . $options['fragment'];
}
}
}
......@@ -1237,40 +1253,54 @@ function drupal_attributes($attributes = array()) {
* @param $text
* The text to be enclosed with the anchor tag.
* @param $path
* The Drupal path being linked to, such as "admin/content/node". Can be an external
* or internal URL.
* - If you provide the full URL, it will be considered an
* external URL.
* - If you provide only the path (e.g. "admin/content/node"), it is considered an
* internal link. In this case, it must be a system URL as the url() function
* will generate the alias.
* @param $attributes
* An associative array of HTML attributes to apply to the anchor tag.
* @param $query
* A query string to append to the link.
* @param $fragment
* A fragment identifier (named anchor) to append to the link.
* @param $absolute
* Whether to force the output to be an absolute link (beginning with http:).
* Useful for links that will be displayed outside the site, such as in an RSS
* feed.
* @param $html
* Whether the title is HTML, or just plain-text. For example for making an
* image a link, this must be set to TRUE, or else you will see the encoded
* HTML.
* The Drupal path being linked to, such as "admin/content/node". Can be an
* external or internal URL.
* - If you provide the full URL, it will be considered an external URL.
* - If you provide only the path (e.g. "admin/content/node"), it is
* considered an internal link. In this case, it must be a system URL
* as the url() function will generate the alias.
* - If you provide a path, and 'alias' is set to TRUE (see below), it is
* used as is.
* @param $options
* An associative array of additional options, with the following keys:
* 'attributes'
* An associative array of HTML attributes to apply to the anchor tag.
* 'query'
* A query string to append to the link, or an array of query key/value
* properties.
* 'fragment'
* A fragment identifier (named anchor) to append to the link.
* Do not include the '#' character.
* 'absolute' (default FALSE)
* Whether to force the output to be an absolute link (beginning with
* http:). Useful for links that will be displayed outside the site, such
* as in an RSS feed.
* 'html' (default FALSE)
* Whether the title is HTML, or just plain-text. For example for making
* an image a link, this must be set to TRUE, or else you will see the
* escaped HTML.
* 'alias' (default FALSE)
* Whether the given path is an alias already.
* @return
* an HTML string containing a link to the given path.
*/
function l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {
function l($text, $path, $options = array()) {
// Merge in defaults
$options += array(
'attributes' => array(),
'html' => FALSE,
);
// Append active class
if ($path == $_GET['q']) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
if (isset($options['attributes']['class'])) {
$options['attributes']['class'] .= ' active';
}
else {
$attributes['class'] = 'active';
$options['attributes']['class'] = 'active';
}
}
return '<a href="'. check_url(url($path, $query, $fragment, $absolute)) .'"'. drupal_attributes($attributes) .'>'. ($html ? $text : check_plain($text)) .'</a>';
return '<a href="'. check_url(url($path, $options)) .'"'. drupal_attributes($options['attributes']) .'>'. ($options['html'] ? $text : check_plain($text)) .'</a>';
}
/**
......
......@@ -35,7 +35,7 @@ function file_create_url($path) {
case FILE_DOWNLOADS_PUBLIC:
return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path);
case FILE_DOWNLOADS_PRIVATE:
return url('system/files/'. $path, NULL, NULL, TRUE);
return url('system/files/'. $path, array('absolute' => TRUE));
}
}
......
......@@ -1038,7 +1038,7 @@ function theme_fieldset($element) {
}
}
return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . ($element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . $element['#value'] . "</fieldset>\n";
return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . $element['#value'] . "</fieldset>\n";
}
/**
......@@ -1401,7 +1401,7 @@ function theme_textfield($element) {
if ($element['#autocomplete_path']) {
drupal_add_js('misc/autocomplete.js');
$class[] = 'form-autocomplete';
$extra = '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], NULL, NULL, TRUE)) .'" disabled="disabled" />';
$extra = '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], array('absolute' => TRUE))) .'" disabled="disabled" />';
}
_form_set_class($element, $class);
......
......@@ -392,7 +392,7 @@ function theme_pager_link($text, $page_new, $element, $parameters = array(), $at
}
}
return l($text, $_GET['q'], $attributes, count($query) ? implode('&', $query) : NULL);
return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL));
}
/**
......
......@@ -83,7 +83,7 @@ function tablesort_header($cell, $header, $ts) {
if (!empty($ts['query_string'])) {
$ts['query_string'] = '&'. $ts['query_string'];
}
$cell['data'] = l($cell['data'] . $image, $_GET['q'], array('title' => $title), 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) . $ts['query_string'], NULL, FALSE, TRUE);
$cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) . $ts['query_string'], 'html' => TRUE));
unset($cell['field'], $cell['sort']);
}
......
......@@ -563,19 +563,13 @@ function theme_links($links, $attributes = array('class' => 'links')) {
}
$output .= '<li class="'. $extra_class . $class .'">';
// Is the title HTML?
$html = isset($link['html']) && $link['html'];
// Initialize fragment and query variables.
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
if (isset($link['href'])) {
$output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
// Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link);
}
else if ($link['title']) {
//Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (!$html) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
......
......@@ -1212,7 +1212,7 @@ function aggregator_page_rss() {
$output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<rss version=\"2.0\">\n";
$output .= format_rss_channel(variable_get('site_name', 'Drupal') . ' ' . t('aggregator'), url('aggregator' . $url, NULL, NULL, TRUE), variable_get('site_name', 'Drupal') . ' - ' . t('aggregated feeds') . $title, $items, 'en');
$output .= format_rss_channel(variable_get('site_name', 'Drupal') . ' ' . t('aggregator'), url('aggregator' . $url, array('absolute' => TRUE)), variable_get('site_name', 'Drupal') . ' - ' . t('aggregated feeds') . $title, $items, 'en');
$output .= "</rss>\n";
drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
......@@ -1290,7 +1290,7 @@ function theme_aggregator_feed($feed) {
$output .= theme('feed_icon', $feed->url) ."\n";
$output .= $feed->image;
$output .= '<div class="feed-description">'. aggregator_filter_xss($feed->description) ."</div>\n";
$output .= '<div class="feed-url"><em>'. t('URL:') .'</em> '. l($feed->link, $feed->link, array(), NULL, NULL, TRUE) ."</div>\n";
$output .= '<div class="feed-url"><em>'. t('URL:') .'</em> '. l($feed->link, $feed->link, array('absolute' => TRUE)) ."</div>\n";
if ($feed->checked) {
$updated = t('@time ago', array('@time' => format_interval(time() - $feed->checked)));
......@@ -1355,7 +1355,7 @@ function theme_aggregator_page_item($item) {
$source = '';
if ($item->ftitle && $item->fid) {
$source = l($item->ftitle, "aggregator/sources/$item->fid", array('class' => 'feed-item-source')) . ' -';
$source = l($item->ftitle, "aggregator/sources/$item->fid", array('attributes' => array('class' => 'feed-item-source'))) . ' -';
}
if (date('Ymd', $item->timestamp) == date('Ymd')) {
......
......@@ -85,7 +85,7 @@ function blog_feed_user($uid = 0) {
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $uid, 0, variable_get('feed_default_items', 10));
$channel['title'] = $account->name ."'s blog";
$channel['link'] = url("blog/$uid", NULL, NULL, TRUE);
$channel['link'] = url("blog/$uid", array('absolute' => TRUE));
$channel['description'] = $term->description;
node_feed($result, $channel);
}
......@@ -96,7 +96,7 @@ function blog_feed_user($uid = 0) {
function blog_feed_last() {
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10));
$channel['title'] = variable_get('site_name', 'Drupal') .' blogs';
$channel['link'] = url('blog', NULL, NULL, TRUE);
$channel['link'] = url('blog', array('absolute' => TRUE));
$channel['description'] = $term->description;
node_feed($result, $channel);
}
......
......@@ -138,7 +138,7 @@ function blogapi_blogger_get_users_blogs($appid, $username, $password) {
$types = _blogapi_get_node_types();
$structs = array();
foreach ($types as $type) {
$structs[] = array('url' => url('blog/' . $user->uid, NULL, NULL, TRUE), 'blogid' => $type, 'blogName' => $user->name . ": " . $type);
$structs[] = array('url' => url('blog/' . $user->uid, array('absolute' => TRUE)), 'blogid' => $type, 'blogName' => $user->name . ": " . $type);
}
return $structs;
}
......@@ -161,7 +161,7 @@ function blogapi_blogger_get_user_info($appkey, $username, $password) {
'firstname' => $name[0],
'nickname' => $user->name,
'email' => $user->mail,
'url' => url('blog/' . $user->uid, NULL, NULL, TRUE));
'url' => url('blog/' . $user->uid, array('absolute' => TRUE)));
}
else {
return blogapi_error($user);
......@@ -575,7 +575,7 @@ function blogapi_init() {
drupal_add_link(array('rel' => 'EditURI',
'type' => 'application/rsd+xml',
'title' => t('RSD'),
'href' => url('blogapi/rsd', NULL, NULL, TRUE)));
'href' => url('blogapi/rsd', array('absolute' => TRUE))));
}
}
......@@ -583,7 +583,7 @@ function blogapi_rsd() {
global $base_url;
$xmlrpc = $base_url .'/'. 'xmlrpc.php';
$base = url('', NULL, NULL, TRUE);
$base = url('', array('absolute' => TRUE));
$blogid = 1; # until we figure out how to handle multiple bloggers
drupal_set_header('Content-Type: application/rsd+xml; charset=utf-8');
......@@ -658,8 +658,8 @@ function _blogapi_get_post($node, $bodies = TRUE) {
'dateCreated' => xmlrpc_date($node->created),
'title' => $node->title,
'postid' => $node->nid,
'link' => url('node/'.$node->nid, NULL, NULL, TRUE),
'permaLink' => url('node/'.$node->nid, NULL, NULL, TRUE),
'link' => url('node/'.$node->nid, array('absolute' => TRUE)),
'permaLink' => url('node/'.$node->nid, array('absolute' => TRUE)),
);
if ($bodies) {
if ($node->comment == 1) {
......
......@@ -284,7 +284,7 @@ function comment_get_recent($number = 10) {
function theme_comment_block() {
$items = array();
foreach (comment_get_recent() as $comment) {
$items[] = l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
$items[] = l($comment->subject, 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
}
if ($items) {
return theme('item_list', $items);
......@@ -443,7 +443,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
case 'rss item':
if ($node->comment != COMMENT_NODE_DISABLED) {
return array(array('key' => 'comments', 'value' => url('node/'. $node->nid, NULL, 'comments', TRUE)));
return array(array('key' => 'comments', 'value' => url('node/'. $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))));
}
else {
return array();
......@@ -538,7 +538,7 @@ function comment_admin_settings() {
COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
'#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="@url">permissions page</a>.', array('@url' => url('admin/user/access', NULL, 'module-comment'))),
'#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="@url">permissions page</a>.', array('@url' => url('admin/user/access', array('fragment' => 'module-comment')))),
);
if (!user_access('post comments', user_load(array('uid' => 0)))) {
$form['posting_settings']['comment_anonymous']['#disabled'] = TRUE;
......@@ -718,7 +718,7 @@ function comment_save($edit) {
comment_invoke_comment($edit, 'update');
// Add an entry to the watchdog log.
watchdog('content', t('Comment: updated %subject.', array('%subject' => $edit['subject'])), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
watchdog('content', t('Comment: updated %subject.', array('%subject' => $edit['subject'])), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], array('fragment' => 'comment-'. $edit['cid'])));
}
else {
// Check for duplicate comments. Note that we have to use the
......@@ -799,7 +799,7 @@ function comment_save($edit) {
comment_invoke_comment($edit, 'insert');
// Add an entry to the watchdog log.
watchdog('content', t('Comment: added %subject.', array('%subject' => $edit['subject'])), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], NULL, NULL, 'comment-'. $edit['cid']));
watchdog('content', t('Comment: added %subject.', array('%subject' => $edit['subject'])), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], array('fragment' => 'comment-'. $edit['cid'])));
}
// Clear the cache so an anonymous user can see his comment being added.
......@@ -1187,10 +1187,10 @@ function comment_admin_overview($type = 'new', $arg) {
while ($comment = db_fetch_object($result)) {
$comments[$comment->cid] = '';
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$form['subject'][$comment->cid] = array('#value' => l($comment->subject, 'node/'. $comment->nid, array('title' => truncate_utf8($comment->comment, 128)), NULL, 'comment-'. $comment->cid));
$form['subject'][$comment->cid] = array('#value' => l($comment->subject, 'node/'. $comment->nid, array('title' => truncate_utf8($comment->comment, 128), 'fragment' => 'comment-'. $comment->cid)));
$form['username'][$comment->cid] = array('#value' => theme('username', $comment));
$form['timestamp'][$comment->cid] = array('#value' => format_date($comment->timestamp, 'small'));
$form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array(), $destination));
$form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array('query' => $destination)));
}
$form['comments'] = array('#type' => 'checkboxes', '#options' => isset($comments) ? $comments: array());
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
......@@ -1226,7 +1226,7 @@ function comment_admin_overview_submit($form_id, $form_values) {
// Allow modules to respond to the updating of a comment.
comment_invoke_comment($comment, $form_values['operation']);
// Add an entry to the watchdog log.
watchdog('content', t('Comment: updated %subject.', array('%subject' => $comment->subject)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid));
watchdog('content', t('Comment: updated %subject.', array('%subject' => $comment->subject)), WATCHDOG_NOTICE, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)));
}
}
cache_clear_all();
......@@ -1772,7 +1772,7 @@ function comment_controls_submit($form_id, $form_values) {
function theme_comment($comment, $links = array()) {
$output = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">';
$output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") .' '. theme('mark', $comment->new) ."</div>\n";
$output .= '<div class="subject">'. l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) . ' ' . theme('mark', $comment->new) ."</div>\n";
$output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n";
$output .= '<div class="body">'. $comment->comment .'</div>';
$output .= '<div class="links">'. theme('links', $links) .'</div>';
......@@ -1782,7 +1782,7 @@ function theme_comment($comment, $links = array()) {
function theme_comment_folded($comment) {
$output = "<div class=\"comment-folded\">\n";
$output .= ' <span class="subject">'. l($comment->subject, comment_node_url() .'/'. $comment->cid, NULL, NULL, "comment-$comment->cid") .' '. theme('mark', $comment->new) .'</span> ';
$output .= ' <span class="subject">'. l($comment->subject, comment_node_url() .'/'. $comment->cid, array('fragment' => "comment-$comment->cid")) . ' '. theme('mark', $comment->new) .'</span> ';
$output .= '<span class="credit">'. t('by') .' '. theme('username', $comment) ."</span>\n";
$output .= "</div>\n";
return $output;
......@@ -1822,10 +1822,10 @@ function theme_comment_post_forbidden($nid) {
}
if (variable_get('user_register', 1)) {
return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination)));
return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
}
else {
return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', $destination)));
return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
}
}
}
......
......@@ -16,7 +16,7 @@ function contact_help($section) {
$output .= '<p>'. t("Users can activate/deactivate their personal contact forms in their account settings. Upon activation, a contact tab will appear in their user profiles. Privileged users such as site administrators are able to contact users even if they have chosen not to enable this feature.") .'</p>';
$output .= '<p>'. t("Note that the contact tab will not appear when a user views his or her own profile; only when viewing another user's profile, if that user's contact form is enabled.") .'</p>';
$output .= '<p>'. t('If the menu module is enabled, a menu item linking to the site-wide contact page is added to the navigation block. It is disabled by default, but can be enabled via the <a href="@menu-module">menu management</a> page. Links to the contact page may also be added to the primary and secondary links using the same page.', array('@menu-module' => url('admin/build/menu'))) .'</p>';
$output .= '<p>'. t('For more information, please read the configuration and customization handbook page for the <a href="@contact">contact module</a>.', array('@contact' => url('http://drupal.org/handbook/modules/contact/', NULL, NULL, TRUE))) .'</p>';
$output .= '<p>'. t('For more information, please read the configuration and customization handbook page for the <a href="@contact">contact module</a>.', array('@contact' => url('http://drupal.org/handbook/modules/contact/', array('absolute' => TRUE)))) .'</p>';
return $output;
case 'admin/build/contact':
$output = '<p>'. t('This page lets you setup <a href="@form">your site-wide contact form</a>. To do so, add one or more categories. You can associate different recipients with each category to route e-mails to different people. For example, you can route website feedback to the webmaster and direct product information requests to the sales department. On the <a href="@settings">settings page</a>, you can customize the information shown above the contact form. This can be useful to provide additional contact information such as your postal address and telephone number.', array('@settings' => url('admin/build/contact/settings'), '@form' => url('contact'))) .'</p>';
......@@ -345,8 +345,8 @@ function contact_mail_user_submit($form_id, $form_values) {
$account = user_load(array('uid' => arg(1), 'status' => 1));
// Compose the body:
$message[] = "$account->name,";
$message[] = t("!name (!name-url) has sent you a message via your contact form (!form-url) at !site.", array('!name' => $user->name, '!name-url' => url("user/$user->uid", NULL, NULL, TRUE), '!form-url' => url($_GET['q'], NULL, NULL, TRUE), '!site' => variable_get('site_name', 'Drupal')));
$message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", NULL, NULL, TRUE)));
$message[] = t("!name (!name-url) has sent you a message via your contact form (!form-url) at !site.", array('!name' => $user->name, '!name-url' => url("user/$user->uid", array('absolute' => TRUE)), '!form-url' => url($_GET['q'], array('absolute' => TRUE)), '!site' => variable_get('site_name', 'Drupal')));
$message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", array('absolute' => TRUE))));
$message[] = t('Message:');
$message[] = $form_values['message'];
......@@ -494,7 +494,7 @@ function contact_mail_page_submit($form_id, $form_values) {
$from = $form_values['mail'];
// Compose the body:
$message[] = t("!name sent a message using the contact form at !form.", array('!name' => $form_values['name'], '!form' => url($_GET['q'], NULL, NULL, TRUE)));
$message[] = t("!name sent a message using the contact form at !form.", array('!name' => $form_values['name'], '!form' => url($_GET['q'], array('absolute' => TRUE))));
$message[] = $form_values['message'];
// Tidy up the body:
......
......@@ -915,7 +915,7 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output .= '<li>'. t('You are not allowed to post a new forum topic.') .'</li>';
}
else {
$output .= '<li>'. t('<a href="@login">Login</a> to post a new forum topic.', array('@login' => url('user/login', drupal_get_destination()))) .'</li>';
$output .= '<li>'. t('<a href="@login">Login</a> to post a new forum topic.', array('@login' => url('user/login', array('query' => drupal_get_destination())))) .'</li>';
}
$output .= '</ul>';
......@@ -977,7 +977,7 @@ function theme_forum_list($forums, $parents, $tid) {
$row = array(
'data' => array(
array('data' => $description, 'class' => 'forum'),
array('data' => $forum->num_topics . ($new_topics ? '<br />'. l(format_plural($new_topics, '1 new', '@count new'), "forum/$forum->tid", NULL, NULL, 'new') : ''), 'class' => 'topics'),
array('data' => $forum->num_topics . ($new_topics ? '<br />'. l(format_plural($new_topics, '1 new', '@count new'), "forum/$forum->tid", array('fragment' => 'new')) : ''), 'class' => 'topics'),
array('data' => $forum->num_posts, 'class' => 'posts'),
array('data' => _forum_format($forum->last_post), 'class' => 'last-reply'),
),
......@@ -1018,7 +1018,7 @@ function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page) {
$rows[] = array(
array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(format_plural($topic->new_replies, '1 new', '@count new'), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(format_plural($topic->new_replies, '1 new', '@count new'), "node/$topic->nid", array('fragment' => 'new')) : ''), 'class' => 'replies'),
array('data' => _forum_format($topic), 'class' => 'created'),
array('data' => _forum_format(isset($topic->last_reply) ? $topic->last_reply : NULL), 'class' => 'last-reply')
);
......
......@@ -922,7 +922,7 @@ function node_search($op = 'search', $keys = NULL) {
$node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
$extra = node_invoke_nodeapi($node, 'search result');
$results[] = array('link' => url('node/'. $item->sid, NULL, NULL, TRUE),
$results[] = array('link' => url('node/'. $item->sid, array('absolute' => TRUE)),
'type' => node_get_types('name', $node),
'title' => $node->title,
'user' => theme('username', $node),
......@@ -1530,7 +1530,7 @@ function node_admin_nodes() {
$form['name'][$node->nid] = array('#value' => node_get_types('name', $node));
$form['username'][$node->nid] = array('#value' => theme('username', $node));
$form['status'][$node->nid] = array('#value' => ($node->status ? t('published') : t('not published')));
$form['operations'][$node->nid] = array('#value' => l(t('edit'), 'node/'. $node->nid .'/edit', array(), $destination));
$form['operations'][$node->nid] = array('#value' => l(t('edit'), 'node/'. $node->nid .'/edit', array('query' => $destination)));
}
$form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
......@@ -1764,7 +1764,7 @@ function node_feed($nodes = 0, $channel = array()) {
while ($node = db_fetch_object($nodes)) {
// Load the specified node:
$item = node_load($node->nid);
$link = url("node/$node->nid", NULL, NULL, 1);
$link = url("node/$node->nid", array('absolute' => TRUE));
if ($item_length != 'title') {
$teaser = ($item_length == 'teaser') ? TRUE : FALSE;
......@@ -1798,7 +1798,7 @@ function node_feed($nodes = 0, $channel = array()) {
case 'teaser':
$item_text = $item->teaser;
if ($item->readmore) {
$item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'</p>';
$item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, array('absolute' => TRUE)) .'</p>';
}
break;
case 'title':
......@@ -2128,7 +2128,7 @@ function node_add($type = NULL) {
if (function_exists($type->module .'_form') && node_access('create', $type->type)) {
$type_url_str = str_replace('_', '-', $type->type);
$title = t('Add a new @s.', array('@s' => $type->name));
$out = '<dt>'. l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('title' => $title)) .'</dt>';
$out = '<dt>'. l(drupal_ucfirst($type->name), "node/add/$type_url_str", array('attributes' => array('title' => $title))) .'</dt>';
$out .= '<dd>'. filter_xss_admin($type->description) .'</dd>';
$item[$type->type] = $out;
}
......@@ -2348,7 +2348,7 @@ function node_page_default() {
$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
$feed_url = url('rss.xml', NULL, NULL, TRUE);
$feed_url = url('rss.xml', array('absolute' => TRUE));
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
$output = '';
......
......@@ -187,7 +187,7 @@ function path_form($edit = '') {
'#maxlength' => 64,
'#size' => 45,
'#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'),
'#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
);
$form['dst'] = array(
'#type' => 'textfield',
......@@ -195,7 +195,7 @@ function path_form($edit = '') {
'#maxlength' => 64,
'#size' => 45,
'#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
'#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
'#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
);
if ($edit['pid']) {
......@@ -312,7 +312,7 @@ function path_overview() {
$rows = array();
$destination = drupal_get_destination();
while ($data = db_fetch_object($result)) {
$rows[] = array(check_plain($data->dst), check_plain($data->src), l(t('edit'), "admin/build/path/edit/$data->pid", array(), $destination), l(t('delete'), "admin/build/path/delete/$data->pid", array(), $destination));
$rows[] = array(check_plain($data->dst), check_plain($data->src), l(t('edit'), "admin/build/path/edit/$data->pid", array('query' => $destination)), l(t('delete'), "admin/build/path/delete/$data->pid", array('query' => $destination)));
}
if (empty($rows)) {
......
......@@ -176,7 +176,7 @@ function statistics_access_log($aid) {
$result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid);
if ($access = db_fetch_object($result)) {
$output = '<table border="1" cellpadding="2" cellspacing="2">';
$output .= ' <tr><th>'. t('URL') ."</th><td>". l(url($access->path, NULL, NULL, TRUE), $access->path) ."</td></tr>";
$output .= ' <tr><th>'. t('URL') ."</th><td>". l(url($access->path, array('absolute' => TRUE)), $access->path) ."</td></tr>";
$output .= ' <tr><th>'. t('Title') .'</th><td>'. $access->title .'</td></tr>'; // safe because it comes from drupal_get_title()
$output .= ' <tr><th>'. t('Referrer') ."</th><td>". ($access->url ? l($access->url, $access->url) : '') ."</td></tr>";
$output .= ' <tr><th>'. t('Date') .'</th><td>'. format_date($access->timestamp, 'large') .'</td></tr>';
......@@ -318,7 +318,7 @@ function statistics_top_visitors() {
$rows = array();
while ($account = db_fetch_object($result)) {
$qs = drupal_get_destination();
$ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array(), $qs) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array(), $qs);
$ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array('query' => $qs)) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array('query' => $qs));
$rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link);
}
......
......@@ -565,7 +565,7 @@ function system_site_information_settings() {
'#default_value' => variable_get('site_frontpage', 'node'),
'#size' => 40,
'#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'),