Skip to content

Commit 529a0ce

Browse files
Merge branch 'develop'
2 parents 96a0303 + b87b36d commit 529a0ce

File tree

102 files changed

+447250
-404960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+447250
-404960
lines changed

.htaccess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Allow from all
1010
<FilesMatch "^(index|service|tilepic)\.php$">
1111
Allow from all
1212
</FilesMatch>
13-
<FilesMatch "^.*\.(css|gif|jpg|png|js|woff|woff2|ttf|swf|map|tif|tiff|m4v|xml|ply|stl|html|json|mp3|wav|aiff|tiff|obj|bmp|mp4)$">
13+
<FilesMatch "^.*\.(css|gif|jpg|png|js|woff|woff2|ttf|swf|map|tif|tiff|m4v|xml|ply|stl|html|json|mp3|wav|aiff|tiff|obj|bmp|mp4|pdf)$">
1414
Allow from all
1515
</FilesMatch>
1616

app/conf/app.conf

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ ca_movements_disable_quickadd = 0
212212
disable_add_object_to_lot_inspector_controls = 0
213213

214214
# ----------------------------------
215-
# Show "add child record" control in the inspector?
215+
# Show related counts in the inspector?
216216
# ----------------------------------
217217
#
218218
ca_objects_show_related_counts_in_inspector_for = []
@@ -225,6 +225,20 @@ ca_loans_show_related_counts_in_inspector_for = []
225225
ca_movements_show_related_counts_in_inspector_for = []
226226
ca_tour_stops_show_related_counts_in_inspector_for = []
227227

228+
# ---------------------------------------------------
229+
# Show "add child record" control in editor inspector?
230+
# ----------------------------------------------------
231+
#
232+
ca_objects_show_add_child_control_in_inspector = 0
233+
ca_entities_show_add_child_control_in_inspector = 0
234+
ca_places_show_add_child_control_in_inspector = 1
235+
ca_occurrences_show_add_child_control_in_inspector = 0
236+
ca_collections_show_add_child_control_in_inspector = 1
237+
ca_storage_locations_show_add_child_control_in_inspector = 1
238+
ca_loans_show_add_child_control_in_inspector = 0
239+
ca_movements_show_add_child_control_in_inspector = 0
240+
ca_tour_stops_show_add_child_control_in_inspector = 0
241+
228242
# -------------------------
229243
# Set duplication disable
230244
# -------------------------
@@ -355,7 +369,25 @@ ca_collections_hierarchy_summary_sort_values =
355369
#
356370
ca_storage_locations_hierarchy_browser_hide_root = 0
357371
ca_places_locations_hierarchy_browser_hide_root = 0
358-
372+
373+
374+
# ------------------------------------
375+
# Show/Hide child records in search/browse results
376+
# ------------------------------------
377+
#
378+
# Normally all results, regardless of their position in a hierarchy are displayed
379+
# in search/browse results. Set this option for alternative policies. Possible
380+
# settings are:
381+
# show = show all results by default; allow user to filter children if they wish
382+
# hide = hide all child records (those that are not at the top of their hierarchy) by default; allow user to remove filtering if desired
383+
# alwaysShow = show all results; do not allow filtering
384+
# alwaysHide = hide all child records; do not allow the user to disable filtering
385+
#
386+
# "alwaysShow" is the default.
387+
#
388+
# While this option may be set for any table, it is typically used only for objects.
389+
#
390+
ca_objects_children_display_mode_in_results = alwaysShow
359391

360392
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361393
#
@@ -568,6 +600,14 @@ quicksearch_breakout_by_type =
568600
# Switch to disable out of process search indexing
569601
#
570602
disable_out_of_process_search_indexing = 0
603+
604+
# -------------------
605+
# Caption formatting for object search/browse "thumbnail" results
606+
# -------------------
607+
# Set a display template here to customize display of captions under thumbnails in the thumbnail result view. The
608+
# template will be evaluated relative to each object in the result set.
609+
#
610+
ca_objects_results_thumbnail_caption_template = ^ca_objects.preferred_labels.name%truncate=27&ellipsis=1<br/><l>^ca_objects.idno</l>
571611

572612

573613
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

