Skip to content

Commit 04e3807

Browse files
committed
Releasing 0.9.3
2 parents 04175b3 + b47bb73 commit 04e3807

File tree

9 files changed

+77
-27
lines changed

9 files changed

+77
-27
lines changed

src/WebApp/Application.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ protected function initMailQueue() {
130130
$this->dataModel->register('emails', $mailDAO);
131131
}
132132
}
133-
$this->mailQueue = new \TgEmail\EmailQueue(\TgEmail\EmailConfig::from($this->config->get('mailQueue')), $mailDAO);
133+
$mailConfig = \TgEmail\EmailConfig::from($this->config->get('mailQueue'));
134134
$credentialsProvider = $this->config->getCredentialsProvider('mailQueue', $this->vault);
135135
if ($credentialsProvider != NULL) {
136-
$this->mailQueue->setCredentialsProvider($credentialsProvider);
136+
$mailConfig->getSmtpConfig()->setCredentialsProvider($credentialsProvider);
137137
}
138+
$this->mailQueue = new \TgEmail\EmailQueue($mainConfig, $mailDAO);
138139
}
139140
}
140141

src/WebApp/BootstrapTheme/DefaultLayout.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public function __construct($theme, $page) {
1616
}
1717

1818
protected function renderLinks() {
19-
$rc = '<link rel="stylesheet" href="'.FontAwesome::getUri().'" rel="stylesheet" type="text/css">'.
20-
Bootstrap::getCssLink().
21-
'<link rel="stylesheet" href="'.Utils::getCssBaseUrl(TRUE).'/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css">';
19+
$webroot = $this->app->request->webRoot;
20+
$rc = '<link rel="stylesheet" href="'.$webroot.FontAwesome::getUri().'" rel="stylesheet" type="text/css">'.
21+
'<link rel="stylesheet" href="'.$webroot.Bootstrap::getCssUri().'" rel="stylesheet" type="text/css">'.
22+
'<link rel="stylesheet" href="'.Utils::getCssBasePath(TRUE).'/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css">';
2223
$rc .= parent::renderLinks();
2324
return $rc;
2425
}
@@ -44,7 +45,7 @@ protected function renderNavbar() {
4445
protected function renderNavbarBrand() {
4546
$rc = '<span class="navbar-brand mb-0 display-4">';
4647
$link = $this->app->getBrandLink();
47-
if ($link == null) $link = \WebApp\Utils::getAppPath('/');
48+
if ($link == null) $link = $this->app->router->getCanonicalPath('/');
4849
if ($link != null) $rc .= '<a class="navbar-brand" href="'.$link.'">';
4950
$logo = $this->app->getBrandLogo();
5051
if ($logo != null) {
@@ -81,7 +82,7 @@ protected function renderNavbarContent() {
8182
$userMenu = array();
8283
$userItem = new \WebApp\Component\MenuItem($this, $principal->__toString(), '#');
8384
$logoutLink = $this->app->getPageLink('logout');
84-
if ($logoutLink != NULL) $logoutLink = Utils::getAppPath($logoutLink);
85+
if ($logoutLink != NULL) $logoutLink = $this->app->router->getCanonicalPath($logoutLink);
8586
else $logoutLink = '';
8687
$userMenu[] = new \WebApp\Component\MenuItem($userItem, 'logout_label', $logoutLink.'?logout');
8788
$userMenu = array($userItem);
@@ -97,7 +98,7 @@ protected function renderNavbarContent() {
9798
$rc .= '</ul>';
9899
} else if ($this->app->getPageLink('login') != NULL) {
99100
$uri = $this->app->request->uri;
100-
$login = Utils::getAppPath($this->app->getPageLink('login'));
101+
$login = $this->app->router->getCanonicalPath($this->app->getPageLink('login'));
101102
if ($this->app->request->path == $login) {
102103
$uri = $this->app->request->path;
103104
} else {
@@ -120,10 +121,11 @@ protected function renderContent() {
120121
}
121122

122123
protected function renderJavascript() {
123-
$rc = JQuery::getLink('3.5.1', JQuery::MINIFIED).
124-
'<script src="'.Bootstrap::getJsUri().'"></script>'.
125-
'<script src="'.Utils::getJavascriptBaseUrl(TRUE).'/webapp.js"></script>'.
126-
'<script src="'.Utils::getJavascriptBaseUrl(TRUE).'/utils.js"></script>';
124+
$webroot = $this->app->request->webRoot;
125+
$rc = '<script src="'.$webroot.JQuery::getUri('3.5.1', JQuery::MINIFIED).'"></script>'.
126+
'<script src="'.$webroot.Bootstrap::getJsUri().'"></script>'.
127+
'<script src="'.Utils::getJavascriptBasePath(TRUE).'/webapp.js"></script>'.
128+
'<script src="'.Utils::getJavascriptBasePath(TRUE).'/utils.js"></script>';
127129
$rc .= parent::renderJavascript();
128130
return $rc;
129131
}

src/WebApp/BootstrapTheme/LoginPage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function getLoginForm() {
6969

7070
$rc[] = $form;
7171
if ($this->app->getPageLink('forgot_password') != NULL) {
72-
$link = Utils::getAppPath($this->app->getPageLink('forgot_password'));
72+
$link = $this->app->router->getCanonicalPath($this->app->getPageLink('forgot_password'));
7373
$forgot = new \WebApp\Component\Div($this, new \WebApp\Component\Link($this, $link, 'Passwort vergessen?'));
7474
$forgot->addClass('small');
7575
$forgot->setStyle('margin-top', '1em');

src/WebApp/BootstrapTheme/MenuItemRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function createLink($component) {
3939
if (substr($pageLink, 0, 1) != '/') {
4040
$rc = $pageLink;
4141
} else {
42-
$rc = \WebApp\Utils::getAppPath($pageLink);
42+
$rc = $this->app->router->getCanonicalPath($pageLink);
4343
}
4444
}
4545
return $rc;

src/WebApp/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function processRequest() {
9292
$this->processLogoutAction();
9393
$home = $this->app->getPageLink('home');
9494
if ($home == NULL) $home = $this->request->path;
95-
else $home = Utils::getAppPath($home);
95+
else $home = $this->app->router->getCanonicalPath($home);
9696
return array('redirect', $home);
9797
}
9898

@@ -148,7 +148,7 @@ protected function computeDisplayMode() {
148148
$this->display = 'login';
149149
$uri = $this->app->getPageLink('login');
150150
if ($uri != NULL) {
151-
$uri = Utils::getAppPath($uri);
151+
$uri = $this->app->router->getCanonicalPath($uri);
152152
if ($uri != $this->request->path) {
153153
return array('redirect', $uri.'?return='.urlencode($this->request->uri));
154154
}

src/WebApp/Renderer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
class Renderer {
66

77
protected $parent;
8+
protected $app;
89
protected $theme;
910
protected $component;
1011
protected $attributes;
1112
protected $styles;
1213

1314
// was __construct($theme, $parent, $component) {
1415
public function __construct($theme, $component) {
16+
$this->app = $theme->app;
1517
$this->theme = $theme;
1618
$this->parent = $parent;
1719
$this->component = $component;

src/WebApp/Router.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,38 @@ public function getPageMap() {
6969
);
7070
}
7171

72-
public function getCanonicalPath() {
72+
/**
73+
* Returns the absolute canonical URI path for a page path from the app root.
74+
* <p>Returns the canonical path for the current URI when no arguments given.</p>
75+
* @param string $localPath - an appRoot-relative path without language (u
76+
* @param string $language - the language to be used
77+
* @return string the absolute path for the URI.
78+
*/
79+
public function getCanonicalPath($pagePath = NULL, $language = NULL) {
7380
if (!isset($this->request->canonicalPath)) {
7481
$this->initPagePath();
7582
}
83+
if (($pagePath == NULL) && ($language != NULL)) $pagePath = $this->request->pagePath;
84+
if ($pagePath != NULL) {
85+
return $this->computeCanonicalPath($pagePath, $language);
86+
}
7687
return $this->request->canonicalPath;
7788
}
7889

90+
/**
91+
* Computes the absolute canonical URI path for a page path from the app root.
92+
* @param string $pagePath - a page path
93+
* @param string $language - the language to be used
94+
* @return string the absolute, canonical path for the page with this language.
95+
*/
96+
protected function computeCanonicalPath($pagePath, $language) {
97+
if ($language == NULL) $language = $this->request->language;
98+
if (!$this->request->useLanguagePath || ($language == NULL)) $language = '';
99+
else $language = '/'.$language;
100+
101+
return $this->getAbsolutePath($language.$pagePath);
102+
}
103+
79104
public function getPagePath() {
80105
if (!isset($this->request->pagePath)) {
81106
$this->initPagePath();
@@ -191,5 +216,12 @@ public function getPage() {
191216

192217
return $page;
193218
}
219+
220+
/** Returns the absolute path to a relative app path */
221+
public function getAbsolutePath($relativePath) {
222+
$request = $this->app->request;
223+
return $request->webRoot.$request->relativeAppPath.$relativePath;
224+
}
225+
194226
}
195227

src/WebApp/Service.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ protected function createPage() {
4040

4141
// Check the path info
4242
$canonical = $this->app->router->getCanonicalPath();
43-
if ($request->path != $request->relativeAppPath.$canonical) {
43+
$requested = $request->originalPath;
44+
if ($requested != $canonical) {
4445
$params = $request->params;
4546
if ($params) $params = '?'.$params;
46-
header('Location: '.$request->webRootUri.$request->relativeAppPath.$canonical.$params);
47-
//Log::debug('redirect='.$request->webRootUri.$request->relativeAppPath.$canonical.$params);
47+
header('Location: '.$canonical.$params);
48+
exit;
4849
}
4950

5051
// Try to find the correct page

src/WebApp/Utils.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,41 @@ public static function getWebRootUrl($webapp = FALSE) {
1313
return $request->webRootUri.$request->relativeAppPath.($webapp ? WEBAPP_SUB_PATH : '');
1414
}
1515

16+
public static function getWebRootPath($webapp = FALSE) {
17+
$request = Request::getRequest();
18+
return $request->webRoot.$request->relativeAppPath.($webapp ? WEBAPP_SUB_PATH : '');
19+
}
20+
1621
public static function getJavascriptBaseUrl($webapp = FALSE) {
1722
return self::getWebRootUrl($webapp).'/js';
1823
}
1924

25+
public static function getJavascriptBasePath($webapp = FALSE) {
26+
return self::getWebRootPath($webapp).'/js';
27+
}
28+
2029
public static function getImageBaseUrl($webapp = FALSE) {
2130
return self::getWebRootUrl($webapp).'/images';
2231
}
2332

33+
public static function getImageBasePath($webapp = FALSE) {
34+
return self::getWebRootPath($webapp).'/images';
35+
}
36+
2437
public static function getCssBaseUrl($webapp = FALSE) {
2538
return self::getWebRootUrl($webapp).'/css';
2639
}
2740

41+
public static function getCssBasePath($webapp = FALSE) {
42+
return self::getWebRootPath($webapp).'/css';
43+
}
44+
2845
public function getFontBaseUrl($webapp = FALSE) {
2946
return self::getWebRootUrl($webapp).'/fonts';
3047
}
3148

32-
public function getAppPath($localPath, $language = NULL) {
33-
$request = Request::getRequest();
34-
if ($language == NULL) $language = $request->language;
35-
if (!$request->useLanguagePath || ($language == NULL)) $language = '';
36-
else $language = '/'.$language;
37-
38-
return $request->webRoot.$language.$request->relativeAppPath.$localPath;
49+
public function getFontBasePath($webapp = FALSE) {
50+
return self::getWebRootPath($webapp).'/fonts';
3951
}
4052
}
4153

0 commit comments

Comments
 (0)