aboutsummaryrefslogtreecommitdiff
path: root/class/class.w.app.php
diff options
context:
space:
mode:
Diffstat (limited to 'class/class.w.app.php')
-rw-r--r--class/class.w.app.php62
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;