Commit 1a953660 authored by M.Nowocyn's avatar M.Nowocyn

Change Variable formation and changed some class directories and namespaces

parent 1ebcb064
......@@ -20,14 +20,15 @@ namespace Iko\Language;
use Iko\Core;
use Iko\Event\Handler;
use Iko\Language;
use Iko\Lib\Multiton\Cache\Mixed;
use iko\user\User;
use Iko\User;
use PDO;
class Key extends Mixed implements iKey
{
const TABLE = language::TABLE;
const NAME = language::NAME;
const TABLE = Language::TABLE;
const NAME = Language::NAME;
protected static $cache = array ();
protected static $cache_exist = array ();
......@@ -62,15 +63,15 @@ class Key extends Mixed implements iKey
* @param $name
*
* @return bool
* @permission iko.language.keys.delete
* Allows User to delete language keys
* @permission iko.Language.keys.delete
* Allows User to delete Language keys
*/
public static function delete ($name)
{
if (!$name instanceof Key) {
$name = self::get($name);
}
if (User::get_session()->has_permission("iko.language.keys.delete")) {
if (User::getSession()->hasPermission("iko.Language.keys.delete")) {
$key = Core::PDO()->quote($name->getKey());
$sql = "DELETE FROM " . self::TABLE . " WHERE " . self::NAME . " = " . $key;
$statement = Core::PDO()->exec($sql);
......@@ -88,13 +89,13 @@ class Key extends Mixed implements iKey
* @param string $name
*
* @return bool
* @permission iko.language.keys.create
* @permission iko.Language.keys.create
* Allows User to create new Keys
*/
public static function create (string $name)
{
if ($name != "" && !self::exist($name)) {
if (User::get_session()->has_permission("iko.language.keys.create")) {
if (User::getSession()->hasPermission("iko.Language.keys.create")) {
$name = Core::PDO()->quote($name);
$sql = "INSERT INTO " . self::TABLE . " (" . self::NAME . ") VALUE('" . $name . "')";
$statement = Core::PDO()->exec($sql);
......@@ -175,7 +176,7 @@ class Key extends Mixed implements iKey
private function loadLang (string $lang)
{
if (language::getInstance()->isSupportedLanguage($lang)) {
if (Language::getInstance()->isSupportedLanguage($lang)) {
$sql = "SELECT " . $lang . " FROM " . self::TABLE . " WHERE " . self::NAME . " = '" . $this->getKey() . "'";
$statement = Core::PDO()->query($sql);
$fetch = $statement->fetch(PDO::FETCH_ASSOC);
......@@ -198,15 +199,15 @@ class Key extends Mixed implements iKey
* @param $value
*
* @return bool
* @permission iko.language.keys.set.lang
* @permission iko.Language.keys.set.lang
*
*/
public function setLang ($lang, $value)
{
if (language::getInstance()->isSupportedLanguage($lang)) {
if (Language::getInstance()->isSupportedLanguage($lang)) {
if ($value != "" && $value != $this->getLang($lang)) {
if (User::get_session()->has_permission("iko.language.keys.set.lang")) {
if (Handler::event("iko.language.keys.set.lang", $this, NULL, TRUE)) {
if (User::getSession()->hasPermission("iko.Language.keys.set.lang")) {
if (Handler::event("iko.Language.keys.set.lang", $this, NULL, TRUE)) {
$sql_value = Core::PDO()->quote($value);
$statement = Core::PDO()->exec("UPDATE " . self::TABLE . " Set " . $lang . " = " . $sql_value . " WHERE " . self::NAME . " = '" . self::getKey() . "' ");
if ($statement == 1) {
......@@ -225,8 +226,8 @@ class Key extends Mixed implements iKey
public function setKey ($name)
{
if ($name != "" && $name != $this->getKey()) {
if (User::get_session()->has_permission("iko.language.keys.set.name")) {
if (Handler::event("iko.language.keys.set.name", $name)) {
if (User::getSession()->hasPermission("iko.Language.keys.set.name")) {
if (Handler::event("iko.Language.keys.set.name", $name)) {
$sql_name = Core::PDO()->quote($name);
$statement = Core::PDO()->exec("UPDATE " . self::TABLE . " Set " . self::TABLE . " = " . $sql_name . " WHERE " . self::NAME . " = '" . self::getKey() . "' ");
if ($statement == 1) {
......
......@@ -16,16 +16,13 @@
* Date: 11.01.2017
* Time: 23:29
*/
namespace iko\language;
namespace Iko;
use Iko\Config;
use Iko\Core;
use iko\language\iLanguage;
use Iko\Lib\Singleton\Instance;
use Iko\Session;
use iko\user\User;
class language extends Instance implements iLanguage
class Language extends Instance implements iLanguage
{
const DEFAULT = "english";
const TABLE = "{prefix}translation";
......@@ -35,7 +32,7 @@ class language extends Instance implements iLanguage
"english");
protected static $instance = NULL;
public static function getInstance ($args = NULL): language
public static function getInstance ($args = NULL): Language
{
return parent::getInstance($args);
}
......@@ -50,7 +47,7 @@ class language extends Instance implements iLanguage
$lang = User::get_session()->get_language();
}
if ($lang == NULL || $lang == "") {
$config = Config::load("pdo", "language");
$config = Config::load("pdo", "Language");
$lang = $config->default_language ?? self::DEFAULT;
}
$this->current = $lang;
......@@ -91,7 +88,7 @@ class language extends Instance implements iLanguage
if (($func == "add" && !$this->isSupportedLanguage($name)) || ($func == "remove" && $this->isSupportedLanguage($name) && array_search($name,
self::FIXED, TRUE) === FALSE)
) {
if (User::get_session()->has_permission("iko.language." . $func . ".lang")) {
if (User::get_session()->has_permission("iko.Language." . $func . ".lang")) {
if ($func == "add") {
$sql = "ALTER TABLE " . self::TABLE . " ADD :lang TEXT";
}
......
......@@ -23,7 +23,7 @@ class Loader extends \Iko\Module\Loader
protected function preCheckPDOTables ()
{
//Add Tables like User and choosen language assignment and more
//Add Tables like User and choosen Language assignment and more
$tables = array (
"translation",
"users",);
......
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