Commit 68c83067 authored by Michael Herold's avatar Michael Herold
Browse files

Adds footer that can be customized. Closes #20.

All config options moved from printf to _msg.
Version number can be included in footer.
parent ef176dae
......@@ -3,3 +3,4 @@ vendor/
*.mo
*.css
*.css.map
VERSION
v0.6.0-unreleased
- Fixes missing unicode support for requests.
- Adds config fields 'site_information_url' and 'footer'
- [dns] Adds support for NS, SSHFP and TXT resource records
- [login_http] Adds support for login via email address as user account
v0.5.0
......
all: composer l10n css
all: composer l10n css version
dev: composer-dev l10n css
dev: composer-dev l10n css version
l10n:
# generate l10n
......@@ -16,3 +16,6 @@ composer:
composer-dev:
composer install
version:
git describe --tags > VERSION
......@@ -5,6 +5,7 @@
"This file is @generated automatically"
],
"hash": "20a1754350d9f4b11ef9f6229f0c948b",
"content-hash": "d95cd60200cb24e8a02c10ff7b4f1a7f",
"packages": [
{
"name": "hemio/form",
......
......@@ -27,9 +27,15 @@ locales:
# base URL: can be relative or absolute
base_url: '/'
# document title, must contain one %s
title: 'Edentata %s'
# document title
title: 'Edentata {module}'
# footer
footer: 'Powered by Edentata {version}'
# support URL, disabled if set to off
support_url: 'https://git.hemio.de/hemio/edentata'
support_url: False
# site information URL, disabled if set to off
# with german l10n this link appears as 'Impressum'
site_information_url: False
......@@ -45,6 +45,11 @@ class Config implements \ArrayAccess
}
}
public function enabled($key)
{
return $this[$key] !== false && $this[$key] !== null;
}
public function offsetExists($offset)
{
return isset($this->values[$offset]);
......
......@@ -26,6 +26,70 @@ namespace hemio\edentata;
class Utils
{
public static function getIdnaErrorMessage($int)
{
switch ($int) {
case IDNA_ERROR_EMPTY_LABEL:
return _('IDNA_ERROR_EMPTY_LABEL');
case IDNA_ERROR_LABEL_TOO_LONG:
return _('IDNA_ERROR_LABEL_TOO_LONG');
case IDNA_ERROR_DOMAIN_NAME_TOO_LONG:
return _('IDNA_ERROR_DOMAIN_NAME_TOO_LONG');
case IDNA_ERROR_LEADING_HYPHEN:
return _('IDNA_ERROR_LEADING_HYPHEN');
case IDNA_ERROR_TRAILING_HYPHEN:
return _('IDNA_ERROR_TRAILING_HYPHEN');
case IDNA_ERROR_HYPHEN_3_4:
return _('IDNA_ERROR_HYPHEN_3_4');
case IDNA_ERROR_LEADING_COMBINING_MARK:
return _('IDNA_ERROR_LEADING_COMBINING_MARK');
case IDNA_ERROR_DISALLOWED:
return _('IDNA_ERROR_DISALLOWED');
case IDNA_ERROR_PUNYCODE:
return _('IDNA_ERROR_PUNYCODE');
case IDNA_ERROR_LABEL_HAS_DOT:
return _('IDNA_ERROR_LABEL_HAS_DOT');
case IDNA_ERROR_INVALID_ACE_LABEL:
return _('IDNA_ERROR_INVALID_ACE_LABEL');
case IDNA_ERROR_BIDI:
return _('IDNA_ERROR_BIDI');
case IDNA_ERROR_CONTEXTJ:
return _('IDNA_ERROR_CONTEXTJ');
default:
return _('Unkown IDNA Error');
}
}
public static function idnToAscii($domain)
{
$idnaInfo = [];
$utf8 = idn_to_ascii($domain
,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII
| IDNA_DEFAULT
, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
if ($utf8 === false)
throw new exception\Error(self::getIdnaErrorMessage($idnaInfo['errors']),
$idnaInfo['errors']);
return $utf8;
}
public static function getPost()
{
$input = file_get_contents('php://input');
......
......@@ -217,10 +217,12 @@ try {
$header[] = $ul;
}
$aSupport = new html\A;
$aSupport->setAttribute('href', $config['support_url']);
$aSupport[] = new html\Str(_('Support'));
$header[] = $aSupport;
if ($config->enabled('support_url')) {
$aSupport = new html\A;
$aSupport->setAttribute('href', $config['support_url']);
$aSupport[] = new html\Str(_('Support'));
$header[] = $aSupport;
}
$aLogout = new html\A;
$aLogout->setAttribute('href', '?auth=logout');
......@@ -244,7 +246,8 @@ try {
# modules
if ($request->role === 'settings') {
$title->setValue(sprintf($config['title'], _('Settings')));
$title->setValue(_msg($config['title'], ['module' => _('Settings')]));
$nav = new gui\Window(_('Settings'));
$list = new gui\Sidebar();
......@@ -274,7 +277,8 @@ try {
$loadedModule = new LoadModule($activeModuleName, $pdo, $i10n);
$title->setValue(sprintf($config['title'], $loadedModule->getName()));
$title->setValue(_msg($config['title'],
['module' => $loadedModule->getName()]));
# generate content
$content = $loadedModule->getContent($request, $i10n);
......@@ -287,5 +291,25 @@ try {
$mainContent['messages']->addChild(new gui\Message($e));
}
$version = file_get_contents('VERSION');
$body['footer'] = new html\Footer();
if ($config->enabled('footer'))
$body['footer']['text'] = new html\Str(_msg($config['footer'],
['version' => $version]));
if ($config->enabled('site_information_url')) {
$siteInfo = new html\A;
$siteInfo->setAttribute('href', $config['site_information_url']);
$siteInfo[] = new html\Str(_('Site Information'));
if (isset($body['footer']['text']))
$body['footer'][] = new html\Str(' – ');
$body['footer']['site_information'] = $siteInfo;
}
echo $doc->__toString();
//echo System::reportString();
......@@ -35,6 +35,24 @@ class ServiceDetails extends Window
_('Service Activation'), $domain,
_('Save'));
var_dump($domain);
\hemio\edentata\Utils::idnToAscii($domain);
$idnaInfo = [];
$x = idn_to_ascii($domain,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII
| IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
var_dump($x);
var_dump($idnaInfo);
$idnaInfo = [];
$x = idn_to_utf8($x,
IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_UNICODE,
INTL_IDNA_VARIANT_UTS46, $idnaInfo);
var_dump($x);
var_dump($idnaInfo);
$activeServices = [];
$dnsService = $this->db->serviceSelect($domain)->fetchAll();
foreach ($dnsService as $service) {
......
......@@ -41,7 +41,7 @@ class Login extends Window
{
global $config;
return sprintf($config['title'], _('User Login'));
return _msg($config['title'], ['module' => _('User Login')]);
}
protected function nojsLogin()
......
/*
Copyright (C) 2016 Michael Herold <quabla@hemio.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Created on : Jan 6, 2016, 12:10:31 PM
Author : Michael Herold <quabla@hemio.de>
*/
footer {
font-size: 0.9em;
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@import "_functions.scss";
@import "_basics.scss";
@import "_header.scss";
@import "_footer.scss";
@import "_content_transition.scss";
@import "gui/_window.scss";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment