From eaff54436b3a13663b5987086eda6c11d2594704 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Mon, 23 Apr 2012 10:25:45 -0300 Subject: [PATCH] Get rid of more explicit markup output, in favour of Drupal methods. --- ObjectHelper.inc | 8 ++- formClass.inc | 5 +- plugins/ShowDemoStreamsInFieldSets.inc | 5 +- plugins/ShowStreamsInFieldSets.inc | 42 ++++++----- plugins/herbarium.inc | 4 +- plugins/qt_viewer.inc | 99 +++++++++++++++----------- plugins/slide_viewer.inc | 6 +- plugins/tagging_form.inc | 30 +++++--- 8 files changed, 116 insertions(+), 83 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 7fed4f86..18000b80 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -702,9 +702,11 @@ class ObjectHelper { } if ($allow) { // $ingestObject = ' $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() . - 'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '">' . t('Add a New Object') . ' ' . t('Add to this Collection'); + $ingest_text = t('Ingest a new object into @collection_name PID @collection_pid', array('@collection_name' => $collectionName, '@collection_pid' => $collection_pid)); + $ingestObject = l(theme('image', "$path/images/ingest.png", $ingest_text), "fedora/ingestObject/$collection_pid/$collectionName", array('attributes' => array( + 'class' => 'icon', + 'title' => $ingest_text, + ))) . t('Add to this Collection'); } } } diff --git a/formClass.inc b/formClass.inc index 4bd1e132..d6cb23df 100644 --- a/formClass.inc +++ b/formClass.inc @@ -230,7 +230,10 @@ class formClass { '#description' => t('The URL to use for SOAP connections'), '#required' => TRUE, '#weight' => -12, - '#suffix' => '

' . (fedora_available() ? '' . t('Successfully connected to Fedora server at !fedora_soap_url', array('!fedora_soap_url' => variable_get('fedora_soap_url', ''))) : ' ' . t('Unable to connect to Fedora server at !fedora_soap_url

', array('!fedora_soap_url' => variable_get('fedora_soap_url', '')))), + '#suffix' => '

' . ( + 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', '')))) . '

', ); $form['fedora_soap_manage_url'] = array( diff --git a/plugins/ShowDemoStreamsInFieldSets.inc b/plugins/ShowDemoStreamsInFieldSets.inc index 80f8017c..9d210d2a 100644 --- a/plugins/ShowDemoStreamsInFieldSets.inc +++ b/plugins/ShowDemoStreamsInFieldSets.inc @@ -29,11 +29,10 @@ class ShowDemoStreamsInFieldSets { * @return type */ function showMediumSize() { - global $base_url; + $path = "fedora/repository/{$this->pid}/MEDIUM_SIZE"; $collection_fieldset = array( '#collapsible' => FALSE, - '#value' => '', + '#value' => l(theme('image', $path), $path, array('html' => TRUE)), ); return theme('fieldset', $collection_fieldset); } diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index 9e20ca5a..0bbf9403 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -29,15 +29,21 @@ class ShowStreamsInFieldSets { function showFlv() { //FLV is the datastream id $path = drupal_get_path('module', 'Fedora_Repository'); - $fullPath = base_path() . $path; + $fullPath = url($path); $content = ""; $pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/swfobject.js'; drupal_add_js("$pathTojs"); - $content .= '
Get the Flash Player to see this player.
'; - drupal_add_js('var s1 = new SWFObject("' . $fullPath . '/flash/flvplayer.swf","single","320","240","7"); - s1.addParam("allowfullscreen","TRUE"); - s1.addVariable("file","' . base_path() . 'fedora/repository/' . $this->pid . '/FLV/FLV.flv"); - s1.write("player' . $this->pid . 'FLV");', 'inline', 'footer'); + $div_id = "player' . $this->pid . 'FLV"; + $content .= <<Get the Flash Player to see this player. +EOH; + drupal_add_js(<<pid}/FLV/FLV.flv"); +s1.write("$div_id"); +EOJS +, 'inline', 'footer'); $collection_fieldset = array( '#title' => t('Flash Video'), '#collapsible' => TRUE, @@ -48,30 +54,26 @@ class ShowStreamsInFieldSets { /** * Show the TN ?? - * @global type $base_url * @return type */ function showTN() { - global $base_url; $collection_fieldset = array( '#title' => '', '#attributes' => array(), '#collapsible' => FALSE, - '#value' => '', + '#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); } /** * Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ - * @global type $base_url * @return type */ function showArtInventoryTN() { - global $base_url; $collection_fieldset = array( '#collapsible' => FALSE, - '#value' => '', + '#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); } @@ -102,14 +104,16 @@ class ShowStreamsInFieldSets { $objectHelper = new ObjectHelper(); $item = new Fedora_Item($this->pid); if (key_exists('TN', $item->datastreams)) { - $tn_url = $base_url . '/fedora/repository/' . $item->pid . '/TN'; + $tn_url = "fedora/repository/{$item->pid}/TN"; } 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); - $dl_link = l('

