Skip to content

Commit

Permalink
Merge branch 'develop' into dev/php8
Browse files Browse the repository at this point in the history
  • Loading branch information
collectiveaccess committed Jan 18, 2023
2 parents 59f4306 + 484429d commit 7e5c46e
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 23 deletions.
88 changes: 75 additions & 13 deletions app/lib/BaseFindEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,28 +308,53 @@ public function sortHits(array $hits, string $table, $sort_list, $sort_direction
$sort_directions = array_pad($sort_directions, sizeof($sort_fields), "asc");
}

$primary_sort_field = array_shift($sort_fields);
$parsed_sort_spec = self::_parseSortOpts(array_shift($sort_fields));
$primary_sort_field = $parsed_sort_spec['sort'];
$options = array_merge($options, $parsed_sort_spec['options']);
if ($primary_sort_field === '_natural') { return $hits; }
$primary_sort_direction = self::sortDirection(array_shift($sort_directions));

$sorted_hits = $this->doSort($hits, $table, $primary_sort_field, $primary_sort_direction, array_merge($options, ['relationshipTypes' => array_shift($rel_types)]));

// secondary sorts?
if(is_array($sort_fields) && (sizeof($sort_fields) > 0)) {
if(is_array($sort_fields) && (sizeof($sort_fields) > 0)) {
foreach($sort_fields as $i => $s) {
$parsed_sort_spec = self::_parseSortOpts($s);
$sort_fields[$i] = $parsed_sort_spec['sort'];
$options = array_merge($options, $parsed_sort_spec['options']);
}
$sorted_hits = $this->_secondarySortHits($hits, $sorted_hits, $table, $primary_sort_field, $primary_sort_direction, $sort_fields, $sort_directions, array_merge($options, ['relationshipTypes' => $rel_types]));
}

return $sorted_hits;
}
# ------------------------------------------------------------------
/**
*
*/
private static function _parseSortOpts(string $sort) : array {
$tmp = explode('%', $sort);
$spec = array_shift($tmp);
$opts = join("%", $tmp);

$tag_opt_tmp = array_filter(preg_split("![\%\&]{1}!", $opts), "strlen");

$opts = [];
foreach($tag_opt_tmp as $t) {
$tmp2 = explode('=', $t);
$opts[$tmp2[0]] = $tmp2[1];
}
return ['sort' => $spec, 'options' => $opts];
}
# ------------------------------------------------------------------
/**
*
*/
public function _secondarySortHits(array $hits, array $page_hits, string $table, string $primary_field, string $primary_sort_direction, array $sort_fields, array $sort_directions, array $options=null) {
if(!sizeof($hits)) { return []; }
$sort_spec = array_shift($sort_fields);
$sort_direction = self::sortDirection(array_shift($sort_directions));
list($sort_table, $sort_field, $sort_subfield) = array_pad(explode(".", $sort_spec), 3, null);
list($sort_table, $sort_field, $sort_subfield) = explode(".", $sort_spec);

// Extract sortable values present on results page ($page_hits)
$values = $this->_getSortValues($page_hits, $table, $primary_field, $sort_direction);
Expand Down Expand Up @@ -443,15 +468,18 @@ public function doSort(array $hits, string $table, string $sort_field, string $s

$table_pk = $t_table->primaryKey();
$table_num = $t_table->tableNum();
list($sort_table, $sort_field, $sort_subfield) = array_pad(explode(".", $sort_field), 3, null);
list($sort_table, $sort_field, $sort_subfield) = explode(".", $sort_field);
if (!($t_bundle = Datamodel::getInstanceByTableName($sort_table, true))) {
//throw new ApplicationException(_t('Invalid sort field: %1', $sort_table));
return $hits;
}

$hit_table = $this->_createTempTableForHits($hits);
if ($sort_table === $table) { // sort in primary table
if ($t_table->hasField($sort_field)) { // sort key is intrinsic
if (in_array($sort_field, ['history_tracking_current_value', 'ca_objects_location'])) {
$policy = caGetOption('policy', $options, $table::getDefaultHistoryTrackingCurrentValuePolicyForTable($sort_table));
$sort_key_values = $this->_sortByHistoryTrackingCurrentValue($t_table, $hit_table, $policy, $limit_sql, $sort_direction, $hits);
} elseif ($t_table->hasField($sort_field)) { // sort key is intrinsic
$sort_key_values = $this->_sortByIntrinsic($t_table, $hit_table, $sort_field, $limit_sql, $sort_direction);
} elseif(method_exists($t_table, 'hasElement') && $t_table->hasElement($sort_field)) { // is attribute
$sort_key_values = $this->_sortByAttribute($t_table, $hit_table, $sort_field, $sort_subfield, $limit_sql, $sort_direction, $hits);
Expand Down Expand Up @@ -656,6 +684,43 @@ private function _sortByAttribute($t_table, string $hit_table, string $element_c
return $sort_keys;
}
# ------------------------------------------------------------------
/**
*
*/
private function _sortByHistoryTrackingCurrentValue($t_table, string $hit_table, string $policy=null, string $limit_sql=null, $direction='asc', array $hits=null) {
$table_num = $t_table->tableNum();
$table_name = $t_table->tableName();

if(!method_exists($t_table, 'getPolicyConfig')) { return []; }
if(!is_array($policy_info = $table_name::getPolicyConfig($policy))) {
throw new ApplicationException(_t('Invalid policy %1', $policy));
}

$direction = self::sortDirection($direction);


$sql = "SELECT htcv.row_id
FROM ca_history_tracking_current_values htcv
INNER JOIN ca_history_tracking_current_value_labels AS l ON htcv.tracking_id = l.tracking_id
INNER JOIN {$hit_table} AS ht ON ht.row_id = htcv.row_id
WHERE
htcv.table_num = ? AND (is_future IS NULL OR is_future = 0) AND htcv.policy = ?
ORDER BY l.value_sort {$direction}
{$limit_sql}";
$qr_sort = $this->db->query($sql, [$table_num, $policy]);
$sort_keys = [];
while($qr_sort->nextRow()) {
$row = $qr_sort->getRow();
$sort_keys[$row['row_id']] = true;
}

// Add any row without the attribute set to the end of the sort set
foreach($hits as $h) {
if (!$sort_keys[$h]) { $sort_keys[$h] = true; }
}
return $sort_keys;
}
# ------------------------------------------------------------------
/**
*
*/
Expand Down Expand Up @@ -709,7 +774,7 @@ private function _getSortValues(array $hits, string $table, string $sort_field,
$table_pk = $t_table->primaryKey();
$table_num = $t_table->tableNum();

list($sort_table, $sort_field, $sort_subfield) = array_pad(explode(".", $sort_field), 3, null);
list($sort_table, $sort_field, $sort_subfield) = explode(".", $sort_field);

$values = [];

Expand Down Expand Up @@ -768,8 +833,6 @@ private function _getSortValuesForIntrinsic(array $hits, $t_table, string $intri
$sort_keys = [];
while($qr_sort->nextRow()) {
$row = $qr_sort->getRow();

if(!isset($sort_keys[$row['val']])) { $sort_keys[$row['val']] = 0; }
$sort_keys[$row['val']]++;
}
return $sort_keys;
Expand All @@ -791,9 +854,9 @@ private function _getRelatedSortValuesForIntrinsic(array $hits, $t_table, $t_rel

$sql = "
SELECT s.`{$intrinsic}` val
FROM {$table}
FROM {$table} t
{$join_sql}
WHERE {$table}.{$table_pk} IN (?)
WHERE t.{$table_pk} IN (?)
ORDER BY val {$direction}
";
$qr_sort = $this->db->query($sql, [$hits]);
Expand Down Expand Up @@ -828,7 +891,6 @@ private function _getSortValuesForLabel(array $hits, $t_table, string $label_fie
$sort_keys = [];
while($qr_sort->nextRow()) {
$row = $qr_sort->getRow();
if(!isset($sort_keys[$row['val']])) { $sort_keys[$row['val']] = 0; }
$sort_keys[$row['val']]++;
}

Expand Down Expand Up @@ -949,7 +1011,7 @@ private function _getRowIDsForValues(array $hits, string $table, string $sort_fi
$table_pk = $t_table->primaryKey();
$table_num = $t_table->tableNum();

list($sort_table, $sort_field, $sort_subfield) = array_pad(explode(".", $sort_field), 3, null);
list($sort_table, $sort_field, $sort_subfield) = explode(".", $sort_field);

$row_ids = [];

Expand Down Expand Up @@ -1054,7 +1116,7 @@ private function _getRelatedRowIDsForIntrinsic(array $values, $t_table, $t_rel_t
*
*/
private function _getRowIDsForLabel(array $values, $t_table, string $hit_table, string $label_field) {
if (!is_array($values) || !sizeof($values)) { return []; }
if (!is_array($hits) || !sizeof($hits)) { return []; }
$table = $t_table->tableName();
$table_pk = $t_table->primaryKey();
$table_num = $t_table->tableNum();
Expand Down
75 changes: 74 additions & 1 deletion themes/default/assets/pawtucket/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3024,6 +3024,79 @@ div.caMediaOverlayRepThumbs a.selectedRep img{
border:1px solid #FFF;
}

.caAudioPlayer {
position: absolute;
top: 50%;
left:0;
right:0;
margin-left: auto;
margin-right: auto;
padding: 0px;
width: 50%;
height: 40px;
}

.caAudioPlayerEmbedded {
position: absolute;
bottom: 0;
left:0;
right:0;
margin-left: auto;
margin-right: auto;
padding: 0px;
width: 100%;
height: 40px;
}

#caMediaOverlayContent {
margin: 0px;
width: 100%;
height: 100%;
overflow: auto;
text-align: center;
background-color: #000;
}

div.caMediaOverlayControls {
background-color: rgba(0,0,0,.5);
color:#FFF;
font-size: 11px;
text-align:center;
position:absolute;
padding: 10px 0px 10px 0px;
width:100%;
height: 40px;
top:0px;
left:0px;
z-index: 32000; /* needs to be on top of caMediaPanel, which has z-index=31000 */
opacity:1;
}

.plyr {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.plyr .plyr__video-wrapper {
width: 100%;
height: 100%;
}
.plyr video {
height: 100%;
width: 100%;
object-fit: fill;
}
.plyr__poster {
background-size: contain;
}
.video-responsive {
position: relative;
width: 100%;
height: 100%;
}


/* --------------------------------------------------------- */
/* Static Pages */
Expand Down Expand Up @@ -3600,4 +3673,4 @@ input[type='text'].ui-autocomplete-loading {
.highlightText {
background-color: #FBF719;
opacity: 0.8;
}
}
2 changes: 1 addition & 1 deletion themes/estee/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ front_page_set_code = frontPage
# code embedded in the template on EVERY page load. Depending upon your point of view this is either a
# feature or a security hole. It doesn't have to be a problem, but keep it in mind...
#
allow_php_in_site_page_templates = 0
allow_php_in_site_page_templates = 1

# -------------------
# Content caching
Expand Down
19 changes: 11 additions & 8 deletions themes/estee/templates/aboutTabbed.tmpl
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
<?php
$vs_tab = strToLower($_REQUEST["tab"]);
?>
<div class="row">
<div class="col-sm-12 col-md-10 col-md-offset-1 tabModuleContent">
<h1>{{{title}}}</h1>

<article class="tabModuleContentInner float100">
<section class="tabsTitle float100">
<ul role="tablist">
<li role="presentation" class="active"><a href="#about" aria-controls="About" role="tab" data-toggle="tab">About</a></li>
<li role="presentation"><a href="#faq" aria-controls="FAQ" role="tab" data-toggle="tab">FAQ</a></li>
<li role="presentation"><a href="#newsletter" aria-controls="FAQ" role="tab" data-toggle="tab">Quarterly Newsletters</a></li>
<ul role="tablist" class="tablist">
<li role="presentation" id="tababout"<?php print (!$vs_tab || ($vs_tab == "about")) ? " class='active'" : ""; ?>><a href="#about" aria-controls="About" role="tab" data-toggle="tab">About</a></li>
<li role="presentation" id="tabfaq"<?php print ($vs_tab == "faq") ? " class='active'" : ""; ?>><a href="#faq" aria-controls="FAQ" role="tab" data-toggle="tab">FAQ</a></li>
<li role="presentation" id="tabnewsletter"<?php print ($vs_tab == "newsletter") ? " class='active'" : ""; ?>><a href="#newsletter" aria-controls="FAQ" role="tab" data-toggle="tab">Quarterly Newsletters</a></li>
<!--<li role="presentation"><a href="#guide" aria-controls="guide" role="tab" data-toggle="tab">Guide to Use</a></li>-->
</ul>
</section>
<section class="tabsContent float100">

<div class="tab-content">
<div role="tabpanel" class="tab-pane active tabContent float100" id="about">
<div role="tabpanel" class="tab-pane tabContent float100 <?php print (!$vs_tab || ($vs_tab == "about")) ? "active" : ""; ?>" id="about">
{{{AboutText}}}
</div>
<div role="tabpanel" class="tab-pane tabContent float100" id="faq">
<div role="tabpanel" class="tab-pane tabContent float100 <?php print ($vs_tab == "faq") ? "active" : ""; ?>" id="faq">
{{{FAQText}}}
</div>
<div role="tabpanel" class="tab-pane tabContent float100" id="newsletter">
<div role="tabpanel" class="tab-pane tabContent float100 <?php print ($vs_tab == "newsletter") ? "active" : ""; ?>" id="newsletter">
{{{NewsletterText}}}
</div>
<!--<div role="tabpanel" class="tab-pane tabContent float100" id="guide">
Expand All @@ -30,4 +33,4 @@
</section>
</article>
</div>
</div>
</div>

0 comments on commit 7e5c46e

Please sign in to comment.