Commit 55b67b82 authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-1983: Unsetting os-publications query_biblio_alter and adding...

ISTWCMS-1983: Unsetting os-publications query_biblio_alter and adding uw_virtual_site_homepage query_biblio_alter to the end.  Adding function to fix query_biblio_alter to work with latest biblio.
parent e95e8bc9
...@@ -6,6 +6,109 @@ ...@@ -6,6 +6,109 @@
include_once 'uw_virtual_site_homepage.features.inc'; include_once 'uw_virtual_site_homepage.features.inc';
/**
* Implements hook_module_implements_alter().
* Remove the os_publications query_biblio_alter.
*/
function uw_virtual_site_homepage_module_implements_alter(&$implementations, $hook) {
// If we are on the query_biblio_alter hook, unset os_publications and place uw_virtual_site_homepage last.
if($hook == "query_biblio_alter") {
// Move uw_virtual_site_homepage's query_biblio_alter to be done last.
$group = $implementations['uw_virtual_site_homepage'];
unset($implementations['uw_virtual_site_homepage']);
$implementations['uw_virtual_site_homepage'] = $group;
// Remove os_publicatons' query_biblio_alter.
unset($implementations['os_publications']);
}
}
/**
* Implements hook query_TAG_alter().
* TAG: biblio.
* Set the searching and sorting options for the biblio query and add the space.
*/
function uw_virtual_site_homepage_query_biblio_alter(QueryAlterableInterface $query) {
// Ensure that we have vsite turned on.
if (!module_exists('vsite') || !$space = spaces_get_space()) {
return;
}
_os_publications_filter_by_term($query);
// this has to be separate because of scoping.
if ($space->type == 'og') {
$query->innerJoin('og_membership', 'ogm', 'n.nid = ogm.etid');
$query->condition('ogm.entity_type', 'node');
$query->condition('ogm.group_type', 'node');
$query->condition('ogm.gid', $space->id);
}
$item = menu_get_item();
// Checking for search_node alter tag.
if(!isset($query->alterTags)) {
// Check if we have a search_node alter tag.
if(!isset($query->alterTags['search_node'])) {
// Check the sort order for biblio.
// If we're sorting by year, we want to sort by date as well to replicate D6
// sorting.
if (variable_get('biblio_sort', 'year') == 'year') {
// Get their sort order.
$biblio_year_sort = $space->controllers->variable->get('biblio_order','space');
$order = &$query->getOrderBy();
// Don't wipe the non-default sort order, this will let users still toggle asc/desc sorting by year.
if (array_key_exists('biblio_year', $order) && $order['biblio_year'] != $biblio_year_sort) {
$biblio_year_sort = $order['biblio_year'];
}
// Rebuild the array to our defaults only when the user is NOT searching. When the user is searching, use their selections
if (isset($_GET['s']) && in_array($_GET['s'], array('author', 'title', 'type'))) {
$s = current(array_keys($order));
$o = current($order);
if ($s = 'biblio_sort_title') {
$biblio_sort_title = $o;
}
}
else {
$order = array();
}
// Sort by year, and after that create another sorting by the node's
// "sticky" property, the creation date of the node, the Biblio date, and
// the Biblio title.
$order['biblio_year'] = isset($biblio_year_sort) ? $biblio_year_sort : 'DESC';
$order['n.sticky'] = 'DESC';
$order['n.created'] = 'DESC';
$order['biblio_sort_title'] = (isset($biblio_sort_title)) ? $biblio_sort_title : 'ASC';
}
elseif (variable_get('biblio_sort', 'year') == 'type') {
// Sort by type, and after that create another sorting by creation date of
// the node.
$order = &$query->getOrderBy();
$new_order = array();
foreach ($order as $key => $value) {
$new_order[$key] = $value;
if ($key == 'biblio_type_name') {
$new_order['n.sticky'] = 'DESC';
$new_order['biblio_year'] = 'DESC';
$new_order['n.created'] = 'DESC';
}
}
$order = $new_order;
}
}
}
}
/* /*
* Implements hook_field_widget_form_alter(). * Implements hook_field_widget_form_alter().
* Adding process to image types to change title to caption for homepage banners. * Adding process to image types to change title to caption for homepage banners.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment