Commit a14e4b28 authored by Tino Goratsch's avatar Tino Goratsch

- added a special parameter bag for the cookies

- moved and renamed some methods
- various fixes and improvements
parent 37ab48a3
......@@ -60,8 +60,6 @@ class Application extends AbstractApplication
{
define('PHP_SELF', htmlentities($_SERVER['SCRIPT_NAME']));
define('ROOT_DIR', substr(PHP_SELF, 0, strrpos(PHP_SELF, '/') + 1));
define('HOST_NAME', 'http://' . $_SERVER['HTTP_HOST']);
define('ROOT_DIR_ABSOLUTE', HOST_NAME . ROOT_DIR);
define('ACP3_DIR', ACP3_ROOT_DIR . 'ACP3/');
define('CLASSES_DIR', ACP3_DIR . 'Core/');
define('MODULES_DIR', ACP3_DIR . 'Modules/');
......@@ -154,7 +152,7 @@ class Application extends AbstractApplication
{
define('DESIGN_PATH', ROOT_DIR . 'designs/' . $this->systemSettings['design'] . '/');
define('DESIGN_PATH_INTERNAL', ACP3_ROOT_DIR . 'designs/' . $this->systemSettings['design'] . '/');
define('DESIGN_PATH_ABSOLUTE', HOST_NAME . DESIGN_PATH);
define('DESIGN_PATH_ABSOLUTE', $this->container->get('core.request')->getDomain() . DESIGN_PATH);
}
/**
......
......@@ -108,8 +108,8 @@ class Auth
{
if ($this->sessionHandler->has(self::AUTH_NAME)) {
$this->populateUserData($this->sessionHandler->get(self::AUTH_NAME, []));
} elseif ($this->request->getCookie()->has(self::AUTH_NAME)) {
list($userId, $token) = explode('|', $this->request->getCookie()->get(self::AUTH_NAME, ''));
} elseif ($this->request->getCookies()->has(self::AUTH_NAME)) {
list($userId, $token) = explode('|', $this->request->getCookies()->get(self::AUTH_NAME, ''));
if (!$this->verifyCredentials($userId, $token)) {
$this->logout($userId);
......@@ -143,14 +143,12 @@ class Auth
* Logs out the current user
*
* @param int $userId
*
* @return bool
*/
public function logout($userId = 0)
{
$this->saveRememberMeToken($userId, '');
$this->sessionHandler->destroy(session_id());
return $this->setCookie(0, '', -50400);
$this->setRememberMeCookie(0, '', -1 * self::REMEMBER_ME_COOKIE_LIFETIME);
}
/**
......@@ -162,11 +160,15 @@ class Auth
*
* @return bool
*/
public function setCookie($userId, $token, $expiry)
public function setRememberMeCookie($userId, $token, $expiry)
{
$value = $userId . '|' . $token;
$expiry = time() + $expiry;
return setcookie(self::AUTH_NAME, $value, $expiry, ROOT_DIR, $this->getCookieDomain());
$this->request->getCookies()->set(
self::AUTH_NAME,
$userId . '|' . $token,
time() + $expiry,
ROOT_DIR,
$this->getCookieDomain()
);
}
/**
......@@ -266,7 +268,7 @@ class Auth
if ($rememberMe === true) {
$token = $this->generateRememberMeToken($user);
$this->saveRememberMeToken($user['id'], $token);
$this->setCookie($user['id'], $token, self::REMEMBER_ME_COOKIE_LIFETIME);
$this->setRememberMeCookie($user['id'], $token, self::REMEMBER_ME_COOKIE_LIFETIME);
}
$this->sessionHandler->secureSession();
......
......@@ -137,14 +137,14 @@ class Alerts
*/
public function errorBox($errors, $contentOnly = true)
{
if ($this->request->getIsAjax() === true) {
if ($this->request->isAjax() === true) {
$contentOnly = true;
}
$this->view->assign('CONTENT_ONLY', $contentOnly);
$content = $this->view->fetchTemplate($this->errorBoxContent($errors));
if ($this->request->getIsAjax() === true) {
if ($this->request->isAjax() === true) {
$return = [
'success' => false,
'content' => $content,
......
......@@ -184,14 +184,14 @@ class Date
*
* @return array
*/
protected function fetchRangeDatePickerValues($name, array $value, $format)
protected function fetchRangeDatePickerValues(array $name, $value, $format)
{
if ($this->request->getPost()->has($name[0]) && $this->request->getPost()->has($name[1])) {
$valueStart = $this->request->getPost()->get($name[0]);
$valueEnd = $this->request->getPost()->get($name[1]);
$valueStartR = $this->date->format($valueStart, 'r', false);
$valueEndR = $this->date->format($valueEnd, 'r', false);
} elseif ($this->dateValidator->date($value[0], $value[1]) === true) {
} elseif (is_array($value) && $this->dateValidator->date($value[0], $value[1]) === true) {
$valueStart = $this->date->format($value[0], $format);
$valueEnd = $this->date->format($value[1], $format);
$valueStartR = $this->date->format($value[0], 'r');
......
......@@ -13,6 +13,10 @@ class RewriteInternalUri
* @var \ACP3\Core\Modules\Helper\ControllerActionExists
*/
protected $controllerActionExists;
/**
* @var \ACP3\Core\Http\Request
*/
protected $request;
/**
* @var \ACP3\Core\Router
*/
......@@ -24,16 +28,19 @@ class RewriteInternalUri
/**
* @param \ACP3\Core\Modules\Helper\ControllerActionExists $controllerActionExists
* @param \ACP3\Core\Http\Request $request
* @param \ACP3\Core\Router $router
* @param \ACP3\Core\Validator\Rules\Router\Aliases $aliasValidator
*/
public function __construct(
Core\Modules\Helper\ControllerActionExists $controllerActionExists,
Core\Http\Request $request,
Core\Router $router,
Core\Validator\Rules\Router\Aliases $aliasValidator
)
{
$this->controllerActionExists = $controllerActionExists;
$this->request = $request;
$this->router = $router;
$this->aliasesValidator = $aliasValidator;
}
......@@ -48,8 +55,12 @@ class RewriteInternalUri
public function rewriteInternalUri($text)
{
$rootDir = str_replace('/', '\/', ROOT_DIR);
$host = $_SERVER['HTTP_HOST'];
return preg_replace_callback('/<a([^>]+)href="(http(s?):\/\/' . $host . ')?(' . $rootDir . ')?(index\.php)?(\/?)((?i:[a-z\d_\-]+\/){2,})"/i', [$this, "_rewriteInternalUriCallback"], $text);
$host = $this->request->getServer()->get('HTTP_HOST');
return preg_replace_callback(
'/<a([^>]+)href="(http(s?):\/\/' . $host . ')?(' . $rootDir . ')?(index\.php)?(\/?)((?i:[a-z\d_\-]+\/){2,})"/i',
[$this, "_rewriteInternalUriCallback"],
$text
);
}
/**
......
<?php
namespace ACP3\Core\Http;
use ACP3\Core\Http\Request\CookiesParameterBag;
use ACP3\Core\Http\Request\FilesParameterBag;
use ACP3\Core\http\Request\ParameterBag;
use ACP3\Core\Http\Request\ParameterBag;
use ACP3\Core\Http\Request\UserAgent;
/**
* Class AbstractRequest
......@@ -23,21 +25,25 @@ abstract class AbstractRequest implements RequestInterface
*/
protected $isAjax;
/**
* @var ParameterBag
* @var \ACP3\Core\Http\Request\FilesParameterBag
*/
protected $files;
/**
* @var ParameterBag
* @var \ACP3\Core\Http\Request\ParameterBag
*/
protected $post;
/**
* @var ParameterBag
* @var \ACP3\Core\Http\Request\ParameterBag
*/
protected $server;
/**
* @var ParameterBag
* @var \ACP3\Core\Http\Request\CookiesParameterBag
*/
protected $cookie;
protected $cookies;
/**
* @var \ACP3\Core\Http\Request\UserAgent
*/
protected $userAgent;
public function __construct()
{
......@@ -74,10 +80,20 @@ abstract class AbstractRequest implements RequestInterface
return $this->hostname;
}
/**
* Returns the protocol with the hostname
*
* @return string
*/
public function getDomain()
{
return $this->protocol . $this->hostname;
}
/**
* @return bool
*/
public function getIsAjax()
public function isAjax()
{
if ($this->isAjax === null) {
$this->isAjax = !empty($this->server->get('HTTP_X_REQUESTED_WITH')) && strtolower($this->server->get('HTTP_X_REQUESTED_WITH', '')) == 'xmlhttprequest';
......@@ -89,17 +105,17 @@ abstract class AbstractRequest implements RequestInterface
/**
* Returns the parameter bag of the $_COOKIE superglobal
*
* @return ParameterBag
* @return \ACP3\Core\Http\Request\CookiesParameterBag
*/
public function getCookie()
public function getCookies()
{
return $this->cookie;
return $this->cookies;
}
/**
* Returns the parameter bag of the uploaded files ($_FILES superglobal)
*
* @return \ACP3\Core\http\Request\ParameterBag
* @return \ACP3\Core\Http\Request\FilesParameterBag
*/
public function getFiles()
{
......@@ -109,7 +125,7 @@ abstract class AbstractRequest implements RequestInterface
/**
* Returns the parameter bag of the $_POST superglobal
*
* @return ParameterBag
* @return \ACP3\Core\Http\Request\ParameterBag
*/
public function getPost()
{
......@@ -119,25 +135,33 @@ abstract class AbstractRequest implements RequestInterface
/**
* Returns the parameter bag of the $_SERVER superglobal
*
* @return \ACP3\Core\http\Request\ParameterBag
* @return \ACP3\Core\Http\Request\ParameterBag
*/
public function getServer()
{
return $this->server;
}
/**
* @return \ACP3\Core\Http\Request\UserAgent
*/
public function getUserAgent()
{
return $this->userAgent;
}
/**
* @param array $server
* @param array $post
* @param array $files
* @param array $cookie
* @param array $cookies
*/
protected function fillParameterBags(array $server, array $post, array $files, array $cookie)
protected function fillParameterBags(array $server, array $post, array $files, array $cookies)
{
$this->files = new FilesParameterBag($files);
$this->post = new ParameterBag($post);
$this->server = new ParameterBag($server);
$this->cookie = new ParameterBag($cookie);
$this->cookies = new CookiesParameterBag($cookies);
$this->userAgent = new UserAgent($this->server);
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ namespace ACP3\Core\Http;
use ACP3\Core\Config;
use ACP3\Core\Modules;
use ACP3\Core\http\Request\ParameterBag;
use ACP3\Core\Http\Request\ParameterBag;
use ACP3\Modules\ACP3\Seo;
/**
......@@ -44,7 +44,7 @@ class Request extends AbstractRequest
*/
protected $controllerAction = '';
/**
* @var ParameterBag
* @var \ACP3\Core\Http\Request\ParameterBag
*/
protected $parameters;
/**
......@@ -232,7 +232,7 @@ class Request extends AbstractRequest
/**
* @inheritdoc
*/
public function getIsHomepage()
public function isHomepage()
{
if ($this->isHomepage === null) {
$this->isHomepage = ($this->query === $this->config->getSettings('system')['homepage']);
......@@ -241,18 +241,6 @@ class Request extends AbstractRequest
return $this->isHomepage;
}
/**
* @inheritdoc
* @see http://detectmobilebrowsers.com/download/php
*/
public function isMobileBrowser()
{
$userAgent = $this->getServer()->get('HTTP_USER_AGENT', '');
return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $userAgent) ||
preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($userAgent, 0, 4));
}
/**
* @inheritdoc
*/
......
<?php
namespace ACP3\Core\Http\Request;
/**
* Class CookieParameterBag
* @package ACP3\Core\Http\Request
*/
class CookiesParameterBag extends ParameterBag
{
/**
* @param string $key
* @param string $value
* @param int $expire
* @param string $path
* @param string $domain
* @param bool $isSecure
* @param bool $isHttpOnly
*
* @return $this
*/
public function set($key, $value, $expire = 0, $path = '', $domain = '', $isSecure = false, $isHttpOnly = true)
{
setcookie($key, $value, $expire, $path, $domain, $isSecure, $isHttpOnly);
return parent::set($key, $value);
}
}
\ No newline at end of file
<?php
namespace ACP3\Core\http\Request;
namespace ACP3\Core\Http\Request;
/**
* Class ParameterBag
* @package ACP3\Core\http\Request
* @package ACP3\Core\Http\Request
*/
class ParameterBag
{
......
<?php
namespace ACP3\Core\Http\Request;
use ACP3\Core\Lang;
/**
* Class UserAgent
* @package ACP3\Core\Http\Request
*/
class UserAgent
{
/**
* @var \ACP3\Core\Http\Request\ParameterBag
*/
protected $server;
/**
* @param \ACP3\Core\Http\Request\ParameterBag $server
*/
public function __construct(ParameterBag $server)
{
$this->server = $server;
}
/**
* @inheritdoc
* @see http://detectmobilebrowsers.com/download/php
*/
public function isMobileBrowser()
{
$userAgent = $this->server->get('HTTP_USER_AGENT', '');
return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $userAgent) ||
preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($userAgent, 0, 4));
}
/**
* Parst den ACCEPT-LANGUAGE Header des Browsers
* und selektiert die präferierte Sprache
*
* @return string
*/
public function parseAcceptLanguage()
{
$languages = [];
if ($this->server->has('HTTP_ACCEPT_LANGUAGE')) {
$matches = [];
preg_match_all(
'/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
$this->server->get('HTTP_ACCEPT_LANGUAGE'),
$matches
);
if (!empty($matches[1])) {
$languages = array_combine($matches[1], $matches[4]);
// Für Einträge ohne q-Faktor, Wert auf 1 setzen
foreach ($languages as $lang => $val) {
if ($val === '') {
$languages[$lang] = 1;
}
}
// Liste nach Sprachpräferenz sortieren
arsort($languages, SORT_NUMERIC);
}
}
// Über die Sprachen iterieren und das passende Sprachpaket auswählen
foreach ($languages as $lang => $val) {
if (Lang::languagePackExists($lang) === true) {
return $lang;
}
}
return 'en_US';
}
}
\ No newline at end of file
<?php
namespace ACP3\Core\Http;
use ACP3\Core\http\Request\ParameterBag;
/**
* Interface RequestInterface
* @package ACP3\Core\Http
......@@ -23,6 +21,13 @@ interface RequestInterface
*/
public function getHostname();
/**
* Returns the protocol with the hostname
*
* @return string
*/
public function getDomain();
/**
* @return string
*/
......@@ -86,20 +91,12 @@ interface RequestInterface
/**
* @return bool
*/
public function getIsHomepage();
/**
* Gibt zurück, ob der aktuelle User Agent ein mobiler Browser ist, oder nicht.
*
* @return boolean
* @see http://detectmobilebrowsers.com/download/php
*/
public function isMobileBrowser();
public function isHomepage();
/**
* Gibt die URI-Parameter aus
*
* @return ParameterBag
* @return \ACP3\Core\Http\Request\ParameterBag
*/
public function getParameters();
......@@ -113,33 +110,33 @@ interface RequestInterface
/**
* @return bool
*/
public function getIsAjax();
public function isAjax();
/**
* Returns the parameter bag of the $_COOKIE superglobal
*
* @return ParameterBag
* @return \ACP3\Core\Http\Request\CookiesParameterBag
*/
public function getCookie();
public function getCookies();
/**
* Returns the parameter bag of the uploaded files ($_FILES superglobal)
*
* @return \ACP3\Core\http\Request\ParameterBag
* @return \ACP3\Core\Http\Request\FilesParameterBag
*/
public function getFiles();
/**
* Returns the parameter bag of the $_POST superglobal
*
* @return ParameterBag
* @return \ACP3\Core\Http\Request\ParameterBag
*/
public function getPost();
/**
* Returns the parameter bag of the $_SERVER superglobal
*
* @return \ACP3\Core\http\Request\ParameterBag
* @return \ACP3\Core\Http\Request\ParameterBag
*/
public function getServer();
}
\ No newline at end of file
......@@ -68,45 +68,6 @@ class Lang
return !preg_match('=/=', $lang) && is_file(MODULES_DIR . 'ACP3/System/Languages/' . $lang . '.xml') === true;
}
/**
* Parst den ACCEPT-LANGUAGE Header des Browsers
* und selektiert die präferierte Sprache
*
* @return string
*/
final public static function parseAcceptLanguage()
{
$languages = [];
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$matches = [];
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
if (!empty($matches[1])) {
$languages = array_combine($matches[1], $matches[4]);
// Für Einträge ohne q-Faktor, Wert auf 1 setzen
foreach ($languages as $lang => $val) {
if ($val === '') {
$languages[$lang] = 1;
}
}
// Liste nach Sprachpräferenz sortieren
arsort($languages, SORT_NUMERIC);
}
}
// Über die Sprachen iterieren und das passende Sprachpaket auswählen
foreach ($languages as $lang => $val) {
if (self::languagePackExists($lang) === true) {
return $lang;
}
}
return 'en_US';
}
/**
* Gibt die aktuell eingestellte Sprache zurück
*
......
......@@ -68,15 +68,14 @@ abstract class FrontendController extends Core\Modules\Controller
$this->view->assign('PHP_SELF', PHP_SELF);
$this->view->assign('REQUEST_URI', $this->request->getServer()->get('REQUEST_URI'));
$this->view->assign('ROOT_DIR', ROOT_DIR);
$this->view->assign('ROOT_DIR_ABSOLUTE', ROOT_DIR_ABSOLUTE);
$this->view->assign('HOST_NAME', HOST_NAME);
$this->view->assign('HOST_NAME', $this->request->getDomain());
$this->view->assign('ROOT_DIR_ABSOLUTE', $this->request->getDomain() . ROOT_DIR);
$this->view->assign('DESIGN_PATH', DESIGN_PATH);
$this->view->assign('DESIGN_PATH_ABSOLUTE', DESIGN_PATH_ABSOLUTE);
$this->view->assign('UA_IS_MOBILE', $this->request->isMobileBrowser());
$this->view->assign('UA_IS_MOBILE', $this->request->getUserAgent()->isMobileBrowser());
$this->view->assign('IN_ADM', $this->request->getArea() === 'admin');
$this->view->assign('IS_HOMEPAGE', $this->request->getIsHomepage());
$this->view->assign('IS_AJAX', $this->request->getIsAjax());
$this->view->assign('IS_HOMEPAGE', $this->request->isHomepage());
$this->view->assign('IS_AJAX', $this->request->isAjax());
$this->view->assign('LANG_DIRECTION', $this->lang->getDirection());
$this->view->assign('LANG', $this->lang->getLanguage2Characters());
......
......@@ -38,7 +38,7 @@ class Redirect
*/
public function toNewPage($url)
{
if ($this->request->getIsAjax() === true) {
if ($this->request->isAjax() === true) {
$this->_ajax($url);
}
......@@ -67,7 +67,7 @@ class Redirect
{
$path = $this->router->route($path, true);
if ($this->request->getIsAjax() === true) {
if ($this->request->isAjax() === true) {
$this->_ajax($path);
}
......@@ -88,7 +88,7 @@ class Redirect
*/
private function _ajax($path)
{
if ($this->request->getIsAjax() === true) {
if ($this->request->isAjax() === true) {
$return = [
'redirect_url' => $path
];
......
......@@ -205,7 +205,7 @@ class SessionHandler implements \SessionHandlerInterface
$this->resetSessionData();
// Session-Cookie löschen
if ($this->request->getCookie()->has(self::SESSION_NAME)) {
if ($this->request->getCookies()->has(self::SESSION_NAME)) {
setcookie(self::SESSION_NAME, '', time() - 3600, ROOT_DIR);
}
......
......@@ -55,7 +55,7 @@ class MoveToBottom extends AbstractFilter
$tpl_output = preg_replace($pattern, '', $tpl_output);
$minifyJs = '';
if (!$this->request->getIsAjax()) {
if (!$this->request->isAjax()) {
$minifyJs = '<script type="text/javascript" src="' . $this->minifier->getURI() . '"></script>' . "\n";
}
......
......@@ -56,7 +56,7 @@ class PageCssClasses extends AbstractFilter
if ($this->request->getArea() === 'admin') {
$pieces[] = 'in-admin';
} elseif ($this->request->getIsHomepage() === true) {
} elseif ($this->request->isHomepage() === true) {
$pieces[] = 'is-homepage';
} else {
$pieces[] = $this->pageCssClasses->getDetails();
......
......@@ -54,4 +54,4 @@ services:
core.helpers.formatter.rewriteInternalUri:
class: ACP3\Core\Helpers\Formatter\RewriteInternalUri
arguments: [@core.modules.controllerActionsExists, '@core.router', '@core.validator.rules.router.aliases']
arguments: [@core.modules.controllerActionsExists, @core.request, '@core.router', '@core.validator.rules.router.aliases']
......@@ -90,7 +90,7 @@ class Helpers
->setBcc($bcc)
->setFrom($from)
->setSubject($newsletter['title'])
->setUrlWeb(HOST_NAME . $this->router->route('newsletter/archive/details/id_' . $newsletterId))
->setUrlWeb($this->router->route('newsletter/archive/details/id_' . $newsletterId, true))
->setMailSignature($settings['mailsig']);
if ($newsletter['html'] == 1) {
......
......@@ -175,7 +175,7 @@ class Account extends Core\Modules\FrontendController
$bool = $this->usersModel->update($updateValues, $this->auth->getUserId());
$user = $this->usersModel->getOneById($this->auth->getUserId());
$this->auth->setCookie(
$this->auth->setRememberMeCookie(
$this->auth->getUserId(),
$user['remember_me_token'],
Core\Auth::REMEMBER_ME_COOKIE_LIFETIME
......
......@@ -343,9 +343,9 @@ class Index extends Core\Modules\AdminController
$bool = $this->usersModel->update($updateValues, $id);
// Falls sich der User selbst bearbeitet hat, Cookie aktualisieren
if ($id == $this->auth->getUserId() && $this->request->getCookie()->has(Core\Auth::AUTH_NAME)) {
if ($id == $this->auth->getUserId() && $this->request->getCookies()->has(Core\Auth::AUTH_NAME)) {
$user = $this->usersModel->getOneById($id);
$this->auth->setCookie(
$this->auth->setRememberMeCookie(
$id,
$user['remember_me_token'],
Core\Auth::REMEMBER_ME_COOKIE_LIFETIME
......
......@@ -37,7 +37,7 @@ class Alerts extends \ACP3\Core\Helpers\Alerts
$this->view->assign('error_box', ['non_integer_keys' => $hasNonIntegerKeys, 'errors' => $errors]);
$content = $this->view->fetchTemplate('error_box.tpl');
if ($this->request->getIsAjax() === true) {
if ($this->request->isAjax() === true) {
$return = [
'success' => false,
'content' => $content,
......
......@@ -91,7 +91,7 @@ class Controller implements ControllerInterface
$this->view->assign('ROOT_DIR', ROOT_DIR);