From 8613054d6970087d51d0fbbc5cd7a924496445f2 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 17 Jan 2024 17:51:25 +0100 Subject: [PATCH 1/7] Asset: introduce save method --- models/Asset.php | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/models/Asset.php b/models/Asset.php index c2973c7..49e43bc 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -8,17 +8,17 @@ class Asset { - protected $id_asset; - protected $id_user_uploaded; - protected $subdir; - protected $filename; - protected $title; - protected $slug; - protected $mimetype; - protected $image_width; - protected $image_height; - protected $date_captured; - protected $priority; + public $id_asset; + public $id_user_uploaded; + public $subdir; + public $filename; + public $title; + public $slug; + public $mimetype; + public $image_width; + public $image_height; + public $date_captured; + public $priority; protected $meta; protected $tags; @@ -675,6 +675,28 @@ class Asset FROM assets'); } + public function save() + { + if (empty($this->id_asset)) + throw new UnexpectedValueException(); + + return Registry::get('db')->query(' + UPDATE assets + SET id_asset = {int:id_asset}, + id_user_uploaded = {int:id_user_uploaded}, + subdir = {string:subdir}, + filename = {string:filename}, + title = {string:title}, + slug = {string:slug}, + mimetype = {string:mimetype}, + image_width = {int:image_width}, + image_height = {int:image_height}, + date_captured = {datetime:date_captured}, + priority = {int:priority} + WHERE id_asset = {int:id_asset}', + get_object_vars($this)); + } + public function setKeyData($title, $slug, DateTime $date_captured = null, $priority) { $params = [ -- 2.46.0 From 069d56383e78cd66b07e08d60ef3fff3d47c0207 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 17 Jan 2024 17:51:45 +0100 Subject: [PATCH 2/7] PhotosIndex: replace edit button with edit menu --- controllers/EditAsset.php | 16 ++++++++++++++++ public/css/admin.css | 24 ------------------------ public/css/default.css | 28 ++++++++++++++++++++++++++++ templates/PhotoPage.php | 20 +++++++++++--------- templates/PhotosIndex.php | 25 +++++++++++++++++++++++-- 5 files changed, 78 insertions(+), 35 deletions(-) diff --git a/controllers/EditAsset.php b/controllers/EditAsset.php index 6937f98..010144f 100644 --- a/controllers/EditAsset.php +++ b/controllers/EditAsset.php @@ -30,6 +30,22 @@ class EditAsset extends HTMLController header('Location: ' . $redirectUrl); exit; } + else if ((isset($_REQUEST['inc_prio']) || isset($_REQUEST['dec_prio'])) && Session::validateSession('get')) + { + if (isset($_REQUEST['inc_prio'])) + $priority = $asset->priority + 1; + else + $priority = $asset->priority - 1; + + $asset->priority = max(0, min(100, $priority)); + $asset->save(); + + if (isset($_SERVER['HTTP_REFERER'])) + header('Location: ' . $_SERVER['HTTP_REFERER']); + else + header('Location: ' . BASEURL . '/' . $asset->getSubdir()); + exit; + } // Get a list of available photo albums $allAlbums = []; diff --git a/public/css/admin.css b/public/css/admin.css index 24c1941..3213d44 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -1,27 +1,3 @@ -/* Edit icon on tiled grids ------------------------------*/ -.polaroid { - position: relative; -} -.polaroid a.edit { - background: var(--bs-body-bg); - border-radius: 3px; - box-shadow: 1px 1px 2px rgba(0,0,0,0.3); - color: var(--bs-body-color); - opacity: 0; - left: 20px; - line-height: 1.5; - padding: 5px 10px; - position: absolute; - transition: 0.25s; - top: 20px; - z-index: 50; -} -.polaroid:hover > a.edit { - opacity: 1; -} - - /* Crop editor ----------------*/ #crop_editor { diff --git a/public/css/default.css b/public/css/default.css index ee3b117..03f25f1 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -296,6 +296,34 @@ div.polaroid a { } +/* Edit icon on tiled grids +-----------------------------*/ +.polaroid { + position: relative; +} +.polaroid div.edit { + box-shadow: 1px 1px 2px rgba(0,0,0,0.3); + opacity: 0; + left: 20px; + position: absolute; + transition: 0.25s; + top: 20px; + z-index: 50; +} +.polaroid div.edit .dropdown-item { + line-height: 1.4; +} +.polaroid div.edit .dropdown-toggle { + line-height: 1.4; + padding: 0.25rem 0.5rem; +} +.polaroid div.edit .dropdown-toggle::after { + margin-left: 0; +} +.polaroid:hover > div.edit { + opacity: 1; +} + /* Album title boxes ----------------------*/ diff --git a/templates/PhotoPage.php b/templates/PhotoPage.php index 0b30954..39d6c79 100644 --- a/templates/PhotoPage.php +++ b/templates/PhotoPage.php @@ -25,7 +25,15 @@ class PhotoPage extends Template echo '
-
+
'; + + $this->photoMeta(); + + echo ' +
+
+
+
'; $this->userActions(); @@ -39,12 +47,6 @@ class PhotoPage extends Template echo '
-
'; - - $this->photoMeta(); - - echo ' -
'; } @@ -109,12 +111,12 @@ class PhotoPage extends Template private function photoMeta() { echo ' -