Skip to content

Commit d4fa469

Browse files
Simplify links (#580)
1 parent 5e0f80e commit d4fa469

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

include/layout.inc

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,9 @@ function make_submit($file, $alt = false, $align = false, $extras = false,
152152
}
153153

154154
// Return a hiperlink to something within the site
155-
function make_link ($url, $linktext = false, $target = false, $extras = false)
155+
function make_link (string $url, string $linktext = ''): string
156156
{
157-
return sprintf("<a href=\"%s\"%s%s>%s</a>",
158-
$url,
159-
($target ? ' target="' . $target . '"' : ''),
160-
($extras ? ' ' . $extras : ''),
161-
($linktext ?: $url)
162-
);
163-
}
164-
165-
// Print a hyperlink to something, within the site
166-
function print_link($url, $linktext = false, $target = false, $extras = false)
167-
{
168-
echo make_link($url, $linktext, $target, $extras);
157+
return sprintf("<a href=\"%s\">%s</a>", $url, $linktext ?: $url);
169158
}
170159

171160
// make_popup_link()
@@ -196,7 +185,7 @@ function download_link($file, $title)
196185
$download_link = "/distributions/" . $file;
197186

198187
// Print out the download link
199-
print_link($download_link, $title);
188+
echo make_link($download_link, $title);
200189

201190
// We have a full path or a relative to the distributions dir
202191
if ($tmp = strrchr($file, "/")) {
@@ -208,7 +197,7 @@ function download_link($file, $title)
208197
if (@file_exists($local_file . ".asc")) {
209198
echo " ";
210199
$sig_link = "/distributions/$file.asc";
211-
print_link($sig_link, "(sig)");
200+
echo make_link($sig_link, "(sig)");
212201
}
213202

214203
// Try to get the size of the file

include/site.inc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ const MIRROR_DOESNOTWORK = 3;
1515

1616
$MIRRORS = [
1717
"https://www.php.net/" => [
18-
"DEU", "MyraCloud", false,
19-
"https://myracloud.com/en/", MIRROR_SPECIAL, true,
20-
"en", MIRROR_OK],
18+
"DEU",
19+
"MyraCloud",
20+
false,
21+
"https://myracloud.com/en/",
22+
MIRROR_SPECIAL,
23+
true,
24+
"en",
25+
MIRROR_OK
26+
]
2127
];
2228

2329
/**

mirror.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@
6666

6767
<ul>
6868
<li>This site is <?php echo is_official_mirror() ? "" : "not"; ?> an official PHP.net mirror site</li>
69-
<li>The mirror site's address is <?php print_link($MYSITE); ?></li>
69+
<li>The mirror site's address is <?= make_link($MYSITE)?></li>
7070
</ul>
7171

7272
<?php if (is_official_mirror()) { ?>
7373
<h2>Mirror Provider</h2>
7474
<ul>
7575
<li>
76-
<p>The provider of this mirror is <?php print_link(mirror_provider_url(), mirror_provider()); ?></p>
76+
<p>The provider of this mirror is <?= make_link(mirror_provider_url(), mirror_provider())?></p>
7777
<?php if ($MIRROR_IMAGE) { ?>
7878
<p><?php echo $MIRROR_IMAGE; ?></p>
7979
<?php } ?>

0 commit comments

Comments
 (0)