Browse Source

Get rid of more explicit markup output, in favour of Drupal methods.

pull/99/head
Adam Vessey 13 years ago
parent
commit
eaff54436b
  1. 8
      ObjectHelper.inc
  2. 5
      formClass.inc
  3. 5
      plugins/ShowDemoStreamsInFieldSets.inc
  4. 42
      plugins/ShowStreamsInFieldSets.inc
  5. 4
      plugins/herbarium.inc
  6. 65
      plugins/qt_viewer.inc
  7. 6
      plugins/slide_viewer.inc
  8. 30
      plugins/tagging_form.inc

8
ObjectHelper.inc

@ -702,9 +702,11 @@ class ObjectHelper {
} }
if ($allow) { if ($allow) {
// $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() . // $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() .
$ingestObject = '<a title="' . t('Ingest a New object into !collection_name PID !collection_pid', array('!collection_name' => $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() . $ingest_text = t('Ingest a new object into @collection_name PID @collection_pid', array('@collection_name' => $collectionName, '@collection_pid' => $collection_pid));
'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path . $ingestObject = l(theme('image', "$path/images/ingest.png", $ingest_text), "fedora/ingestObject/$collection_pid/$collectionName", array('attributes' => array(
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a> ' . t('Add to this Collection'); 'class' => 'icon',
'title' => $ingest_text,
))) . t('Add to this Collection');
} }
} }
} }

5
formClass.inc

