From 45466657b9761ed027e1fa9994dc851a831984ec Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 19:53:23 +0200 Subject: [PATCH 01/28] Added items count for recent collections --- admin/themes/default/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/index.php b/admin/themes/default/index.php index 181ddbee36..964b655ab2 100644 --- a/admin/themes/default/index.php +++ b/admin/themes/default/index.php @@ -74,7 +74,7 @@ foreach (loop('collections') as $collection): ?>
-

+

From 46ca5c06b087577bcd0de3b7085e80a46b20769c Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:06:28 +0200 Subject: [PATCH 02/28] Added recent_admin setting option --- application/forms/AppearanceSettings.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/forms/AppearanceSettings.php b/application/forms/AppearanceSettings.php index bd136c90d3..721fa9c432 100644 --- a/application/forms/AppearanceSettings.php +++ b/application/forms/AppearanceSettings.php @@ -44,6 +44,13 @@ public function init() 'required' => true, )); + $this->addElement('text', 'recent_admin', array( + 'label' => __('Recents Items/Collections (admin)'), + 'description' => __('Limit the number of recent Items and Collections displayed in the administrative inteface dashboard.'), + 'validators' => array('Digits'), + 'required' => true, + )); + $this->addElement('text', 'per_page_admin', array( 'label' => __('Results Per Page (admin)'), 'description' => __('Limit the number of results displayed per page in the administrative interface.'), @@ -99,7 +106,7 @@ public function init() $this->addDisplayGroup( array( - 'use_square_thumbnail', 'link_to_file_metadata', 'per_page_admin', 'per_page_public', + 'use_square_thumbnail', 'link_to_file_metadata', 'recent_admin', 'per_page_admin', 'per_page_public', 'show_empty_elements', 'show_element_set_headings', ), 'display-settings', array('legend' => __('Display Settings')) From b65690c6b65687452b0d0ec8435b041b22156415 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:09:51 +0200 Subject: [PATCH 03/28] Added default value for recent_admin setting Value is the one used now for Omeka: 5 --- application/controllers/AppearanceController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/controllers/AppearanceController.php b/application/controllers/AppearanceController.php index 1a7fd818b9..7d1870fc10 100644 --- a/application/controllers/AppearanceController.php +++ b/application/controllers/AppearanceController.php @@ -14,6 +14,7 @@ class AppearanceController extends Omeka_Controller_AbstractActionController const DEFAULT_FULLSIZE_CONSTRAINT = 800; const DEFAULT_THUMBNAIL_CONSTRAINT = 200; const DEFAULT_SQUARE_THUMBNAIL_CONSTRAINT = 200; + const DEFAULT_RECENT_ADMIN = 5; const DEFAULT_PER_PAGE_ADMIN = 10; const DEFAULT_PER_PAGE_PUBLIC = 10; From 90401ce3d9d71089f7ddd4cb552268066d4a7432 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:13:09 +0200 Subject: [PATCH 04/28] Added recent_admin option --- application/forms/Install.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/forms/Install.php b/application/forms/Install.php index e82175fd39..f82a91c012 100644 --- a/application/forms/Install.php +++ b/application/forms/Install.php @@ -15,6 +15,7 @@ class Omeka_Form_Install extends Omeka_Form const DEFAULT_FULLSIZE_CONSTRAINT = 800; const DEFAULT_THUMBNAIL_CONSTRAINT = 200; const DEFAULT_SQUARE_THUMBNAIL_CONSTRAINT = 200; + const DEFAULT_RECENT_ADMIN = 5; const DEFAULT_PER_PAGE_ADMIN = 10; const DEFAULT_PER_PAGE_PUBLIC = 10; const DEFAULT_SHOW_EMPTY_ELEMENTS = false; @@ -148,6 +149,14 @@ public function init() 'required' => true )); + $this->addElement('text', 'recent_admin', array( + 'label' => __('Recent Items/Collections (admin)'), + 'description' => __('Limit the number of recent Items and Collections displayed in the administrative inteface.'), + 'value' => self::DEFAULT_RECENT_ADMIN, + 'validators' => array('Digits'), + 'required' => true + )); + $this->addElement('text', 'per_page_admin', array( 'label' => __('Items Per Page (admin)'), 'description' => __('Limit the number of items displayed per page in the administrative interface.'), @@ -190,8 +199,8 @@ public function init() array('administrator_email', 'site_title', 'description', 'copyright', 'author', 'tag_delimiter', 'fullsize_constraint', 'thumbnail_constraint', 'square_thumbnail_constraint', - 'per_page_admin', 'per_page_public', 'show_empty_elements', - 'path_to_convert'), + 'recent_admin', 'per_page_admin', 'per_page_public', + 'show_empty_elements', 'path_to_convert'), 'site_settings', array('legend' => __('Site Settings')) ); From 663e468a92f17ab83d7b010457652846d2102ead Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:14:39 +0200 Subject: [PATCH 05/28] Update AppearanceSettings.php --- application/forms/AppearanceSettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/AppearanceSettings.php b/application/forms/AppearanceSettings.php index 721fa9c432..da36bdfca7 100644 --- a/application/forms/AppearanceSettings.php +++ b/application/forms/AppearanceSettings.php @@ -46,7 +46,7 @@ public function init() $this->addElement('text', 'recent_admin', array( 'label' => __('Recents Items/Collections (admin)'), - 'description' => __('Limit the number of recent Items and Collections displayed in the administrative inteface dashboard.'), + 'description' => __('Limit the number of recent Items and Collections displayed in the administrative inteface.'), 'validators' => array('Digits'), 'required' => true, )); From c89d27bed1dd052e22521d4ef86f4345ecfc02aa Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:16:56 +0200 Subject: [PATCH 06/28] Added recent_admin option --- application/models/Installer/Default.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/models/Installer/Default.php b/application/models/Installer/Default.php index 9e679700d9..da20f99aa3 100644 --- a/application/models/Installer/Default.php +++ b/application/models/Installer/Default.php @@ -106,6 +106,7 @@ private function _addOptions() 'thumbnail_constraint' => $this->_getValue('thumbnail_constraint'), 'square_thumbnail_constraint' => $this->_getValue('square_thumbnail_constraint'), 'fullsize_constraint' => $this->_getValue('fullsize_constraint'), + 'recent_admin' => $this->_getValue('recent_admin'), 'per_page_admin' => $this->_getValue('per_page_admin'), 'per_page_public' => $this->_getValue('per_page_public'), 'show_empty_elements' => $this->_getValue('show_empty_elements'), From 68f36ac2b0b67408fd1b00e156ad747420e5cba5 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:18:19 +0200 Subject: [PATCH 07/28] Added recent_admin option --- application/models/Installer/Task/Options.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/models/Installer/Task/Options.php b/application/models/Installer/Task/Options.php index a2f77ca0ef..0434441b9f 100644 --- a/application/models/Installer/Task/Options.php +++ b/application/models/Installer/Task/Options.php @@ -22,6 +22,7 @@ class Installer_Task_Options implements Installer_TaskInterface 'thumbnail_constraint', 'square_thumbnail_constraint', 'fullsize_constraint', + 'recent_admin', 'per_page_admin', 'per_page_public', 'show_empty_elements', From fbb28aab0a9e29c7ad704d11fa15b8f96bfded65 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:19:08 +0200 Subject: [PATCH 08/28] Added recent_admin option --- application/models/Installer/Test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/models/Installer/Test.php b/application/models/Installer/Test.php index f327231610..2c67f50490 100644 --- a/application/models/Installer/Test.php +++ b/application/models/Installer/Test.php @@ -24,6 +24,7 @@ class Installer_Test extends Installer_Default 'thumbnail_constraint' => Omeka_Form_Install::DEFAULT_THUMBNAIL_CONSTRAINT, 'square_thumbnail_constraint' => Omeka_Form_Install::DEFAULT_SQUARE_THUMBNAIL_CONSTRAINT, 'fullsize_constraint' => Omeka_Form_Install::DEFAULT_FULLSIZE_CONSTRAINT, + 'recent_admin' => Omeka_Form_Install::DEFAULT_RECENT_ADMIN, 'per_page_admin' => Omeka_Form_Install::DEFAULT_PER_PAGE_ADMIN, 'per_page_public' => Omeka_Form_Install::DEFAULT_PER_PAGE_PUBLIC, 'show_empty_elements' => Omeka_Form_Install::DEFAULT_SHOW_EMPTY_ELEMENTS, From f97c1bb05a0b89922cf65c90d22407cb9dc7d041 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 21:23:48 +0200 Subject: [PATCH 09/28] Added option for recent Items and Collections Number of recent Items and Collections displayed in the Admin dashboard is now configurable (default value: 5) --- admin/themes/default/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/index.php b/admin/themes/default/index.php index 964b655ab2..5d9bd586ae 100644 --- a/admin/themes/default/index.php +++ b/admin/themes/default/index.php @@ -51,7 +51,7 @@

@@ -69,7 +69,7 @@

From abe7a9bb9183924d4ca7b1ac0b7b6011cc9c1670 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 21:41:01 +0200 Subject: [PATCH 10/28] Added styling for input type=email --- admin/themes/default/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/css/style.css b/admin/themes/default/css/style.css index e9941d924b..fbabcb731e 100644 --- a/admin/themes/default/css/style.css +++ b/admin/themes/default/css/style.css @@ -246,7 +246,7 @@ img { border: 0; } font-family: monospace; } - input[type=text], input[type=password] { + input[type=text], input[type=password], input[type=email] { { height: 30px; border: 1px solid #d8d8d8; -webkit-border-radius: 0; From 89c4c938dd7c25c88486dd0a02c758b0bb8998a8 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 21:43:22 +0200 Subject: [PATCH 11/28] Added styling for .inputs input[type=email] --- admin/themes/default/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/css/style.css b/admin/themes/default/css/style.css index fbabcb731e..e2dedf658f 100644 --- a/admin/themes/default/css/style.css +++ b/admin/themes/default/css/style.css @@ -304,7 +304,7 @@ img { border: 0; } } - .inputs input[type=text], .inputs input[type=password], .inputs textarea { + .inputs input[type=text], .inputs input[type=password], .inputs input[type=email], .inputs textarea { width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; From d4b13a0148a0c3a7664d95e8552ac8fb82ec722b Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 21:48:25 +0200 Subject: [PATCH 12/28] Corrected typo --- admin/themes/default/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/css/style.css b/admin/themes/default/css/style.css index e2dedf658f..74afe5e50d 100644 --- a/admin/themes/default/css/style.css +++ b/admin/themes/default/css/style.css @@ -246,7 +246,7 @@ img { border: 0; } font-family: monospace; } - input[type=text], input[type=password], input[type=email] { { + input[type=text], input[type=password], input[type=email] { height: 30px; border: 1px solid #d8d8d8; -webkit-border-radius: 0; From 16b3e75fd93006e9d7edb05ed74fc71ad8966add Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 21:58:18 +0200 Subject: [PATCH 13/28] Added Delete link to Collections Just like for Items browse, I've added a Delete link to every single collection for which Editing and Deleting are possible (there should be no Deleting without Editing permission) --- admin/themes/default/collections/browse.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/collections/browse.php b/admin/themes/default/collections/browse.php index 11f1ec141d..f1c6493317 100644 --- a/admin/themes/default/collections/browse.php +++ b/admin/themes/default/collections/browse.php @@ -46,11 +46,12 @@ public) echo __('(Private)'); ?> - - $collection, 'view' => $this)); ?> From 3b40caef2218ae0a58e63bebdfaaeffafed16051 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 22:08:18 +0200 Subject: [PATCH 14/28] Added quick-filters.php file --- admin/themes/default/collections/quick-filters.php | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 admin/themes/default/collections/quick-filters.php diff --git a/admin/themes/default/collections/quick-filters.php b/admin/themes/default/collections/quick-filters.php new file mode 100644 index 0000000000..d608e1721d --- /dev/null +++ b/admin/themes/default/collections/quick-filters.php @@ -0,0 +1,11 @@ + From a5fb02d0d4fa39c8fa263f47e01489f0e87b4620 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 22:12:37 +0200 Subject: [PATCH 15/28] Added quick-filters Just like for Items browse, added quick-filters. I'm using the same function used in Items browse (item_search_filters()) to show the quick-filters, as there's no Collections search page that can alter it; though, a dedicated function could be neater. --- admin/themes/default/collections/browse.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/admin/themes/default/collections/browse.php b/admin/themes/default/collections/browse.php index f1c6493317..73e271fe25 100644 --- a/admin/themes/default/collections/browse.php +++ b/admin/themes/default/collections/browse.php @@ -3,6 +3,7 @@ $totalItemsWithoutCollection = get_db()->getTable('Item')->count(array('collection' => 0)); echo head(array('title'=>$pageTitle, 'bodyclass'=>'collections')); echo flash(); +echo item_search_filters(); ?> 0): ?> @@ -12,6 +13,7 @@ +

Date: Wed, 31 Mar 2021 22:26:08 +0200 Subject: [PATCH 16/28] Added styling for collection-filters --- admin/themes/default/css/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/css/style.css b/admin/themes/default/css/style.css index 74afe5e50d..b97564e284 100644 --- a/admin/themes/default/css/style.css +++ b/admin/themes/default/css/style.css @@ -1547,14 +1547,14 @@ header nav { margin-bottom: 20px; } - #item-filters ul { + #item-filters ul, #collection-filters ul { clear: both; list-style-type: none; padding: 0; margin: 0; } - #item-filters li { + #item-filters li, #collection-filters li { display: inline-block; background: url('../images/search.png') no-repeat; padding: 0 0 0 21px; From 5117c19afbd451838e7340f370e1f240ed16b5e6 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 22:29:38 +0200 Subject: [PATCH 17/28] Added collection_search_filters function --- application/libraries/globals.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/application/libraries/globals.php b/application/libraries/globals.php index 1863e33d7a..dd589fa5bf 100644 --- a/application/libraries/globals.php +++ b/application/libraries/globals.php @@ -2023,6 +2023,19 @@ function item_search_filters(array $params = null) return get_view()->itemSearchFilters($params); } +/** + * Get a list of the current search collection filters in use. + * + * @package Omeka\Function\Search + * @uses Omeka_View_Helper_SearchFilters::searchFilters() + * @params array $params Params to override the ones read from the request. + * @return string + */ +function collection_search_filters(array $params = null) +{ + return get_view()->collectionSearchFilters($params); +} + /** * Get metadata for a record. * From 7c4a23b066120ac3944646a12c225cb6c61d70b4 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Wed, 31 Mar 2021 22:32:05 +0200 Subject: [PATCH 18/28] Added file Needed to show search filter in Collection/browse page, Admin side --- .../views/helpers/CollectionSearchFilters.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 application/views/helpers/CollectionSearchFilters.php diff --git a/application/views/helpers/CollectionSearchFilters.php b/application/views/helpers/CollectionSearchFilters.php new file mode 100644 index 0000000000..dac7c81eab --- /dev/null +++ b/application/views/helpers/CollectionSearchFilters.php @@ -0,0 +1,70 @@ +getRequest(); + $requestArray = $request->getParams(); + } else { + $requestArray = $params; + } + + $db = get_db(); + $displayArray = array(); + foreach ($requestArray as $key => $value) { + if ($value != null) { + $filter = ucfirst($key); + $displayValue = null; + switch ($key) { + case 'public': + case 'featured': + $displayValue = ($value == 1 ? __('Yes') : $displayValue = __('No')); + break; + } + if ($displayValue) { + $displayArray[$filter] = $displayValue; + } + } + } + + $displayArray = apply_filters('collection_search_filters', $displayArray, array('request_array' => $requestArray)); + + $html = ''; + if (!empty($displayArray) || !empty($advancedArray)) { + $html .= '

'; + $html .= '
    '; + foreach ($displayArray as $name => $query) { + $class = html_escape(strtolower(str_replace(' ', '-', $name))); + $html .= '
  • ' . html_escape(__($name)) . ': ' . html_escape($query) . '
  • '; + } + if (!empty($advancedArray)) { + foreach ($advancedArray as $j => $advanced) { + $html .= '
  • ' . html_escape($advanced) . '
  • '; + } + } + $html .= '
'; + $html .= '
'; + } + return $html; + } +} \ No newline at end of file From 524de440d1b0ffadec2b936f78f1cf5ed878c6ae Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 00:12:52 +0200 Subject: [PATCH 19/28] Added details handling Added details handling, like for Items browse --- admin/themes/default/collections/browse.php | 33 +++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/admin/themes/default/collections/browse.php b/admin/themes/default/collections/browse.php index 73e271fe25..1cc5dee4cb 100644 --- a/admin/themes/default/collections/browse.php +++ b/admin/themes/default/collections/browse.php @@ -1,9 +1,10 @@ getTable('Item')->count(array('collection' => 0)); echo head(array('title'=>$pageTitle, 'bodyclass'=>'collections')); echo flash(); -echo item_search_filters(); +echo collection_search_filters(); ?> 0): ?> @@ -13,7 +14,7 @@ - +

public) echo __('(Private)'); ?> +

+ $collection, 'view' => $this)); ?> +
+

