From cbecc0dfc819febf4c2b36791d5a2a7e69d842af Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 2 Sep 2018 16:19:13 +0200 Subject: 2.5 mobile update + minor upgrades and fixes --- class/class.w.app.php | 62 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 15 deletions(-) (limited to 'class/class.w.app.php') diff --git a/class/class.w.app.php b/class/class.w.app.php index efb8986..5e1ddb0 100644 --- a/class/class.w.app.php +++ b/class/class.w.app.php @@ -37,25 +37,52 @@ class App } catch (PDOException $e) { $caught = false; echo '

Error 500, database offline

'; - echo '

Homepage for admin login (connect on the top right side)

'; - if ($this->session() >= 3) { + if ($this->session() >= self::EDITOR) { echo '

Error : ' . $e->getMessage() . '

'; - if ($this->session() == 10) { + if ($this->session() == self::ADMIN) { echo '

Go to the Admin Panel to edit your database credentials

'; } else { echo '

Logout and and come back with an admin password to edit the database connexions settings.

'; } + } else { + echo '

Homepage for admin login (connect on the top right side)

'; } exit; } - if ($caught) { - $this->arttable = $config->arttable(); - } return $caught; } + public function settable(Config $config) + { + if (!empty($config->arttable())) { + $this->arttable = $config->arttable(); + } else { + echo '

Table Error

'; + + if ($this->session() >= self::EDITOR) { + if ($this->session() == self::ADMIN) { + echo '

Go to the Admin Panel to select or add an Article table

'; + } else { + echo '

Logout and and come back with an admin password to edit table settings.

'; + } + } else { + echo '

Homepage for admin login (connect on the top right side)

'; + } + $caught = false; + exit; + } + } + + public function bddinit(Config $config) + { + $test = $this->setbdd($config); + if ($test) { + $this->settable($config); + } + } + // _________________________________________ C O N F I G ____________________________________ @@ -206,7 +233,6 @@ class App public function getlisteropt(Opt $opt) { - $artlist = []; $select = 'SELECT ' . $opt->col('string') . ' FROM ' . $this->arttable; @@ -252,15 +278,24 @@ class App - public function filtertagor(array $artlist, array $tagchecked) + public function filtertagfilter(array $artlist, array $tagchecked, $tagcompare = 'OR') { $filteredlist = []; foreach ($artlist as $art) { - if (!empty(array_intersect($art->tag('array'), $tagchecked))) { - $filteredlist[] = $art->id(); - } elseif (empty($tagchecked)) { + if(empty($tagchecked)) { $filteredlist[] = $art->id(); + } else { + $inter = (array_intersect($art->tag('array'), $tagchecked)); + if($tagcompare == 'OR') { + if (!empty($inter)) { + $filteredlist[] = $art->id(); + } + } elseif($tagcompare == 'AND') { + if (!array_diff($tagchecked, $art->tag('array'))) { + $filteredlist[] = $art->id(); + } + } } } return $filteredlist; @@ -311,9 +346,6 @@ class App public function tableexist($dbname, $tablename) { - var_dump($dbname); - var_dump($tablename); - $req = $this->bdd->prepare('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = :dbname AND @@ -341,7 +373,7 @@ class App $arttables = []; foreach ($donnees as $table) { - $arttables[] = $table['Tables_in_wcms']; + $arttables[] = $table['Tables_in_' . $dbname]; } return $arttables; -- cgit v1.2.3