-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISLANDORA-2116 adjusted newspaper display to only load first year iss…
…ues, also added ajax handler to populate for any year clicked
- Loading branch information
Showing
6 changed files
with
193 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* AJAX handler functions for the Islandora Newspaper Solution pack module. | ||
*/ | ||
|
||
function islandora_newspaper_ajax_get_year($islandora_object, $year) { | ||
module_load_include('inc', 'islandora_newspaper', 'includes/utilities'); | ||
$issues = islandora_newspaper_get_issues($islandora_object); | ||
$grouped_issues = islandora_newspaper_group_issues($issues); | ||
$output = array( | ||
'tabs' => array( | ||
'#type' => 'vertical_tabs', | ||
), | ||
); | ||
ksort($grouped_issues); | ||
$tabs = &$output['tabs']; | ||
$pid = $islandora_object->id; | ||
$months = $grouped_issues[$year]; | ||
foreach ($months as $month => $days) { | ||
$month_name = t("@date", array( | ||
"@date" => date("F", mktime(0, 0, 0, $month, 1, 2000)), | ||
)); | ||
$tabs[$year][$month] = array( | ||
'#id' => 'y_' . $year . '_' . $month, | ||
'#title' => $month_name, | ||
'#type' => 'fieldset', | ||
'#attributes' => array( | ||
'class' => array('collapsible', 'month'), | ||
), | ||
); | ||
foreach ($days as $day => $issues) { | ||
foreach ($issues as $issue) { | ||
$tabs[$year][$month][$day][] = array( | ||
'#id' => 'y_' . $year . '_' . $month . '_' . $day, | ||
'#theme' => 'link', | ||
'#prefix' => '<div>', | ||
'#suffix' => '</div>', | ||
'#text' => t("@month @day, @year", array( | ||
'@year' => $year, | ||
'@month' => $month_name, | ||
'@day' => $day, | ||
)), | ||
'#path' => "islandora/object/{$issue['pid']}", | ||
'#options' => array( | ||
'attributes' => array(), | ||
'html' => FALSE, | ||
), | ||
); | ||
} | ||
} | ||
ksort($tabs[$year][$month]); | ||
} | ||
$html = theme('islandora_newspaper_single_year_issues', array('tabs' => $tabs)); | ||
|
||
print $html; | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(function($) { | ||
Drupal.behaviors.loadNewspaperBehavior = { | ||
attach: function (context, settings) { | ||
|
||
$(".islandora-newspaper-content ul .vertical-tab-button a").click(function() { | ||
// From the current link, get the year value from the text. | ||
var a = $(this); | ||
var year = a.first()[0].innerText | ||
year = year.replace('(active tab)', '').trim(); | ||
|
||
// Also, need to grab the hidden PID field value. | ||
var pid = $('#hidden-pid').text().trim(); | ||
|
||
if (year && pid) { | ||
newspaper_year_callback(pid, year); | ||
} | ||
}); | ||
|
||
} | ||
}; | ||
})(jQuery); | ||
|
||
|
||
function newspaper_year_callback(pid, year) { | ||
if (pid && year) { | ||
var url = window.location.protocol + "//" + window.location.host + "/islandora/object/" + pid + "/newspaper/get_year/" + year; | ||
ajax=islandora_newspaper_AjaxCaller(); | ||
ajax.open("GET", url, true); | ||
ajax.onreadystatechange=function(){ | ||
if(ajax.readyState==4){ | ||
if(ajax.status==200){ | ||
jQuery("#y_" + year).html(ajax.responseText); | ||
} | ||
} | ||
} | ||
ajax.send(null); | ||
} | ||
} | ||
|
||
function islandora_newspaper_AjaxCaller(){ | ||
var xmlhttp=false; | ||
try{ | ||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); | ||
}catch(e){ | ||
try{ | ||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | ||
}catch(E){ | ||
xmlhttp = false; | ||
} | ||
} | ||
|
||
if(!xmlhttp && typeof XMLHttpRequest!='undefined'){ | ||
xmlhttp = new XMLHttpRequest(); | ||
} | ||
return xmlhttp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* islandora-newspaper-single-year-issues.tpl.php | ||
* | ||
* This is the template file to render the months / issues for signle year of | ||
* a newspaper. | ||
* | ||
* Available variables: | ||
* - $tabs: The form elements. | ||
* | ||
*/ | ||
?> | ||
<?php print drupal_render($tabs); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters