diff options
-rw-r--r-- | app/class/Colors.php | 2 | ||||
-rw-r--r-- | app/class/Controllerhome.php | 34 | ||||
-rw-r--r-- | app/class/Controlleruser.php | 36 | ||||
-rw-r--r-- | app/class/Element.php | 2 | ||||
-rw-r--r-- | app/class/Medialist.php | 15 | ||||
-rw-r--r-- | app/class/Modelrender.php | 10 | ||||
-rw-r--r-- | app/class/Routes.php | 2 | ||||
-rw-r--r-- | app/view/templates/backtopbar.php | 4 | ||||
-rw-r--r-- | app/view/templates/homemenu.php | 40 | ||||
-rw-r--r-- | app/view/templates/mediamenu.php | 48 | ||||
-rw-r--r-- | assets/css/edit.css | 6 | ||||
-rw-r--r-- | assets/css/home.css | 21 |
12 files changed, 127 insertions, 93 deletions
diff --git a/app/class/Colors.php b/app/class/Colors.php index 2e4af23..bdea98e 100644 --- a/app/class/Colors.php +++ b/app/class/Colors.php @@ -121,7 +121,7 @@ class Colors extends Item foreach ($this->tagcolor as $tag => $color) { $i = '<input type="color" name="tagcolor[' . $tag . ']" value="' . $color . '" id="color_' . $tag . '">'; $l = '<label for="color_' . $tag . '" >' . $tag . '</label>'; - $html .= "\n<li>$i . $l</li>"; + $html .= "\n<li>$i$l</li>"; } $html .= PHP_EOL . '</ul>'; return $html; diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php index 1385652..4dd8227 100644 --- a/app/class/Controllerhome.php +++ b/app/class/Controllerhome.php @@ -177,40 +177,6 @@ class Controllerhome extends Controllerpage $this->routedirect('home'); } - public function bookmark() - { - if ($this->user->iseditor() && isset($_POST['action']) && isset($_POST['id']) && !empty($_POST['id'])) { - if ($_POST['action'] == 'add' && isset($_POST['query'])) { - if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) { - $bookmark = new Bookmark($_POST); - $bookmark->init($_POST['id'], 'home', $_POST['query'], [], $_POST['icon']); - $usermanager = new Modeluser(); - $user = $usermanager->get($_POST['user']); - $user->addbookmark($bookmark); - $usermanager->add($user); - } else { - Config::addbookmark($_POST['id'], $_POST['query']); - Config::savejson(); - } - } elseif ($_POST['action'] == 'del') { - if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) { - $usermanager = new Modeluser(); - $user = $usermanager->get($_POST['user']); - foreach ($_POST['id'] as $id) { - $user->deletebookmark($id); - } - $usermanager->add($user); - } else { - foreach ($_POST['id'] as $id) { - Config::deletebookmark($id); - } - Config::savejson(); - } - } - } - $this->routedirect('home'); - } - public function multi() { if (isset($_POST['action']) && $this->user->issupereditor() && !empty($_POST['pagesid'])) { diff --git a/app/class/Controlleruser.php b/app/class/Controlleruser.php index d5bf934..7f12e77 100644 --- a/app/class/Controlleruser.php +++ b/app/class/Controlleruser.php @@ -49,6 +49,42 @@ class Controlleruser extends Controller } + public function bookmark() + { + if ($this->user->iseditor() && isset($_POST['action']) && isset($_POST['id']) && !empty($_POST['id'])) { + if ($_POST['action'] == 'add' && isset($_POST['query'])) { + if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) { + $bookmark = new Bookmark(); + $bookmark->init($_POST['id'], $_POST['route'], $_POST['query'], [], $_POST['icon']); + $usermanager = new Modeluser(); + $user = $usermanager->get($_POST['user']); + $user->addbookmark($bookmark); + $usermanager->add($user); + } else { + Config::addbookmark($_POST['id'], $_POST['query']); + Config::savejson(); + } + } elseif ($_POST['action'] == 'del') { + if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) { + $usermanager = new Modeluser(); + $user = $usermanager->get($_POST['user']); + foreach ($_POST['id'] as $id) { + $user->deletebookmark($id); + } + $usermanager->add($user); + } else { + foreach ($_POST['id'] as $id) { + Config::deletebookmark($id); + } + Config::savejson(); + } + } + } + $this->routedirect($_POST['route']); + } + + + diff --git a/app/class/Element.php b/app/class/Element.php index 7478256..b4a9285 100644 --- a/app/class/Element.php +++ b/app/class/Element.php @@ -46,7 +46,7 @@ class Element extends Item public function addtags() { - $this->content = "\n<' . $this->type() . '>\n' . $this->content() . '\n</' . $this->type() . '>\n"; + $this->content = "\n<{$this->type()}>\n{$this->content()}\n</{$this->type()}>\n"; } diff --git a/app/class/Medialist.php b/app/class/Medialist.php index c597505..e716845 100644 --- a/app/class/Medialist.php +++ b/app/class/Medialist.php @@ -127,7 +127,20 @@ class Medialist extends Item if (array_diff(self::TYPES, $this->type) != []) { $query['type'] = $this->type; } - return '%MEDIA?' . urldecode(http_build_query($query)) . '%'; + return urldecode(http_build_query($query)); + } + + /** + * Get the code to insert directly + */ + public function getcode(): string + { + return '%MEDIA?' . $this->getquery() . '%'; + } + + public function getadress(): string + { + return '?' . $this->getquery(); } diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 1ad9e20..8f20f83 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -89,7 +89,7 @@ class Modelrender extends Modelpage $body = $this->getbody($this->readbody()); $parsebody = $this->bodyparser($body); - $html = "<!DOCTYPE html>\n<html>\n<head>\n' . $head . '\n</head>\n' . $parsebody . '\N</html>"; + $html = "<!DOCTYPE html>\n<html>\n<head>\n$head\n</head>\n$parsebody\n</html>"; return $html; } @@ -288,16 +288,16 @@ class Modelrender extends Modelpage if (!empty($this->page->templatecss())) { $tempaltecsspage = $this->page->templatecss(); - $head .= "<link href=\"$renderpath . $tempaltecsspage.css\" rel=\"stylesheet\" />\n"; + $head .= "<link href=\"$renderpath$tempaltecsspage.css\" rel=\"stylesheet\" />\n"; } - $head .= "<link href=\"$renderpath . $id.css\" rel=\"stylesheet\" />\n"; + $head .= "<link href=\"$renderpath$id.css\" rel=\"stylesheet\" />\n"; if (!empty($this->page->templatejavascript())) { $templatejspage = $this->page->templatejavascript(); - $head .= "<script src=\"$renderpath . $templatejspage.js\" async/></script>\n"; + $head .= "<script src=\"$renderpath$templatejspage.js\" async/></script>\n"; } if (!empty($this->page->javascript())) { - $head .= "<script src=\"$renderpath . $id.js\" async/></script>\n"; + $head .= "<script src=\"$renderpath$id.js\" async/></script>\n"; } if (!empty(Config::analytics())) { diff --git a/app/class/Routes.php b/app/class/Routes.php index 2a1e088..59659ea 100644 --- a/app/class/Routes.php +++ b/app/class/Routes.php @@ -25,7 +25,6 @@ class Routes ['POST', '/columns', 'Controllerhome#columns', 'homecolumns'], ['POST', '/colors', 'Controllerhome#colors', 'homecolors'], ['GET', '//renderall', 'Controllerhome#renderall', 'homerenderall'], - ['POST', '/bookmark', 'Controllerhome#bookmark', 'homebookmark'], ['POST', '/multi', 'Controllerhome#multi', 'multi'], ['POST', '/upload', 'Controllerpage#upload', 'pageupload'], ['POST', '/!co', 'Controllerconnect#log', 'log'], @@ -45,6 +44,7 @@ class Routes ['GET', '/!user', 'Controlleruser#desktop', 'user'], ['POST', '/!user/add', 'Controlleruser#add', 'useradd'], ['POST', '/!user/update', 'Controlleruser#update', 'userupdate'], + ['POST', '/!user/bookmark', 'Controlleruser#bookmark', 'userbookmark'], ['POST', '/!user/pref', 'Controlleruser#pref', 'userpref'], ['POST', '/!user/token', 'Controlleruser#token', 'usertoken'], ['GET', '/!info', 'Controllerinfo#desktop', 'info'], diff --git a/app/view/templates/backtopbar.php b/app/view/templates/backtopbar.php index 6aded61..a9dc553 100644 --- a/app/view/templates/backtopbar.php +++ b/app/view/templates/backtopbar.php @@ -34,9 +34,9 @@ </span> -<span id="shortcuts" class="hidephone"> +<span id="shortcuts"> <?php foreach ($user->bookmark() as $bookmark) { ?> - <a href="<?= $this->url($bookmark->route(), $bookmark->params(), $bookmark->query()) ?>"><?= $bookmark->icon() ?> <?= $bookmark->id() ?></a> + <a href="<?= $this->url($bookmark->route(), $bookmark->params(), $bookmark->query()) ?>"><?= $bookmark->icon() ?><span class="hidephone"> <?= $bookmark->id() ?></span></a> <?php } ?> </span> diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php index 0848506..f3564f8 100644 --- a/app/view/templates/homemenu.php +++ b/app/view/templates/homemenu.php @@ -250,60 +250,34 @@ <details class="hidephone" id="bookmarks"> <summary>Bookmarks</summary> <div class="submenu"> - <h2>Public</h2> - <?php if(!empty(Wcms\Config::bookmark())) { ?> - <form action="<?= $this->url('homebookmark') ?>" method="post"> - <ul> - <?php foreach (Wcms\Config::bookmark() as $id => $query) { ?> - <li> - <label for="public-bookmark_<?= $id ?>"> - <a href="<?= $query ?>" title="<?= $query ?>"><?= $id ?></a> - </label> - <?php if($user->issupereditor()) { ?> - <input type="checkbox" name="id[]" value="<?= $id ?>" id="public-bookmark_<?= $id ?>"> - <?php } ?> - </li> - <?php } ?> - </ul> - <input type="hidden" name="action" value="del"> - <input type="submit" value="delete selected"> - </form> - <?php } elseif($user->issupereditor()) { ?> - <p>This will store your filters settings as a Bookmark that every editors users can use.</p> - <?php } else { ?> - <p>No public Bookmarks yet</p> - <?php } ?> - <?php if($user->issupereditor()) { ?> - <form action="<?= $this->url('homebookmark') ?>" method="post"> - <input type="text" name="id" placeholder="bookmark id" minlength="1" maxlength="16"> - <input type="hidden" name="query" value="<?= $opt->getadress() ?>"> - <input type="submit" name="action" value="add"> - </form> - <?php } ?> <h2>Personnal</h2> <?php if(!empty($user->bookmark())) { ?> - <form action="<?= $this->url('homebookmark') ?>" method="post"> + <form action="<?= $this->url('userbookmark') ?>" method="post"> <ul> <?php foreach ($user->bookmark() as $bookmark) { ?> + <?php if($bookmark->route() === 'home') { ?> <li> - <label for="bookmark_<?= $bookmark->id() ?>" title="<?= $bookmark->query() ?>"><?= $bookmark->id() ?></label> <input type="checkbox" name="id[]" value="<?= $bookmark->id() ?>" id="bookmark_<?= $bookmark->id() ?>"> + <label for="bookmark_<?= $bookmark->id() ?>" title="<?= $bookmark->query() ?>"><?= $bookmark->id() ?></label> </li> + <?php } ?> <?php } ?> </ul> <input type="hidden" name="action" value="del"> + <input type="hidden" name="route" value="home"> <input type="hidden" name="user" value="<?= $user->id() ?>"> <input type="submit" value="delete selected"> </form> <?php } else { ?> <p>This will store your filters settings as a Bookmark that only you can use.</p> <?php } ?> - <form action="<?= $this->url('homebookmark') ?>" method="post"> + <form action="<?= $this->url('userbookmark') ?>" method="post"> <select name="icon" id="icon"> <?= options(Wcms\Model::BOOKMARK_ICONS, null, true) ?> </select> <input type="text" name="id" placeholder="bookmark id" minlength="1" maxlength="16" required> <input type="hidden" name="query" value="<?= $opt->getadress() ?>"> + <input type="hidden" name="route" value="home"> <input type="hidden" name="user" value="<?= $user->id() ?>"> <input type="submit" name="action" value="add"> </form> diff --git a/app/view/templates/mediamenu.php b/app/view/templates/mediamenu.php index 560025a..2a33b65 100644 --- a/app/view/templates/mediamenu.php +++ b/app/view/templates/mediamenu.php @@ -73,8 +73,54 @@ <p>Use this code to print the content of the actual folder in a page</p> - <code><?= $mediaopt->getquery() ?></code> + <code><?= $mediaopt->getcode() ?></code> </div> </details> + + + + + + + <details class="hidephone" id="bookmarks"> + <summary>Bookmarks</summary> + <div class="submenu"> + <h2>Personnal</h2> + <?php if(!empty($user->bookmark())) { ?> + <form action="<?= $this->url('userbookmark') ?>" method="post"> + <ul> + <?php foreach ($user->bookmark() as $bookmark) { ?> + <?php if($bookmark->route() === 'media') { ?> + <li> + <input type="checkbox" name="id[]" value="<?= $bookmark->id() ?>" id="bookmark_<?= $bookmark->id() ?>"> + <label for="bookmark_<?= $bookmark->id() ?>" title="<?= $bookmark->query() ?>"><?= $bookmark->id() ?></label> + </li> + <?php } ?> + <?php } ?> + </ul> + <input type="hidden" name="action" value="del"> + <input type="hidden" name="route" value="media"> + <input type="hidden" name="user" value="<?= $user->id() ?>"> + <input type="submit" value="delete selected"> + </form> + <?php } else { ?> + <p>This will store your filters settings as a Bookmark that only you can use.</p> + <?php } ?> + <form action="<?= $this->url('userbookmark') ?>" method="post"> + <select name="icon" id="icon"> + <?= options(Wcms\Model::BOOKMARK_ICONS, null, true) ?> + </select> + <input type="text" name="id" placeholder="bookmark id" minlength="1" maxlength="16" required> + <input type="hidden" name="query" value="<?= $mediaopt->getadress() ?>"> + <input type="hidden" name="route" value="media"> + <input type="hidden" name="user" value="<?= $user->id() ?>"> + <input type="submit" name="action" value="add"> + </form> + </div> + </details> + + + + </aside>
\ No newline at end of file diff --git a/assets/css/edit.css b/assets/css/edit.css index f43684c..c774434 100644 --- a/assets/css/edit.css +++ b/assets/css/edit.css @@ -406,6 +406,12 @@ span.cm-wkeyword { img.icon { height: 23px; } + + + span#shortcuts { + font-size: 23px; + line-height: 1; + } } diff --git a/assets/css/home.css b/assets/css/home.css index 221472e..e06165b 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -107,20 +107,6 @@ aside summary:hover { } -aside.home details#bookmarks input[type="checkbox"] { - opacity: 0.2; - float: right; - height: 11px; -} - -aside.home details#bookmarks input[type="checkbox"]:hover { - opacity: 1; -} - -aside.home details#bookmarks ul { - padding: 2%; -} - aside.home #edit input[type="submit"] { width: 100%; } @@ -674,6 +660,12 @@ footer { height: 23px; } + + span#shortcuts { + font-size: 23px; + line-height: 1; + } + } @@ -687,3 +679,4 @@ footer { } } + |