aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-01-02 19:50:28 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-02 19:50:28 +0100
commitafeeafc2a691b661ba2c92250f883fda6bd33392 (patch)
tree6f596f3cf31c1f62e0463ceff4e17e3541762da5 /app/class
parentd5a2af69c6d62475c26dc7e9812f9a977e9dfa12 (diff)
downloadwcms-afeeafc2a691b661ba2c92250f883fda6bd33392.tar.gz
wcms-afeeafc2a691b661ba2c92250f883fda6bd33392.zip
render path check
Diffstat (limited to 'app/class')
-rw-r--r--app/class/application.php8
-rw-r--r--app/class/controllerart.php29
-rw-r--r--app/class/modelart.php27
3 files changed, 54 insertions, 10 deletions
diff --git a/app/class/application.php b/app/class/application.php
index f4b2a84..926db20 100644
--- a/app/class/application.php
+++ b/app/class/application.php
@@ -19,6 +19,9 @@ class Application
} else {
Config::hydrate($_POST['configinit']);
}
+ if(!is_dir(Model::RENDER_DIR)) {
+ mkdir(Model::RENDER_DIR);
+ }
if(!Config::savejson()) {
echo 'Cant write config file';
exit;
@@ -37,7 +40,7 @@ class Application
} else {
if(Config::readconfig()) {
- if(!Config::checkbasepath() || empty(Config::arttable())) {
+ if(!Config::checkbasepath() || empty(Config::arttable()) || !is_dir(Model::RENDER_DIR)) {
echo '<ul>';
if(!Config::checkbasepath()) {
echo '<li>Wrong path</li>';
@@ -45,6 +48,9 @@ class Application
if(empty(Config::arttable())) {
echo '<li>Unset table name</li>';
}
+ if(!is_dir(Model::RENDER_DIR)) {
+ echo '<li>Render path not existing</li>';
+ }
echo '</ul>';
$this->configform();
exit;
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index f292975..0ef82da 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -9,6 +9,8 @@ class Controllerart extends Controller
protected $fontmanager;
protected $mediamanager;
+ const COMBINE = true;
+
public function __construct($router)
{
parent::__construct($router);
@@ -124,8 +126,8 @@ class Controllerart extends Controller
$faviconlist = $this->mediamanager->listfavicon();
$idlist = $this->artmanager->list();
-
- $artlist = $this->artmanager->getlister();
+
+ $artlist = $this->artmanager->getlister();
$tagartlist = $this->artmanager->tagartlist($this->art->tag('array'), $artlist);
$lasteditedartlist = $this->artmanager->lasteditedartlist(5, $artlist);
@@ -165,7 +167,7 @@ class Controllerart extends Controller
$defaultbody = $defaultart->body();
}
}
- if(empty(Config::defaultart()) || $defaultart === false) {
+ if (empty(Config::defaultart()) || $defaultart === false) {
$defaultbody = Config::defaultbody();
}
$this->art->setbody($defaultbody);
@@ -204,7 +206,7 @@ class Controllerart extends Controller
$_SESSION['workspace']['showrightpanel'] = isset($_POST['workspace']['showrightpanel']);
$_SESSION['workspace']['showleftpanel'] = isset($_POST['workspace']['showleftpanel']);
- if(!empty($_POST['fontsize']) && $_POST['fontsize'] !== Config::fontsize()) {
+ if (!empty($_POST['fontsize']) && $_POST['fontsize'] !== Config::fontsize()) {
Config::setfontsize($_POST['fontsize']);
Config::savejson();
}
@@ -215,18 +217,27 @@ class Controllerart extends Controller
$date = ['date' => $date];
if ($this->importart() && $this->canedit()) {
+
+ $oldart = clone $this->art;
$this->art->hydrate($_POST);
+
+ if (self::COMBINE) {
+ if ($_POST['thisdatemodif'] === $oldart->datemodif('string')) {
+ $compare = $this->artmanager->combine($this->art, $oldart);
+ if (!empty($compare['diff'])) {
+ $this->art->hydrate($compare['mergeart']);
+ }
+ }
+ }
$this->art->hydrate($date);
$this->art->updateedited();
$this->art->addauthor($this->user->id());
$this->artmanager->update($this->art);
+ $this->routedirect('artedit', ['art' => $this->art->id()]);
+
+ //$this->showtemplate('updatemerge', $compare);
}
-
- $this->routedirect('artedit', ['art' => $this->art->id()]);
-
-
-
}
public function artdirect($id)
diff --git a/app/class/modelart.php b/app/class/modelart.php
index f80826a..0cb9b1c 100644
--- a/app/class/modelart.php
+++ b/app/class/modelart.php
@@ -99,6 +99,33 @@ class Modelart extends Modeldb
$this->repo->store($artdata);
}
+ public function combine(Art2 $arta, Art2 $artb)
+ {
+ $mergeart = $arta;
+ $merge = [];
+ $diff = [];
+ foreach ($arta::TABS as $element) {
+ if($arta->$element() !== $artb->$element()) {
+ $merge[$element] = compare($arta->$element(), $artb->$element());
+ $diff[] = $element;
+ }
+ }
+ $mergeart->hydrate($merge);
+
+ return ['diff' => $diff, 'mergeart' => $mergeart];
+ }
+
+ // public function diffartelement(Art2 $arta, Art2 $artb)
+ // {
+ // $diff = [];
+ // foreach ($arta::TABS as $element) {
+ // if($arta->$element() !== $artb->$element()) {
+ // $diff[] = $element;
+ // }
+ // }
+ // return $diff;
+ // }
+
public function artcompare($art1, $art2, $method = 'id', $order = 1)
{
$result = ($art1->$method('sort') <=> $art2->$method('sort'));