Commit ffd8ae81 authored by Michael Herold's avatar Michael Herold
Browse files

Updates main header (closes #16)

parent 0c7509c7
v0.7.0-unpublished:
v0.10.0-unpublished:
- Version number jump to get in sync with carnivora
- Adds cantarell as web font
- Updated dark theme
- Style fixes for radio lists
- Shows current deputy role
- Updates header (always shows owner, not contact email)
v0.6.0:
- Fixes missing unicode support for requests.
- Adds config fields 'site_information_url' and 'footer'
......
all: composer l10n css version
dev: composer-dev l10n css version fonts
dev: dev-composer l10n css version dev-fonts
l10n:
./gettextfmtall . ./locale edentata
./dev/gettextfmtall . ./locale edentata
css:
scss --style compressed --sourcemap=none --force --update src/scss:src/htdocs/static/design
scss --style compressed --sourcemap=none --force \
--update src/scss:src/htdocs/static/design
composer:
composer install --no-dev
composer-dev:
composer install
version:
git describe --tags > VERSION
fonts:
# Developement
test:
phpunit
dev-composer:
composer install
dev-fonts:
cd src/htdocs/static/design && \
cp /usr/share/doc/fonts-cantarell/copyright ./LICENSE-CANTARELL && \
cp /usr/share/fonts/opentype/cantarell/*.otf ./ && \
for f in *.otf; do sfnt2woff $$f; done && \
rm *.otf
test:
phpunit
dev-serve:
php -S localhost:8080 -t src/htdocs src/htdocs/index.php
This diff is collapsed.
msgid ""
msgstr ""
"Project-Id-Version: edentata\n"
"POT-Creation-Date: 2016-01-06 17:47+0100\n"
"PO-Revision-Date: 2016-01-06 17:51+0100\n"
"POT-Creation-Date: 2016-03-18 19:23+0100\n"
"PO-Revision-Date: 2016-03-18 19:23+0100\n"
"Last-Translator: Michael Herold <quabla@hemio.de>\n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.10\n"
"X-Generator: Poedit 1.8.7.1\n"
"X-Poedit-Basepath: ../../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
......@@ -198,11 +198,15 @@ msgstr "Unbekannter Status"
msgid "Overview"
msgstr "Übersicht"
#: src/class/sql/ExceptionMapping.php:42
#: src/class/sql/ExceptionMapping.php:41
msgid "Invalid unser login."
msgstr "Ungültige Benutzerdaten."
#: src/class/sql/ExceptionMapping.php:52
#: src/class/sql/ExceptionMapping.php:48
msgid "Acting as deputy failed."
msgstr "Das Ausüben der Stellvertretung ist fehlgeschlagen."
#: src/class/sql/ExceptionMapping.php:58
msgid ""
"The operation you want to perform would exceed your current contingent. "
"Please contact the support to extend your contingent."
......@@ -211,13 +215,13 @@ msgstr ""
"überschreiten. Bitte Kontaktieren Sie den Support um Ihr Kontingent zu "
"erweitern."
#: src/class/sql/ExceptionMapping.php:60
#: src/class/sql/ExceptionMapping.php:66
msgid "The object you tried to change is inaccessible or missing."
msgstr ""
"Das Objekt, welches Sie versucht haben zu ändern, ist für Sie nicht "
"zugänglich oder existiert nicht."
#: src/load/main.php:40 src/load/main.php:69
#: src/load/main.php:39 src/load/main.php:67
#, php-format
msgid ""
"An error has occured. We are sorry. You should contact the support and "
......@@ -228,46 +232,49 @@ msgstr ""
"kontaktieren und die Fehler-Nummer \"%s\" angeben. Sie können die \"Zurück\"-"
"Funktion Ihres Browsers benutzen und es noch einmal versuchen."
#: src/load/main.php:143
#: src/load/main.php:140
msgid "Logout successfull"
msgstr "Abmeldung Erfolgreich"
#: src/load/main.php:155 src/load/main.php:176
#: src/load/main.php:152 src/load/main.php:173
msgid "Login failed"
msgstr "Anmeldung fehlgeschlagen"
#: src/load/main.php:184
msgid "User"
msgstr "Benutzer"
msgstr "Benutzer*in"
#: src/load/main.php:189
msgid "User Settings"
msgstr "Benutzereinstellungen"
#: src/load/main.php:198
msgid "Act as Deputy"
msgstr "Stellvertretung Ausüben"
#: src/load/main.php:203
msgid "Stop acting as deputy"
msgstr "Stellvertretung aufgeben"
#: src/load/main.php:200
msgid "In Place of"
msgstr "In Stellvertretung für"
#: src/load/main.php:213
msgid "Act as Deputy"
msgstr "Stellvertretung Ausüben"
msgid "Stop acting as deputy"
msgstr "Stellvertretung aufgeben"
#: src/load/main.php:223
#: src/load/main.php:230
msgid "Support"
msgstr ""
#: src/load/main.php:229
#: src/load/main.php:236
msgid "Logout"
msgstr "Abmelden"
#: src/load/main.php:250 src/load/main.php:252
#: src/load/main.php:257 src/load/main.php:259
msgid "Settings"
msgstr "Optionen"
#: src/load/main.php:276
#: src/load/main.php:283
msgid "Tried to access unknown or disabled module"
msgstr ""
#: src/load/main.php:305
#: src/load/main.php:310
msgid "Site Information"
msgstr "Impressum"
#~ msgid "User Settings"
#~ msgstr "Benutzereinstellungen"
......@@ -56,6 +56,7 @@ class ContentNav
->addChild(new html\Header())
->addChild(new html\H1())
->addChild(new html\Str(_('Services')));
$nav->addCssClass('window');
$contentEvents = new ContentEvents($nav);
......
......@@ -33,6 +33,7 @@ class HeaderbarMenu extends form\Container
$this['ul'] = new html\Ul();
$this['ul']->addCssClass('popover');
$this['ul']->addCssClass('popover_window');
}
public function addEntry(edentata\Request $request = null, $text = null)
......
<?php
/*
* Copyright (C) 2015 Michael Herold <quabla@hemio.de>
*
......@@ -25,8 +26,7 @@ use hemio\edentata\exception;
*
* @author Michael Herold <quabla@hemio.de>
*/
class ExceptionMapping extends ExceptionMapper
{
class ExceptionMapping extends ExceptionMapper {
/**
*
......@@ -34,14 +34,20 @@ class ExceptionMapping extends ExceptionMapper
* @throws exception\Error
* @throws exception\SqlSpecific
*/
public function map(exception\SqlSpecific $e)
{
public function map(exception\SqlSpecific $e) {
switch ($e->getMessage()) {
case 'user:login_invalid':
return $this->error(
_('Invalid unser login.')
, 1001
, $e
_('Invalid unser login.')
, 1001
, $e
);
case 'user:deputy_failed':
return $this->error(
_('Acting as deputy failed.')
, 1004
, $e
);
case 'system:no_contingent':
......@@ -49,21 +55,22 @@ class ExceptionMapping extends ExceptionMapper
case 'system:contingent_total_exceeded':
case 'system:contingent_domain_exceeded':
return $this->error(
_('The operation you want to perform would exceed your current contingent.'
.' Please contact the support to extend your contingent.')
, 1002
, $e
_('The operation you want to perform would exceed your current contingent.'
. ' Please contact the support to extend your contingent.')
, 1002
, $e
);
case 'commons:inaccessible_or_missing':
return $this->error(
_('The object you tried to change is inaccessible or missing.')
, 1003
, $e
_('The object you tried to change is inaccessible or missing.')
, 1003
, $e
);
default:
return $e;
}
}
}
......@@ -16,8 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
chdir(__DIR__);
if (preg_match('/PHP .* Development Server/', @$_SERVER['SERVER_SOFTWARE']))
if (file_exists(substr($_SERVER['REQUEST_URI'], 1)))
return false;
chdir(__DIR__.'/../../');
$loader = require_once 'vendor/autoload.php';
require 'src/load/main.php';
<?php
/*
* Copyright (C) 2015 Michael Herold <quabla@hemio.de>
*
......@@ -28,28 +29,26 @@ ini_set('log_errors', true);
ini_set('error_log', 'syslog');
set_error_handler(
function ($errno, $errstr, $errfile, $errline, array $errcontext) {
function ($errno, $errstr, $errfile, $errline, array $errcontext) {
$id = uniqid();
syslog(LOG_ERR, sprintf('PHP error[%s] message: %s', $id, $errstr));
syslog(LOG_ERR,
sprintf('PHP error[%s] details: (%s) %s:%s', $id, $errno, $errfile,
$errline));
syslog(LOG_ERR, sprintf('PHP error[%s] details: (%s) %s:%s', $id, $errno, $errfile, $errline));
echo sprintf(
_(
'An error has occured. We are sorry. '
.'You should contact the support and reference to error id "%s". '
.'You can use the back button of your browser and try again.'
), $id
_(
'An error has occured. We are sorry. '
. 'You should contact the support and reference to error id "%s". '
. 'You can use the back button of your browser and try again.'
), $id
);
trigger_error(
sprintf(
'Made non fatal error fatal. (%s:%s %s)'
, $errfile
, $errline
, $errstr
), E_USER_ERROR
sprintf(
'Made non fatal error fatal. (%s:%s %s)'
, $errfile
, $errline
, $errstr
), E_USER_ERROR
);
exit(1);
......@@ -57,19 +56,18 @@ set_error_handler(
);
set_exception_handler(
function (\Exception $e) {
function (\Exception $e) {
$id = uniqid();
syslog(LOG_ERR, sprintf('PHP exception[%s] class: %s', $id, get_class($e)));
syslog(LOG_ERR,
sprintf('PHP exception[%s] message: %s', $id, $e->getMessage()));
syslog(LOG_ERR, sprintf('PHP exception[%s] message: %s', $id, $e->getMessage()));
echo sprintf(
_(
'An error has occured. We are sorry. '
.'You should contact the support and reference to error id "%s". '
.'You can use the back button of your browser and try again.'
), $id
_(
'An error has occured. We are sorry. '
. 'You should contact the support and reference to error id "%s". '
. 'You can use the back button of your browser and try again.'
), $id
);
throw $e;
......@@ -86,10 +84,9 @@ else
$loader->addPsr4('hemio\\edentata\\module\\', $config['module_load_dirs']);
$request = new Request($_GET, Utils::getPost(),
urldecode($_SERVER['REQUEST_URI']), $config['base_url']);
$request = new Request($_GET, Utils::getPost(), urldecode($_SERVER['REQUEST_URI']), $config['base_url']);
$modulesNavi = $config['modules_nav'];
$modulesNavi = $config['modules_nav'];
$modulesAllowed = $config->getAllowedModules();
I10n::$supportedLocales = $config['locales'];
......@@ -103,37 +100,37 @@ if (!$activeModuleName)
try {
# doc
$title = new html\Str('Edentata');
$doc = new form\Document($title);
$doc = new form\Document($title);
$doc->getHtml()->getHead()->addCssFile('static/design/style.css');
$doc->getHtml()->setAttribute('lang', $i10n->getLang());
$doc->getHtml()->getHead()->setBaseUrl($config['base_url']);
$body = $doc->getHtml()->getBody();
$header = new html\Header();
$header = new html\Header();
$body['header'] = $header;
$body['main'] = new html\Div();
$body['main']->addCssClass('main');
$mainNav = new html\Div();
$mainNav = new html\Div();
$body['main']['main_nav'] = $mainNav;
$mainNav->setId('main_nav');
$mainContent = new html\Div();
$mainContent = new html\Div();
$body['main']['main_content'] = $mainContent;
$mainContent->setId('main_content');
$mainContent['messages'] = new \hemio\form\Container;
$mainContent['messages'] = new \hemio\form\Container;
# db connect
$pdo = new sql\Connection($config['database_dsn']);
$pdo->addExceptionMapper(
new sql\ExceptionMapping($request->derive())
new sql\ExceptionMapping($request->derive())
);
$httpAuth = isset($_GET['auth']) && $_GET['auth'] === 'http';
$authMethod = isset($_GET['auth']) ? $_GET['auth'] : null;
$httpAuth = isset($_GET['auth']) && $_GET['auth'] === 'http';
$authMethod = isset($_GET['auth']) ? $_GET['auth'] : null;
$httpAuthSupplied = isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']);
# db auth
......@@ -167,7 +164,7 @@ try {
try {
$qryAuth = new sql\QuerySelectFunction($pdo, 'user.ins_login', $usrData);
$qryAuth->execute();
$loginData = $qryAuth->execute()->fetch();
} catch (\Exception $e) {
if ($httpAuth) {
usleep(100 * 1000);
......@@ -180,54 +177,64 @@ try {
}
}
$span = new html\Span;
$span[] = new html\Str(_('User').': '.$_SERVER['PHP_AUTH_USER']);
$header->addChild($span);
$header->addCssClass('header');
$headerNav = new html\Ul();
$header->addChild(new html\Nav())->addChild($headerNav);
$header[] = new gui\Link(
$request->deriveRole('settings')->deriveModule($config['modules_settings'][0])
, _('User Settings')
);
$userStr = new html\Str(_('User') . ': ' . $loginData['user']);
$headerNav->addLine(new gui\Link(
$request->deriveRole('settings')->deriveModule($config['modules_settings'][0])
, $userStr
));
$userModule = (new LoadModule('user', $pdo, $i10n))->getInstance($request);
$users = $userModule->db->selectDeputy()->fetchAll();
$users = $userModule->db->selectDeputy()->fetchAll();
if (!empty($users)) {
$ul = new html\Ul;
$aSettings = new html\A;
$aSettings->addCssClass('popover');
if (!$request->get('deputy'))
$aSettings[] = new html\Str(_('Act as Deputy'));
else
$aSettings[] = new html\Str(_('In Place of') .': ' . $request->get('deputy'));
$aSettings->setAttribute('href', $request->getUrl() . '#');
//$header[] = $aSettings;
$ul = $headerNav->addSubUl($aSettings);
$ul->addCssClass('popover');
$req = $request->deriveModule($request->module);
$req->get['deputy'] = null;
$ul->addLine(new gui\Link($req, _('Stop acting as deputy')));
$ul->addLine(new html\Hr());
if ($request->get('deputy')) {
$ul->addLine(new gui\Link($req, _('Stop acting as deputy')));
$ul->addLine(new html\Hr());
}
foreach ($users as $represented) {
$req->get['deputy'] = $represented['represented'];
$ul->addLine(new gui\Link($req, $represented['represented']));
}
$aSettings = new html\A;
$aSettings->addCssClass('popover');
$aSettings[] = new html\Str(_('Act as Deputy'));
$aSettings->setAttribute('href', $request->getUrl().'#');
$header[] = $aSettings;
$header[] = $ul;
//$header[] = $ul;
}
if ($config->enabled('support_url')) {
$aSupport = new html\A;
$aSupport = new html\A;
$aSupport->setAttribute('href', $config['support_url']);
$aSupport[] = new html\Str(_('Support'));
$header[] = $aSupport;
$headerNav->addLine($aSupport);
}
$aLogout = new html\A;
$aLogout = new html\A;
$aLogout->setAttribute('href', '?auth=logout');
$aLogout[] = new html\Str(_('Logout'));
$header[] = $aLogout;
$headerNav->addLine($aLogout);
if ($request->get('deputy'))
$userModule->db->actAsDeputy($request->get('deputy'));
......@@ -249,8 +256,8 @@ try {
$title->setValue(_msg($config['title'], ['module' => _('Settings')]));
$nav = new gui\Window(_('Settings'));
$list = new gui\Sidebar();
$nav = new gui\Window(_('Settings'));
$list = new gui\Sidebar();
$nav[] = $list;
if (count($config['modules_settings']) > 1)
$mainContent->addChild($nav);
......@@ -259,8 +266,8 @@ try {
$loadedModule = new LoadModule($moduleId, $pdo, $i10n);
$a = $list->addLinkEntry(
$request->deriveModule($moduleId)
, new html\Str($loadedModule->getName())
$request->deriveModule($moduleId)
, new html\Str($loadedModule->getName())
);
if ($moduleId === $request->module)
......@@ -277,8 +284,7 @@ try {
$loadedModule = new LoadModule($activeModuleName, $pdo, $i10n);
$title->setValue(_msg($config['title'],
['module' => $loadedModule->getName()]));
$title->setValue(_msg($config['title'], ['module' => $loadedModule->getName()]));
# generate content
$content = $loadedModule->getContent($request, $i10n);
......@@ -286,7 +292,7 @@ try {
}
} catch (\PDOException $e) {
$mainContent['messages']
->addChild(new gui\Message(new exception\Error('*DB operation failed* '.$e->getMessage())));
->addChild(new gui\Message(new exception\Error('*DB operation failed* ' . $e->getMessage())));
} catch (exception\Printable $e) {
$mainContent['messages']->addChild(new gui\Message($e));
}
......@@ -296,11 +302,10 @@ $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]));
$body['footer']['text'] = new html\Str(_msg($config['footer'], ['version' => $version]));
if ($config->enabled('site_information_url')) {
$siteInfo = new html\A;
$siteInfo = new html\A;
$siteInfo->setAttribute('href', $config['site_information_url']);
$siteInfo[] = new html\Str(_('Site Information'));
......
......@@ -33,7 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
margin-bottom: 1em;
}
.header > .link {
.header .link {
display: inline-block;
padding: 0 0.7em;
border: 1px solid $outer-background-color;
......@@ -41,29 +41,60 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
flex-grow: 1;
}
body > header {
@extend .header;
.header .link:hover {
background-color: adjust-color(lighten($outer-background-color, 12%), $red: -5);
}
.header .link:focus {
background-color: adjust-color(darken($outer-background-color, 12%), $red: -5);
}
body > header > a {
.header a {
@extend .link;
}
body > header > :first-child {
.header ul {
margin: 0;
padding: 0;
}
.header li {
display: inline-block;
}
.header li li, .header li li a {
display: block;
text-align: left;
}
.header hr {
border: none;
border-top: 1px solid darken($outer-background-color, 6%);
margin: 1em 3em;
}
.header :first-child {
border-bottom-left-radius: inherit;
}
body > header > :last-child {
.header :last-child {
border-bottom-right-radius: inherit;
}
.header li ul:nth-child(n) {
background-color: $outer-background-color;
padding: 1em 0;
margin-top: 1em;
border-radius: 0.25em;
}
.header .link:hover {
background-color: adjust-color(lighten($outer-background-color, 12%), $red: -5);