dropped Pimple Dipendency Injector in favor of a Registry

parent c32441ba
......@@ -10,13 +10,6 @@ namespace ACP3;
class CMS {
/**
* Pimple Dependency Injector
*
* @var \ACP3\Core\Pimple
*/
public static $injector;
/**
* Führt alle nötigen Schritte aus, um die Seite anzuzeigen
*/
......@@ -81,10 +74,10 @@ class CMS {
*/
public static function checkForMaintenanceMode() {
if ((bool) CONFIG_MAINTENANCE_MODE === true &&
(defined('IN_ADM') === false && strpos(self::$injector['URI']->query, 'users/login/') !== 0)) {
self::$injector['View']->assign('PAGE_TITLE', CONFIG_SEO_TITLE);
self::$injector['View']->assign('CONTENT', CONFIG_MAINTENANCE_MESSAGE);
self::$injector['View']->displayTemplate('system/maintenance.tpl');
(defined('IN_ADM') === false && strpos(Registry::getClass('URI')->query, 'users/login/') !== 0)) {
Registry::get('View')->assign('PAGE_TITLE', CONFIG_SEO_TITLE);
Registry::getClass('View')->assign('CONTENT', CONFIG_MAINTENANCE_MESSAGE);
Registry::getClass('View')->displayTemplate('system/maintenance.tpl');
exit;
}
}
......@@ -93,9 +86,6 @@ class CMS {
* Initialisieren der anderen Klassen
*/
public static function initializeClasses() {
// DI
self::$injector = new Core\Pimple();
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => CONFIG_DB_NAME,
......@@ -105,7 +95,7 @@ class CMS {
'driver' => 'pdo_mysql',
'charset' => 'utf8'
);
self::$injector['Db'] = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
Core\Registry::set('Db', \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config));
define('DB_PRE', CONFIG_DB_PRE);
// Sytemeinstellungen laden
......@@ -120,53 +110,56 @@ class CMS {
foreach ($classes as $class) {
$className = "\\ACP3\\Core\\" . $class;
self::$injector[$class] = new $className();
Core\Registry::set($class, new $className());
}
Core\View::factory('Smarty');
Core\ACL::initialize(self::$injector['Auth']->getUserId());
Core\ACL::initialize(Core\Registry::get('Auth')->getUserId());
}
/**
* Gibt die Seite aus
*/
public static function outputPage() {
$view = Core\Registry::get('View');
$uri = Core\Registry::get('URI');
// Einige Template Variablen setzen
self::$injector['View']->assign('PHP_SELF', PHP_SELF);
self::$injector['View']->assign('REQUEST_URI', htmlentities($_SERVER['REQUEST_URI']));
self::$injector['View']->assign('ROOT_DIR', ROOT_DIR);
self::$injector['View']->assign('DESIGN_PATH', DESIGN_PATH);
self::$injector['View']->assign('UA_IS_MOBILE', Core\Functions::isMobileBrowser());
self::$injector['View']->assign('IN_ADM', defined('IN_ADM') ? true : false);
$view->assign('PHP_SELF', PHP_SELF);
$view->assign('REQUEST_URI', htmlentities($_SERVER['REQUEST_URI']));
$view->assign('ROOT_DIR', ROOT_DIR);
$view->assign('DESIGN_PATH', DESIGN_PATH);
$view->assign('UA_IS_MOBILE', Core\Functions::isMobileBrowser());
$view->assign('IN_ADM', defined('IN_ADM') ? true : false);
$lang_info = Core\XML::parseXmlFile(ACP3_ROOT_DIR . 'languages/' . self::$injector['Lang']->getLanguage() . '/info.xml', '/language');
self::$injector['View']->assign('LANG_DIRECTION', isset($lang_info['direction']) ? $lang_info['direction'] : 'ltr');
self::$injector['View']->assign('LANG', CONFIG_LANG);
$lang_info = Core\XML::parseXmlFile(ACP3_ROOT_DIR . 'languages/' . Core\Registry::get('Lang')->getLanguage() . '/info.xml', '/language');
$view->assign('LANG_DIRECTION', isset($lang_info['direction']) ? $lang_info['direction'] : 'ltr');
$view->assign('LANG', CONFIG_LANG);
self::checkForMaintenanceMode();
// Aktuelle Datensatzposition bestimmen
if (Core\Validate::isNumber(self::$injector['URI']->page) && self::$injector['URI']->page >= 1)
define('POS', (int) (self::$injector['URI']->page - 1) * self::$injector['Auth']->entries);
if (Core\Validate::isNumber($uri->page) && $uri->page >= 1)
define('POS', (int) ($uri->page - 1) * Core\Registry::get('Auth')->entries);
else
define('POS', 0);
if (defined('IN_ADM') === true && self::$injector['Auth']->isUser() === false && self::$injector['URI']->query !== 'users/login/') {
$redirect_uri = base64_encode('acp/' . self::$injector['URI']->query);
self::$injector['URI']->redirect('users/login/redirect_' . $redirect_uri);
if (defined('IN_ADM') === true && Core\Registry::get('Auth')->isUser() === false && $uri->query !== 'users/login/') {
$redirect_uri = base64_encode('acp/' . $uri->query);
$uri->redirect('users/login/redirect_' . $redirect_uri);
}
if (Core\Modules::check(self::$injector['URI']->mod, self::$injector['URI']->file) === true) {
$module = ucfirst(self::$injector['URI']->mod);
if (Core\Modules::check($uri->mod, $uri->file) === true) {
$module = ucfirst($uri->mod);
$section = defined('IN_ADM') === true ? 'Admin' : 'Frontend';
$className = "\\ACP3\\Modules\\" . $module . "\\" . $module . $section;
$action = 'action' . ucfirst(defined('IN_ADM') === true ? substr(self::$injector['URI']->file, 4) : self::$injector['URI']->file);
$action = 'action' . ucfirst(defined('IN_ADM') === true ? substr($uri->file, 4) : $uri->file);
// Modul einbinden
$mod = new $className(self::$injector);
$mod = new $className();
$mod->$action();
$mod->display();
} else {
self::$injector['URI']->redirect('errors/404');
$uri->redirect('errors/404');
}
}
......
......@@ -62,7 +62,7 @@ class ACL
*/
public static function setResourcesCache()
{
$resources = \ACP3\CMS::$injector['Db']->fetchAll('SELECT r.id AS resource_id, r.module_id, m.name AS module, r.page, r.params, r.privilege_id, p.key FROM ' . DB_PRE . 'acl_resources AS r JOIN ' . DB_PRE . 'acl_privileges AS p ON(r.privilege_id = p.id) JOIN ' . DB_PRE . 'modules AS m ON(r.module_id = m.id) WHERE m.active = 1 ORDER BY r.module_id ASC, r.page ASC');
$resources = Registry::get('Db')->fetchAll('SELECT r.id AS resource_id, r.module_id, m.name AS module, r.page, r.params, r.privilege_id, p.key FROM ' . DB_PRE . 'acl_resources AS r JOIN ' . DB_PRE . 'acl_privileges AS p ON(r.privilege_id = p.id) JOIN ' . DB_PRE . 'modules AS m ON(r.module_id = m.id) WHERE m.active = 1 ORDER BY r.module_id ASC, r.page ASC');
$c_resources = count($resources);
$data = array();
......@@ -103,7 +103,7 @@ class ACL
$user_id = $user_id === 0 ? self::$userId : $user_id;
$field = $mode === 2 ? 'r.name' : 'r.id';
$key = substr($field, 2);
$user_roles = \ACP3\CMS::$injector['Db']->fetchAll('SELECT ' . $field . ' FROM ' . DB_PRE . 'acl_user_roles AS ur JOIN ' . DB_PRE . 'acl_roles AS r ON(ur.role_id = r.id) WHERE ur.user_id = ? ORDER BY r.left_id DESC', array($user_id), array(\PDO::PARAM_INT));
$user_roles = Registry::get('Db')->fetchAll('SELECT ' . $field . ' FROM ' . DB_PRE . 'acl_user_roles AS ur JOIN ' . DB_PRE . 'acl_roles AS r ON(ur.role_id = r.id) WHERE ur.user_id = ? ORDER BY r.left_id DESC', array($user_id), array(\PDO::PARAM_INT));
$c_user_roles = count($user_roles);
$roles = array();
......@@ -119,7 +119,7 @@ class ACL
*/
public static function setRolesCache()
{
$roles = \ACP3\CMS::$injector['Db']->fetchAll('SELECT n.id, n.name, n.parent_id, n.left_id, n.right_id, COUNT(*)-1 AS level, ROUND((n.right_id - n.left_id - 1) / 2) AS children FROM ' . DB_PRE . 'acl_roles AS p, ' . DB_PRE . 'acl_roles AS n WHERE n.left_id BETWEEN p.left_id AND p.right_id GROUP BY n.left_id ORDER BY n.left_id');
$roles = Registry::get('Db')->fetchAll('SELECT n.id, n.name, n.parent_id, n.left_id, n.right_id, COUNT(*)-1 AS level, ROUND((n.right_id - n.left_id - 1) / 2) AS children FROM ' . DB_PRE . 'acl_roles AS p, ' . DB_PRE . 'acl_roles AS n WHERE n.left_id BETWEEN p.left_id AND p.right_id GROUP BY n.left_id ORDER BY n.left_id');
$c_roles = count($roles);
for ($i = 0; $i < $c_roles; ++$i) {
......@@ -159,7 +159,7 @@ class ACL
public static function setRulesCache(array $roles)
{
// Berechtigungen einlesen, auf die der Benutzer laut seinen Rollen Zugriff hat
$rules = \ACP3\CMS::$injector['Db']->executeQuery('SELECT ru.role_id, ru.privilege_id, ru.permission, ru.module_id, m.name AS module_name, p.key, p.description FROM ' . DB_PRE . 'acl_rules AS ru JOIN ' . DB_PRE . 'modules AS m ON (ru.module_id = m.id) JOIN ' . DB_PRE . 'acl_privileges AS p ON(ru.privilege_id = p.id) WHERE ru.role_id IN(?)',
$rules = Registry::get('Db')->executeQuery('SELECT ru.role_id, ru.privilege_id, ru.permission, ru.module_id, m.name AS module_name, p.key, p.description FROM ' . DB_PRE . 'acl_rules AS ru JOIN ' . DB_PRE . 'modules AS m ON (ru.module_id = m.id) JOIN ' . DB_PRE . 'acl_privileges AS p ON(ru.privilege_id = p.id) WHERE ru.role_id IN(?)',
array($roles), array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY))->fetchAll();
$c_rules = count($rules);
$privileges = array();
......@@ -195,7 +195,7 @@ class ACL
*/
public static function getAllPrivileges()
{
$privileges = \ACP3\CMS::$injector['Db']->fetchAll('SELECT id, `key`, description FROM ' . DB_PRE . 'acl_privileges ORDER BY `key` ASC');
$privileges = Registry::get('Db')->fetchAll('SELECT id, `key`, description FROM ' . DB_PRE . 'acl_privileges ORDER BY `key` ASC');
return $privileges;
}
/**
......@@ -209,7 +209,7 @@ class ACL
*/
private static function getPermissionValue($key, $role_id)
{
$value = \ACP3\CMS::$injector['Db']->fetchAssoc('SELECT ru.permission FROM ' . DB_PRE . 'acl_roles AS r, ' . DB_PRE . 'acl_roles AS parent JOIN ' . DB_PRE . 'acl_rules AS ru ON(parent.id = ru.role_id) JOIN ' . DB_PRE . 'acl_privileges AS p ON(ru.privilege_id = p.id) WHERE r.id = ? AND p.key = ? AND ru.permission != 2 AND parent.left_id < r.left_id AND parent.right_id > r.right_id ORDER BY parent.left_id DESC LIMIT 1', array($role_id, $key));
$value = Registry::get('Db')->fetchAssoc('SELECT ru.permission FROM ' . DB_PRE . 'acl_roles AS r, ' . DB_PRE . 'acl_roles AS parent JOIN ' . DB_PRE . 'acl_rules AS ru ON(parent.id = ru.role_id) JOIN ' . DB_PRE . 'acl_privileges AS p ON(ru.privilege_id = p.id) WHERE r.id = ? AND p.key = ? AND ru.permission != 2 AND parent.left_id < r.left_id AND parent.right_id > r.right_id ORDER BY parent.left_id DESC LIMIT 1', array($role_id, $key));
return isset($value['permission']) ? $value['permission'] : 0;
}
/**
......
......@@ -62,7 +62,7 @@ class Auth
$cookie = base64_decode($_COOKIE[self::COOKIE_NAME]);
$cookie_arr = explode('|', $cookie);
$user = \ACP3\CMS::$injector['Db']->executeQuery('SELECT id, super_user, pwd, entries, language FROM ' . DB_PRE . 'users WHERE nickname = ? AND login_errors < 3', array($cookie_arr[0]))->fetchAll();
$user = Registry::get('Db')->executeQuery('SELECT id, super_user, pwd, entries, language FROM ' . DB_PRE . 'users WHERE nickname = ? AND login_errors < 3', array($cookie_arr[0]))->fetchAll();
if (count($user) === 1) {
$db_password = substr($user[0]['pwd'], 0, 40);
if ($db_password === $cookie_arr[1]) {
......@@ -103,7 +103,7 @@ class Auth
if (empty($user_info[$user_id])) {
$countries = Lang::worldCountries();
$info = \ACP3\CMS::$injector['Db']->fetchAssoc('SELECT * FROM ' . DB_PRE . 'users WHERE id = ?', array($user_id), array(\PDO::PARAM_INT));
$info = Registry::get('Db')->fetchAssoc('SELECT * FROM ' . DB_PRE . 'users WHERE id = ?', array($user_id), array(\PDO::PARAM_INT));
if (!empty($info)) {
$info['country_formatted'] = !empty($info['country']) && isset($countries[$info['country']]) ? $countries[$info['country']] : '';
$user_info[$user_id] = $info;
......@@ -154,7 +154,7 @@ class Auth
*/
public function login($username, $password, $expiry)
{
$user = \ACP3\CMS::$injector['Db']->fetchAssoc('SELECT id, pwd, login_errors FROM ' . DB_PRE . 'users WHERE nickname = ?', array($username));
$user = Registry::get('Db')->fetchAssoc('SELECT id, pwd, login_errors FROM ' . DB_PRE . 'users WHERE nickname = ?', array($username));
if (!empty($user)) {
// Useraccount ist gesperrt
......@@ -172,7 +172,7 @@ class Auth
if ($db_hash === $form_pwd_hash) {
// Login-Fehler zurücksetzen
if ($user['login_errors'] > 0)
\ACP3\CMS::$injector['Db']->update(DB_PRE . 'users', array('login_errors' => 0), array('id', (int) $user['id']));
Registry::get('Db')->update(DB_PRE . 'users', array('login_errors' => 0), array('id', (int) $user['id']));
$this->setCookie($username, $db_hash, $expiry);
......@@ -186,7 +186,7 @@ class Auth
// Beim dritten falschen Login den Account sperren
} else {
$login_errors = $user['login_errors'] + 1;
\ACP3\CMS::$injector['Db']->update(DB_PRE . 'users', array('login_errors' => $login_errors), array('id' => (int) $user['id']));
Registry::get('Db')->update(DB_PRE . 'users', array('login_errors' => $login_errors), array('id' => (int) $user['id']));
if ($login_errors === 3) {
return -1;
}
......@@ -201,7 +201,7 @@ class Auth
*/
public function logout()
{
\ACP3\CMS::$injector['Session']->session_destroy(session_id());
Registry::get('Session')->session_destroy(session_id());
return $this->setCookie('', '', -50400);
}
/**
......
......@@ -52,9 +52,9 @@ class Breadcrumb {
{
// Frontendbereich
if (defined('IN_ADM') === false) {
$uri = \ACP3\CMS::$injector['URI'];
$uri = Registry::get('URI');
$in = array($uri->query, $uri->getCleanQuery(), $uri->mod . '/' . $uri->file . '/', $uri->mod);
$items = \ACP3\CMS::$injector['Db']->executeQuery('SELECT p.title, p.uri, p.left_id, p.right_id FROM ' . DB_PRE . 'menu_items AS c, ' . DB_PRE . 'menu_items AS p WHERE c.left_id BETWEEN p.left_id AND p.right_id AND c.uri IN(?) GROUP BY p.uri ORDER BY p.left_id ASC', array($in), array(\Doctrine\DBAL\Connection::PARAM_STR_ARRAY))->fetchAll();
$items = Registry::get('Db')->executeQuery('SELECT p.title, p.uri, p.left_id, p.right_id FROM ' . DB_PRE . 'menu_items AS c, ' . DB_PRE . 'menu_items AS p WHERE c.left_id BETWEEN p.left_id AND p.right_id AND c.uri IN(?) GROUP BY p.uri ORDER BY p.left_id ASC', array($in), array(\Doctrine\DBAL\Connection::PARAM_STR_ARRAY))->fetchAll();
$c_items = count($items);
// Dynamische Seite (ACP3 intern)
......@@ -189,39 +189,39 @@ class Breadcrumb {
*/
public function output($mode = 1)
{
$module = \ACP3\CMS::$injector['URI']->mod;
$file = \ACP3\CMS::$injector['URI']->file;
$module = Registry::get('URI')->mod;
$file = Registry::get('URI')->file;
if (empty($this->breadcrumb_cache)) {
// Brotkrümelspur für das Admin-Panel
if (defined('IN_ADM') === true) {
if ($module !== 'acp')
$this->setTitlePostfix(\ACP3\CMS::$injector['Lang']->t('system', 'acp'));
$this->setTitlePostfix(Registry::get('Lang')->t('system', 'acp'));
// Wenn noch keine Brotkrümelspur gesetzt ist, dies nun tun
if (empty($this->steps_mods)) {
$this->append(\ACP3\CMS::$injector['Lang']->t('system', 'acp'), \ACP3\CMS::$injector['URI']->route('acp'));
$this->append(Registry::get('Lang')->t('system', 'acp'), Registry::get('URI')->route('acp'));
if ($module !== 'errors') {
if ($module !== 'acp') {
$this->append(\ACP3\CMS::$injector['Lang']->t($module, $module), \ACP3\CMS::$injector['URI']->route('acp/' . $module));
$this->append(Registry::get('Lang')->t($module, $module), Registry::get('URI')->route('acp/' . $module));
if ($file !== 'acp_list')
$this->append(\ACP3\CMS::$injector['Lang']->t($module, $file), \ACP3\CMS::$injector['URI']->route('acp/' . $module . '/' . $file));
$this->append(Registry::get('Lang')->t($module, $file), Registry::get('URI')->route('acp/' . $module . '/' . $file));
}
} else {
$this->append(\ACP3\CMS::$injector['Lang']->t($module, $file), \ACP3\CMS::$injector['URI']->route('acp/' . $module . '/' . $file));
$this->append(Registry::get('Lang')->t($module, $file), Registry::get('URI')->route('acp/' . $module . '/' . $file));
}
// Falls bereits Stufen gesetzt wurden, Links für das Admin-Panel und
// die Modulverwaltung in umgedrehter Reihenfolge voranstellen
} else {
if ($module !== 'acp')
$this->prepend(\ACP3\CMS::$injector['Lang']->t($module, $module), \ACP3\CMS::$injector['URI']->route('acp/' . $module));
$this->prepend(\ACP3\CMS::$injector['Lang']->t('system', 'acp'), \ACP3\CMS::$injector['URI']->route('acp'));
$this->prepend(Registry::get('Lang')->t($module, $module), Registry::get('URI')->route('acp/' . $module));
$this->prepend(Registry::get('Lang')->t('system', 'acp'), Registry::get('URI')->route('acp'));
}
$this->breadcrumb_cache = $this->steps_mods;
// Brotkrümelspur für das Frontend
} else {
if (empty($this->steps_db) && empty($this->steps_mods)) {
$this->append($file === 'list' ? \ACP3\CMS::$injector['Lang']->t($module, $module) : \ACP3\CMS::$injector['Lang']->t($module, $file), \ACP3\CMS::$injector['URI']->route($module . '/' . $file));
$this->append($file === 'list' ? Registry::get('Lang')->t($module, $module) : Registry::get('Lang')->t($module, $file), Registry::get('URI')->route($module . '/' . $file));
$this->breadcrumb_cache = $this->steps_mods;
} elseif (!empty($this->steps_db) && empty($this->steps_mods)) {
$this->breadcrumb_cache = $this->steps_db;
......@@ -245,8 +245,8 @@ class Breadcrumb {
// Brotkrümelspur ausgeben
if ($mode === 1) {
\ACP3\CMS::$injector['View']->assign('breadcrumb', $this->breadcrumb_cache);
return \ACP3\CMS::$injector['View']->fetchTemplate('system/breadcrumb.tpl');
Registry::get('View')->assign('breadcrumb', $this->breadcrumb_cache);
return Registry::get('View')->fetchTemplate('system/breadcrumb.tpl');
// Nur Titel ausgeben
} else {
// Letzter Eintrag der Brotkrümelspur ist der Seitentitel
......
......@@ -40,10 +40,10 @@ class Config
public static function setSettings($module, $data)
{
$bool = $bool2 = false;
$mod_id = \ACP3\CMS::$injector['Db']->fetchColumn('SELECT id FROM ' . DB_PRE . 'modules WHERE name = ?', array($module));
$mod_id = Registry::get('Db')->fetchColumn('SELECT id FROM ' . DB_PRE . 'modules WHERE name = ?', array($module));
if (!empty($mod_id)) {
foreach ($data as $key => $value) {
$bool = \ACP3\CMS::$injector['Db']->executeUpdate('UPDATE ' . DB_PRE . 'settings SET value = ? WHERE module_id = ? AND name = ?', array($value, (int) $mod_id, $key));
$bool = Registry::get('Db')->executeUpdate('UPDATE ' . DB_PRE . 'settings SET value = ? WHERE module_id = ? AND name = ?', array($value, (int) $mod_id, $key));
}
$bool2 = self::setModuleCache($module);
}
......@@ -71,7 +71,7 @@ class Config
*/
private static function setModuleCache($module)
{
$settings = \ACP3\CMS::$injector['Db']->executeQuery('SELECT s.name, s.value FROM ' . DB_PRE . 'settings AS s JOIN ' . DB_PRE . 'modules AS m ON(m.id = s.module_id) WHERE m.name = ?', array($module))->fetchAll();
$settings = Registry::get('Db')->executeQuery('SELECT s.name, s.value FROM ' . DB_PRE . 'settings AS s JOIN ' . DB_PRE . 'modules AS m ON(m.id = s.module_id) WHERE m.name = ?', array($module))->fetchAll();
$c_settings = count($settings);
$cache_ary = array();
......
......@@ -46,7 +46,7 @@ class Date {
*/
function __construct()
{
$info = \ACP3\CMS::$injector['Auth']->getUserInfo();
$info = Registry::get('Auth')->getUserInfo();
if (!empty($info)) {
$this->date_format_long = $info['date_format_long'];
......@@ -71,10 +71,10 @@ class Date {
$dateformat = array();
$dateformat[0]['value'] = 'short';
$dateformat[0]['selected'] = Functions::selectEntry('dateformat', 'short', $format);
$dateformat[0]['lang'] = \ACP3\CMS::$injector['Lang']->t('system', 'date_format_short');
$dateformat[0]['lang'] = Registry::get('Lang')->t('system', 'date_format_short');
$dateformat[1]['value'] = 'long';
$dateformat[1]['selected'] = Functions::selectEntry('dateformat', 'long', $format);
$dateformat[1]['lang'] = \ACP3\CMS::$injector['Lang']->t('system', 'date_format_long');
$dateformat[1]['lang'] = Registry::get('Lang')->t('system', 'date_format_long');
return $dateformat;
}
......@@ -159,9 +159,9 @@ class Date {
$datepicker['value'] = $value;
}
\ACP3\CMS::$injector['View']->assign('datepicker', $datepicker);
Registry::get('View')->assign('datepicker', $datepicker);
return \ACP3\CMS::$injector['View']->fetchTemplate('system/date.tpl');
return Registry::get('View')->fetchTemplate('system/date.tpl');
}
/**
......@@ -218,62 +218,62 @@ class Date {
private function localizeDaysAbbr()
{
return array(
'Mon' => \ACP3\CMS::$injector['Lang']->t('system', 'date_mon'),
'Tue' => \ACP3\CMS::$injector['Lang']->t('system', 'date_tue'),
'Wed' => \ACP3\CMS::$injector['Lang']->t('system', 'date_wed'),
'Thu' => \ACP3\CMS::$injector['Lang']->t('system', 'date_thu'),
'Fri' => \ACP3\CMS::$injector['Lang']->t('system', 'date_fri'),
'Sat' => \ACP3\CMS::$injector['Lang']->t('system', 'date_sat'),
'Sun' => \ACP3\CMS::$injector['Lang']->t('system', 'date_sun')
'Mon' => Registry::get('Lang')->t('system', 'date_mon'),
'Tue' => Registry::get('Lang')->t('system', 'date_tue'),
'Wed' => Registry::get('Lang')->t('system', 'date_wed'),
'Thu' => Registry::get('Lang')->t('system', 'date_thu'),
'Fri' => Registry::get('Lang')->t('system', 'date_fri'),
'Sat' => Registry::get('Lang')->t('system', 'date_sat'),
'Sun' => Registry::get('Lang')->t('system', 'date_sun')
);
}
private function localizeDays()
{
return array(
'Monday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_monday'),
'Tuesday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_tuesday'),
'Wednesday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_wednesday'),
'Thursday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_thursday'),
'Friday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_friday'),
'Saturday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_saturday'),
'Sunday' => \ACP3\CMS::$injector['Lang']->t('system', 'date_sunday')
'Monday' => Registry::get('Lang')->t('system', 'date_monday'),
'Tuesday' => Registry::get('Lang')->t('system', 'date_tuesday'),
'Wednesday' => Registry::get('Lang')->t('system', 'date_wednesday'),
'Thursday' => Registry::get('Lang')->t('system', 'date_thursday'),
'Friday' => Registry::get('Lang')->t('system', 'date_friday'),
'Saturday' => Registry::get('Lang')->t('system', 'date_saturday'),
'Sunday' => Registry::get('Lang')->t('system', 'date_sunday')
);
}
private function localizeMonths()
{
return array(
'January' => \ACP3\CMS::$injector['Lang']->t('system', 'date_january'),
'February' => \ACP3\CMS::$injector['Lang']->t('system', 'date_february'),
'March' => \ACP3\CMS::$injector['Lang']->t('system', 'date_march'),
'April' => \ACP3\CMS::$injector['Lang']->t('system', 'date_april'),
'May' => \ACP3\CMS::$injector['Lang']->t('system', 'date_may_full'),
'June' => \ACP3\CMS::$injector['Lang']->t('system', 'date_june'),
'July' => \ACP3\CMS::$injector['Lang']->t('system', 'date_july'),
'August' => \ACP3\CMS::$injector['Lang']->t('system', 'date_august'),
'September' => \ACP3\CMS::$injector['Lang']->t('system', 'date_september'),
'October' => \ACP3\CMS::$injector['Lang']->t('system', 'date_october'),
'November' => \ACP3\CMS::$injector['Lang']->t('system', 'date_november'),
'December' => \ACP3\CMS::$injector['Lang']->t('system', 'date_december')
'January' => Registry::get('Lang')->t('system', 'date_january'),
'February' => Registry::get('Lang')->t('system', 'date_february'),
'March' => Registry::get('Lang')->t('system', 'date_march'),
'April' => Registry::get('Lang')->t('system', 'date_april'),
'May' => Registry::get('Lang')->t('system', 'date_may_full'),
'June' => Registry::get('Lang')->t('system', 'date_june'),
'July' => Registry::get('Lang')->t('system', 'date_july'),
'August' => Registry::get('Lang')->t('system', 'date_august'),
'September' => Registry::get('Lang')->t('system', 'date_september'),
'October' => Registry::get('Lang')->t('system', 'date_october'),
'November' => Registry::get('Lang')->t('system', 'date_november'),
'December' => Registry::get('Lang')->t('system', 'date_december')
);
}
private function localizeMonthsAbbr()
{
return array(
'Jan' => \ACP3\CMS::$injector['Lang']->t('system', 'date_jan'),
'Feb' => \ACP3\CMS::$injector['Lang']->t('system', 'date_feb'),
'Mar' => \ACP3\CMS::$injector['Lang']->t('system', 'date_mar'),
'Apr' => \ACP3\CMS::$injector['Lang']->t('system', 'date_apr'),
'May' => \ACP3\CMS::$injector['Lang']->t('system', 'date_may_abbr'),
'Jun' => \ACP3\CMS::$injector['Lang']->t('system', 'date_jun'),
'Jul' => \ACP3\CMS::$injector['Lang']->t('system', 'date_jul'),
'Aug' => \ACP3\CMS::$injector['Lang']->t('system', 'date_aug'),
'Sep' => \ACP3\CMS::$injector['Lang']->t('system', 'date_sep'),
'Oct' => \ACP3\CMS::$injector['Lang']->t('system', 'date_oct'),
'Nov' => \ACP3\CMS::$injector['Lang']->t('system', 'date_nov'),
'Dec' => \ACP3\CMS::$injector['Lang']->t('system', 'date_dec')
'Jan' => Registry::get('Lang')->t('system', 'date_jan'),
'Feb' => Registry::get('Lang')->t('system', 'date_feb'),
'Mar' => Registry::get('Lang')->t('system', 'date_mar'),
'Apr' => Registry::get('Lang')->t('system', 'date_apr'),
'May' => Registry::get('Lang')->t('system', 'date_may_abbr'),
'Jun' => Registry::get('Lang')->t('system', 'date_jun'),
'Jul' => Registry::get('Lang')->t('system', 'date_jul'),
'Aug' => Registry::get('Lang')->t('system', 'date_aug'),
'Sep' => Registry::get('Lang')->t('system', 'date_sep'),
'Oct' => Registry::get('Lang')->t('system', 'date_oct'),
'Nov' => Registry::get('Lang')->t('system', 'date_nov'),
'Dec' => Registry::get('Lang')->t('system', 'date_dec')
);
}
......@@ -322,10 +322,10 @@ class Date {
{
$datetime_format = 'Y-m-d H:i';
if ($end === '' || $start >= $end) {
$title = $end === '' ? $this->format($start, $format) : sprintf(\ACP3\CMS::$injector['Lang']->t('system', 'date_published_since'), $this->format($start, $format));
$title = $end === '' ? $this->format($start, $format) : sprintf(Registry::get('Lang')->t('system', 'date_published_since'), $this->format($start, $format));
return '<time datetime="' . $start . '" title="' . $title . '">' . $this->format($start, $datetime_format) . '</time>';
} else {
$title = sprintf(\ACP3\CMS::$injector['Lang']->t('system', 'date_time_range'), $this->format($start, $format), $this->format($end, $format));
$title = sprintf(Registry::get('Lang')->t('system', 'date_time_range'), $this->format($start, $format), $this->format($end, $format));
return '<time datetime="' . $start . '/' . $end . '" title="' . $title . '">' . $this->format($start, $datetime_format) . '&ndash;' . $this->format($end, $datetime_format) . '</time>';
}
}
......
This diff is collapsed.
......@@ -35,7 +35,7 @@ class Lang
function __construct()
{
$lang = \ACP3\CMS::$injector['Auth']->getUserLanguage();
$lang = Registry::get('Auth')->getUserLanguage();
$this->lang = $this->languagePackExists($lang) === true ? $lang : CONFIG_LANG;
}
......
......@@ -9,45 +9,39 @@ namespace ACP3\Core;
*/
abstract class ModuleController {
protected $injector;
public function __construct(Pimple $injector)
{
$this->injector = $injector;
}
public function display()
{
$view = Registry::get('View');
// Content-Template automatisch setzen
if ($this->injector['View']->getContentTemplate() === '') {
$this->injector['View']->setContentTemplate($this->injector['URI']->mod . '/' . $this->injector['URI']->file . '.tpl');
if ($view->getContentTemplate() === '') {
$view->setContentTemplate(Registry::get('URI')->mod . '/' . Registry::get('URI')->file . '.tpl');
}
if ($this->injector['View']->getNoOutput() === false) {
if ($this->injector['View']->getContent() === '') {
$this->injector['View']->setContent($this->injector['View']->fetchTemplate($this->injector['View']->getContentTemplate()));
if ($view->getNoOutput() === false) {
if ($view->getContent() === '') {
$view->setContent($view->fetchTemplate($view->getContentTemplate()));
}
// Evtl. gesetzten Content-Type des Servers überschreiben
header($this->injector['View']->getContentType());
if ($this->injector['View']->getLayout() !== '') {
$this->injector['View']->assign('PAGE_TITLE', CONFIG_SEO_TITLE);
$this->injector['View']->assign('HEAD_TITLE', $this->injector['Breadcrumb']->output(3));
$this->injector['View']->assign('TITLE', $this->injector['Breadcrumb']->output(2));
$this->injector['View']->assign('BREADCRUMB', $this->injector['Breadcrumb']->output());
$this->injector['View']->assign('META', SEO::getMetaTags());
$this->injector['View']->assign('CONTENT', $this->injector['View']->getContent() . $this->injector['View']->getContentAppend());
$minify = $this->injector['View']->buildMinifyLink();
$file = $this->injector['View']->getLayout();
header($view->getContentType());
if ($view->getLayout() !== '') {
$view->assign('PAGE_TITLE', CONFIG_SEO_TITLE);
$view->assign('HEAD_TITLE', Registry::get('Breadcrumb')->output(3));
$view->assign('TITLE', Registry::get('Breadcrumb')->output(2));
$view->assign('BREADCRUMB', Registry::get('Breadcrumb')->output());
$view->assign('META', SEO::getMetaTags());
$view->assign('CONTENT', $view->getContent() . $view->getContentAppend());
$minify = $view->buildMinifyLink();
$file = $view->getLayout();
$layout = substr($file, 0, strpos($file, '.'));
$this->injector['View']->assign('MIN_STYLESHEET', sprintf($minify, 'css') . ($layout !== 'layout' ? '&amp;layout=' . $layout : ''));
$this->injector['View']->assign('MIN_JAVASCRIPT', sprintf($minify, 'js'));
$view->assign('MIN_STYLESHEET', sprintf($minify, 'css') . ($layout !== 'layout' ? '&amp;layout=' . $layout : ''));
$view->assign('MIN_JAVASCRIPT', sprintf($minify, 'js'));
$this->injector['View']->displayTemplate($file);
$view->displayTemplate($file);
} else {
echo $this->injector['View']->getContent();
echo $view->getContent();
}
}
}
......
......@@ -19,8 +19,6 @@ namespace ACP3\Core;
*/
abstract class ModuleInstaller {
protected static $injector;
/**
* Die bei der Installation an das Modul zugewiesene ID
*
......@@ -36,10 +34,6 @@ abstract class ModuleInstaller {
*/
protected $special_resources = array();
public function __construct(Pimple $injector) {
self::$injector = $injector;
}
public static function buildClassName($module) {
$mod_name = preg_replace('/(\s+)/', '', ucwords(strtolower(str_replace('_', ' ', $module))));
return "\\ACP3\\Modules\\$mod_name\\{$mod_name}Installer";
......@@ -51,7 +45,7 @@ abstract class ModuleInstaller {
* @param mixed $module_id
*/
public function setModuleId() {
$mod_id = self::$injector['Db']->fetchColumn('SELECT id FROM ' . DB_PRE . 'modules WHERE name = ?', array($this->getName()));
$mod_id = Registry::get('Db')->fetchColumn('SELECT id FROM ' . DB_PRE . 'modules WHERE name = ?', array($this->getName()));
$this->module_id = !empty($mod_id) ? (int) $mod_id : 0;
}
......@@ -106,15 +100,15 @@ abstract class ModuleInstaller {
$search = array('{pre}', '{engine}', '{charset}');
$replace = array(DB_PRE, 'ENGINE=MyISAM', 'CHARACTER SET `utf8` COLLATE `utf8_general_ci`');
self::$injector['Db']->beginTransaction();
Registry::get('Db')->beginTransaction();
try {
foreach ($queries as $query) {
if (!empty($query))
self::$injector['Db']->query(str_replace($search, $replace, $query));