Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
c243918e
Commit
c243918e
authored
19 years ago
by
Steven Wittens
Browse files
Options
Downloads
Patches
Plain Diff
-
#32785
: Allow external URLs in menus (and make url() more flexible)
parent
79a193a2
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/common.inc
+31
-10
31 additions, 10 deletions
includes/common.inc
with
31 additions
and
10 deletions
includes/common.inc
+
31
−
10
View file @
c243918e
...
@@ -933,17 +933,21 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
...
@@ -933,17 +933,21 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
*/
*/
/**
/**
* Generate a
n internal Drupal
URL.
* Generate a
URL from a Drupal menu path. Will also pass-through existing
URL
s
.
*
*
* @param $path
* @param $path
* The Drupal path being linked to, such as "admin/node".
* The Drupal path being linked to, such as "admin/node", or an existing URL
* like "http://drupal.org/".
* @param $query
* @param $query
* A query string to append to the link.
* A query string to append to the link
or URL
.
* @param $fragment
* @param $fragment
* A fragment identifier (named anchor) to append to the link.
* 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
* @param $absolute
* Whether to force the output to be an absolute link (beginning with http:).
* 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.
* Useful for links that will be displayed outside the site, such as in an
* RSS feed.
* @return
* @return
* an HTML string containing a link to the given path.
* an HTML string containing a link to the given path.
*
*
...
@@ -951,8 +955,29 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
...
@@ -951,8 +955,29 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
* alternative than url().
* alternative than url().
*/
*/
function
url
(
$path
=
NULL
,
$query
=
NULL
,
$fragment
=
NULL
,
$absolute
=
FALSE
)
{
function
url
(
$path
=
NULL
,
$query
=
NULL
,
$fragment
=
NULL
,
$absolute
=
FALSE
)
{
global
$base_url
;
if
(
isset
(
$fragment
))
{
$fragment
=
'#'
.
$fragment
;
}
// Return an external link if $path contains an allowed absolute URL.
// Only call the slow filter_xss_bad_protocol if $path contains a ':'.
if
(
strpos
(
$path
,
':'
)
!==
FALSE
&&
filter_xss_bad_protocol
(
$path
)
==
$path
)
{
// Split off the fragment
if
(
strpos
(
$path
,
'#'
))
{
list
(
$path
,
$old_fragment
)
=
explode
(
'#'
,
$path
,
2
);
if
(
isset
(
$old_fragment
)
&&
!
isset
(
$fragment
))
{
$fragment
=
'#'
.
$old_fragment
;
}
}
// Append the query
if
(
isset
(
$query
))
{
$path
.
=
(
strpos
(
$path
,
'?'
)
?
'&'
:
'?'
)
.
$query
;
}
// Reassemble
return
$path
.
$fragment
;
}
global
$base_url
;
static
$script
;
static
$script
;
static
$clean_url
;
static
$clean_url
;
...
@@ -968,10 +993,6 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
...
@@ -968,10 +993,6 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
$clean_url
=
(
variable_get
(
'clean_url'
,
'0'
)
==
'0'
)
?
false
:
true
;
$clean_url
=
(
variable_get
(
'clean_url'
,
'0'
)
==
'0'
)
?
false
:
true
;
}
}
if
(
isset
(
$fragment
))
{
$fragment
=
'#'
.
$fragment
;
}
$base
=
(
$absolute
?
$base_url
.
'/'
:
''
);
$base
=
(
$absolute
?
$base_url
.
'/'
:
''
);
// The special path '<front>' links to the default front page.
// The special path '<front>' links to the default front page.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment