Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
4a97009b
Commit
4a97009b
authored
2 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
do not decode passed links in SkipLinks::addLink(), fixes #951
Closes #951 Merge request
studip/studip!545
parent
bd0aea77
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/classes/SkipLinks.php
+11
-40
11 additions, 40 deletions
lib/classes/SkipLinks.php
templates/layouts/base.php
+1
-1
1 addition, 1 deletion
templates/layouts/base.php
with
12 additions
and
41 deletions
lib/classes/SkipLinks.php
+
11
−
40
View file @
4a97009b
...
@@ -25,12 +25,6 @@ class SkipLinks
...
@@ -25,12 +25,6 @@ class SkipLinks
*/
*/
private
static
$links
=
[];
private
static
$links
=
[];
/**
* array of positions of skip links
* @var array
*/
private
static
$position
=
[];
/**
/**
* Returns whether skiplinks are enabled.
* Returns whether skiplinks are enabled.
*
*
...
@@ -59,34 +53,28 @@ class SkipLinks
...
@@ -59,34 +53,28 @@ class SkipLinks
* @param string $name the displayed name of the links
* @param string $name the displayed name of the links
* @param string $url the url of the links
* @param string $url the url of the links
* @param integer $position the position of the link in the list
* @param integer $position the position of the link in the list
* @param boolean $overwriteable false if position is not overwritable by another link
*/
*/
public
static
function
addLink
(
$name
,
$url
,
$position
=
null
,
$overwriteable
=
false
)
public
static
function
addLink
(
string
$name
,
string
$url
,
$position
=
null
)
{
{
$position
=
(
!
$position
||
$position
<
1
)
?
count
(
self
::
$links
)
+
100
:
(
int
)
$position
;
$position
=
(
!
$position
||
$position
<
1
)
?
count
(
self
::
$links
)
+
100
:
(
int
)
$position
;
$new_link
=
[
self
::
$links
[
$url
]
=
[
'name'
=>
$name
,
'name'
=>
$name
,
'url'
=>
decodeHTML
(
$url
),
'url'
=>
$url
,
'position'
=>
$position
,
'position'
=>
$position
,
'overwriteable'
=>
$overwriteable
,
];
];
if
(
self
::
checkOverwrite
(
$new_link
))
{
self
::
$links
[
$new_link
[
'url'
]]
=
$new_link
;
}
}
}
/**
/**
* Adds a link to an anker on the same page to the list of skip links.
* Adds a link to an anker on the same page to the list of skip links.
*
*
* @param string $name the displayed name of the links
* @param string
$name
the displayed name of the links
* @param string $id the id of the anker
* @param string
$id
the id of the anker
* @param integer $position the position of the link in the list
* @param integer $position the position of the link in the list
* @param boolean $overwriteable false if position is not overwritable by another link
*/
*/
public
static
function
addIndex
(
$name
,
$id
,
$position
=
null
,
$overwriteable
=
false
)
public
static
function
addIndex
(
$name
,
$id
,
$position
=
null
)
{
{
$url
=
'#'
.
$id
;
$url
=
'#'
.
$id
;
self
::
addLink
(
$name
,
$url
,
$position
,
$overwriteable
);
self
::
addLink
(
$name
,
$url
,
$position
);
}
}
/**
/**
...
@@ -101,11 +89,11 @@ class SkipLinks
...
@@ -101,11 +89,11 @@ class SkipLinks
}
}
usort
(
self
::
$links
,
function
(
$a
,
$b
)
{
usort
(
self
::
$links
,
function
(
$a
,
$b
)
{
return
$a
[
'position'
]
>
$b
[
'position'
];
return
$a
[
'position'
]
-
$b
[
'position'
];
});
});
$navigation
=
new
Navigation
(
''
);
$navigation
=
new
Navigation
(
''
);
foreach
(
self
::
$links
as
$index
=>
$link
)
{
foreach
(
array_values
(
self
::
$links
)
as
$index
=>
$link
)
{
$navigation
->
addSubNavigation
(
$navigation
->
addSubNavigation
(
"/skiplinks/link-
{
$index
}
"
,
"/skiplinks/link-
{
$index
}
"
,
new
Navigation
(
$link
[
'name'
],
$link
[
'url'
])
new
Navigation
(
$link
[
'name'
],
$link
[
'url'
])
...
@@ -113,21 +101,4 @@ class SkipLinks
...
@@ -113,21 +101,4 @@ class SkipLinks
}
}
return
$GLOBALS
[
'template_factory'
]
->
render
(
'skiplinks'
,
compact
(
'navigation'
));
return
$GLOBALS
[
'template_factory'
]
->
render
(
'skiplinks'
,
compact
(
'navigation'
));
}
}
/**
* Checks if there is another link at the same position and if it is overwritable.
*
* @return boolean true if the link at the same position is overwritable
*/
private
static
function
checkOverwrite
(
$link
)
{
if
(
isset
(
self
::
$position
[
$link
[
'position'
]]))
{
return
false
;
}
if
(
!
$link
[
'overwrite'
])
{
self
::
$position
[
$link
[
'position'
]]
=
true
;
}
return
true
;
}
}
}
This diff is collapsed.
Click to expand it.
templates/layouts/base.php
+
1
−
1
View file @
4a97009b
...
@@ -97,7 +97,7 @@ $getInstalledLanguages = function () {
...
@@ -97,7 +97,7 @@ $getInstalledLanguages = function () {
<body
id=
"
<?=
$body_id
?:
PageLayout
::
getBodyElementId
()
?>
"
<?
if
(
SkipLinks
::
isEnabled
())
echo
'class="enable-skiplinks"'
;
?>
>
<body
id=
"
<?=
$body_id
?:
PageLayout
::
getBodyElementId
()
?>
"
<?
if
(
SkipLinks
::
isEnabled
())
echo
'class="enable-skiplinks"'
;
?>
>
<div
id=
"layout_wrapper"
>
<div
id=
"layout_wrapper"
>
<?
SkipLinks
::
insertContainer
()
?>
<?
SkipLinks
::
insertContainer
()
?>
<?
SkipLinks
::
addIndex
(
_
(
'Hauptinhalt'
),
'layout_content'
,
100
,
true
)
?>
<?
SkipLinks
::
addIndex
(
_
(
'Hauptinhalt'
),
'layout_content'
,
100
)
?>
<?=
PageLayout
::
getBodyElements
()
?>
<?=
PageLayout
::
getBodyElements
()
?>
<?
include
'lib/include/header.php'
?>
<?
include
'lib/include/header.php'
?>
...
...
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