+ : + +

+

+ : + true, 'delimiter'=>' | ')); ?> +

+
hasContributor()): ?> @@ -78,7 +91,17 @@ +

+ + +

From 2e23da0637e6286df0500b47f3ad39212a7ea9a3 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 00:15:05 +0200 Subject: [PATCH 20/28] Provided details handling during browsing In Collections/Browse, details are now handled like for Items/Browse (admin side) --- .../default/javascripts/collections-browse.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 admin/themes/default/javascripts/collections-browse.js diff --git a/admin/themes/default/javascripts/collections-browse.js b/admin/themes/default/javascripts/collections-browse.js new file mode 100644 index 0000000000..560444d1fd --- /dev/null +++ b/admin/themes/default/javascripts/collections-browse.js @@ -0,0 +1,39 @@ +if (!Omeka) { + var Omeka = {}; +} + +Omeka.CollectionsBrowse = {}; + +(function ($) { + Omeka.CollectionsBrowse.setupDetails = function (detailsText, showDetailsText, hideDetailsText) { + $('.details').hide(); + $('.action-links').prepend(' '); + + $('tr.collection').each(function() { + var collectionDetails = $(this).find('.details'); + if ($.trim(collectionDetails.html()) != '') { + $(this).find('.details-link').css({'color': '#4E7181', 'cursor': 'pointer'}).click(function() { + collectionDetails.slideToggle('fast'); + }); + } + }); + + var toggleList = '' + showDetailsText + ''; + + $('.advanced-search-link').before(toggleList); + + // Toggle collection details. + var detailsShown = false; + $('.toggle-all-details').click(function (e) { + e.preventDefault(); + if (detailsShown) { + $('.toggle-all-details').text(showDetailsText); + $('.details').slideUp('fast'); + } else { + $('.toggle-all-details').text(hideDetailsText); + $('.details').slideDown('fast'); + } + detailsShown = !detailsShown; + }); + }; +})(jQuery); \ No newline at end of file From 83846d4b9b97038ccd1a4e6653f77674e946b75d Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 00:20:53 +0200 Subject: [PATCH 21/28] Fixed Details blue button visualization --- admin/themes/default/javascripts/collections-browse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/javascripts/collections-browse.js b/admin/themes/default/javascripts/collections-browse.js index 560444d1fd..b051c7b759 100644 --- a/admin/themes/default/javascripts/collections-browse.js +++ b/admin/themes/default/javascripts/collections-browse.js @@ -20,7 +20,7 @@ Omeka.CollectionsBrowse = {}; var toggleList = '' + showDetailsText + ''; - $('.advanced-search-link').before(toggleList); + $('.quick-filter-wrapper').before(toggleList); // Toggle collection details. var detailsShown = false; @@ -36,4 +36,4 @@ Omeka.CollectionsBrowse = {}; detailsShown = !detailsShown; }); }; -})(jQuery); \ No newline at end of file +})(jQuery); From d46af0eb760d02ea60879e02c3599850c462da5e Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 00:29:56 +0200 Subject: [PATCH 22/28] Added autosuggest for tag field --- admin/themes/default/items/batch-edit.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/admin/themes/default/items/batch-edit.php b/admin/themes/default/items/batch-edit.php index 8c22a587d9..d3c96393f4 100644 --- a/admin/themes/default/items/batch-edit.php +++ b/admin/themes/default/items/batch-edit.php @@ -1,4 +1,6 @@ ">
+

From cc11a98da1ec52fb2f0f9882974d446971231b33 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:46:19 +0200 Subject: [PATCH 23/28] Added mergeTags function --- application/models/Table/Tag.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/application/models/Table/Tag.php b/application/models/Table/Tag.php index 71b95e7bba..049e2d9e7e 100644 --- a/application/models/Table/Tag.php +++ b/application/models/Table/Tag.php @@ -191,4 +191,21 @@ public function findTagNamesLike($partialName, $limit = 10) $tags = $db->fetchCol($sql, array($partialName . '%')); return $tags; } + + public function mergeTags($oldTagId, $newTagId, $recordType = '') + { + if ($recordType != '') $recordType = " AND record_type = '" . $recordType . "'"; + + $db = $this->getDb(); + $sql = "UPDATE $db->RecordsTag SET tag_id = $newTagId, time = CURRENT_TIMESTAMP WHERE tag_id = $oldTagId" . $recordType . " AND record_id NOT IN (SELECT record_id FROM (SELECT DISTINCT record_id FROM $db->RecordsTag WHERE tag_id = $newTagId) AS tmptable)"; + $db->query($sql); + $sql = "DELETE FROM $db->RecordsTag WHERE tag_id = $oldTagId" . $recordType; + $db->query($sql); + $sql = "DELETE FROM $db->Tag WHERE id = $oldTagId"; + $db->query($sql); + + $sql = "SELECT COUNT(id) AS tagCount FROM $db->RecordsTag WHERE tag_id = $newTagId" . $recordType; + $tagCount = $db->fetchOne($sql); + return $tagCount; + } } From 4a8fd1b42ee67da09e764fac58efcc87de245ece Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:53:27 +0200 Subject: [PATCH 24/28] Added code to delete tags if not used anymore --- application/models/Mixin/Tag.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/application/models/Mixin/Tag.php b/application/models/Mixin/Tag.php index 4c736fd681..ffcee0b4db 100644 --- a/application/models/Mixin/Tag.php +++ b/application/models/Mixin/Tag.php @@ -139,6 +139,14 @@ public function deleteTags($tags, $delimiter = null) $removed[] = $this->_tagTable->find($tagging->tag_id); $tagging->delete(); } + + $db = $this->_record->getDb(); + foreach ($tags as $tag) { + $count = $this->_joinTable->count(array('tag' => $tag)); + if ($count == 0) { + $db->delete($db->Tags, array('name = ?' => $tag)); + } + } $nameForHook = strtolower($this->_type); fire_plugin_hook("remove_{$nameForHook}_tag", array('record' => $this->_record, 'removed' => $removed)); From 457b6764f90e83d070483bdfcd856a8c142f5436 Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 08:56:31 +0200 Subject: [PATCH 25/28] Cleaned up indentation --- application/models/Mixin/Tag.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/models/Mixin/Tag.php b/application/models/Mixin/Tag.php index ffcee0b4db..dcfaec5d43 100644 --- a/application/models/Mixin/Tag.php +++ b/application/models/Mixin/Tag.php @@ -141,12 +141,12 @@ public function deleteTags($tags, $delimiter = null) } $db = $this->_record->getDb(); - foreach ($tags as $tag) { - $count = $this->_joinTable->count(array('tag' => $tag)); - if ($count == 0) { - $db->delete($db->Tags, array('name = ?' => $tag)); - } - } + foreach ($tags as $tag) { + $count = $this->_joinTable->count(array('tag' => $tag)); + if ($count == 0) { + $db->delete($db->Tags, array('name = ?' => $tag)); + } + } $nameForHook = strtolower($this->_type); fire_plugin_hook("remove_{$nameForHook}_tag", array('record' => $this->_record, 'removed' => $removed)); From bd08d16affa2184ed77c4313b31e7254842cc13f Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 09:06:36 +0200 Subject: [PATCH 26/28] Extended delete function, added merge capability --- application/controllers/TagsController.php | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/application/controllers/TagsController.php b/application/controllers/TagsController.php index ecec1f54de..70a8c165ed 100644 --- a/application/controllers/TagsController.php +++ b/application/controllers/TagsController.php @@ -88,6 +88,23 @@ protected function _getBrowseDefaultSort() return array('name', 'a'); } + protected function _getDeleteConfirmMessage($tag) + { + return __('This will delete the tag "%s" from all records associated to it.', $tag->name); + } + + /** + * Redirect to another page after a record is successfully deleted. + * + * The default is to redirect to this controller's browse page. + * + * @param Omeka_Record_AbstractRecord $record + */ + protected function _redirectAfterDelete($record) + { + $this->_helper->redirector('browse'); + } + public function autocompleteAction() { $tagText = $this->_getParam('term'); @@ -109,8 +126,15 @@ public function renameAjaxAction() $oldTag->name = $newName; $this->_helper->viewRenderer->setNoRender(); - if ($csrf->isValid($_POST) && $oldTag->save(false)) { - $this->getResponse()->setBody($newName); + if ($csrf->isValid($_POST)) { + if ($oldTag->save(false)) { + $this->getResponse()->setBody($newName); + } else { + $newTag = $this->_helper->db->findOrNew($newName); + $newTagId = $newTag->id; + $count = $this->_helper->db->mergeTags($oldTagId, $newTagId); + $this->getResponse()->setBody($newName); + } } else { $this->getResponse()->setHttpResponseCode(500); $this->getResponse()->setBody($error); From d33ffbd7f4433e2a17ca78c31ff16e17670341be Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Thu, 1 Apr 2021 12:03:29 +0200 Subject: [PATCH 27/28] Added specification to page title --- application/views/scripts/items/tags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/scripts/items/tags.php b/application/views/scripts/items/tags.php index 5d9e27f96a..c27383d9a0 100644 --- a/application/views/scripts/items/tags.php +++ b/application/views/scripts/items/tags.php @@ -1,5 +1,5 @@ $pageTitle, 'bodyclass' => 'items tags')); ?> From 44f78e0123bd7ee96cf5972ae158d6f3199aae7f Mon Sep 17 00:00:00 2001 From: DBinaghi <39097246+DBinaghi@users.noreply.github.com> Date: Fri, 9 Apr 2021 09:32:19 +0200 Subject: [PATCH 28/28] Hide sort options when no results are available Same behaviour of items/browse --- application/views/scripts/collections/browse.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/views/scripts/collections/browse.php b/application/views/scripts/collections/browse.php index 652d5afbbd..b7bb18de2d 100644 --- a/application/views/scripts/collections/browse.php +++ b/application/views/scripts/collections/browse.php @@ -4,8 +4,11 @@ ?>

+ + 0): ?> +
+ +