' . t('View Document') .'
', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); + $dl_link = l('
' . theme('image', $tn_url, '', '', NULL, FALSE) . '
' . t('View Document') .'
', "fedora/repository/{$this->pid}/OBJ", array('html' => TRUE)); $tabset['first_tab']['tabs']['view'] = array( '#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( '#type' => 'tabpage', '#title' => t('Read Online'), - '#content' => "" + '#content' => <<" +EOM ); // Render the tabset. @@ -164,7 +170,7 @@ class ShowStreamsInFieldSets { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $streams = $item->get_datastreams_list_as_array(); - return "" . $streams['OBJ']['label'] . ""; + return l($streams['OBJ']['label'], "fedora/repository/{$this->pid}/OBJ"); } /** diff --git a/plugins/herbarium.inc b/plugins/herbarium.inc index f7a6d685..0ad13fd6 100644 --- a/plugins/herbarium.inc +++ b/plugins/herbarium.inc @@ -161,13 +161,13 @@ class Herbarium { '#title' => t('Full-size'), '#content' => $html ); + $image = theme('image', "fedora/imageapi/{$this->pid}/JPG/JPG.jpg", '', '', NULL, FALSE); $tabset['first_tab'] = array( // #type and #title are the minimum requirements. '#type' => 'tabpage', '#title' => t('View'), // This will be the content of the tab. - '#content' => '' . '

' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', + '#content' => l($image, "fedora/repository/{$this->pid}/FULL_JPG", array('html' => TRUE)), '

' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', ); $dwc = new DarwinCore($this->item); diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index e52e4363..e321f00f 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -125,59 +125,76 @@ class ShowQtStreamsInFieldSets { if ($media === FALSE) { return ''; } - global $base_url; + $path = drupal_get_path('module', 'Fedora_Repository'); - $fullPath = base_path() . $path; - $content = ''; - $pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/AC_Quicktime.js'; - drupal_add_js($pathTojs); + + drupal_add_js("$path/js/AC_Quicktime.js"); $divid = 'player' . md5($this->pid) . 'MOV'; - $content .= '
'; + + $collection_fieldset = array( + '#title' => t('Quicktime'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + 'player' => array( + '#type' => 'markup', + '#prefix' => '
', + '#suffix' => '
', + ), + ); + if ($pframe !== FALSE) { - $content .= '
'; - $content .= ''; - $content .= '
'; - $content .= '
'; + $collection_fieldset['player']['poster_container'] = array( + '#type' => 'markup', + '#prefix' => '
', + '#suffix' => '
', + 'poster' => array( + '#type' => 'markup', + '#value' => theme('image', "fedora/repository/{$this->pid}/{$pframe->ID}/poster.jpg", '', '', NULL, FALSE) + ) + 'play' => array( + '#type' => 'markup', + '#prefix' => '
', + '#suffix' => '
', + '#value' => ' ', + ), + ); } - $content .= '
'; if ($this->enableDownload()) { - $url = base_path() . 'fedora/repository/' . $this->pid . '/OBJ/MOV.mov'; - $content .= 'Download Media File'; + //$url = url(); + $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'; - $qtparams = ''; - $qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', "; + $src = url("fedora/repository/{$this->pid}/{$media->ID}/MOV.mov"; + + $qtparams = "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', "; $init = << t('Quicktime'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - '#value' => $content); return theme('fieldset', $collection_fieldset); } diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index f3bdd6b9..729e824e 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -30,14 +30,13 @@ class ShowSlideStreamsInFieldSets { function showJPG() { module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); - global $base_url; global $user; $tabset = array(); $qs = ''; 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; @@ -55,8 +54,7 @@ class ShowSlideStreamsInFieldSets { '#type' => 'tabpage', '#title' => t('View'), // This will be the content of the tab. - '#content' => '' . '

' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', + '#content' => theme('image', "fedora/imageapi/{$this->pid}/JPG/JPG.jpg", '', '', NULL, FALSE) . '

' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', ); return $tabset; diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index 390bf36c..f00274d4 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -19,13 +19,15 @@ function _show_subject_tags($pid) { $obj = new Fedora_Item($pid); $tags = new TagSet($obj); if (!empty($tags->tags)) { - $output = "
    "; + $items = array(); foreach ($tags->tags as $tag) { - $output .= "
  • "; + 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. $tagset = new TagSet($obj); + $tags = array(); foreach ($tagset->tags as $tag) { - $form['tags-wrapper']['tags'][$tag['name']] = array( + $form_tag =& $form['tags-wrapper']['tags'][$tag['name']] = array( '#prefix' => '
  • ', '#suffix' => '
  • ', ); - $form['tags-wrapper']['tags'][$tag['name']]['tag'] = array( - '#prefix' => '', - '#value' => $tag['name'], - '#suffix' => '', + + $tag_title_text = t('Added by @creator.', array( + '@creator' => $tag['creator'], + )); + $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')) { // Delete button for each existing tag. - $form['tags-wrapper']['tags'][$tag['name']]['delete'] = array( + $form_tag['delete'] = array( '#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'], '#title' => t('Delete this tag'), );