Add ZRL parameter support sitewide in templates

This commit is contained in:
Hypolite Petovan 2020-06-13 13:21:18 -04:00
parent 57dd610e73
commit 476f7ae832
9 changed files with 30 additions and 28 deletions

View File

@ -13,12 +13,12 @@
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light static-top">
<div class="container">
<a class="navbar-brand" href="">
<a class="navbar-brand" href="<?php echo $this->escapeHtmlAttr($this->u(''))?>">
<img src="assets/images/friendica-32.png" width="32" height="32" class="d-inline-block align-top" alt="">
<?php echo $this->__('Friendica Directory')?>
</a>
<?php if (empty($noNavSearch)): ?>
<form class="form-inline my-2 my-lg-0 d-none d-md-flex" action="search">
<form class="form-inline my-2 my-lg-0 d-none d-md-flex" action="<?php echo $this->escapeHtmlAttr($this->r('search'))?>">
<div class="input-group">
<label class="sr-only" for="header_search"><?php echo $this->__('Search terms')?></label>
<input name="q" class="form-control" type="search" id="header_search" placeholder="<?php echo $this->p__('noun', 'Search')?>..."
@ -38,7 +38,7 @@
<ul class="navbar-nav ml-auto">
<?php if (empty($noNavSearch)): ?>
<li class="nav-item d-md-none">
<form action="search">
<form action="<?php echo $this->escapeHtmlAttr($this->r('search'))?>">
<div class="input-group">
<label class="sr-only" for="nav_search"><?php echo $this->__('Search terms')?></label>
<input name="q" class="form-control form-control-sm" type="search" id="nav_search"
@ -52,12 +52,12 @@
<?php endif; ?>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa fa-address-card"></i> <?php echo $this->__('Directory')?>
<a class="nav-link" href="<?php echo $this->escapeHtmlAttr($this->u(''))?>"><i class="fa fa-address-card"></i> <?php echo $this->__('Directory')?>
<!--<span class="sr-only">(current)</span>-->
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="servers"><i class="fa fa-hotel"></i> <?php echo $this->__('Public servers')?></a>
<a class="nav-link" href="<?php echo $this->escapeHtmlAttr($this->r('servers'))?>"><i class="fa fa-hotel"></i> <?php echo $this->__('Public servers')?></a>
</li>
<li class="nav-item">
<div class="dropdown">
@ -66,7 +66,7 @@
</button>
<div class="dropdown-menu" aria-labelledby="languageDropdown">
<?php foreach($languages as $lang):?>
<a class="dropdown-item" href="?lang=<?php echo $this->escapeUrl($lang)?>">
<a class="dropdown-item" href="<?php echo $this->escapeHtmlAttr($this->u('?lang=' . $lang))?>">
<?php echo $this->e(Friendica\Directory\Utils\L10n::localeToLanguageString($lang)) ?>
</a>
<?php endforeach;?>
@ -94,11 +94,11 @@
<a class="nav-link" href="https://github.com/friendica/friendica-directory"><?php echo $this->__('Source Code on GitHub')?> <i class="fa fa-external-link-alt"></i></a>
</li>
<li class="nav-item">
<a class="nav-link" href="stats"><i class="fa fa-clipboard-list"></i> <?php echo $this->__('Stats')?></a>
<a class="nav-link" href="<?php echo $this->escapeHtmlAttr($this->r('stats'))?>"><i class="fa fa-clipboard-list"></i> <?php echo $this->__('Stats')?></a>
</li>
<?php foreach ($pages as $page):?>
<li class="nav-item">
<a class="nav-link" href="<?php echo strtolower(basename($page, '.html'))?>"><?php echo str_replace('_', ' ', basename($page, '.html'))?></a>
<a class="nav-link" href="<?php echo $this->u(strtolower(basename($page, '.html')))?>"><?php echo str_replace('_', ' ', basename($page, '.html'))?></a>
</li>
<?php endforeach;?>
</ul>

View File

@ -1,5 +1,5 @@
<!--<h1>Search</h1>-->
<form action="search">
<form action="<?php echo $this->escapeHtmlAttr($this->r('search'))?>">
<div class="input-group">
<label class="sr-only" for="search_search"><?php echo $this->__('Search terms')?></label>
<?php if ($field):?>

View File

