Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved TN validation to be more reliable #28

Merged
merged 1 commit into from May 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 8 additions & 13 deletions islandora_ip_embargo.module
Expand Up @@ -185,28 +185,23 @@ function islandora_ip_embargo_cron() {
/**
* Implements hook_preprocess_theme().
*
* Checks the path, if it's an Islandora TN DS then it uses JS to watermark
* the resulting image.
* Determine if tokenized datastream is TN and add text if the parent
* is embargoed.
*/
function islandora_ip_embargo_preprocess_image(&$variables) {
module_load_include('inc', 'islandora_ip_embargo', 'includes/utilities');

$image_path = parse_url($variables['path'], PHP_URL_PATH);
$image_path_parts = explode('/', $image_path);
$size_of_image_path = count($image_path_parts);
$text = variable_get('islandora_ip_embargo_overlay_text', 'EMBARGOED');
$color = variable_get('islandora_ip_embargo_overlay_text_color', 'FF0000');
$ds = menu_get_object('islandora_tokened_datastream', 4, $variables['path']);

if ($image_path_parts[$size_of_image_path - 1] == 'view' &&
$image_path_parts[$size_of_image_path - 2] == 'TN' &&
$image_path_parts[$size_of_image_path - 3] == 'datastream') {

$pid = urldecode($image_path_parts[$size_of_image_path - 4]);
$embargo_result = islandora_ip_embargo_get_embargo($pid);
if ($ds && $ds->id == 'TN') {
$embargo_result = islandora_ip_embargo_get_embargo($ds->parent->id);

if ($embargo_result->rowCount()) {
$text = variable_get('islandora_ip_embargo_overlay_text', 'EMBARGOED');
$color = variable_get('islandora_ip_embargo_overlay_text_color', 'FF0000');
drupal_add_js(drupal_get_path('module', 'islandora_ip_embargo') . '/js/embargoed_images.js');
drupal_add_js(array('islandora_ip_embargo' => array('text' => $text, 'color' => $color)), array('type' => 'setting'));

if (isset($variables['#attributes']['class'])) {
$variables['attributes']['class'] = $variables['#attributes']['class']
. 'islandora_ip_embargo_embargoed';
Expand Down