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.aff.php | 65 ++++++++++++++++++++++++++++++++++++++++-------- class/class.w.app.php | 62 ++++++++++++++++++++++++++++++++++----------- class/class.w.art.php | 12 ++++++--- class/class.w.config.php | 3 +++ class/class.w.opt.php | 45 +++++++++++++++++++-------------- 5 files changed, 140 insertions(+), 47 deletions(-) (limited to 'class') diff --git a/class/class.w.aff.php b/class/class.w.aff.php index 9f1177a..198f61e 100644 --- a/class/class.w.aff.php +++ b/class/class.w.aff.php @@ -162,7 +162,7 @@ class Aff
- +
@@ -197,7 +197,7 @@ public function copy(Art $art, $list) - + @@ -313,13 +313,27 @@ public function header() public function home2table(App $app, $getlist) { + echo '
'; + ?> +
+ + + +
+ session() >= $app::EDITOR) { echo ''; - echo ''; + echo ''; foreach ($getlist as $item) { echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -332,6 +346,7 @@ public function home2table(App $app, $getlist) echo ''; } echo '
titletagsummary↘ to↗ fromlast modificationdate of creationprivacy⚙ edit
xtitletagsummary↘ to↗ fromlast modificationdate of creationprivacy⚙ edit
' . $item->titre() . '' . $item->tag('sort') . '' . $item->intro() . '
'; + echo '
'; } } @@ -340,15 +355,19 @@ public function option(App $app, Opt $opt) if ($app->session() >= $app::EDITOR) { echo '
'; + echo ''; + echo '⬅'; + - $this->optiontag($opt); - $this->optionprivacy($opt); $this->optionsort($opt); + $this->optionprivacy($opt); + $this->optiontag($opt); - echo ''; + echo ''; + echo '⬅'; echo '
'; @@ -360,13 +379,34 @@ public function optiontag(Opt $opt) { echo '
Tag
'; } @@ -389,7 +429,9 @@ public function optionsort(Opt $opt) echo ''; } echo ''; + echo '
'; echo 'order() == '1' ? "checked" : "") . ' />'; + echo '
'; echo 'order() == '-1' ? "checked" : "") . ' />'; echo ''; @@ -469,7 +511,7 @@ public function nav($app) echo 'edit'; } } - if ($app->session() >= $app::EDITOR && !isset($_GET['id'])) { + if ($app->session() >= $app::EDITOR) { echo 'Media'; echo 'Record'; if ($app->session() >= $app::ADMIN) { @@ -827,6 +869,7 @@ public function nav($app) + //______________________________________________________ S E T _________________________________________________ public function setsession($session) 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; diff --git a/class/class.w.art.php b/class/class.w.art.php index d757e0d..ffdb670 100644 --- a/class/class.w.art.php +++ b/class/class.w.art.php @@ -73,7 +73,7 @@ class Art public function updatelien() { - $this->lien = search($this->md(), self::DEBUT, self::FIN); + $this->lien = search($this->md(true), self::DEBUT, self::FIN); } public static function classvarlist() @@ -179,9 +179,14 @@ class Art return $temp . $this->css; } - public function md() + public function md($expand = false) { - return $this->html; + if($expand == true) { + $md = str_replace('](=', '](?id=', $this->html); + } else { + $md = $this->html; + } + return $md; } public function html(App $app) @@ -200,6 +205,7 @@ class Art $html = str_replace($lien, $titlelien, $html); } + $html = str_replace('href="=', 'href="?id=', $html); $html = str_replace('href="http', ' class="external" target="_blank" href="http', $html); $html = str_replace('