@ -8,9 +8,10 @@ use \Friendica\Directory\Utils\L10n;
L10n::formatNumber($stats['profile']['total']),
L10n::formatNumber($stats['profile']['ratio'], L10n::PERCENT)
)?></p>
<p><?php echo $this->__('Out of those, there currently are <strong>%s available profiles (%s)</strong>. <a href="/">Check them out!</a>',
<p><?php echo $this->__('Out of those, there currently are <strong>%s available profiles (%s)</strong>. <a href="%s">Check them out!</a>',
L10n::formatNumber($stats['profile']['available']['total']),
L10n::formatNumber($stats['profile']['available']['ratio'], L10n::PERCENT)
L10n::formatNumber($stats['profile']['available']['ratio'], L10n::PERCENT),
$this->escapeHtmlAttr($this->u(''))
)?></p>
<h3><?php echo $this->__('Languages') ?></h3>
<p><?php echo $this->__('Out of <strong>%s</strong> profiles reporting their language there are:', L10n::formatNumber($stats['profile']['language']['total']))?></p>
@ -35,9 +36,10 @@ use \Friendica\Directory\Utils\L10n;
L10n::formatNumber($stats['server']['available']['total']),
L10n::formatNumber($stats['server']['available']['ratio'], L10n::PERCENT)
)?></li>
<li><?php echo $this->__('<strong>%s public servers (%s)</strong> currently open for registration. <a href="/servers">Check them out!</a>',
<li><?php echo $this->__('<strong>%s public servers (%s)</strong> currently open for registration. <a href="%s">Check them out!</a>',
L10n::formatNumber($stats['server']['open']['total']),
L10n::formatNumber($stats['server']['open']['ratio'], L10n::PERCENT)
L10n::formatNumber($stats['server']['open']['ratio'], L10n::PERCENT),
$this->escapeHtmlAttr($this->r('servers'))
)?></li>
</ul>

View File

@ -1,19 +1,19 @@
<?php
$parts = [];
if (!empty($profile['locality'])) {
$parts[] = $this->escapeHtml($profile['locality']) . ' <a href="search?field=locality&q=' . $this->escapeUrl($profile['locality']) . '">
$parts[] = $this->escapeHtml($profile['locality']) . ' <a href="' . $this->escapeHtmlAttr($this->r('search', [], ['field' => 'locality', 'q' => $profile['locality']])) . '">
<span class="fa fa-filter" title="' . $this->__('Filter by locality') . '" aria-hidden="true"></span>
</a>';
}
if (!empty($profile['region'])
&& strtolower($profile['locality']) != strtolower($profile['region'])) {
$parts[] = $this->escapeHtml($profile['region']) . ' <a href="search?field=region&q=' . $this->escapeUrl($profile['region']) . '">
$parts[] = $this->escapeHtml($profile['region']) . ' <a href="' . $this->escapeHtmlAttr($this->r('search', [], ['field' => 'region', 'q' => $profile['region']])) . '">
<span class="fa fa-filter" title="' . $this->__('Filter by region') . '" aria-hidden="true"></span>
</a>';
}
if (!empty($profile['country'])) {
$parts[] = $this->escapeHtml($profile['country']) . ' <a href="search?field=country&q=' . $this->escapeUrl($profile['country']) . '">
$parts[] = $this->escapeHtml($profile['country']) . ' <a href="' . $this->escapeHtmlAttr($this->r('search', [], ['field' => 'country', 'q' => $profile['country']])) . '">
<span class="fa fa-filter" title="' . $this->__('Filter by country') . '" aria-hidden="true"></span>
</a>';
}
@ -21,20 +21,20 @@ if (!empty($profile['country'])) {
<figure id="profile-<?php echo $this->escapeHtmlAttr($profile['id']) ?>" class="bg-light p-3 rounded">
<div class="media">
<a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->u($profile['profile_url'])) ?>">
<img class="mr-3 rounded" src="photo/<?php echo $profile['id'] ?>.jpg">
</a>
<div class="media-body">
<h5 class="name">
<?php if ($profile['dfrn_request']): ?>
<a href="<?php echo $profile['dfrn_request']; ?>" class="card-link btn btn-primary float-right">
<a href="<?php echo $this->escapeHtmlAttr($this->u($profile['dfrn_request'])); ?>" class="card-link btn btn-primary float-right">
<i class="fa fa-external-link-alt"></i> <?php echo $this->p__('verb', 'Follow')?>
</a>
<?php endif; ?>
<?php echo $this->escapeHtml($profile['name']) ?>
</h5>
<p class="url">
<a href="<?php echo $this->escapeHtmlAttr($profile['profile_url']) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->u($profile['profile_url'])) ?>">
<?php echo $this->escapeHtml($profile['addr']) ?>
</a>
</p>
@ -46,7 +46,7 @@ if (!empty($profile['country'])) {
<div class="language">
<i class="fa fa-language" alt="<?php echo $this->__('Language')?>" title="<?php echo $this->__('Language')?>"></i>
<?php echo $this->e(Friendica\Directory\Utils\L10n::localeToLanguageString($profile['language'])) ?>
<a href="/search?field=language&amp;q=<?php echo $this->escapeUrl($profile['language']) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->r('search', [], ['field' => 'language', 'q' => $profile['language']])) ?>">
<i class="fa fa-filter" title="<?php echo $this->__('Filter by language')?>"></i>
</a>
</div>
@ -65,7 +65,7 @@ if (!empty($profile['country'])) {
foreach ($tags as $tag):?>
<span class="badge">
<?php echo $this->escapeHtml($tag) ?>
<a href="/search?q=<?php echo $this->escapeUrl($tag) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->r('search', [], ['q' => $tag])) ?>">
<i class="fa fa-tag" title="<?php echo $this->__('Search Tag')?>"></i>
</a>
</span>

View File

@ -34,7 +34,7 @@ $base_url_display = substr($base_url, strpos($base_url, '/') + 2);
<?php else: ?>
<span class="badge badge-secondary"><i class="fa fa-lock-open"></i> HTTP</span>
<?php endif; ?>
<a href="<?php echo $base_url; ?>"><?php echo $this->e($base_url_display); ?></a>
<a href="<?php echo $this->escapeHtmlAttr($this->u($base_url)); ?>"><?php echo $this->e($base_url_display); ?></a>
</h6>
<p class="card-text">
<span class="badge <?php echo $badge_class ?>">
@ -51,7 +51,7 @@ $base_url_display = substr($base_url, strpos($base_url, '/') + 2);
</span>
<?php echo $version_badge; ?>
<?php if ($server['admin_profile'] && $server['admin_name']): ?>
<a href="<?php echo $server['admin_profile']; ?>" class="badge badge-primary">
<a href="<?php echo $this->escapeHtmlAttr($this->u($server['admin_profile'])); ?>" class="badge badge-primary">
<i class="fa fa-star"></i> <?php echo $this->__('Admin')?>: <?php echo $this->e($server['admin_name']); ?>
</a>
<?php endif; ?>
@ -61,7 +61,7 @@ $base_url_display = substr($base_url, strpos($base_url, '/') + 2);
<?php else: ?>
<p class="card-text text-muted">&lt;<?php echo $this->__('No description provided')?>&gt;</p>
<?php endif; ?>
<a href="<?php echo $base_url; ?>" class="card-link btn btn-primary"><i class="fa fa-external-link-alt"></i>
<a href="<?php echo $this->escapeHtmlAttr($this->u($base_url)); ?>" class="card-link btn btn-primary"><i class="fa fa-external-link-alt"></i>
<?php echo $this->__('Visit Server')?></a>
</div>
</div>

View File

@ -2,7 +2,7 @@
<?php foreach ($tabs as $tab): ?>
<li class="nav-item">
<a class="nav-link<?php echo $tab['active'] ? ' active' : '' ?>"
href="<?php echo $this->escapeHtmlAttr($tab['link']) ?>"><?php echo $this->e($tab['title']) ?></a>
href="<?php echo $this->escapeHtmlAttr($this->u($tab['link'])) ?>"><?php echo $this->e($tab['title']) ?></a>
</li>
<?php endforeach; ?>
</ul>

View File

@ -3,7 +3,7 @@
<ul>
<?php foreach ($countries as $country): ?>
<li>
<a href="search?field=country&q=<?php echo $this->escapeUrl($country['country']) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->r('search', [], ['field' => 'country', 'q' => $country['country']])) ?>">
<?php echo $this->e($country['country']) ?>
</a>
</li>

View File

@ -3,7 +3,7 @@
<ul>
<?php foreach ($languages as $language): ?>
<li>
<a href="search?field=language&q=<?php echo $this->escapeUrl($language['language']) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->r('search', [], ['field' => 'language', 'q' => $language['language']])) ?>">
<?php echo $this->e(Friendica\Directory\Utils\L10n::localeToLanguageString($language['language'])) ?>
</a>
</li>

View File

@ -3,7 +3,7 @@
<ul>
<?php foreach ($tags as $tag): ?>
<li>
<a href="search?q=<?php echo $this->escapeUrl($tag['term']) ?>">
<a href="<?php echo $this->escapeHtmlAttr($this->r('search', [], ['q' => $tag['term']])) ?>">
<?php echo $this->e($tag['term']) ?>
</a>
</li>