app/conf/search_indexing.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# DONT_INCLUDE_IN_SEARCH_FORM (causes field to not be includable in user-defined search forms)
88
# BOOST (numeric "boost" value to index field with; higher values will cause search hits on the boosted field to count for more when sorting by relevance)
99
# INDEX_AS_IDNO (causes value to be indexed with various permutations for flexible retrieval as a record identifer)
10+
# INDEX_AS_MIMETYPE (causes value to be indexed as a mimetype, including both the literal mimetype and the display text value for the type)
1011
# INDEX_ANCESTORS (enables hierarchical indexing for field, assuming it is in an hierarchical table, resulting in all values for this field in
1112
# records above the subject in the hierarchy being indexing against the subject)
1213
# INDEX_ANCESTORS_START_AT_LEVEL (forces hierarchical indexing to start X levels down from the root. This allows you to omit the very highest, and least selective, levels of
@@ -330,7 +331,7 @@ ca_objects = {
330331
fields = {
331332
representation_id = { DONT_INCLUDE_IN_SEARCH_FORM },
332333
media_content = { DONT_INCLUDE_IN_SEARCH_FORM },
333-
mimetype = { STORE, DONT_TOKENIZE },
334+
mimetype = { STORE, INDEX_AS_MIMETYPE },
334335
md5 = { STORE, DONT_TOKENIZE },
335336
original_filename = { STORE, DONT_TOKENIZE }
336337
}
@@ -1023,7 +1024,7 @@ ca_object_representations = {
10231024
idno = { STORE, DONT_TOKENIZE, INDEX_AS_IDNO, BOOST = 100 },
10241025
type_id = { STORE, DONT_TOKENIZE },
10251026
_metadata = { },
1026-
mimetype = { STORE, DONT_TOKENIZE },
1027+
mimetype = { STORE, INDEX_AS_MIMETYPE },
10271028
access = { STORE, DONT_TOKENIZE },
10281029
status = { STORE, DONT_TOKENIZE },
10291030
md5 = { STORE, DONT_TOKENIZE },

app/lib/ca/BaseAdvancedSearchController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* ----------------------------------------------------------------------
88
*
99
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
10-
* Copyright 2010-2016 Whirl-i-Gig
10+
* Copyright 2010-2017 Whirl-i-Gig
1111
*
1212
* For more information visit http://www.CollectiveAccess.org
1313
*
@@ -137,7 +137,8 @@ public function Index($pa_options=null) {
137137
'appendToSearch' => $vs_append_to_search,
138138
'getCountsByField' => 'type_id',
139139
'checkAccess' => $va_access_values,
140-
'no_cache' => $vb_is_new_search
140+
'no_cache' => $vb_is_new_search,
141+
'rootRecordsOnly' => $this->view->getVar('hide_children')
141142
);
142143

143144
if ($vb_is_new_search ||isset($pa_options['saved_search']) || (is_subclass_of($po_search, "BrowseEngine") && !$po_search->numCriteria()) ) {

app/lib/ca/BaseBrowseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function Index($pa_options=null) {
191191
if ($vs_facet_group = $this->request->config->get($this->ops_tablename.(($this->opo_browse->numCriteria() < 1) ? '_browse_facet_group' : '_browse_refine_facet_group'))) {
192192
$this->opo_browse->setFacetGroup($vs_facet_group);
193193
}
194-
$this->opo_browse->execute(array('checkAccess' => $va_access_values, 'no_cache' => !$this->opo_result_context->cacheIsValid()));
194+
$this->opo_browse->execute(array('checkAccess' => $va_access_values, 'no_cache' => !$this->opo_result_context->cacheIsValid(), 'rootRecordsOnly' => $this->view->getVar('hide_children')));
195195
$this->opo_result_context->validateCache();
196196

197197
$this->opo_result_context->setSearchExpression($this->opo_browse->getBrowseID());

app/lib/ca/BaseFindController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,23 @@ public function Index($pa_options=null) {
257257

258258
$this->view->setVar('result_context', $this->opo_result_context);
259259
$this->view->setVar('access_restrictions',AccessRestrictions::load());
260+
261+
#
262+
#
263+
#
264+
$this->view->setVar('children_display_mode_default', ($vs_children_display_mode_default = $this->request->config->get($this->ops_tablename."_children_display_mode_in_results")) ? $vs_children_display_mode_default : "alwaysShow");
265+
266+
$ps_children_display_mode = $this->opo_result_context->getCurrentChildrenDisplayMode();
267+
268+
// force mode when "always" is set
269+
if (strtolower($vs_children_display_mode_default) == 'alwaysshow') {
270+
$ps_children_display_mode = 'show';
271+
} elseif(strtolower($vs_children_display_mode_default) == 'alwayshide') {
272+
$ps_children_display_mode = 'hide';
273+
}
274+
$this->view->setVar('children_display_mode', $ps_children_display_mode);
275+
$this->view->setVar('hide_children', $pb_hide_children = in_array(strtolower($ps_children_display_mode), ['hide', 'alwayshide']));
276+
$this->view->setVar('show_children_display_mode_control', !in_array(strtolower($vs_children_display_mode_default), ['alwaysshow', 'alwayshide']));
260277
}
261278
# -------------------------------------------------------
262279
/**

app/lib/ca/BaseQuickAddController.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public function Form($pa_values=null, $pa_options=null) {
7979
$this->opo_result_context->setParameter($t_subject->tableName().'_last_parent_id', $vn_parent_id);
8080
}
8181

82+
// Get user query
83+
$this->view->setVar('q', preg_replace("!^[^:]*:!", "", $this->request->getParameter('q', pString)));
84+
8285
//
8386
// Is record of correct type?
8487
//
@@ -108,6 +111,28 @@ public function Form($pa_values=null, $pa_options=null) {
108111
return;
109112
}
110113
}
114+
115+
116+
if (is_array($va_prepopulate_quickadd_fields = explode(";", $this->request->getParameter('prepopulate_fields', pString)))) {
117+
$va_prepopulate_quickadd_fields = array_filter($va_prepopulate_quickadd_fields, function($v) { return strlen($v); });
118+
foreach($va_prepopulate_quickadd_fields as $vs_field) {
119+
if ($t_subject->hasField($vs_field)) { $t_subject->set($vs_field, caUcFirstUTF8Safe($this->view->getVar('q'))); }
120+
}
121+
}
122+
123+
if (!is_array($va_prepopulate_quickadd_fields) || !sizeof($va_prepopulate_quickadd_fields) || in_array('preferred_labels', $va_prepopulate_quickadd_fields)) {
124+
global $g_ui_locale_id;
125+
$va_force_new_label = [
126+
'locale_id' => $g_ui_locale_id, // use default locale
127+
$t_subject->getLabelDisplayField() => caUcFirstUTF8Safe($this->view->getVar('q')) // query text is used for display field
128+
];
129+
foreach($t_subject->getLabelUIFields() as $vn_i => $vs_fld) {
130+
if ($vs_fld === $t_subject->getLabelDisplayField()) { continue; }
131+
$va_force_new_label[$vs_fld] = '';
132+
}
133+
$this->view->setVar('forceLabel', $va_force_new_label);
134+
}
135+
111136

112137
if(is_array($pa_values)) {
113138
foreach($pa_values as $vs_key => $vs_val) {
@@ -211,7 +236,6 @@ public function Form($pa_values=null, $pa_options=null) {
211236
$this->view->setVar('fieldNamePrefix', $_REQUEST['_formName']);
212237
$this->view->setVar('n', $vs_n);
213238

214-
$this->view->setVar('q', preg_replace("!^[^:]*:!", "", $this->request->getParameter('q', pString)));
215239

216240
$this->view->setVar('default_parent_id', $this->opo_result_context->getParameter($t_subject->tableName().'_last_parent_id'));
217241

app/lib/ca/BaseSearchController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* ----------------------------------------------------------------------
88
*
99
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
10-
* Copyright 2009-2014 Whirl-i-Gig
10+
* Copyright 2009-2017 Whirl-i-Gig
1111
*
1212
* For more information visit http://www.CollectiveAccess.org
1313
*
@@ -168,9 +168,11 @@ public function Index($pa_options=null) {
168168
'checkAccess' => $va_access_values,
169169
'no_cache' => $vb_is_new_search,
170170
'dontCheckFacetAvailability' => true,
171-
'filterNonPrimaryRepresentations' => true
171+
'filterNonPrimaryRepresentations' => true,
172+
'rootRecordsOnly' => $this->view->getVar('hide_children')
172173
);
173174

175+
174176
if ($vb_is_new_search ||isset($pa_options['saved_search']) || (is_subclass_of($po_search, "BrowseEngine") && !$po_search->numCriteria()) ) {
175177
$vs_browse_classname = get_class($po_search);
176178
$po_search = new $vs_browse_classname;

app/lib/ca/Browse/BrowseEngine.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ public function getInfoForFacetsWithContent() {
971971
* limitToModifiedOn = if set returned results will be limited to rows modified within the specified date range. The value should be a date/time expression parse-able by TimeExpressionParser
972972
* user_id = If set item level access control is performed relative to specified user_id, otherwise defaults to logged in user
973973
* expandResultsHierarchically = expand result set items that are hierarchy roots to include their entire hierarchy. [Default is false]
974+
* rootRecordsOnly = only return records that are the root of whatever hierarchy they are in. [Default is false]
974975
*
975976
* @return bool True on success, null if the browse could not be executed (Eg. no settings), false no error
976977
*/
@@ -1731,6 +1732,8 @@ public function execute($pa_options=null) {
17311732
$t_loc = new ca_storage_locations();
17321733

17331734
if (!is_array($va_loc_ids = $t_loc->getHierarchy($va_row_tmp[2], ['returnAsArray' => true, 'includeSelf' => true, 'idsOnly' => true])) || !sizeof($va_loc_ids)) { continue; }
1735+
1736+
array_pop($va_row_tmp);
17341737
$va_row_tmp[] = array_values($va_loc_ids);
17351738

17361739
$vs_sql = "
@@ -2058,6 +2061,10 @@ public function execute($pa_options=null) {
20582061
if ((!isset($pa_options['showDeleted']) || !$pa_options['showDeleted']) && $t_item->hasField('deleted')) {
20592062
$va_wheres[] = "(".$this->ops_browse_table_name.".deleted = 0)";
20602063
}
2064+
2065+
if ((isset($pa_options['rootRecordsOnly']) && $pa_options['rootRecordsOnly']) && $t_item->hasField('parent_id')) {
2066+
$va_wheres[] = "(".$this->ops_browse_table_name.".parent_id IS NULL)";
2067+
}
20612068

20622069
if ((isset($pa_options['limitToModifiedOn']) && $pa_options['limitToModifiedOn'])) {
20632070
$o_tep = new TimeExpressionParser();
@@ -2130,6 +2137,9 @@ public function execute($pa_options=null) {
21302137
if ((!isset($pa_options['showDeleted']) || !$pa_options['showDeleted']) && $t_item->hasField('deleted')) {
21312138
$va_wheres[] = "(".$this->ops_browse_table_name.".deleted = 0)";
21322139
}
2140+
if ((isset($pa_options['rootRecordsOnly']) && $pa_options['rootRecordsOnly']) && $t_item->hasField('parent_id')) {
2141+
$va_wheres[] = "(".$this->ops_browse_table_name.".parent_id IS NULL)";
2142+
}
21332143

21342144
if ((isset($pa_options['limitToModifiedOn']) && $pa_options['limitToModifiedOn'])) {
21352145
$o_tep = new TimeExpressionParser();

app/lib/ca/BundlableLabelableBaseModelWithAttributes.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,15 +1712,14 @@ public function getBundleFormHTML($ps_bundle_name, $ps_placement_code, $pa_bundl
17121712
case 'hierarchy_navigation':
17131713
if ($vb_batch) { return null; } // not supported in batch mode
17141714
if ($this->isHierarchical()) {
1715-
$vs_element .= $this->getHierarchyNavigationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, array(), $pa_bundle_settings, $pa_options);
1715+
$vs_element .= $this->getHierarchyNavigationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options, $pa_bundle_settings);
17161716
}
17171717
break;
17181718
# -------------------------------
17191719
// Hierarchical item location control
17201720
case 'hierarchy_location':
1721-
if ($vb_batch) { return null; } // not supported in batch mode
17221721
if ($this->isHierarchical()) {
1723-
$vs_element .= $this->getHierarchyLocationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, array(), $pa_bundle_settings, $pa_options);
1722+
$vs_element .= $this->getHierarchyLocationHTMLFormBundle($pa_options['request'], $pa_options['formName'], $ps_placement_code, $pa_options, $pa_bundle_settings);
17241723
}
17251724
break;
17261725
# -------------------------------
@@ -2611,6 +2610,8 @@ private function _getHierarchyLocationHTMLFormBundleInfo($po_request, $ps_form_n
26112610
$vs_view_path = (isset($pa_options['viewPath']) && $pa_options['viewPath']) ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
26122611
$o_view = new View($po_request, "{$vs_view_path}/bundles/");
26132612

2613+
$pb_batch = caGetOption('batch', $pa_options, false);
2614+
26142615
if(!is_array($pa_bundle_settings)) { $pa_bundle_settings = array(); }
26152616

26162617
if (!($vs_label_table_name = $this->getLabelTableName())) { return ''; }
@@ -2747,10 +2748,18 @@ private function _getHierarchyLocationHTMLFormBundleInfo($po_request, $ps_form_n
27472748
}
27482749
}
27492750

2751+
$vn_first_id = null;
2752+
if ($pb_batch && ($pn_set_id = caGetOption('set_id', $pa_options, null))) {
2753+
$t_set = new ca_sets($pn_set_id);
2754+
if (is_array($va_ids = $t_set->getItemRowIDs()) && sizeof($va_ids)) {
2755+
$vn_first_id = array_shift($va_ids);
2756+
}
2757+
}
27502758

2759+
$o_view->setVar('batch', $pb_batch);
27512760
$o_view->setVar('parent_id', $vn_parent_id);
27522761
$o_view->setVar('ancestors', $va_ancestor_list);
2753-
$o_view->setVar('id', $this->getPrimaryKey());
2762+
$o_view->setVar('id', $pb_batch && $vn_first_id ? $vn_first_id : $this->getPrimaryKey());
27542763
$o_view->setVar('settings', $pa_bundle_settings);
27552764

27562765
return $o_view;
@@ -2917,6 +2926,8 @@ public function getRelatedHTMLFormBundle($po_request, $ps_form_name, $ps_related
29172926
if (!$pa_bundle_settings['readonly']) { $pa_bundle_settings['readonly'] = (!isset($pa_bundle_settings['readonly']) || !$pa_bundle_settings['readonly']) ? $vb_read_only : true; }
29182927

29192928
// pass bundle settings
2929+
2930+
if(!is_array($pa_bundle_settings['prepopulateQuickaddFields'])) { $pa_bundle_settings['prepopulateQuickaddFields'] = []; }
29202931
$o_view->setVar('settings', $pa_bundle_settings);
29212932
$o_view->setVar('graphicsPath', $pa_options['graphicsPath']);
29222933

@@ -3006,6 +3017,7 @@ public function getRelatedListHTMLFormBundle($po_request, $ps_bundle_name, $ps_f
30063017
$vb_read_only = ($po_request->user->getBundleAccessLevel($this->tableName(), $ps_bundle_name) == __CA_BUNDLE_ACCESS_READONLY__) ? true : false;
30073018
if (!$pa_bundle_settings['readonly']) { $pa_bundle_settings['readonly'] = (!isset($pa_bundle_settings['readonly']) || !$pa_bundle_settings['readonly']) ? $vb_read_only : true; }
30083019

3020+
if(!is_array($pa_bundle_settings['prepopulateQuickaddFields'])) { $pa_bundle_settings['prepopulateQuickaddFields'] = []; }
30093021
$o_view->setVar('settings', $pa_bundle_settings);
30103022
$o_view->setVar('placement_code', $ps_placement_code);
30113023
$o_view->setVar('add_label', caExtractSettingValueByLocale($pa_bundle_settings, 'add_label', $g_ui_locale));
@@ -3518,11 +3530,12 @@ public function saveBundlesForScreen($pm_screen, $po_request, &$pa_options) {
35183530
}
35193531
}
35203532

3521-
if (!$vb_batch) { // hierarchy moves are not supported in batch mode
35223533
if (is_array($va_fields_by_type['special'])) {
35233534
foreach($va_fields_by_type['special'] as $vs_placement_code => $vs_bundle) {
35243535
if ($vs_bundle !== 'hierarchy_location') { continue; }
35253536

3537+
if ($po_request->getParameter($vs_placement_code.$vs_form_prefix.'_batch_mode', pString) !== '_replace_') { continue; }
3538+
35263539
$va_parent_tmp = explode("-", $po_request->getParameter("{$vs_placement_code}{$vs_form_prefix}_new_parent_id", pString));
35273540

35283541
// Hierarchy browser sets new_parent_id param to "X" if user wants to extract item from hierarchy
@@ -3558,7 +3571,6 @@ public function saveBundlesForScreen($pm_screen, $po_request, &$pa_options) {
35583571
break;
35593572
}
35603573
}
3561-
}
35623574

35633575
//
35643576
// Call processBundlesBeforeBaseModelSave() method in sub-class, if it is defined. The method is passed

0 commit comments

Comments
 (0)