aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-01-11 14:16:18 +0100
committervincent-peugnet <v.peugnet@free.fr>2020-01-11 14:16:18 +0100
commitc599b349667630b328ab2560abccbb7e4fe47801 (patch)
treeff7acf6aa39b3d99396e3eb6b44a7e99ab704661
parentd9816ef4affa3d7096a2189e9b171d9d130a727e (diff)
downloadwcms-c599b349667630b328ab2560abccbb7e4fe47801.tar.gz
wcms-c599b349667630b328ab2560abccbb7e4fe47801.zip
multiedit : addauthor
-rw-r--r--app/class/Controllerhome.php7
-rw-r--r--app/class/Controllerpage.php1
-rw-r--r--app/class/Metaedit.php44
-rw-r--r--app/class/Modelpage.php26
-rw-r--r--app/class/Page.php2
-rw-r--r--app/view/templates/home.php2
-rw-r--r--app/view/templates/homemenu.php28
7 files changed, 57 insertions, 53 deletions
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 @@
-<?php
-
-namespace Wcms;
-
-class Pageedit extends Page
-{
- protected $resettag;
- protected $resetdate;
- protected $emptycontent;
-
-
-
-
- /**
- * Edit a page based on object seting
- *
- * @param Page $page Page to be metaedited
- *
- * @return Page Edited page object
- */
- public function editpage(Page $page)
- {
- if($this->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 @@
<?php
$optlist = $optlist ?? null;
- $this->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 @@
</select>
<label for="setlevel">Privacy level</label>
</br>
+ <strong>Favicon</strong>
+ </br>
+ <select name="datas[favicon]" id="favicon">
+ <option value="" disabled selected>--set favicon--</option>
+ <?php
+ foreach ($faviconlist as $favicon) {
+ echo '<option value ="' . $favicon . '">' . $favicon . '</option>';
+ }
+ ?>
+ </select>
+ <label for="favicon">Favicon</label>
+ </br>
<strong>Templates</strong>
</br>
<select name="datas[templatebody]" id="templatebody">
@@ -106,6 +118,22 @@
?> </select>
<label for="templatejavascript">Javascript</label>
</br>
+ <strong>Author</strong>
+ </br>
+ <select name="addauthor" id="addauthor">
+ <option value="" disabled selected>--add author--</option>
+ <?php
+ foreach ($editorlist as $editor) {
+ echo '<option value ="' . $editor . '">' . $editor . '</option>';
+ }
+ ?>
+ </select>
+ <label for="addauthor">Author</label>
+ </br>
+ <input type="hidden" name="reset[author]" value="0">
+ <input type="checkbox" name="reset[author]" id="resetauthor" value="1">
+ <label for="resetauthor">Empty Authors</label>
+ </br>
<input type="hidden" name="reset[datemodif]" value="0">
<input type="checkbox" name="reset[datemodif]" id="resetdatemodif" value="1">
<label for="resetdatemodif">update modification date</label>