diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-09-02 16:19:13 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-09-02 16:19:13 +0200 |
commit | cbecc0dfc819febf4c2b36791d5a2a7e69d842af (patch) | |
tree | c181eb875cef9ca6a48f0b807905d7a2c15bee98 /class/class.w.app.php | |
parent | e9b2ca7c06875069fa03379258625490872cc33d (diff) | |
download | wcms-cbecc0dfc819febf4c2b36791d5a2a7e69d842af.tar.gz wcms-cbecc0dfc819febf4c2b36791d5a2a7e69d842af.zip |
2.5 mobile update + minor upgrades and fixes
Diffstat (limited to 'class/class.w.app.php')
-rw-r--r-- | class/class.w.app.php | 62 |
1 files changed, 47 insertions, 15 deletions
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 '<h1>Error 500, database offline</h1>'; - echo '<p><a href=".">Homepage for admin login</a> (connect on the top right side)</p>'; - if ($this->session() >= 3) { + if ($this->session() >= self::EDITOR) { echo '<p>Error : ' . $e->getMessage() . '</p>'; - if ($this->session() == 10) { + if ($this->session() == self::ADMIN) { echo '<p>Go to the <a href="?aff=admin">Admin Panel</a> to edit your database credentials</p>'; } else { echo '<p>Logout and and come back with an <strong>admin password</strong> to edit the database connexions settings.</p>'; } + } else { + echo '<p><a href=".">Homepage for admin login</a> (connect on the top right side)</p>'; } exit; } - if ($caught) { - $this->arttable = $config->arttable(); - } return $caught; } + public function settable(Config $config) + { + if (!empty($config->arttable())) { + $this->arttable = $config->arttable(); + } else { + echo '<h1>Table Error</h1>'; + + if ($this->session() >= self::EDITOR) { + if ($this->session() == self::ADMIN) { + echo '<p>Go to the <a href="?aff=admin">Admin Panel</a> to select or add an Article table</p>'; + } else { + echo '<p>Logout and and come back with an <strong>admin password</strong> to edit table settings.</p>'; + } + } else { + echo '<p><a href=".">Homepage for admin login</a> (connect on the top right side)</p>'; + } + $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; |