aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-26 15:41:48 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-26 15:41:48 +0200
commit53e6d5fde32a917718a0658fb95f366dc7dfc248 (patch)
tree6510be3ee713a444a477aef8faf60a62fb47b165
parent0efeef6b6693d62675ec8a45e73c71f69e0a0362 (diff)
downloadwcms-53e6d5fde32a917718a0658fb95f366dc7dfc248.tar.gz
wcms-53e6d5fde32a917718a0658fb95f366dc7dfc248.zip
user bookmarks use new object
+ shortcuts visible in backtopbar
-rw-r--r--app/class/Bookmark.php106
-rw-r--r--app/class/Colors.php2
-rw-r--r--app/class/Config.php2
-rw-r--r--app/class/Controller.php9
-rw-r--r--app/class/Controllerhome.php4
-rw-r--r--app/class/Element.php2
-rw-r--r--app/class/Item.php39
-rw-r--r--app/class/Model.php7
-rw-r--r--app/class/Modelrender.php66
-rw-r--r--app/class/Modeluser.php2
-rw-r--r--app/class/Opt.php6
-rw-r--r--app/class/Page.php2
-rw-r--r--app/class/User.php19
-rw-r--r--app/fn/fn.php18
-rw-r--r--app/view/templates/backtopbar.php36
-rw-r--r--app/view/templates/homemenu.php15
-rw-r--r--assets/css/home.css5
-rw-r--r--index.php2
18 files changed, 259 insertions, 83 deletions
diff --git a/app/class/Bookmark.php b/app/class/Bookmark.php
new file mode 100644
index 0000000..bc77310
--- /dev/null
+++ b/app/class/Bookmark.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace Wcms;
+
+use DateTime;
+use DateTimeImmutable;
+use DateTimeZone;
+use Exception;
+use RuntimeException;
+
+class Bookmark extends Item
+{
+ /** @var string $id Bookmark ID */
+ protected $id;
+ /** @var string $query */
+ protected $query = '';
+ /** @var string $route Can be `page|media` */
+ protected $route;
+ /** @var array $params*/
+ protected $params = [];
+ /** @var string $icon associated emoji */
+ protected $icon = 'โญ';
+
+
+ public function __construct(array $datas = [])
+ {
+ $this->hydrate($datas);
+ }
+
+ public function init(string $id, string $route, string $query, array $params = [], string $icon = 'โญ')
+ {
+ $this->setid($id);
+ $this->setroute($route);
+ $this->setquery($query);
+ $this->setparams($params);
+ $this->seticon($icon);
+ }
+
+
+
+
+ // _____________________________ G E T __________________________________
+
+
+ public function id()
+ {
+ return $this->id;
+ }
+
+ public function query()
+ {
+ return $this->query;
+ }
+
+ public function route()
+ {
+ return $this->route;
+ }
+
+ public function params()
+ {
+ return $this->params;
+ }
+
+ public function icon()
+ {
+ return $this->icon;
+ }
+
+ // _____________________________ S E T __________________________________
+
+ public function setid($id)
+ {
+ if (is_string($id)) {
+ $this->id = idclean($id);
+ }
+ }
+
+ public function setquery($query)
+ {
+ if (is_string($query)) {
+ $this->query = substr($query, 0, Model::MAX_QUERY_LENGH);
+ }
+ }
+
+ public function setroute($route)
+ {
+ if ($route === 'home' || $route === 'media') {
+ $this->route = $route;
+ }
+ }
+
+ public function setparams($params)
+ {
+ if (is_array($params)) {
+ $this->params = $params;
+ }
+ }
+
+ public function seticon($icon)
+ {
+ if (is_string($icon)) {
+ $this->icon = substr(strip_tags($icon), 0, 16);
+ }
+ }
+}
diff --git a/app/class/Colors.php b/app/class/Colors.php
index 87a5414..2e4af23 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/Config.php b/app/class/Config.php
index 3c9afd9..45ba86f 100644
--- a/app/class/Config.php
+++ b/app/class/Config.php
@@ -21,7 +21,7 @@ abstract class Config
protected static $privatepass = false;
protected static $notpublishedpass = false;
protected static $alertcss = false;
- protected static $defaultbody = '%HEADER%\n\n%NAV%\n\n%ASIDE%\n\n%MAIN%\n\n%FOOTER%';
+ protected static $defaultbody = "%HEADER%\n\n%NAV%\n\n%ASIDE%\n\n%MAIN%\n\n%FOOTER%";
protected static $defaultfavicon = '';
protected static $defaultthumbnail = '';
protected static $analytics = '';
diff --git a/app/class/Controller.php b/app/class/Controller.php
index 34b3d11..46c9ee0 100644
--- a/app/class/Controller.php
+++ b/app/class/Controller.php
@@ -46,8 +46,8 @@ class Controller
{
$router = $this->router;
$this->plates = new Engine(Model::TEMPLATES_DIR);
- $this->plates->registerFunction('url', function (string $string, array $vars = []) {
- return $this->generate($string, $vars);
+ $this->plates->registerFunction('url', function (string $string, array $vars = [], string $get = '') {
+ return $this->generate($string, $vars, $get);
});
$this->plates->registerFunction('upage', function (string $string, string $id) {
return $this->generate($string, ['page' => $id]);
@@ -79,13 +79,14 @@ class Controller
*
* @param string $route The name of the route.
* @param array $params Associative array of parameters to replace placeholders with.
+ * @param string $get Optionnal query GET parameters formated
* @return string The URL of the route with named parameters in place.
* @throws InvalidArgumentException If the route does not exist.
*/
- public function generate(string $route, array $params = []): string
+ public function generate(string $route, array $params = [], string $get = ''): string
{
try {
- return $this->router->generate($route, $params);
+ return $this->router->generate($route, $params) . $get;
} catch (Exception $e) {
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php
index 6e2155a..1385652 100644
--- a/app/class/Controllerhome.php
+++ b/app/class/Controllerhome.php
@@ -182,9 +182,11 @@ class Controllerhome extends Controllerpage
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($_POST['id'], $_POST['query']);
+ $user->addbookmark($bookmark);
$usermanager->add($user);
} else {
Config::addbookmark($_POST['id'], $_POST['query']);
diff --git a/app/class/Element.php b/app/class/Element.php
index 638d624..7478256 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/Item.php b/app/class/Item.php
index a76e700..76fa78e 100644
--- a/app/class/Item.php
+++ b/app/class/Item.php
@@ -29,14 +29,47 @@ abstract class Item
}
}
-
public function dry()
{
$array = [];
+ $array = $this->obj2array($this, $array);
+ return $array;
+ }
+
+
+ public function obj2array($obj, &$arr)
+ {
+ if (!is_object($obj) && !is_array($obj)) {
+ $arr = $obj;
+ return $arr;
+ }
+ foreach ($obj as $key => $value) {
+ if (!empty($value)) {
+ $arr[$key] = array();
+ $this->obj2array($value, $arr[$key]);
+ } else {
+ $arr[$key] = $value;
+ }
+ }
+ return $arr;
+ }
+
+ public function dryold()
+ {
+ $array = [];
foreach (get_object_vars($this) as $var => $value) {
- $array[$var] = $this->$var();
+ if (is_object($value) && is_subclass_of($value, get_class($this))) {
+ $array[$var] = $value->dry();
+ } else {
+ if (method_exists($this, $var)) {
+ $array[$var] = $this->$var();
+ } else {
+ $array[$var] = $value;
+ }
+ }
}
- return $array;
+ return get_object_vars($this);
+ // return $array;
}
diff --git a/app/class/Model.php b/app/class/Model.php
index 692257a..7e891f1 100644
--- a/app/class/Model.php
+++ b/app/class/Model.php
@@ -80,6 +80,12 @@ abstract class Model
'' => 'other'
];
+ public const BOOKMARK_ICONS = [
+ '๐ŸŒ˜', 'โ˜‚๏ธ', 'โญ๏ธ', 'โœˆ๏ธ', '๐Ÿšฒ', '๐Ÿ’ก', '๐Ÿ’พ', '๐Ÿ’ฟ', '๐Ÿ’Ž', '๐ŸŽž', ' โš’', '๐Ÿ’Š', '๐Ÿ“œ', '๐Ÿ“Œ', '๐Ÿ”', '๐Ÿ“ฆ', '๐Ÿ”’',
+ '๐Ÿ“’', '๐Ÿ”“', '๐ŸŒก', 'โ˜Ž๏ธ', '๐Ÿ–ค', 'โœ๏ธ', 'โ˜ข๏ธ', 'โœ…', '๐ŸŒ', '๐ŸŒ', 'โœณ๏ธ', '๐Ÿด', '๐Ÿ˜Ž', '๐Ÿ‘ป', '๐Ÿ’ฉ', '๐Ÿ‘', 'โšก๏ธ', '๐Ÿธ',
+ '๐Ÿด', 'โšฝ๏ธ', '๐Ÿญ', '๐Ÿš€', 'โš“๏ธ'
+ ];
+
public const LIST_STYLES = [
'list' => 'list',
'card' => 'card'
@@ -115,6 +121,7 @@ abstract class Model
public const PASSWORD_MIN_LENGTH = 4;
public const PASSWORD_MAX_LENGTH = 32;
public const MAX_COOKIE_CONSERVATION = 365;
+ public const MAX_QUERY_LENGH = 256;
/** RENDER OPTIONS */
// add class in html element indicating from witch page the content come.
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php
index 7322955..1ad9e20 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;
}
@@ -164,7 +164,7 @@ class Modelrender extends Modelpage
if ($subcontent !== false) {
if (empty($subcontent && self::RENDER_VERBOSE > 0)) {
$message = 'The ' . strtoupper($type) . ' from page "' . $source . '" is currently empty !';
- $subcontent = '\n<!-- ' . $message . ' -->\n';
+ $subcontent = "\n<!-- ' . $message . ' -->\n";
}
} else {
$read = '<h2>Rendering error :</h2>';
@@ -231,45 +231,51 @@ class Modelrender extends Modelpage
public function gethead()
{
+ $id = $this->page->id();
+ $globalpath = Model::globalpath();
+ $renderpath = Model::renderpath();
+ $description = $this->page->description();
+ $title = $this->page->title();
+ $url = Config::url();
$head = '';
- $head .= '<meta charset="utf-8" />\n';
- $head .= '<title>' . $this->page->title() . '</title>\n';
+ $head .= "<meta charset=\"utf-8\" />\n";
+ $head .= "<title>$title</title>\n";
if (!empty($this->page->favicon())) {
$href = Model::faviconpath() . $this->page->favicon();
- $head .= '<link rel="shortcut icon" href="' . $href . '" type="image/x-icon">';
+ $head .= "<link rel=\"shortcut icon\" href=\"$href\" type=\"image/x-icon\">";
} elseif (!empty(Config::defaultfavicon())) {
$href = Model::faviconpath() . Config::defaultfavicon();
- $head .= '<link rel="shortcut icon" href="' . $href . '" type="image/x-icon">';
+ $head .= "<link rel=\"shortcut icon\" href=\"$href\" type=\"image/x-icon\">";
}
- $head .= '<meta name="description" content="' . $this->page->description() . '" />\n';
- $head .= '<meta name="viewport" content="width=device-width" />\n';
+ $head .= "<meta name=\"description\" content=\"$description\" />\n";
+ $head .= "<meta name=\"viewport\" content=\"width=device-width\" />\n";
- $head .= '<meta property="og:title" content="' . $this->page->title() . '">\n';
- $head .= '<meta property="og:description" content="' . $this->page->description() . '">\n';
+ $head .= "<meta property=\"og:title\" content=\"$title\">\n";
+ $head .= "<meta property=\"og:description\" content=\"$description\">\n";
if (!empty($this->page->thumbnail())) {
$content = Config::domain() . self::thumbnailpath() . $this->page->thumbnail();
- $head .= '<meta property="og:image" content="' . $content . '">\n';
+ $head .= "<meta property=\"og:image\" content=\"$content\">\n";
} elseif (!empty(Config::defaultthumbnail())) {
$content = Config::domain() . self::thumbnailpath() . Config::defaultthumbnail();
- $head .= '<meta property="og:image" content="' . $content . '">\n';
+ $head .= "<meta property=\"og:image\" content=\"$content\">\n";
}
- $head .= '<meta property="og:url" content="' . Config::url() . $this->page->id() . '/">\n';
+ $head .= "<meta property=\"og:url\" content=\"$url . $id/\">\n";
foreach ($this->page->externalcss() as $externalcss) {
- $head .= '<link href="' . $externalcss . '" rel="stylesheet" />\n';
+ $head .= "<link href=\"$externalcss\" rel=\"stylesheet\" />\n";
}
if (!empty($this->page->templatecss() && in_array('externalcss', $this->page->templateoptions()))) {
$templatecss = $this->get($this->page->templatecss());
if ($templatecss !== false) {
foreach ($templatecss->externalcss() as $externalcss) {
- $head .= '<link href="' . $externalcss . '" rel="stylesheet" />\n';
+ $head .= "<link href=\"$externalcss\" rel=\"stylesheet\" />\n";
}
}
}
@@ -277,45 +283,45 @@ class Modelrender extends Modelpage
$head .= PHP_EOL . $this->page->customhead() . PHP_EOL;
- $head .= '<link href="' . Model::globalpath() . 'fonts.css" rel="stylesheet" />\n';
- $head .= '<link href="' . Model::globalpath() . 'global.css" rel="stylesheet" />\n';
+ $head .= "<link href=\"{$globalpath}fonts.css\" rel=\"stylesheet\" />\n";
+ $head .= "<link href=\"{$globalpath}global.css\" rel=\"stylesheet\" />\n";
if (!empty($this->page->templatecss())) {
$tempaltecsspage = $this->page->templatecss();
- $head .= '<link href="' . Model::renderpath() . $tempaltecsspage . '.css" rel="stylesheet" />\n';
+ $head .= "<link href=\"$renderpath . $tempaltecsspage.css\" rel=\"stylesheet\" />\n";
}
- $head .= '<link href="' . Model::renderpath() . $this->page->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="' . Model::renderpath() . $templatejspage . '.js" async/></script>\n';
+ $head .= "<script src=\"$renderpath . $templatejspage.js\" async/></script>\n";
}
if (!empty($this->page->javascript())) {
- $head .= '<script src="' . Model::renderpath() . $this->page->id() . '.js" async/></script>\n';
+ $head .= "<script src=\"$renderpath . $id.js\" async/></script>\n";
}
if (!empty(Config::analytics())) {
- $head .= '\n
- <!-- Global site tag (gtag.js) - Google Analytics -->
- <script async src="https://www.googletagmanager.com/gtag/js?id=' . Config::analytics() . '"></script>
+ $analitycs = Config::analytics();
+ $head .= "\n
+ <!-- Global site tag (gtag.js) - Google Analytics -->
+ <script async src=\"https://www.googletagmanager.com/gtag/js?id=$analitycs\"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
- gtag(\'js\', new Date());
+ gtag('js', new Date());
- gtag(\'config\', \'' . Config::analytics() . '\');
+ gtag('config', 'Config::analytics()');
</script>
- \n';
+ \n";
}
if (!empty($this->page->redirection())) {
if (preg_match('%https?:\/\/\S*%', $this->page->redirection(), $out)) {
$url = $out[0];
- $head .= '\n<meta http-equiv="refresh" content="' . $this->page->refresh() . '; URL=' . $url . '" />';
} elseif (key_exists($this->page->redirection(), $this->pagelist())) {
$url = $this->upage($this->page->redirection());
- $head .= '\n<meta http-equiv="refresh" content="' . $this->page->refresh() . '; URL=' . $url . '" />';
}
+ $head .= "\n<meta http-equiv=\"refresh\" content=\"{$this->page->refresh()}; URL=$url\" />";
}
@@ -503,7 +509,7 @@ class Modelrender extends Modelpage
} else {
$id = ' ';
}
- return '<article ' . $id . ' markdown="1" >\n\n' . $matches[3] . '\n\n</article>\n\n';
+ return "<article $id markdown=\"1\" >\n\n$matches[3]\n\n</article>\n\n";
}, $text);
$text = preg_replace('/\R\R[=]{3,}([\w-]*)\R/', '', $text);
return $text;
diff --git a/app/class/Modeluser.php b/app/class/Modeluser.php
index 0e3cc5f..c9e38c6 100644
--- a/app/class/Modeluser.php
+++ b/app/class/Modeluser.php
@@ -55,7 +55,7 @@ class Modeluser extends Modeldb
if (hash_equals($cookiemac, secrethash($dbtoken->getId()))) {
$user = $this->get($dbtoken->user);
if ($user !== false) {
- $this->writesession($user, $_COOKIE['authtoken']);
+ $this->writesession($user);
}
return $user;
}
diff --git a/app/class/Opt.php b/app/class/Opt.php
index df3cb50..24c7f90 100644
--- a/app/class/Opt.php
+++ b/app/class/Opt.php
@@ -165,7 +165,7 @@ class Opt extends Item
$authorstring = "";
foreach ($authorlist as $author) {
$href = $this->getfilteradress(['authorfilter' => [$author]]);
- $authorstring .= '<a class="author author_' . $author . '" href="?' . $href . '" >' . $author . '</a>\n';
+ $authorstring .= "<a class=\"author author_$author\" href=\"?$href\" >$author</a>\n";
}
return $authorstring;
}
@@ -173,7 +173,7 @@ class Opt extends Item
public function securelink(int $level, string $secure)
{
$href = $this->getfilteradress(['secure' => $level]);
- return '<a class="secure ' . $secure . '" href="?' . $href . '">' . $secure . '</a>\n';
+ return "<a class=\"secure $secure\" href=\"?$href\">$secure</a>\n";
}
public function linktolink(array $linktolist)
@@ -181,7 +181,7 @@ class Opt extends Item
$linktostring = "";
foreach ($linktolist as $linkto) {
$href = $this->getfilteradress(['linkto' => $linkto]);
- $linktostring .= '<a class="linkto" href="?' . $href . '" >' . $linkto . '</a>\n';
+ $linktostring .= "<a class=\"linkto\" href=\"?$href\" >$linkto</a>\n";
}
return $linktostring;
}
diff --git a/app/class/Page.php b/app/class/Page.php
index da149f7..43cf387 100644
--- a/app/class/Page.php
+++ b/app/class/Page.php
@@ -387,7 +387,7 @@ class Page extends Dbitem
public function setid($id)
{
- if (strlen($id) <= Model::MAX_ID_LENGTH and is_string($id)) {
+ if (is_string($id) && strlen($id) <= Model::MAX_ID_LENGTH) {
$this->id = strip_tags(strtolower(str_replace(" ", "", $id)));
}
}
diff --git a/app/class/User.php b/app/class/User.php
index a62091f..56e994d 100644
--- a/app/class/User.php
+++ b/app/class/User.php
@@ -16,6 +16,7 @@ class User extends Item
protected $columns = ['title', 'datemodif', 'datecreation', 'secure', 'visitcount'];
protected $connectcount = 0;
protected $expiredate = false;
+ /** @var Bookmark[] Associative array as `id => Bookmark`*/
protected $bookmark = [];
protected $display = ['bookmark' => false];
@@ -198,7 +199,15 @@ class User extends Item
public function setbookmark($bookmark)
{
if (is_array($bookmark)) {
- $this->bookmark = $bookmark;
+ $bookmark = array_map(
+ function ($datas) {
+ if (is_array($datas) && !empty($datas)) {
+ return new Bookmark($datas);
+ }
+ },
+ $bookmark
+ );
+ $this->bookmark = array_filter($bookmark);
}
}
@@ -285,12 +294,10 @@ class User extends Item
$this->connectcount ++;
}
- public function addbookmark(string $id, string $query)
+ public function addbookmark(Bookmark $bookmark)
{
- if (!empty($id) && !empty($query)) {
- $id = idclean($id);
- $id = substr($id, 0, 16);
- $this->bookmark[$id] = $query;
+ if (!empty($bookmark->id()) && !empty($bookmark->query()) && !empty($bookmark->route())) {
+ $this->bookmark[$bookmark->id()] = $bookmark;
}
}
diff --git a/app/fn/fn.php b/app/fn/fn.php
index 737590f..4ad0c6b 100644
--- a/app/fn/fn.php
+++ b/app/fn/fn.php
@@ -87,7 +87,13 @@ function arrayclean($input)
return $output;
}
-function idclean(string $input): string
+/**
+ * Clean string from characters outside `[0-9a-z-_]` and troncate it
+ * @param string $input
+ * @param int $max lenght to trucate id
+ * @return string output formated id
+ */
+function idclean(string $input, int $max = Wcms\Model::MAX_ID_LENGTH): string
{
$input = urldecode($input);
$search = ['รฉ', 'ร ', 'รจ', 'รง', 'รน', 'รฏ', 'รฎ', ' '];
@@ -96,7 +102,7 @@ function idclean(string $input): string
$input = preg_replace('%[^a-z0-9-_+]%', '', strtolower(trim($input)));
- $input = substr($input, 0, Wcms\Model::MAX_ID_LENGTH);
+ $input = substr($input, 0, $max);
return $input;
}
@@ -335,18 +341,22 @@ function recurse_copy($src, $dst)
*
* @param array $options as `value => title`
* @param string|int $selected value of actualy selected option
+ * @param bool $title Use title as value. Default : false
*
* @return string HTML list of options
*/
-function options(array $options, $selected = null): string
+function options(array $options, $selected = null, $title = false): string
{
$html = '';
foreach ($options as $value => $title) {
- if ($value == $selected) {
+ if ($value === $selected) {
$attribute = 'selected';
} else {
$attribute = '';
}
+ if ($title) {
+ $value = $title;
+ }
$html .= '<option value="' . $value . '" ' . $attribute . '>' . $title . '</option>' . PHP_EOL;
}
return $html;
diff --git a/app/view/templates/backtopbar.php b/app/view/templates/backtopbar.php
index 597ae6f..6aded61 100644
--- a/app/view/templates/backtopbar.php
+++ b/app/view/templates/backtopbar.php
@@ -30,25 +30,15 @@
<img src="<?= Wcms\Model::iconpath() ?>media.png" alt="" class="icon">
<span class="hidephone">media</span>
</a>
-<?php
-if($user->isadmin()) {
-?>
-<a href="<?= $this->url('admin') ?>" <?= $tab == 'admin' ? 'class="actualpage"' : '' ?>>
- <img src="<?= Wcms\Model::iconpath() ?>admin.png" alt="" class="icon">
- <span class="hidephone">admin</span>
-</a>
-<?php
-}
-?>
-<a href="<?= $this->url('info') ?>" <?= $tab == 'info' ? 'class="actualpage"' : '' ?>>
- <img src="<?= Wcms\Model::iconpath() ?>info.png" alt="" class="icon">
- <span class="hidephone">info</span>
-</a>
</span>
-
+<span id="shortcuts" class="hidephone">
+ <?php foreach ($user->bookmark() as $bookmark) { ?>
+ <a href="<?= $this->url($bookmark->route(), $bookmark->params(), $bookmark->query()) ?>"><?= $bookmark->icon() ?> <?= $bookmark->id() ?></a>
+ <?php } ?>
+</span>
<?php } ?>
@@ -75,6 +65,22 @@ if($user->isadmin()) {
<span>
+<?php
+if($user->isadmin()) {
+?>
+<a href="<?= $this->url('admin') ?>" <?= $tab == 'admin' ? 'class="actualpage"' : '' ?>>
+ <img src="<?= Wcms\Model::iconpath() ?>admin.png" alt="" class="icon">
+ <span class="hidephone">admin</span>
+
+</a>
+<?php
+}
+?>
+<a href="<?= $this->url('info') ?>" <?= $tab == 'info' ? 'class="actualpage"' : '' ?>>
+ <img src="<?= Wcms\Model::iconpath() ?>info.png" alt="" class="icon">
+ <span class="hidephone">info</span>
+</a>
+
<a href="<?= $this->url('user') ?>" <?= $tab == 'user' ? 'class="actualpage"' : '' ?>>
<img src="<?= Wcms\Model::iconpath() ?>user.png" alt="" class="icon">
<span class="hidephone"><?= $user->id() ?></span>
diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php
index 540806b..0848506 100644
--- a/app/view/templates/homemenu.php
+++ b/app/view/templates/homemenu.php
@@ -266,7 +266,7 @@
<?php } ?>
</ul>
<input type="hidden" name="action" value="del">
- <input type="submit" value="delete selected" class="floatright">
+ <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>
@@ -284,22 +284,25 @@
<?php if(!empty($user->bookmark())) { ?>
<form action="<?= $this->url('homebookmark') ?>" method="post">
<ul>
- <?php foreach ($user->bookmark() as $id => $query) { ?>
+ <?php foreach ($user->bookmark() as $bookmark) { ?>
<li>
- <a href="<?= $query ?>" title="<?= $query ?>"><?= $id ?></a>
- <input type="checkbox" name="id[]" value="<?= $id ?>">
+ <label for="bookmark_<?= $bookmark->id() ?>" title="<?= $bookmark->query() ?>"><?= $bookmark->id() ?></label>
+ <input type="checkbox" name="id[]" value="<?= $bookmark->id() ?>" id="bookmark_<?= $bookmark->id() ?>">
</li>
<?php } ?>
</ul>
<input type="hidden" name="action" value="del">
<input type="hidden" name="user" value="<?= $user->id() ?>">
- <input type="submit" value="delete selected" class="floatright">
+ <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">
- <input type="text" name="id" placeholder="bookmark id" minlength="1" maxlength="16">
+ <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="user" value="<?= $user->id() ?>">
<input type="submit" name="action" value="add">
diff --git a/assets/css/home.css b/assets/css/home.css
index 5cabfda..221472e 100644
--- a/assets/css/home.css
+++ b/assets/css/home.css
@@ -6,11 +6,6 @@
display: inline;
}
-.floatright {
- float: right;
-}
-
-
#flashmessage {
color: white;
border: solid white 1px;
diff --git a/index.php b/index.php
index 230b0e6..41a2184 100644
--- a/index.php
+++ b/index.php
@@ -33,7 +33,7 @@ if (isreportingerrors()) {
try {
$matchoper = new Wcms\Routes();
$matchoper->match();
-} catch (Throwable $e) {
+} catch (Exception $e) {
if (isreportingerrors()) {
Sentry\captureException($e);
}