formLabel('collection_tree_browse_only_root', __('Browse root-level collections only')); ?>
From dc5dcd245ed17b932065fcfec59fd12986842c49 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Wed, 21 Apr 2021 22:06:09 +0200
Subject: [PATCH 05/16] Added explanation string
---
views/shared/index/index.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/views/shared/index/index.php b/views/shared/index/index.php
index 9ad45ae..abb2f72 100644
--- a/views/shared/index/index.php
+++ b/views/shared/index/index.php
@@ -1,7 +1,8 @@
__('Collection Tree'))); ?>
full_collection_tree): ?>
+
full_collection_tree; ?>
-
\ No newline at end of file
+
From 72bb0a892486646274ff1edff7643f06ca6fc683 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Wed, 21 Apr 2021 22:08:41 +0200
Subject: [PATCH 06/16] JS code for treeview style
---
views/shared/javascripts/file-explore.js | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 views/shared/javascripts/file-explore.js
diff --git a/views/shared/javascripts/file-explore.js b/views/shared/javascripts/file-explore.js
new file mode 100644
index 0000000..8a456f1
--- /dev/null
+++ b/views/shared/javascripts/file-explore.js
@@ -0,0 +1,18 @@
+jQuery(document).ready(function () {
+ var $ = jQuery;
+
+ init();
+
+ function init() {
+ jQuery("#collection-tree ul:not(:first)").hide();
+
+ jQuery("#collection-tree li").prepend("
");
+
+ jQuery("#collection-tree li:has(ul)")
+ .children(":first-child").addClass("collapsed")
+ .click(function(){
+ jQuery(this).toggleClass("collapsed expanded")
+ .siblings("ul").toggle();
+ });
+ }
+});
From da63a2fb69bce00aafa20d0b9021299d81a820b6 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Wed, 21 Apr 2021 22:09:40 +0200
Subject: [PATCH 07/16] CSS file for treeview style
---
views/shared/css/file-explore.css | 55 +++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 views/shared/css/file-explore.css
diff --git a/views/shared/css/file-explore.css b/views/shared/css/file-explore.css
new file mode 100644
index 0000000..0ac7277
--- /dev/null
+++ b/views/shared/css/file-explore.css
@@ -0,0 +1,55 @@
+#collection-tree ul {
+ list-style-type: none;
+ font-size: 1em;
+ line-height: 1.8em;
+ margin-top: 0;
+ margin-left: 10px;
+ padding-left: 18px;
+ border-left: 1px dotted #aaa;
+}
+
+#collection-tree li {
+ position: relative;
+}
+
+#collection-tree li a{
+ text-decoration: none;
+ color:#444;
+}
+
+#collection-tree li:before{
+ position: absolute;
+ display: block;
+ content: " ";
+ width: 10px;
+ height: 1px;
+ border-bottom: 1px dotted #aaa;
+ top: .6em;
+ left: -14px;
+}
+
+.collection-tree-icon {
+ display: block;
+ font-family: FontAwesome;
+ font-size: 1.2em;
+}
+
+.handle:before {
+ margin-right: .2em;
+ content: '\f0f6';
+ float: left;
+}
+
+.collapsed:before {
+ margin-right: .2em;
+ color: #FFD04E;
+ content: "\f07b";
+ cursor: pointer;
+}
+
+.expanded:before {
+ margin-right: .2em;
+ color: #FFD04E;
+ content: "\f07c";
+ cursor: pointer;
+}
From ce6c0a17f21379fc9a1b51b202106eb2e2f2256e Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Thu, 22 Apr 2021 11:01:00 +0200
Subject: [PATCH 08/16] Update file-explore.js
---
views/shared/javascripts/file-explore.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/views/shared/javascripts/file-explore.js b/views/shared/javascripts/file-explore.js
index 8a456f1..a7cfebd 100644
--- a/views/shared/javascripts/file-explore.js
+++ b/views/shared/javascripts/file-explore.js
@@ -1,10 +1,12 @@
jQuery(document).ready(function () {
- var $ = jQuery;
+ var treeExpanded = false;
init();
function init() {
- jQuery("#collection-tree ul:not(:first)").hide();
+ if (!treeExpanded) {
+ jQuery("#collection-tree ul:not(:first)").hide();
+ }
jQuery("#collection-tree li").prepend("
");
From b10350e570c1e8a68162fed280c30bd42ab5e787 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Thu, 22 Apr 2021 13:57:56 +0200
Subject: [PATCH 09/16] Removed custom color for links
---
views/shared/css/file-explore.css | 1 -
1 file changed, 1 deletion(-)
diff --git a/views/shared/css/file-explore.css b/views/shared/css/file-explore.css
index 0ac7277..eb86fd0 100644
--- a/views/shared/css/file-explore.css
+++ b/views/shared/css/file-explore.css
@@ -14,7 +14,6 @@
#collection-tree li a{
text-decoration: none;
- color:#444;
}
#collection-tree li:before{
From 9694a83ca6c14a0092df7141123091000a6c4886 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Fri, 23 Apr 2021 11:22:41 +0200
Subject: [PATCH 10/16] Added option to force expansion of treeview
---
CollectionTreePlugin.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/CollectionTreePlugin.php b/CollectionTreePlugin.php
index 1dd4ca2..8b08724 100644
--- a/CollectionTreePlugin.php
+++ b/CollectionTreePlugin.php
@@ -55,7 +55,8 @@ class CollectionTreePlugin extends Omeka_Plugin_AbstractPlugin
'collection_tree_show_subcollections' => 0,
'collection_tree_hide_orphans' => 0,
'collection_tree_treeview_style' => 0,
- 'collection_tree_browse_only_root' => 0,
+ 'collection_tree_treeview_expanded' => 0,
+ 'collection_tree_browse_only_root' => 0,
'collection_tree_search_descendant' => 0,
);
From 9b6c7dc343bdc2082b62a778eda1b478c773ce2b Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Fri, 23 Apr 2021 11:23:45 +0200
Subject: [PATCH 11/16] Added check for forced tree expansion
---
views/shared/javascripts/file-explore.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/views/shared/javascripts/file-explore.js b/views/shared/javascripts/file-explore.js
index a7cfebd..b0e880a 100644
--- a/views/shared/javascripts/file-explore.js
+++ b/views/shared/javascripts/file-explore.js
@@ -1,5 +1,5 @@
jQuery(document).ready(function () {
- var treeExpanded = false;
+ var treeExpanded = (jQuery("#collection-tree").hasClass("treeExpanded"));
init();
From 4075f93bdc3c6480ef0c9c4f8de57d898ad2e98d Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Fri, 23 Apr 2021 11:24:38 +0200
Subject: [PATCH 12/16] Added check for forced tree expansion
---
views/shared/collections/collection-tree-list.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/views/shared/collections/collection-tree-list.php b/views/shared/collections/collection-tree-list.php
index 93f012b..4192b38 100644
--- a/views/shared/collections/collection-tree-list.php
+++ b/views/shared/collections/collection-tree-list.php
@@ -1,4 +1,4 @@
-
+
>
collectionTreeList($collection_tree); ?>
From c4345c31002759e31429267af659a72153f4c079 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Fri, 23 Apr 2021 11:25:31 +0200
Subject: [PATCH 13/16] Added option to force tree expansion
---
.../plugins/collection-tree-config-form.php | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/views/admin/plugins/collection-tree-config-form.php b/views/admin/plugins/collection-tree-config-form.php
index 12285f7..8971f30 100644
--- a/views/admin/plugins/collection-tree-config-form.php
+++ b/views/admin/plugins/collection-tree-config-form.php
@@ -64,6 +64,22 @@
From b8771b167048bca231021ad48f9056073827c4eb Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Wed, 28 Apr 2021 18:05:34 +0200
Subject: [PATCH 14/16] Modified option to accept more values
---
CollectionTreePlugin.php | 87 ++++++++++++++++++++--------------------
1 file changed, 44 insertions(+), 43 deletions(-)
diff --git a/CollectionTreePlugin.php b/CollectionTreePlugin.php
index 8b08724..e724f17 100644
--- a/CollectionTreePlugin.php
+++ b/CollectionTreePlugin.php
@@ -1,14 +1,14 @@
0,
'collection_tree_hide_orphans' => 0,
'collection_tree_treeview_style' => 0,
- 'collection_tree_treeview_expanded' => 0,
- 'collection_tree_browse_only_root' => 0,
+ 'collection_tree_treeview_expanded' => '',
+ 'collection_tree_browse_only_root' => 0,
'collection_tree_search_descendant' => 0,
);
@@ -70,7 +70,7 @@ public function hookInstall()
{
// collection_id must be unique to satisfy the AT MOST ONE parent
// collection constraint.
- $sql = "
+ $sql = "
CREATE TABLE IF NOT EXISTS `{$this->_db->CollectionTree}` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`parent_collection_id` int(10) unsigned NOT NULL,
@@ -95,7 +95,7 @@ public function hookInstall()
$collectionTree->save();
}
}
-
+
/**
* Uninstall the plugin.
*/
@@ -106,7 +106,7 @@ public function hookUninstall()
$this->_uninstallOptions();
}
-
+
/**
* Initialize the plugin.
*/
@@ -115,22 +115,22 @@ public function hookInitialize()
// Add translation.
add_translation_source(dirname(__FILE__) . '/languages');
}
-
+
/**
* Upgrade from earlier versions.
*/
public function hookUpgrade($args)
{
- // Prior to Omeka 2.0, collection names were stored in the collections
- // table; now they are stored as Dublin Core Title. This upgrade
- // compensates for this by moving the collection names to the
+ // Prior to Omeka 2.0, collection names were stored in the collections
+ // table; now they are stored as Dublin Core Title. This upgrade
+ // compensates for this by moving the collection names to the
// collection_trees table.
if (version_compare($args['old_version'], '2.0', '<')) {
-
+
// Add the name column to the collection_trees table.
$sql = "ALTER TABLE {$this->_db->CollectionTree} ADD `name` TEXT NULL";
$this->_db->query($sql);
-
+
// Assign names to their corresponding collection_tree rows.
$collectionTreeTable = $this->_db->getTable('CollectionTree');
$collectionTable = $this->_db->getTable('Collection');
@@ -187,7 +187,7 @@ public function hookBeforeSaveCollection($args)
}
}
}
-
+
/**
* Save the parent/child relationship.
*/
@@ -201,18 +201,18 @@ public function hookAfterSaveCollection($args)
$collectionTree->collection_id = $collection->id;
$collectionTree->parent_collection_id = 0;
}
-
+
// Only save the relationship during a form submission.
if (isset($args['post']['collection_tree_parent_collection_id'])) {
$collectionTree->parent_collection_id = $args['post']['collection_tree_parent_collection_id'];
}
-
+
$collectionTree->name = metadata($args['record'], array('Dublin Core', 'Title'));
-
+
// Fail silently if the record does not validate.
$collectionTree->save();
}
-
+
/**
* Handle collection deletions.
*
@@ -225,13 +225,13 @@ public function hookAfterDeleteCollection($args)
{
$collection = $args['record'];
$collectionTreeTable = $this->_db->getTable('CollectionTree');
-
+
// Delete the relationship with the parent collection.
$collectionTree = $collectionTreeTable->findByCollectionId($collection->id);
if ($collectionTree) {
$collectionTree->delete();
}
-
+
// Move child collections to root level by deleting their relationships.
$collectionTrees = $collectionTreeTable->findByParentCollectionId($collection->id);
foreach ($collectionTrees as $collectionTree) {
@@ -278,7 +278,7 @@ public function hookItemsBrowseSql($args)
// Collection can be an object when not called from search form.
? $params['descendant_or_self']->id
// Else this should be an integer.
- : (integer) $params['descendant_or_self'];
+ : (int) $params['descendant_or_self'];
if (empty($collection)) {
return;
@@ -293,7 +293,8 @@ public function hookItemsBrowseSql($args)
$select->joinInner(
array('collection_tree_collections' => $this->_db->Collection),
'items.collection_id = collection_tree_collections.id',
- array());
+ array()
+ );
// There are descendants.
if (count($collections) > 1) {
@@ -326,7 +327,7 @@ public function hookPublicItemsSearch($args)
}
/**
- * Append items search checkbox to the advanced search page.
+ * Append items search checkbox to the advanced search page.
*
* @return string HTML
*/
@@ -347,7 +348,7 @@ protected function _itemsSearch($args)
*/
public function hookAdminCollectionsShow($args)
{
- $this->_appendToCollectionsShow($args['collection']);
+ $this->_appendToCollectionsShow($args['collection'], 'admin');
}
/**
@@ -355,18 +356,19 @@ public function hookAdminCollectionsShow($args)
*/
public function hookPublicCollectionsShow($args)
{
- $this->_appendToCollectionsShow($args['collection']);
+ $this->_appendToCollectionsShow($args['collection'], 'public');
}
-
- protected function _appendToCollectionsShow($collection)
+
+ protected function _appendToCollectionsShow($collection, $side)
{
$collectionTree = $this->_db->getTable('CollectionTree')->getCollectionTree($collection->id);
- if (count($collectionTree[0]['children']) > 0 || !get_option('collection_tree_hide_orphans')) {
- echo get_view()->partial(
- 'collections/collection-tree-list.php',
- array('collection_tree' => $collectionTree)
- );
- }
+
+ if (count($collectionTree[0]['children']) > 0 || !(bool)get_Option('collection_tree_hide_orphans')) {
+ echo get_view()->partial(
+ 'collections/collection-tree-list.php',
+ array('collection_tree' => $collectionTree, 'side' => $side)
+ );
+ }
}
/**
@@ -389,7 +391,8 @@ public function hookAdminHead($args)
queue_css_file('file-explore');
queue_js_file('file-explore');
}
- }
+ }
+
/**
* Add the collection tree page to the admin navigation.
*/
@@ -398,7 +401,7 @@ public function filterAdminNavigationMain($nav)
$nav[] = array('label' => __('Collection Tree'), 'uri' => url('collection-tree'));
return $nav;
}
-
+
/**
* Add the collection tree page to the public navigation.
*/
@@ -407,7 +410,7 @@ public function filterPublicNavigationMain($nav)
$nav[] = array('label' => __('Collection Tree'), 'uri' => url('collection-tree'));
return $nav;
}
-
+
/**
* Display the parent collection form.
*/
@@ -415,7 +418,7 @@ public function filterAdminCollectionsFormTabs($tabs, $args)
{
$collection = $args['collection'];
$collectionTreeTable = $this->_db->getTable('CollectionTree');
-
+
$options = $collectionTreeTable->findPairsForSelectForm();
$options = array('0' => __('No parent collection')) + $options;
@@ -426,13 +429,12 @@ public function filterAdminCollectionsFormTabs($tabs, $args)
$parentCollectionId = 0;
}
$tabs['Parent Collection'] = get_view()->partial(
- 'collections/collection-tree-parent-form.php',
+ 'collections/collection-tree-parent-form.php',
array('options' => $options, 'parent_collection_id' => $parentCollectionId)
);
return $tabs;
}
-
/**
* Filter items browse params to broaden the search to subcollections.
*
@@ -446,7 +448,7 @@ public function filterItemsBrowseParams($params)
&& !isset($params['subcollections'])
&& get_option('collection_tree_show_subcollections')
) {
- $params['subcollections'] = 1;
+ $params['subcollections'] = 1;
}
if (!empty($params['subcollections'])) {
@@ -467,7 +469,6 @@ public function filterItemsBrowseParams($params)
return $params;
}
-
/**
* Manage search options for collections.
*
From a5ee96245dbf457936d86e8572e800224c063093 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Wed, 28 Apr 2021 18:06:42 +0200
Subject: [PATCH 15/16] Modified code to accept additional parameter
---
views/shared/collections/collection-tree-list.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/views/shared/collections/collection-tree-list.php b/views/shared/collections/collection-tree-list.php
index 4192b38..29d5d9d 100644
--- a/views/shared/collections/collection-tree-list.php
+++ b/views/shared/collections/collection-tree-list.php
@@ -1,4 +1,12 @@
-
>
+
+
>
collectionTreeList($collection_tree); ?>
From 86d61e628c2c3a0ed9b1417994152beaea4c9d88 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Wed, 28 Apr 2021 18:07:31 +0200
Subject: [PATCH 16/16] Modified option to accept more valued
---
.../plugins/collection-tree-config-form.php | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/views/admin/plugins/collection-tree-config-form.php b/views/admin/plugins/collection-tree-config-form.php
index 8971f30..219d2cc 100644
--- a/views/admin/plugins/collection-tree-config-form.php
+++ b/views/admin/plugins/collection-tree-config-form.php
@@ -22,7 +22,7 @@