aboutsummaryrefslogtreecommitdiff
path: root/app/class/Bookmark.php
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 /app/class/Bookmark.php
parent0efeef6b6693d62675ec8a45e73c71f69e0a0362 (diff)
downloadwcms-53e6d5fde32a917718a0658fb95f366dc7dfc248.tar.gz
wcms-53e6d5fde32a917718a0658fb95f366dc7dfc248.zip
user bookmarks use new object
+ shortcuts visible in backtopbar
Diffstat (limited to 'app/class/Bookmark.php')
-rw-r--r--app/class/Bookmark.php106
1 files changed, 106 insertions, 0 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);
+ }
+ }
+}