@ -230,7 +230,10 @@ class formClass {
'#description' => t('The URL to use for SOAP connections'), '#description' => t('The URL to use for SOAP connections'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -12, '#weight' => -12,
'#suffix' => '<p>' . (fedora_available() ? '<img src="' . url('misc/watchdog-ok.png') . '"/>' . t('Successfully connected to Fedora server at !fedora_soap_url', array('!fedora_soap_url' => variable_get('fedora_soap_url', ''))) : '<img src="' . url('misc/watchdog-error.png') . '"/> ' . t('Unable to connect to Fedora server at !fedora_soap_url</p>', array('!fedora_soap_url' => variable_get('fedora_soap_url', '')))), '#suffix' => '<p>' . (
fedora_available() ?
theme('image', 'misc/watchdog-ok.png') . t('Successfully connected to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', ''))) :
theme('image', 'misc/watchdog-error.png') . t('Unable to connect to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', '')))) . '</p>',
); );
$form['fedora_soap_manage_url'] = array( $form['fedora_soap_manage_url'] = array(

5
plugins/ShowDemoStreamsInFieldSets.inc

@ -29,11 +29,10 @@ class ShowDemoStreamsInFieldSets {
* @return type * @return type
*/ */
function showMediumSize() { function showMediumSize() {
global $base_url; $path = "fedora/repository/{$this->pid}/MEDIUM_SIZE";
$collection_fieldset = array( $collection_fieldset = array(
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#value' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/MEDIUM_SIZE/"><img src="' . '#value' => l(theme('image', $path), $path, array('html' => TRUE)),
$base_url . '/fedora/repository/' . $this->pid . '/MEDIUM_SIZE/MEDIUM_SIZE' . '" /></a>',
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }

42
plugins/ShowStreamsInFieldSets.inc

@ -29,15 +29,21 @@ class ShowStreamsInFieldSets {
function showFlv() { function showFlv() {
//FLV is the datastream id //FLV is the datastream id
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'Fedora_Repository');
$fullPath = base_path() . $path; $fullPath = url($path);
$content = ""; $content = "";
$pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/swfobject.js'; $pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/swfobject.js';
drupal_add_js("$pathTojs"); drupal_add_js("$pathTojs");
$content .= '<div id="player' . $this->pid . 'FLV"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>'; $div_id = "player' . $this->pid . 'FLV";
drupal_add_js('var s1 = new SWFObject("' . $fullPath . '/flash/flvplayer.swf","single","320","240","7"); $content .= <<<EOH
s1.addParam("allowfullscreen","TRUE"); <div id="$div_id"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
s1.addVariable("file","' . base_path() . 'fedora/repository/' . $this->pid . '/FLV/FLV.flv"); EOH;
s1.write("player' . $this->pid . 'FLV");', 'inline', 'footer'); drupal_add_js(<<<EOJS
var s1 = new SWFObject("$fullPath/flash/flvplayer.swf","single","320","240","7");
s1.addParam("allowfullscreen","TRUE");
s1.addVariable("file", "$fullPath/fedora/repository/{$this->pid}/FLV/FLV.flv");
s1.write("$div_id");
EOJS
, 'inline', 'footer');
$collection_fieldset = array( $collection_fieldset = array(
'#title' => t('Flash Video'), '#title' => t('Flash Video'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
@ -48,30 +54,26 @@ class ShowStreamsInFieldSets {
/** /**
* Show the TN ?? * Show the TN ??
* @global type $base_url
* @return type * @return type
*/ */
function showTN() { function showTN() {
global $base_url;
$collection_fieldset = array( $collection_fieldset = array(
'#title' => '', '#title' => '',
'#attributes' => array(), '#attributes' => array(),
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#value' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/OBJ/"><img src="' . $base_url . '/fedora/repository/' . $this->pid . '/TN/TN' . '" /></a>', '#value' => l(theme('image', "fedora/repository/{$this->pid}/TN/TN", '', '', NULL, FALSE), "fedora/repository/{$this->pid}/OBJ", array('html' => TRUE)),
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
/** /**
* Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ * Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ
* @global type $base_url
* @return type * @return type
*/ */
function showArtInventoryTN() { function showArtInventoryTN() {
global $base_url;
$collection_fieldset = array( $collection_fieldset = array(
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#value' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/IMAGE/image.jpg"><img src="' . $base_url . '/fedora/repository/' . $this->pid . '/TN/TN' . '" /></a>', '#value' => l(theme('image', "fedora/repository/{$this->pid}/TN/TN", '', '', NULL, FALSE), "fedora/repository/{$this->pid}/IMAGE/image.jpg", array('html' => TRUE)),
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
@ -102,14 +104,16 @@ class ShowStreamsInFieldSets {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
if (key_exists('TN', $item->datastreams)) { if (key_exists('TN', $item->datastreams)) {
$tn_url = $base_url . '/fedora/repository/' . $item->pid . '/TN'; $tn_url = "fedora/repository/{$item->pid}/TN";
} }
else { else {
$tn_url = $base_path . drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png'; $tn_url = drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png';
} }
$tn_url = url($tn_url);
$dc_html = $objectHelper->getFormattedDC($item); $dc_html = $objectHelper->getFormattedDC($item);
$dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />' . t('View Document') .'</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); $dl_link = l('<div style="float:left; padding: 10px">' . theme('image', $tn_url, '', '', NULL, FALSE) . '<br />' . t('View Document') .'</div>', "fedora/repository/{$this->pid}/OBJ", array('html' => TRUE));
$tabset['first_tab']['tabs']['view'] = array( $tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
@ -126,11 +130,13 @@ class ShowStreamsInFieldSets {
); );
} }
$viewer_url = 'http://docs.google.com/viewer?url=' . url("fedora/repository/{$this->pid}/OBJ/preview.pdf", array('absolute' => TRUE)) . '&embedded=TRUE';
$tabset['second_tab'] = array( $tabset['second_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Read Online'), '#title' => t('Read Online'),
'#content' => "<iframe src=\"http://docs.google.com/viewer?url=" . $base_url . '/fedora/repository/' . '#content' => <<<EOM
$this->pid . '/OBJ/preview.pdf' . "&embedded=TRUE\" style=\"width:600px; height:500px;\" frameborder=\"0\"></iframe>" <iframe src="$viewer_url" style="width:600px; height:500px;" frameborder="0"></iframe>"
EOM
); );
// Render the tabset. // Render the tabset.
@ -164,7 +170,7 @@ class ShowStreamsInFieldSets {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
$streams = $item->get_datastreams_list_as_array(); $streams = $item->get_datastreams_list_as_array();
return "<a href='" . $base_url . "/fedora/repository/" . $this->pid . "/OBJ/" . $streams['OBJ']['label'] . "'>" . $streams['OBJ']['label'] . "</a>"; return l($streams['OBJ']['label'], "fedora/repository/{$this->pid}/OBJ");
} }
/** /**

4
plugins/herbarium.inc

@ -161,13 +161,13 @@ class Herbarium {
'#title' => t('Full-size'), '#title' => t('Full-size'),
'#content' => $html '#content' => $html
); );
$image = theme('image', "fedora/imageapi/{$this->pid}/JPG/JPG.jpg", '', '', NULL, FALSE);
$tabset['first_tab'] = array( $tabset['first_tab'] = array(
// #type and #title are the minimum requirements. // #type and #title are the minimum requirements.
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
// This will be the content of the tab. // This will be the content of the tab.
'#content' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/FULL_JPG/"><img src="' . $base_url . '/fedora/imageapi/' . '#content' => l($image, "fedora/repository/{$this->pid}/FULL_JPG", array('html' => TRUE)), '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
$this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
); );
$dwc = new DarwinCore($this->item); $dwc = new DarwinCore($this->item);

65
plugins/qt_viewer.inc

@ -125,31 +125,53 @@ class ShowQtStreamsInFieldSets {
if ($media === FALSE) { if ($media === FALSE) {
return ''; return '';
} }
global $base_url;
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'Fedora_Repository');
$fullPath = base_path() . $path;
$content = ''; drupal_add_js("$path/js/AC_Quicktime.js");
$pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/AC_Quicktime.js';
drupal_add_js($pathTojs);
$divid = 'player' . md5($this->pid) . 'MOV'; $divid = 'player' . md5($this->pid) . 'MOV';
$content .= '<div class="player" id="' . $divid . '">';
$collection_fieldset = array(
'#title' => t('Quicktime'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'player' => array(
'#type' => 'markup',
'#prefix' => '<div class="player" id="' . $divid . '">',
'#suffix' => '</div>',
),
);
if ($pframe !== FALSE) { if ($pframe !== FALSE) {
$content .= '<div class="poster" style="cursor: pointer; position: relative; width: ' . $width . 'px; min-height: ' . ($height) . 'px;">'; $collection_fieldset['player']['poster_container'] = array(
$content .= '<img src="' . base_path() . 'fedora/repository/' . $this->pid . '/' . $pframe->ID . '/poster.jpg' . '" />'; '#type' => 'markup',
$content .= '<div class="play" style="font-size: 128px; color: white; position: absolute; top: 50%; left: 50%; margin-top: -0.085em; margin-left: -0.33em; opacity: 0.9; "></div>'; '#prefix' => '<div class="poster" style="cursor: pointer; position: relative; width: ' . $width . 'px; min-height: ' . ($height) . 'px;">',
$content .= '</div>'; '#suffix' => '</div>',
'poster' => array(
'#type' => 'markup',
'#value' => theme('image', "fedora/repository/{$this->pid}/{$pframe->ID}/poster.jpg", '', '', NULL, FALSE)
)
'play' => array(
'#type' => 'markup',
'#prefix' => '<div class="play" style="font-size: 128px; color: white; position: absolute; top: 50%; left: 50%; margin-top: -0.085em; margin-left: -0.33em; opacity: 0.9;">',
'#suffix' => '</div>',
'#value' => '&nbsp;',
),
);
} }
$content .= '</div>';
if ($this->enableDownload()) { if ($this->enableDownload()) {
$url = base_path() . 'fedora/repository/' . $this->pid . '/OBJ/MOV.mov'; //$url = url();
$content .= '<a class="download" href="' . $url . '">Download Media File</a>'; $collection_fieldset['download_link'] = array(
'#type' => 'markup',
'#value' => l(t('Download Media File'), "fedora/repository/{$this->pid}/OBJ/MOV.mov", array('attributes' => array('class' => 'download'))),
);
} }
$src = base_path() . 'fedora/repository/' . $this->pid . '/' . $media->ID . '/MOV.mov'; $src = url("fedora/repository/{$this->pid}/{$media->ID}/MOV.mov";
$qtparams = '';
$qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', "; $qtparams = "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', ";
$init = <<<EOD $init = <<<EOD
$(function() { $(function() {
src = "$src"; src = "$src";
if(src.substring(0,4) != 'http') { if(src.substring(0,4) != 'http') {
src = 'http://' + location.host + src; src = 'http://' + location.host + src;
@ -163,21 +185,16 @@ class ShowQtStreamsInFieldSets {
'SCALE', 'aspect', 'SCALE', 'aspect',
'LOOP', 'FALSE' 'LOOP', 'FALSE'
); );
if($('.poster', '#$divid').length ==0) { if($('.poster', '#$divid').length == 0) {
$('#$divid').append(str); $('#$divid').append(str);
} else { } else {
$('#$divid .poster').one('click', function() { $(this).hide(); $('#$divid').append(str); }); $('#$divid .poster').one('click', function() { $(this).hide(); $('#$divid').append(str); });
} }
}); });
EOD; EOD;
drupal_add_js($init, 'inline', 'footer'); drupal_add_js($init, 'inline', 'footer');
$collection_fieldset = array(
'#title' => t('Quicktime'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#value' => $content);
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }

6
plugins/slide_viewer.inc

@ -30,14 +30,13 @@ class ShowSlideStreamsInFieldSets {
function showJPG() { function showJPG() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets');
global $base_url;
global $user; global $user;
$tabset = array(); $tabset = array();
$qs = ''; $qs = '';
if ($user->uid != 0) { if ($user->uid != 0) {
$qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); $qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); //XXX: Base64 encoding is not encryption; SSL would be nice...
} }
$viewer_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs; $viewer_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs;
@ -55,8 +54,7 @@ class ShowSlideStreamsInFieldSets {
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
// This will be the content of the tab. // This will be the content of the tab.
'#content' => '<img src="' . $base_url . '#content' => theme('image', "fedora/imageapi/{$this->pid}/JPG/JPG.jpg", '', '', NULL, FALSE) . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
'/fedora/imageapi/' . $this->pid . '/JPG/JPG.jpg' . '" />' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
); );
return $tabset; return $tabset;

30
plugins/tagging_form.inc

@ -19,13 +19,15 @@ function _show_subject_tags($pid) {
$obj = new Fedora_Item($pid); $obj = new Fedora_Item($pid);
$tags = new TagSet($obj); $tags = new TagSet($obj);
if (!empty($tags->tags)) { if (!empty($tags->tags)) {
$output = "<ul>"; $items = array();
foreach ($tags->tags as $tag) { foreach ($tags->tags as $tag) {
$output .= "<li title=" . $tag['creator'] . '>' . $tag['name'] . '</li> '; $items[] = array(
'data' => $tag['name'],
'title' => $tag['creator'],
);
} }
$output .= "</ul>"; return theme('item_list', $items);
} }
return $output;
} }
/** /**
@ -57,21 +59,27 @@ function fedora_repository_image_tagging_form($form_state, $pid) {
// Add the current tags to the form. // Add the current tags to the form.
$tagset = new TagSet($obj); $tagset = new TagSet($obj);
$tags = array();
foreach ($tagset->tags as $tag) { foreach ($tagset->tags as $tag) {
$form['tags-wrapper']['tags'][$tag['name']] = array( $form_tag =& $form['tags-wrapper']['tags'][$tag['name']] = array(
'#prefix' => '<li>', '#prefix' => '<li>',
'#suffix' => '</li>', '#suffix' => '</li>',
); );
$form['tags-wrapper']['tags'][$tag['name']]['tag'] = array(
'#prefix' => '<a title="Added by ' . $tag['creator'] . '" href="' . $base_url . '/fedora/repository/mnpl_advanced_search/tag:' . $tag['name'] . '">', $tag_title_text = t('Added by @creator.', array(
'#value' => $tag['name'], '@creator' => $tag['creator'],
'#suffix' => '</a>', ));
$tag_mnpl_search_path = "fedora/repository/mnpl_advanced_search/tag:{$tag['name']}"
$form_tag['tag'] = array(
'#value' => l($tag['name'], $tag_mnpl_search_path, array('attributes' => array(
'title' => $tag_title_text
))),
); );
if (user_access('modify fedora datastreams') || user_access('add fedora tags')) { if (user_access('modify fedora datastreams') || user_access('add fedora tags')) {
// Delete button for each existing tag. // Delete button for each existing tag.
$form['tags-wrapper']['tags'][$tag['name']]['delete'] = array( $form_tag['delete'] = array(
'#type' => 'imagebutton', '#type' => 'imagebutton',
'#image' => $base_url . '/' . drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png', '#image' => drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png',
'#default_value' => $tag['name'], '#default_value' => $tag['name'],
'#title' => t('Delete this tag'), '#title' => t('Delete this tag'),
); );

Loading…
Cancel
Save