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 --> <!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light bg-light static-top"> <nav class="navbar navbar-expand-lg navbar-light bg-light static-top">
<div class="container"> <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=""> <img src="assets/images/friendica-32.png" width="32" height="32" class="d-inline-block align-top" alt="">
<?php echo $this->__('Friendica Directory')?> <?php echo $this->__('Friendica Directory')?>
</a> </a>
<?php if (empty($noNavSearch)): ?> <?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"> <div class="input-group">
<label class="sr-only" for="header_search"><?php echo $this->__('Search terms')?></label> <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')?>..." <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"> <ul class="navbar-nav ml-auto">
<?php if (empty($noNavSearch)): ?> <?php if (empty($noNavSearch)): ?>
<li class="nav-item d-md-none"> <li class="nav-item d-md-none">
<form action="search"> <form action="<?php echo $this->escapeHtmlAttr($this->r('search'))?>">
<div class="input-group"> <div class="input-group">
<label class="sr-only" for="nav_search"><?php echo $this->__('Search terms')?></label> <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" <input name="q" class="form-control form-control-sm" type="search" id="nav_search"
@ -52,12 +52,12 @@
<?php endif; ?> <?php endif; ?>
<li class="nav-item"> <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>--> <!--<span class="sr-only">(current)</span>-->
</a> </a>
</li> </li>
<li class="nav-item"> <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>
<li class="nav-item"> <li class="nav-item">
<div class="dropdown"> <div class="dropdown">
@ -66,7 +66,7 @@
</button> </button>
<div class="dropdown-menu" aria-labelledby="languageDropdown"> <div class="dropdown-menu" aria-labelledby="languageDropdown">
<?php foreach($languages as $lang):?> <?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)) ?> <?php echo $this->e(Friendica\Directory\Utils\L10n::localeToLanguageString($lang)) ?>
</a> </a>
<?php endforeach;?> <?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> <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>
<li class="nav-item"> <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> </li>
<?php foreach ($pages as $page):?> <?php foreach ($pages as $page):?>
<li class="nav-item"> <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> </li>
<?php endforeach;?> <?php endforeach;?>
</ul> </ul>

View file

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

View file

@ -8,9 +8,10 @@ use \Friendica\Directory\Utils\L10n;
L10n::formatNumber($stats['profile']['total']), L10n::formatNumber($stats['profile']['total']),
L10n::formatNumber($stats['profile']['ratio'], L10n::PERCENT) L10n::formatNumber($stats['profile']['ratio'], L10n::PERCENT)
)?></p> )?></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']['total']),
L10n::formatNumber($stats['profile']['available']['ratio'], L10n::PERCENT) L10n::formatNumber($stats['profile']['available']['ratio'], L10n::PERCENT),
$this->escapeHtmlAttr($this->u(''))
)?></p> )?></p>
<h3><?php echo $this->__('Languages') ?></h3> <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> <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']['total']),
L10n::formatNumber($stats['server']['available']['ratio'], L10n::PERCENT) L10n::formatNumber($stats['server']['available']['ratio'], L10n::PERCENT)
)?></li> )?></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']['total']),
L10n::formatNumber($stats['server']['open']['ratio'], L10n::PERCENT) L10n::formatNumber($stats['server']['open']['ratio'], L10n::PERCENT),
$this->escapeHtmlAttr($this->r('servers'))
)?></li> )?></li>
</ul> </ul>

View file

@ -1,19 +1,19 @@
<?php <?php
$parts = []; $parts = [];
if (!empty($profile['locality'])) { 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> <span class="fa fa-filter" title="' . $this->__('Filter by locality') . '" aria-hidden="true"></span>
</a>'; </a>';
} }
if (!empty($profile['region']) if (!empty($profile['region'])
&& strtolower($profile['locality']) != strtolower($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> <span class="fa fa-filter" title="' . $this->__('Filter by region') . '" aria-hidden="true"></span>
</a>'; </a>';
} }
if (!empty($profile['country'])) { 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> <span class="fa fa-filter" title="' . $this->__('Filter by country') . '" aria-hidden="true"></span>
</a>'; </a>';
} }
@ -21,20 +21,20 @@ if (!empty($profile['country'])) {
<figure id="profile-<?php echo $this->escapeHtmlAttr($profile['id']) ?>" class="bg-light p-3 rounded"> <figure id="profile-<?php echo $this->escapeHtmlAttr($profile['id']) ?>" class="bg-light p-3 rounded">
<div class="media"> <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"> <img class="mr-3 rounded" src="photo/<?php echo $profile['id'] ?>.jpg">
</a> </a>
<div class="media-body"> <div class="media-body">
<h5 class="name"> <h5 class="name">
<?php if ($profile['dfrn_request']): ?> <?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')?> <i class="fa fa-external-link-alt"></i> <?php echo $this->p__('verb', 'Follow')?>
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php echo $this->escapeHtml($profile['name']) ?> <?php echo $this->escapeHtml($profile['name']) ?>
</h5> </h5>
<p class="url"> <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']) ?> <?php echo $this->escapeHtml($profile['addr']) ?>
</a> </a>
</p> </p>
@ -46,7 +46,7 @@ if (!empty($profile['country'])) {
<div class="language"> <div class="language">
<i class="fa fa-language" alt="<?php echo $this->__('Language')?>" title="<?php echo $this->__('Language')?>"></i> <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'])) ?> <?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> <i class="fa fa-filter" title="<?php echo $this->__('Filter by language')?>"></i>
</a> </a>
</div> </div>
@ -65,7 +65,7 @@ if (!empty($profile['country'])) {
foreach ($tags as $tag):?> foreach ($tags as $tag):?>
<span class="badge"> <span class="badge">
<?php echo $this->escapeHtml($tag) ?> <?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> <i class="fa fa-tag" title="<?php echo $this->__('Search Tag')?>"></i>
</a> </a>
</span> </span>

View file

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

View file

@ -2,7 +2,7 @@
<?php foreach ($tabs as $tab): ?> <?php foreach ($tabs as $tab): ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link<?php echo $tab['active'] ? ' active' : '' ?>" <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> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>

View file

@ -3,7 +3,7 @@
<ul> <ul>
<?php foreach ($countries as $country): ?> <?php foreach ($countries as $country): ?>
<li> <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']) ?> <?php echo $this->e($country['country']) ?>
</a> </a>
</li> </li>

View file

@ -3,7 +3,7 @@
<ul> <ul>
<?php foreach ($languages as $language): ?> <?php foreach ($languages as $language): ?>
<li> <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'])) ?> <?php echo $this->e(Friendica\Directory\Utils\L10n::localeToLanguageString($language['language'])) ?>
</a> </a>
</li> </li>

View file

@ -3,7 +3,7 @@
<ul> <ul>
<?php foreach ($tags as $tag): ?> <?php foreach ($tags as $tag): ?>
<li> <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']) ?> <?php echo $this->e($tag['term']) ?>
</a> </a>
</li> </li>