From c599b349667630b328ab2560abccbb7e4fe47801 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 11 Jan 2020 14:16:18 +0100 Subject: multiedit : addauthor --- app/class/Controllerhome.php | 7 ++++--- app/class/Controllerpage.php | 1 - app/class/Metaedit.php | 44 ----------------------------------------- app/class/Modelpage.php | 26 +++++++++++++++++++++--- app/class/Page.php | 2 +- app/view/templates/home.php | 2 +- app/view/templates/homemenu.php | 28 ++++++++++++++++++++++++++ 7 files changed, 57 insertions(+), 53 deletions(-) delete mode 100644 app/class/Metaedit.php (limited to 'app') diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php index bb22e57..6e691a6 100644 --- a/app/class/Controllerhome.php +++ b/app/class/Controllerhome.php @@ -36,7 +36,7 @@ class Controllerhome extends Controllerpage $columns = $this->modelhome->setcolumns($this->user->columns()); - $vars = ['user' => $this->user, 'table2' => $table2, 'opt' => $this->opt, 'columns' => $columns]; + $vars = ['user' => $this->user, 'table2' => $table2, 'opt' => $this->opt, 'columns' => $columns, 'faviconlist' => $this->mediamanager->listfavicon(), 'editorlist' => $this->usermanager->getlisterbylevel(2, '>=')]; $vars['footer'] = ['version' => getversion(), 'total' => count($table), 'database' => Config::pagetable()]; if (isset($_POST['query']) && $this->user->iseditor()) { @@ -132,9 +132,10 @@ class Controllerhome extends Controllerpage if ($this->user->issupereditor() && isset($_POST['pagesid'])) { $datas = $_POST['datas'] ?? []; $reset = $_POST['reset'] ?? []; - $addtag = $_POST['addtag'] ?? []; + $addtag = $_POST['addtag'] ?? ''; + $addauthor = $_POST['addauthor'] ?? ''; foreach ($_POST['pagesid'] as $id) { - $this->pagemanager->pageedit($id, $datas, $reset, $addtag); + $this->pagemanager->pageedit($id, $datas, $reset, $addtag, $addauthor); } } $this->routedirect('home'); diff --git a/app/class/Controllerpage.php b/app/class/Controllerpage.php index d1bfca5..e12d76e 100644 --- a/app/class/Controllerpage.php +++ b/app/class/Controllerpage.php @@ -163,7 +163,6 @@ class Controllerpage extends Controller } else { $this->showtemplate('alert', ['page' => $this->page, 'pageexist' => $pageexist, 'canedit' => $this->canedit()]); } - } public function edit($id) diff --git a/app/class/Metaedit.php b/app/class/Metaedit.php deleted file mode 100644 index e21a0c2..0000000 --- a/app/class/Metaedit.php +++ /dev/null @@ -1,44 +0,0 @@ -resettag) { - $page->tag([]); - } - $page->addtag($this->tag); - if($this->resetdate) { - $page->date() - } - $page->secure($this->secure); - $page->templatebody($this->templatebody); - $page->templatecss($this->templatecss); - $page->templatejavascript($this->templatejavascript); - - return $page; - } - -} - - - - - -?> \ No newline at end of file diff --git a/app/class/Modelpage.php b/app/class/Modelpage.php index 3f4dcf4..a13b3d4 100644 --- a/app/class/Modelpage.php +++ b/app/class/Modelpage.php @@ -333,21 +333,41 @@ class Modelpage extends Modeldb return $idlist; } - public function pageedit($pageid, $datas, $reset, $addtag) + /** + * Edit a page based on meta infos + * + * @param string $pageid + * @param array $datas + * @param array $reset + * @param string $addtag + * @param string $addauthor + */ + public function pageedit($pageid, $datas, $reset, $addtag, $addauthor) { $page = $this->get($pageid); $page = $this->reset($page, $reset); $page->hydrate($datas); $page->addtag($addtag); + $page->addauthor($addauthor); $this->update($page); } - - public function reset(Page $page, $reset) + /** + * Reset values of a page + * + * @param Page $page Page object to be reseted + * @param array $reset List of parameters needing reset + * + * @return Page The reseted page object + */ + public function reset(Page $page, array $reset) : Page { if($reset['tag']) { $page->settag([]); } + if($reset['author']) { + $page->setauthors([]); + } if($reset['date']) { // reset date as now } diff --git a/app/class/Page.php b/app/class/Page.php index 1daa240..41cf0ab 100644 --- a/app/class/Page.php +++ b/app/class/Page.php @@ -719,7 +719,7 @@ class Page public function setauthors($authors) { if(is_array($authors)) { - $this->authors = array_values(array_filter($authors)); + $this->authors = array_unique(array_values(array_filter($authors))); } } diff --git a/app/view/templates/home.php b/app/view/templates/home.php index 63706d0..a60a5cc 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -16,7 +16,7 @@ insert('homemenu', ['user' => $user, 'opt' => $opt, 'optlist' => $optlist, 'pagelist' => $pagelist]); + $this->insert('homemenu', ['user' => $user, 'opt' => $opt, 'optlist' => $optlist, 'pagelist' => $pagelist, 'faviconlist' => $faviconlist, 'editorlist' => $editorlist]); ?> diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php index fc16340..ade9bac 100644 --- a/app/view/templates/homemenu.php +++ b/app/view/templates/homemenu.php @@ -76,6 +76,18 @@
+ Favicon +
+ + +
Templates

+ Author +
+ + +
+ + + +
-- cgit v1.2.3