# HG changeset patch # User Dirk Wintergruen # Date 1433228268 -7200 # Node ID 6f6e07baad80070b385ed3f8131857d6bf46b13d initial diff -r 000000000000 -r 6f6e07baad80 Copy of digitalobjects-item.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Copy of digitalobjects-item.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,105 @@ + + +

Hello

+ + +

> + +

+ + + +
+ + +
+ + diff -r 000000000000 -r 6f6e07baad80 chooser.js diff -r 000000000000 -r 6f6e07baad80 digitalobject_reader.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobject_reader.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,216 @@ +data)){ + return drupal_json_decode($request->data); + } + else { + return null; + } + +} + +function digitalobjects_getBibFormattedMetaData($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getBibFormattedMetaDataJSON"; + $path = $base ."/getBibFormattedMetaDataJSON"; + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + return drupal_json_decode($request->data); + +} + + +function digitalobjects_getBibFormattedDC($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getDCMappedDataJSON"; + $path = $base ."/getDCMappedData"; + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + #return drupal_json_decode($request->data); + + return drupal_json_decode($request->data); + +} + + +function digitalobjects_getBibFormattedLabel($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getBibFormattedMetaDataJSON"; + $path = $base ."/getBibFormattedLabelJSON"; + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + return drupal_json_decode($request->data); + +} + + + +function digitalobjects_getBibMappedData($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getBibFormattedMetaDataJSON"; + $path = $base ."/getBibMappedDataJSON"; + + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + return drupal_json_decode($request->data); + +} +#here.metadata.getBibFormattedMetaData(bibdata=docinfo.get('bib', None)) + + + +function digitalobjects_readMetadata($objid_full,$format="long"){ + + //objid_full can have the structure ID/Pagenumber + + + $objid_parts = explode("/",$objid_full); + + $objid=$objid_parts[0]; + + + if (isset($objid_parts[1])){ + $pn=$objid_parts[1]; + $pn_set=true; + } else { + $pn="1"; + $pn_set=false; + } + + + + $md = digitalobject_getMetadata($objid); + + switch($format){ + case "long": + $bib = isset($md['bib']) ?digitalobjects_getBibFormattedMetaData($md['bib']): null; + break; + + case "short": + $bib = isset($md['bib']) ?digitalobjects_getBibFormattedLabel($md['bib']): null; + + break; + + case "DC": + $bibArray = isset($md['bib']) ?digitalobjects_getBibFormattedDC($md['bib']): null; + + + + if (count($bibArray) == 0) { + $bibArray = array ( + "creator" => $md['creator'], + "title" => $md['title'], + "date" => $md['date'] + ); + } + + + $bib = ''; + + foreach ($bibArray as $key => $value){ + $bib = $bib . "" . $value . ""; + } + $bib = $bib . ''; + + + + + } // close switch + + + if ($bib == null) { + $bibdata = array ( + "Author" => $md['creator'], + "Title" => $md['title'], + "Date" => $md['date'] + ); + $bib=""; + /*foreach ($bibdata as $key => $content){ + $bib = $bib . '' . $key . ' + ' . $content . ''; + } + */ + foreach ($bibdata as $key => $content){ + $bib = $bib . '' . $key . ': + ' . $content . ' '; + } + } + + + + $access_type = isset($md['accessType']) ? $md['accessType'] : 'mpiwg'; + + if ($pn_set){ + $titlepage=$pn; // im parameter war die Seitenzahl gesetzt. + } else + { + $titlepage = isset($md['titlePage']) ? $md['titlePage'] : 1; + } + + + $data = array( + "thumburl" => create_thumburl_from_dri($objid,$titlepage=$titlepage), + "viewerurl" => create_url_from_dri($objid,$access_type = $access_type,$titlepage=$titlepage), + "md" => $md, + "bibdata" => $bib, + "access_type" => $access_type, + ); + + + return $data; +} + + +function create_library_path($id){ + return "http://141.14.236.36/fmi/xsl/katalog/browserecord.xsl?-db=katalog&-lay=fullrecord&-encoding=UTF-8&-grammar=fmresultset&-max=1&Biblio::ID=" . $id . "&-find="; +} + +function create_url_from_dri($dri,$access_type = "closed",$pn="1"){ + + if ($access_type=="free"){ + return "http://echo.mpiwg-berlin.mpg.de/".$dri . "?pn=" . $pn; + } + else + return "http://libcoll.mpiwg-berlin.mpg.de/".$dri . "?pn=" . $pn; +} + +function create_thumburl_from_dri($dri,$titlepage=1){ + return "http://md.mpiwg-berlin.mpg.de/purls/image/".$dri."?pn=" . $titlepage; +} diff -r 000000000000 -r 6f6e07baad80 digitalobject_reader.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobject_reader.php~ Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,215 @@ +data)){ + return drupal_json_decode($request->data); + } + else { + return null; + } + +} + +function digitalobjects_getBibFormattedMetaData($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getBibFormattedMetaDataJSON"; + $path = $base ."/getBibFormattedMetaDataJSON"; + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + return drupal_json_decode($request->data); + +} + + +function digitalobjects_getBibFormattedDC($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getDCMappedDataJSON"; + $path = $base ."/getDCMappedData"; + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + #return drupal_json_decode($request->data); + + return drupal_json_decode($request->data); + +} + + +function digitalobjects_getBibFormattedLabel($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getBibFormattedMetaDataJSON"; + $path = $base ."/getBibFormattedLabelJSON"; + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + return drupal_json_decode($request->data); + +} + + + +function digitalobjects_getBibMappedData($bibdata){ + $bd = drupal_json_encode($bibdata); + + $base = variable_get('digitalobjects_bibdata_path'); + #$path="http://localhost:18080/metadata/getBibFormattedMetaDataJSON"; + $path = $base ."/getBibMappedDataJSON"; + + $options = array( + + 'method' => 'POST', + 'data' => 'bibdata=' . $bd + ); + $request = drupal_http_request($path, $options); + return drupal_json_decode($request->data); + +} +#here.metadata.getBibFormattedMetaData(bibdata=docinfo.get('bib', None)) + + + +function digitalobjects_readMetadata($objid_full,$format="long"){ + + //objid_full can have the structure ID/Pagenumber + + + $objid_parts = explode("/",$objid_full); + + $objid=$objid_parts[0]; + + + if (isset($objid_parts[1])){ + $pn=$objid_parts[1]; + $pn_set=true; + } else { + $pn="1"; + $pn_set=false; + } + + + + $md = digitalobject_getMetadata($objid); + + switch($format){ + case "long": + $bib = isset($md['bib']) ?digitalobjects_getBibFormattedMetaData($md['bib']): null; + break; + + case "short": + $bib = isset($md['bib']) ?digitalobjects_getBibFormattedLabel($md['bib']): null; + + break; + + case "DC": + $bibArray = isset($md['bib']) ?digitalobjects_getBibFormattedDC($md['bib']): null; + + + + if (count($bibArray) == 0) { + $bibArray = array ( + "creator" => $md['creator'], + "title" => $md['title'], + "date" => $md['date'] + ); + } + + $bib = ''; + + foreach ($bibArray as $key => $value){ + $bib = $bib . "" . $value . ""; + } + $bib = $bib . ''; + + + + + } // close switch + + + if ($bib == null) { + $bibdata = array ( + "Author" => $md['creator'], + "Title" => $md['title'], + "Date" => $md['date'] + ); + $bib=""; + /*foreach ($bibdata as $key => $content){ + $bib = $bib . '' . $key . ' + ' . $content . ''; + } + */ + foreach ($bibdata as $key => $content){ + $bib = $bib . '' . $key . ': + ' . $content . ' '; + } + } + + + + $access_type = isset($md['accessType']) ? $md['accessType'] : 'mpiwg'; + + if ($pn_set){ + $titlepage=$pn; // im parameter war die Seitenzahl gesetzt. + } else + { + $titlepage = isset($md['titlePage']) ? $md['titlePage'] : 1; + } + + + $data = array( + "thumburl" => create_thumburl_from_dri($objid,$titlepage=$titlepage), + "viewerurl" => create_url_from_dri($objid,$access_type = $access_type,$titlepage=$titlepage), + "md" => $md, + "bibdata" => $bib, + "access_type" => $access_type, + ); + + + return $data; +} + + +function create_library_path($id){ + return "http://141.14.236.36/fmi/xsl/katalog/browserecord.xsl?-db=katalog&-lay=fullrecord&-encoding=UTF-8&-grammar=fmresultset&-max=1&Biblio::ID=" . $id . "&-find="; +} + +function create_url_from_dri($dri,$access_type = "closed",$pn="1"){ + + if ($access_type=="free"){ + return "http://echo.mpiwg-berlin.mpg.de/".$dri . "?pn=" . $pn; + } + else + return "http://libcoll.mpiwg-berlin.mpg.de/".$dri . "?pn=" . $pn; +} + +function create_thumburl_from_dri($dri,$titlepage=1){ + return "http://md.mpiwg-berlin.mpg.de/purls/image/".$dri."?pn=" . $titlepage; +} diff -r 000000000000 -r 6f6e07baad80 digitalobjects-collection-nodeLink.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-collection-nodeLink.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,8 @@ + +
+ + title ?> + +
+ + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-collection-simple.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-collection-simple.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,6 @@ +
+ + + +
+ diff -r 000000000000 -r 6f6e07baad80 digitalobjects-collection-usedIn.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-collection-usedIn.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,10 @@ +0): ?> +

Used in

+ +
+ + title ?> + +
+ + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-current-collection.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-current-collection.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,2 @@ +

Current collection

+

title,"node/".$node->nid) ?>

diff -r 000000000000 -r 6f6e07baad80 digitalobjects-image_src_link_viewer.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-image_src_link_viewer.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,1 @@ + \ No newline at end of file diff -r 000000000000 -r 6f6e07baad80 digitalobjects-image_src_link_viewer_large.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-image_src_link_viewer_large.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,1 @@ + \ No newline at end of file diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-objid.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-objid.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,3 @@ +

+ + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-short.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-short.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,22 @@ + +
+ + +
+ +
+
+ + + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-short.tpl.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-short.tpl.php~ Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,26 @@ + + + + +
+ + + + + +
+ + +intern + + + + + + +
+
+ +

: restricted - due to copyright reasons

+ + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-thumbnail.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-thumbnail.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,19 @@ + +
+ +
+ + + + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-thumbnail.tpl.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-thumbnail.tpl.php~ Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,22 @@ + + + + +
+ + + + +
+ + +intern + + + +
+
+ +

: restricted - due to copyright reasons

+ + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-tools.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-tools.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,29 @@ + + +
+ +
+ +
+ + + +
+ +
+ +
+
+ array('class' => 'ajax-link', 'rel' => 'div.details-'. digitalobjects_clean_css_identifier($variables['objid'])))) ?> +
+
+ array('class' => 'ajax-link', 'rel' => 'div.details-'. digitalobjects_clean_css_identifier($variables['objid'])))) ?> +
+ + +
+ +
+ + +
diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-tools.tpl.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-tools.tpl.php~ Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,17 @@ +
+ + + + + + + + + + + + + + + +
diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-usage.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-usage.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,9 @@ +

Collections where the object is used

+
+ + +
diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-xml.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-xml.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,10 @@ + + + + + + + + : restricted - due to copyright reasons + + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item-xml.tpl.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item-xml.tpl.php~ Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,10 @@ + + + + + + + + : restricted - do to copyright reasons + + \ No newline at end of file diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,35 @@ + +
+ + +
+ +
+ +
+
Document ID
+
+
+
+
Permanent URL
+
+ + + +
+
+
+ + + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-item.tpl.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-item.tpl.php~ Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,38 @@ + + +
+ + + +
+ + +intern + + + + + +
+ + + + + + + + + + + +
Document ID:
Permanent URL:
+ +
+ + + +
+ +

: restricted - do to copyright reasons

+ + diff -r 000000000000 -r 6f6e07baad80 digitalobjects-items.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-items.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,35 @@ + + + + +
    + +
+ + +

+ diff -r 000000000000 -r 6f6e07baad80 digitalobjects-pdf_link_viewer.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-pdf_link_viewer.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,1 @@ + \ No newline at end of file diff -r 000000000000 -r 6f6e07baad80 digitalobjects-user-admin-form.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects-user-admin-form.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,6 @@ +

+
+ +
+
+
diff -r 000000000000 -r 6f6e07baad80 digitalobjects.admin.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.admin.inc Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,124 @@ + 'textfield', + '#title' => t('bibdataprovider URL'), + '#default_value' => variable_get('digitalobjects_bibdata_path',"http://localhost:18080/metadata"), + '#maxlength' => 255, + '#description' => t('URL to the bibdataprovider (no "/" at the end!)'), + + ); + + $form['digitalobjects_docuviewer_path'] = array( + '#type' => 'textfield', + '#title' => t('docuviewer URL'), + '#default_value' => variable_get('digitalobjects_docuviewer_path',"http://localhost:18080/ECHOdocuView"), + '#maxlength' => 255, + '#description' => t('URL to the docuviewer (no "/" at the end!)'), + + ); + + + + $scal="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?"; + + $form['digitalobjects_scaler_path'] = array( + '#type' => 'textfield', + '#title' => t('scaler URL'), + '#default_value' => variable_get('digitalobjects_scaler_path',$scal), + '#maxlength' => 255, + '#description' => t('Url to digilib scaler'), + + ); + + $digilibjs="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?"; + + $form['digitalobjects_digilib_path'] = array( + '#type' => 'textfield', + '#title' => t('scaler URL'), + '#default_value' => variable_get('digitalobjects_digilib_path',$digilibjs), + '#maxlength' => 255, + '#description' => t('Url to digilib'), + + ); + + + + + + $pdfViewer="http://content.mpiwg-berlin.mpg.de/pdfViewer/pdf.js-master/web/viewer.html?file="; + + $form['digitalobjects_pdfviewer_path'] = array( + '#type' => 'textfield', + '#title' => t('pdf viewer URL'), + '#default_value' => variable_get('digitalobjects_pdfviewer_path',$pdfViewer), + '#maxlength' => 255, + '#description' => t('URL to the pdfViewer, used for "View PDF in external viewer"'), + + ); + + $repPath="http://content.mpiwg-berlin.mpg.de/mpiwg/online/permanent/"; + + $form['digitalobjects_repository_path'] = array( + '#type' => 'textfield', + '#title' => t('default repository path'), + '#default_value' => variable_get('digitalobjects_repository_path',$repPath), + '#maxlength' => 255, + '#description' => t('Default repository path, used for "View PDF in external viewer"'), + + ); + + + $linkbase="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?fn=/permanent/library/VAQGXTWH/pageimg/"; + $form['digitalobjects_imagebase_digilib_path'] = array( + '#type' => 'textfield', + '#title' => t('EXPERIMENTAL -- default image folder path (digilib)'), + '#default_value' => variable_get('digitalobjects_imagebase_digilib_path',$linkbase), + '#maxlength' => 255, + '#description' => t('Default image folder path, used for "View filename as image with link to digilib"'), + + ); + + $srcbase="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?dw=100&fn="; + + $form['digitalobjects_imagebase_scaler_path'] = array( + '#type' => 'textfield', + '#title' => t('EXPERIMENTAL -- default image folder path (scaler)'), + '#default_value' => variable_get('digitalobjects_imagebase_scaler_path',$srcbase), + '#maxlength' => 255, + '#description' => t('Default image folder path, used for "View filename as image with link to digilib"'), + + ); + + + $srcbase_large="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?dw=200&fn="; + + $form['digitalobjects_imagebase_scaler_path_large'] = array( + '#type' => 'textfield', + '#title' => t('EXPERIMENTAL -- default image folder path (scaler/large)'), + '#default_value' => variable_get('digitalobjects_imagebase_scaler_path_large',$srcbase_large), + '#maxlength' => 255, + '#description' => t('Default image folder path, used for "View filename (200px) as image with link to digilib"'), + + ); + + + + + + + return system_settings_form($form); + +} + + diff -r 000000000000 -r 6f6e07baad80 digitalobjects.collections.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.collections.inc Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,262 @@ +field_digitalobjects_cid[LANGUAGE_NONE])){ + $val = $user_full->field_digitalobjects_cid[LANGUAGE_NONE][0]['objid']; + } else { + $val=""; + } + + $form['digitalobjects_user_admin_form']['digitalcollection']['#default_value']=""; + $form['digitalobjects_user_admin_form']['digitalcollection']['#value']=$val; + $form['digitalobjects_user_admin_form']['userid']['#value']=$key; + + //$form['digitalcollection_chooser'] = drupal_get_form("digitalcollection_chooser"); + + + # $element = $form; + + $form['chooser']=drupal_get_form("digitalcollection_chooser"); + + $form['chooser']['pager'] = array('#markup' => theme('pager')); + $form['chooser']['userid']['#value']=$key; + + #$element += $form3; + + # + #$element += $form2; + + return $form; +} + +function digitalcollection_chooser(array $form){ + // Build the sortable table header. + $header = array( + 'title' => array('data' => t('Title'), 'field' => 'n.title'), + 'nid' => array('data' => t('nid'), 'field' => 'n.nid') + ); + + + #$result = db_query("SELECT nid FROM node WHERE type = :ntype ", array ('ntype' => 'digitalcollection'))->extend('PagerDefault'); + $query = db_select("node","n")->fields('n',array("nid"))->condition('type', 'digitalcollection')->orderby("n.title")->extend('PagerDefault')->limit(20); + $result = $query->execute(); + #$result = db_query("SELECT n.nid FROM {node} n "); + + $nids = array(); + foreach ($result as $record) { + $nids[] = $record->nid; + } + //Get the node data. + //$nids = $query + //->fields('n',array('nid')) + //->limit(50) + //->orderByHeader($header) + //->execute() + //->fetchCol(); + + + $nodes = node_load_multiple($nids); + + //Build the rows. + $options = array(); + $l_options=array(""); + $destination = drupal_get_destination(); + $languages = language_list(); + foreach ($nodes as $node) { + $langcode = entity_language('node', $node); + $l_options = $langcode != LANGUAGE_NONE && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array(); + + $options[$node->nid] = array( + 'title' => array( + 'data' => array( + '#type' => 'link', + '#title' => $node->title, + '#href' => 'node/' . $node->nid, + '#options' => $l_options, + '#suffix' => ' ' , + ), + ), + 'nid' => $node->nid, + ); + + } + + $destination = drupal_get_destination(); + + /* + $operations = array(); + if (node_access('update', $node)) { + $operations['edit'] = array( + 'title' => t('edit'), + 'href' => 'node/' . $node->nid . '/edit', + 'query' => $destination, + ); + } + if (node_access('delete', $node)) { + $operations['delete'] = array( + 'title' => t('delete'), + 'href' => 'node/' . $node->nid . '/delete', + 'query' => $destination, + ); + } + $options[$node->nid]['operations'] = array(); + $options[$node->nid]['operations'] = array( + 'data' => array( + '#theme' => 'links__node_operations', + '#links' => $operations, + '#attributes' => array('class' => array('links', 'inline')), + ), + ); + + + */ + + + + + $form['digitalcollection_chooser'] = array( + '#type' => 'tableselect', + '#header' => $header, + '#options' => $options, + '#empty' => t('No content available.'), + '#attributes' => array('class' => array('search-form', 'ctools-auto-submit-full-form')), + '#multiple' => False, + + ); + + #form['chooser']['change'] = array('#type' => 'actions'); + $form+= $form['submit2'] = array('#type' => 'submit', '#value' => t('Choose')); + #$form['chooser']['#submit'][] = 'digitalobjects_user_change_form_submit'; + $form['submit2']['#submit'][] = 'digitalobjects_user_change_form_submit'; + #$form['chooser']['#attributes']= array('class' => array('ctools-use-ajax', 'ctools-auto-submit-click')); + + $form['userid'] = array( + '#type' => 'hidden', + ); + + return $form; +} + + +function digitalobjects_user_change_form_submit($form,$formstate){ + $input = $formstate['input']['digitalcollection_chooser']; + $userid = $formstate['values']['userid']; + + $user=user_load($userid); + + + $user->field_digitalobjects_cid['und'][0]['objid'] = $input; + + user_save($user); + +} +#füge objid zur aktuelle sammlung hinzu +function digitalobjects_addToCurrentCollection($objid){ + + global $user; + #hole current collection + $user_full = user_load($user->uid); + $val = $user_full->field_digitalobjects_cid['und'][0]['objid']; + + #hole sammlung + + $node = node_load($val); + + foreach ( $node->field_objid['und'] as $obj){ + if ($obj['objid']==$objid){ + return drupal_set_message(t("Already in the current collection"),"error"); + } + + } + + $node->field_objid['und'][]['objid']=$objid; + + $node = node_submit($node); + + node_save($node); + + drupal_goto("node/".$node->nid); +} + + + +function digitalobjects_digitalcollectionsManage($data = NULL){ + + $data = ($data==NULL) ? $_GET : $data; + + + global $user; + #hole current collection + $user_full = user_load($user->uid); + $val = $user_full->field_digitalobjects_cid['und'][0]['objid']; + + #hole sammlung + + $node = node_load($val); + + foreach ($data['digitalobjects_items_select'] as $objid){ + /*foreach ( $node->field_objid['und'] as $obj){ + if ($obj['objid']==$objid){ + return drupal_set_message(t("Already in the current collection"),"error"); + } + + } + */ + $node->field_objid['und'][]['objid']=$objid; + + } + + + $node = node_submit($node); + + node_save($node); + + if (isset($data['redirect'])){ + + drupal_goto(urldecode($data['redirect'])); + } else { + drupal_goto("node/".$node->nid); + } + +/* + $output['digitalobjects_item']= array( + '#theme' => 'digitalobjects_item', + '#objid' => ''); + return $output; + */ +} + +/* suche wo wo eine digitalecollection benutzt wird */ +function digitalcollection_used_id($nid){ + $results = db_query("SELECT * FROM {field_data_field_collid} n where field_collid_objid ='node/" . $nid . "'"); + + $nids = array(); + foreach($results as $result){ + + + $nids[] = $result->entity_id; + } + + $entities = entity_load("node",$nids); + + return $entities; + +} diff -r 000000000000 -r 6f6e07baad80 digitalobjects.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.css Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,35 @@ +/* +Cascading Style Sheets, level 2 revision 1. +CSS 2.1 Specification is available at +http://www.w3.org/TR/2006/WD-CSS21-20061106/ +*/ + +td.digitalobjects_item_image { +vertical-align:top; +} + +div.digitalobjects_item { + padding-top: 10px; + padding-bottom: 10px; +} + +table.digitalobjects_item_short td{ + vertical-align:top; +} + + +div.digitalobjects_item_tools{ + display:inline; +} + + +/* CSS fuer ARB */ + +div.group-more-details{ + padding-bottom: 5px; + padding-top: 5px; +} +div.group-more-details div{ + display:inline; + padding-left: 5px; +} \ No newline at end of file diff -r 000000000000 -r 6f6e07baad80 digitalobjects.import.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.import.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,251 @@ +field_objid[LANGUAGE_NONE][]['objid']=$line; + print $line; + } + + node_save($node); +} + + + +function digitalobjects_importPagesFromFile(){ + $filename = "/tmp/maps.json"; + # $filename = "/tmp/echo.json"; + $handle = fopen($filename, "r"); + $contents = fread($handle, filesize($filename)); + fclose($handle); + + $pages = drupal_json_decode($contents); + + $cnt=0; + foreach ($pages as $key => $page){ + + $page = base64_decode($page); + digitalobjects_importPage($page,$key); + $cnt++; + + } + + +} + + +function digitalobjects_importPage($page,$key){ + + $baseUrl = "http://localhost:18080/echo_nav/echo_pages/content/scientific_revolution/harriot/maps/"; + + $fnames = explode("/",$key); + + if ($fnames[1] != "maps"){ + dpm($fnames[0]); + return; + } + + $fname = str_replace(".pt","1_1.png",$fnames[sizeof($fnames)-1]); + + $image = file_get_contents($baseUrl . $fname); // string + $file = file_save_data($image, 'public://' . $fname,FILE_EXISTS_REPLACE); + + + + + $node = new stdClass(); + $node->type = 'map_page'; + node_object_prepare($node); + + $node->body['und'][0]['value'] = check_markup($page,'full_html'); + + $node->body['und'][0]['format'] = 'full_html'; + + $node->path['alias']="harriot/maps/" . $fnames[sizeof($fnames)-1]; + + $node->title = "_".$key; + + + $node->language = LANGUAGE_NONE; + + + $node->field_echopath['und'][0]['value']=$key; + + $node->field_image[LANGUAGE_NONE]['0']['fid'] = $file->fid; + $node = node_submit($node); + + + + + /*$node->field_admintag['und'][0] = array ( + 'tid' => $tid, + + );*/ + // Try to set your custom field + + $node = node_submit($node); + + node_save($node); + + } + + + +function digitalobjects_importCollectionFromFile() { + + + $filename = "/tmp/china.json"; + $handle = fopen($filename, "r"); + $contents = fread($handle, filesize($filename)); + fclose($handle); + + $collection = drupal_json_decode($contents); + digitalobjects_importCollection($collection); +} + +function digitalobjects_importCollection($collection,$tid){ + + + //schaue ob die collection schon gibt + $qs = "select count(*) as n from field_data_field_echopath where field_echopath_value='". $collection['echo_path'] ."'"; + $results = db_query($qs); + foreach($results as $result){ + + if ($result->n> 0){ + return; + } + } + dpm($collection['echo_path']); + $node = new stdClass(); + $node->type = 'digitalcollection'; + node_object_prepare($node); + + $node->body['und'][0]['value'] = check_markup($collection['description'],'full_html'); + + $node->body['und'][0]['format'] = 'full_html'; + + + $node->title = $collection['title']; + + + $node->language = LANGUAGE_NONE; + + + $node->field_echopath['und'][0]['value']=$collection['echo_path']; + $node->field_label['und'][0]['value']=$collection['label']; + $node = node_submit($node); + + + $cnt=0; + foreach ($collection['content'] as $cont){ + print $cont; + if (($cont != "") && ($cont !=null)){ + $node->field_objid['und'][$cnt]['objid']=$cont; + $cnt++; + + + } + } + + $node->field_admintag['und'][0] = array ( + 'tid' => $tid, + + ); + // Try to set your custom field + + $node = node_submit($node); + + node_save($node); + +} + +function digitalobjects_importCollections($tid) { + #filename = "/tmp/export.json"; + $filename = "/tmp/groups.json"; + # $filename = "/tmp/echo.json"; + $handle = fopen($filename, "r"); + $contents = fread($handle, filesize($filename)); + fclose($handle); + + $collections = drupal_json_decode($contents); + + $cnt=0; + foreach ($collections as $key => $collection){ + digitalobjects_importCollection($collection,$tid); + $cnt++; + + } + +} + +/* suche all e nodes mit echopath = $path */ +function digitalobjects_searchCollectionByPath($path){ + $results = db_query("SELECT * FROM {field_data_field_echopath} n where field_echopath_value ='" . $path . "'"); + + return $results; + } + +function digitalobjects_importStructure(){ + $filename = "/Library/WebServer/Documents/drupal-dev/testData/exportAllCollectionsAndSubCollectionAsJSON"; + # $filename = "/tmp/echo.json"; + $handle = fopen($filename, "r"); + $contents = fread($handle, filesize($filename)); + fclose($handle); + + $collections = drupal_json_decode($contents); + + foreach ($collections as $parentCollection => $value){ + /* finde node id von parent */ + $nodes = digitalobjects_searchCollectionByPath($parentCollection); + if (sizeof($nodes) == 0){ //parent existiert nicht + //generate parent + } else { + foreach($nodes as $node){ // sollte eigentlich nur eine geben aber wenn mehrere gibt, dann eben überall die entsprechenden einträge machen. + // gehe jetzt durch content + + $cnt=0; + foreach($value['content'] as $content){ + $childnodes = digitalobjects_searchCollectionByPath($content); + if (sizeof($nodes) == 0){ // gibt es nicht + //erzeuge + }else{ + + $nodeid = $node->entity_id; + $entities = entity_load("node",array($nodeid)); // hole die entities + foreach($entities as $entity){ + foreach($childnodes as $childnode){ // trage jetzt die childnodes ein. + + $newnode ="node/".$childnode->entity_id; + $qs = "SELECT count(*) as n FROM {field_data_field_collid} n where field_collid_objid ='" . $newnode . "' and entity_id ='". $nodeid . "'"; + $res = db_query($qs); + + foreach($res as $result){ + dpm($result); + dpm($qs); + if ($result->n == 0){ //gibt es noch nicht + + $entity->field_collid['und'][]['objid']=$newnode; + } + } + } + + $entity = node_submit($entity); + + node_save($entity); + } + } + } + } + + } + } + +} + diff -r 000000000000 -r 6f6e07baad80 digitalobjects.info --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.info Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,19 @@ +name = digitalobjects +description = Allows access to the digital library for more see /* zur Dokumentation siehe: https://it-dev.mpiwg-berlin.mpg.de/tracs/echo/wiki/drupal-echo */ +core = 7.x + + +configure = admin/config/media/digitalobjects/settings + +files[] = +files[] = digitalobjects.module +files[] = digitalobjects.install +files[] = digitalobjects.item.inc +files[] = digitalobjects.admin.inc +files[] = digitalobjects-item.tpl.php +files[] = digitalobject_reader.php +files[] = digitalobjects.collections.inc + + +stylesheets[all][] = digitalobjects.css + diff -r 000000000000 -r 6f6e07baad80 digitalobjects.install --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.install Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,35 @@ + array('type' => 'varchar', 'length' => 20, 'not null' => FALSE), //contains id for digitalobjects or collections + ); + $indexes = array( + 'objid' => array('objid'), + ); + return array( + 'columns' => $columns, + 'indexes' => $indexes, + ); +} \ No newline at end of file diff -r 000000000000 -r 6f6e07baad80 digitalobjects.item.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/digitalobjects.item.inc Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,72 @@ + 'field_digitalobjects_cid', + 'type' => 'digitalobjects_digitalcollection', + ); + field_create_field($field); + + // Create the instance on the bundle. + $instance = array( + 'field_name' => 'field_digitalobjects_cid', + 'entity_type' => 'user', + 'label' => 'Current collection', + 'bundle' => 'user', + // If you don't set the "required" property then the field wont be required by default. + 'required' => False, + 'settings' => array( + // Here you inform either or not you want this field showing up on the registration form. + 'user_register_form' => 1, + ), + 'widget' => array( + 'type' => 'digitalcollection_default_textfield', + ), + ); + field_create_instance($instance); + } +} + +function digitalobjects_menu(){ + + $items['digitalcollections/manageCurrent'] = array( + 'description' => 'show an object.', + 'page callback' => 'digitalobjects_digitalcollectionsManage', + 'access arguments' => array('access content'), + 'file' => 'digitalobjects.collections.inc', + + ); + + + $items['digitalobject'] = array( + 'description' => 'show an object.', + 'page callback' => 'digitalobjects_page', + 'access arguments' => array('access content'), + + ); + $items['admin/config/media/digitalobjects'] = array( + 'title' => 'Digitalobject', + 'description' => 'Set path to the metadaprovider for digitalobjects', + 'weight' => 10, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('digitalobjects_settings'), + 'access arguments' => array('administrate digitalobjects'), + 'file' => 'digitalobjects.admin.inc', + + ); + + + + + + $items['user/%/collections'] = array( + 'title' => 'Collections', + 'description' => 'Set path to the metadaprovider for digitalobjects', + 'weight' => 10, + 'page callback' => 'digitalobjects_user_admin_collection', + 'page arguments' => array(1), + 'access arguments' => array('manage private collections'), + 'file' => 'digitalobjects.collections.inc', + 'type' => MENU_LOCAL_TASK, + ); + + + + $items['digitalobject/%/view'] = array( + 'title' => 'View', + 'description' => 'show an object.', + 'page callback' => 'digitalobjects_page', + 'access arguments' => array('access content'), + 'page arguments' => array(1), + + 'access arguments' => array('access content'), + 'type' => MENU_LOCAL_TASK, + + ); + + $items['digitalobject/%/edit'] = array( + 'title' => 'Edit', + 'description' => 'Set path to the metadaprovider for digitalobjects', + 'weight' => 10, + 'page callback' => 'digitalobjects_edit', + 'page arguments' => array(1), + + 'access arguments' => array('administrate digitalobjects'), + 'type' => MENU_LOCAL_TASK, + + ); + + $items['digitalobject/%/usage'] = array( + 'title' => 'Usage', + 'description' => 'Set path to the metadaprovider for digitalobjects', + 'weight' => 10, + 'page callback' => 'digitalobjects_show_usage', + 'page arguments' => array(1), + + 'access arguments' => array('access content'), + 'type' => MENU_LOCAL_TASK, + + ); + + $items['digitalobject/%/add'] = array( + 'title' => 'Add', + 'description' => 'Add an object to the current collection', + 'weight' => 10, + 'page callback' => 'digitalobjects_addToCurrentCollection', + 'page arguments' => array(1), + + 'access arguments' => array('administrate digitalobjects'), + 'file' => 'digitalobjects.collections.inc', + 'type' => MENU_LOCAL_TASK, + + ); + return $items; + +} + + +function digitalobjects_create_primary_node($objid){ +$node = new stdClass(); +$node->type = 'digitalobject'; +node_object_prepare($node); +global $user; +#dpm($user); +#$node->uid=$user->uid; +$node->field_single_objid['und'][0]['objid']=$objid; + +$node->title = $objid; + +$node->language = LANGUAGE_NONE; +#$node = node_submit($node); + +#$node->field_object_type['und'][0]=array('tid'=> '6'); + +$foo = taxonomy_get_term_by_name('primary'); +foreach($foo as $term) { + + if(($term->vocabulary_machine_name) == 'digitalobject_types') { + + $node->field_object_type['und'][]['tid'] = $term->tid; + } +} +$node = node_submit($node); + +node_save($node); + +return $node; +} + +function digitalobjects_edit($objid){ + #suche ob es schon ein locales object zu dieser id gibt. + $query = new EntityFieldQuery(); + $entities = $query->entityCondition('entity_type', 'node') + ->entityCondition('bundle', 'digitalobject') + ->fieldCondition('field_single_objid', 'objid', $objid,"=") + ->execute(); + + if ($entities == null) #existiert noch nicht, dann anlegen + { + $node =digitalobjects_create_primary_node($objid); + #$node->field_object_type['und'][0]=array('tid'=> 'autocreate', + #'name' => "primary", + #'vocabulary_machine_name' => 'digitialobject_types'); + + } else { + + + $nodes = node_load_multiple(array_keys($entities['node'])); + + #gibt es eins, dann gib dieses zum editieren zurück + #TODO falls mehrere existieren, was dann?? + + #gehe durch alle gefundene + foreach ($nodes as $node){ + #$typeTag = $entity->object_type['und'] + + if (isset($node->field_object_type['und'])){ + $tid = $node->field_object_type['und'][0]['tid']; + $tax =taxonomy_term_load($tid); + if ($tax->name == "primary"){ #'primary gefunden' + module_load_include('inc', 'node', 'node.pages'); + return drupal_get_form('digitalobject_node_form', $node); + }} + } # keine primary dann lege diese an: + + $node =digitalobjects_create_primary_node($objid); + + #$vals = array_values($nodes); + #$node= array_shift($vals); + } + + $node = node_submit($node); + + #node_save($node); + module_load_include('inc', 'node', 'node.pages'); + + return drupal_get_form('digitalobject_node_form', $node); + +} + + +function digitalobjects_show_usage($objid){ + $query = new EntityFieldQuery(); + $entities = $query->entityCondition('entity_type', 'node') + ->fieldCondition('field_objid', 'objid', $objid,"=") + ->execute(); + + + $data = array(); + + #treffer gefunden + if (isset($entities['node'])){ + + $nodes = node_load_multiple(array_keys($entities['node'])); + + + foreach ($nodes as $node){ + $data[$node->nid] = $node->title; + + } + + + $output['digitalobjects_item_usage']= array( + '#theme' => 'digitalobjects_item_usage', + '#data' => $data); + + return $output; + } + + return "

object not used in a collection

"; + } + + +function digitalobjects_page($keys = ''){ + + + #suche ob es schon ein locales object zu dieser id gibt. + $query = new EntityFieldQuery(); + $entities = $query->entityCondition('entity_type', 'node') + ->entityCondition('bundle', 'digitalobject') + ->fieldCondition('field_single_objid', 'objid', $keys,"=") + ->execute(); + + if ($entities == null) #existiert noch nicht, dann generische Anzeige + { + + $output['digitalobjects_item']= array( + '#theme' => 'digitalobjects_item', + '#objid' => $keys); + + return $output; + } else { + $nodes = node_load_multiple(array_keys($entities['node'])); + + #gibt es eins, dann gib dieses zum editieren zurück + #TODO falls mehrere existieren, was dann?? + + #gehe durch alle gefundene + foreach ($nodes as $node){ + if (isset($node->field_object_type['und'])){ + $tid = $node->field_object_type['und'][0]['tid']; + $tax =taxonomy_term_load($tid); + + if ($tax->name == "primary"){ #'primary gefunden' + return node_view($node, $view_mode = 'full'); + } + } + } + #keine primary node gefunden, generische ausgabe + $output['digitalobjects_item']= array( + '#theme' => 'digitalobjects_item', + '#objid' => $keys); + return $output; + } +} + +/* implements digitalobject_theme */ + +function digitalobjects_theme(){ + + return array( + 'digitalobjects_item' => array( + 'variables' => array('objid' => NULL), + 'file' => 'digitalobjects.item.inc', + 'template' => 'digitalobjects-item', + ), + 'digitalobjects_item_short' => array( + 'variables' => array('objid' => NULL), + 'file' => 'digitalobjects.item.inc', + 'template' => 'digitalobjects-item-short', + ), + + 'digitalobjects_item_thumbnail' => array( + 'variables' => array('objid' => NULL), + 'file' => 'digitalobjects.item.inc', + 'template' => 'digitalobjects-item-thumbnail', + ), + + 'digitalobjects_item_thumbnail_large' => array( + 'variables' => array('objid' => NULL), + 'file' => 'digitalobjects.item.inc', + 'template' => 'digitalobjects-item-thumbnail', + ), + + 'digitalobjects_item_objid' => array( + 'variables' => array('objid' => NULL), + 'template' => 'digitalobjects-item-objid', + ), + 'digitalobjects_item_tools' => array( + 'variables' => array('objid' => NULL), + 'template' => 'digitalobjects-item-tools', + ), + 'digitalobjects_item_usage' => array( + 'variables' => array('data' => NULL), + 'template' => 'digitalobjects-item-usage', + ), + 'digitalobjects_collection_simple' => array( + 'variables' => array('objid' => NULL), + 'template' => 'digitalobjects-collection-simple', + ), + 'digitalobjects_currentCollection_block' => array( + 'variables' => array('node' => NULL), + 'template' => 'digitalobjects-current-collection', + ), + 'digitalobjects_collection_nodeLink' => array( + 'variables' => array("entities" => $NULL), + 'template' => 'digitalobjects-collection-nodeLink', + ), + + + + 'digitalobjects_item_xml' => array( + 'variables' => array('objid' => NULL), + 'file' => 'digitalobjects.item.inc', + 'template' => 'digitalobjects-item-xml', + ), + + 'digitalobjects_collection_usedIn' => array( + + 'template' => 'digitalobjects-collection-usedIn', + ), + + 'digitalobjects_items' => array( + 'variables' => array('search_results' => NULL), + 'template' => 'digitalobjects-items', + ), + + 'digitalobjects_image_src_link_viewer' => array( + 'variables' => array('src' => NULL,'link' => NULL), + 'template' => 'digitalobjects-image_src_link_viewer', + ), + + 'digitalobjects_image_src_link_viewer_large' => array( + 'variables' => array('src' => NULL,'link' => NULL), + 'template' => 'digitalobjects-image_src_link_viewer_large', + ), + + 'digitalobjects_pdf_link_viewer' => array( + 'variables' => array('title' => NULL,'link' => NULL), + 'template' => 'digitalobjects-pdf_link_viewer', + ), + + /* 'digitalobjects_user_admin_page' => array( + 'variables' => array('digitalobjects_user_admin','uid' =>1), + 'template' => 'digitalobjects-user-admin-form' + ),*/ + ); +} + +function digitalobjects_forms($form_id, $args) { + + $forms['digitalobjects_user_admin_form']= array( + 'callback' => 'digitalobjects_user_admin', + 'callback arguments' => array('digitalobjects_user_admin_page'), + ); + return $forms; +}; + + + + +function digitalobjects_user_admin(array $form, array &$form_state) { + + $form['digitalcollection'] = array( + '#type' => 'textfield', + '#title' => t('Active collection'), + '#size' => 15, + '#default_value' => 'xxxx', + '#attributes' => array('title' => t('Enter the terms id of the current collection.')), + ); + + + $form['userid'] = array( + '#type' => 'hidden', + ); + #$form['actions'] = array('#type' => 'actions'); + $form['submit'] = array('#type' => 'submit', '#value' => t('Save')); + $form['submit']['#submit'][] = 'digitalobjects_user_admin_form_submit'; + + return $form; +} +/* implements a new field type for the digitalobject id */ + +function digitalobjects_field_info(){ + + return array('digitalobjects_digitalobject' => array ( + 'label' => t('Digital Object ID'), + 'description' => t('This field stores a digital object ID'), + 'settings' => array('max_length' =>20), + 'instance_settings' => array('text_processing' => 0), + 'default_widget' => 'digitalobject_default_textfield', + 'default_formatter' => 'digitalobjects_fullmetadata', + ), + 'digitalobjects_digitalcollection' => array ( + 'label' => t('Digital Collection ID'), + 'description' => t('This field stores a digital collection ID'), + 'settings' => array('max_length' =>20), + 'instance_settings' => array('text_processing' => 0), + 'default_widget' => 'digitalcollection_default_textfield', + 'default_formatter' => 'digitalcollection_fullmetadata', + ), + + + ); + + +} + + + + +function digitalobjects_field_formatter_info() { + + return array( + // This formatter shows the obejct with fullmetadata + 'digitalobjects_fullmetadata' => array( + 'label' => t('Fullmetadata formatter'), + 'field types' => array('digitalobjects_digitalobject'), + ), + 'digitalobjects_label' => array( + 'label' => t('Label formatter'), + 'field types' => array('digitalobjects_digitalobject'), + ), + 'digitalobjects_thumbnail' => array( + 'label' => t('Thumbnail formatter (100px'), + 'field types' => array('digitalobjects_digitalobject'), + ), + + 'digitalobjects_thumbnail_large' => array( + 'label' => t('Thumbnail formatter (l200px)'), + 'field types' => array('digitalobjects_digitalobject'), + ), + 'digitalobjects_objid' => array( + 'label' => t('Objid as String formatter'), + 'field types' => array('digitalobjects_digitalobject'), + ), + + 'digitalobjects_xml' => array( + 'label' => t('Objids as XML formatter'), + 'field types' => array('digitalobjects_digitalobject'), + ), + + 'digitalobjects_collection_simple' => array( + 'label' => t('Simple formatter'), + 'field types' => array('digitalobjects_digitalcollection'), + ), + 'digitalobjects_image_src_link_viewer' => array( + 'label' => t('View Image and Link from URL'), + 'field types' => array('link_field'), + ), + + 'digitalobjects_image_src_link_viewer_large' => array( + 'label' => t('View Image and Link from URL (200px)'), + 'field types' => array('link_field'), + ), + 'digitalobjects_image_viewer' => array( + 'label' => t('View filename as image with link to digilib'), + 'field types' => array('text'), + ), + 'digitalobjects_image_viewer_large' => array( + 'label' => t('View filename as image (200px) with link to digilib'), + 'field types' => array('text'), + ), + 'digitalobjects_pdf_link_viewer' => array( + 'label' => t('View PDF in external viewer'), + 'field types' => array('link_field'), + ), + + ); + } + + + + + + + function digitalobjects_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { + $element = array(); + + + switch ($display['type']) { + + case 'digitalobjects_image_viewer': + foreach ($items as $delta => $item) { + + $value = $item['value']; + + $linkbase= variable_get('digitalobjects_imagebase_digilib_path'); + + $value = str_replace(' ', '_', $value); + + $link = $linkbase . $value; + + $srcbase=variable_get('digitalobjects_imagebase_scaler_path'); + + $src= $srcbase . $value; + + + $element[$delta]['#markup'] = theme('digitalobjects_image_src_link_viewer', array("src" => $src,"link" => $link)); + + + } + break; + + case 'digitalobjects_image_viewer_large': + foreach ($items as $delta => $item) { + + $value = $item['value']; + + $linkbase= variable_get('digitalobjects_imagebase_digilib_path'); + + $value = str_replace(' ', '_', $value); + + $link = $linkbase . $value; + + $srcbase=variable_get('digitalobjects_imagebase_scaler_path_large'); + + $src= $srcbase . $value; + + + $element[$delta]['#markup'] = theme('digitalobjects_image_src_link_viewer_large', array("src" => $src,"link" => $link)); + + + } + break; + + + + + case 'digitalobjects_fullmetadata': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + $element[$delta]['#markup'] = theme('digitalobjects_item_tools', array("objid" => $item['objid'])); + $element[$delta]['#markup'] .= theme('digitalobjects_item', array("objid" => $item['objid'])); + + } + } + + break; + + case 'digitalobjects_label': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + + $element[$delta]['#markup'] = theme('digitalobjects_item_short', array("objid" => $item['objid'])); + $element[$delta]['#markup'] .= theme('digitalobjects_item_tools', array("objid" => $item['objid'])); + } + } + break; + + case 'digitalobjects_thumbnail': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + + $element[$delta]['#markup'] = theme('digitalobjects_item_thumbnail', array("objid" => $item['objid'])); + #$element[$delta]['#markup'] .= theme('digitalobjects_item_tools', array("objid" => $item['objid'])); + } + } + break; + + case 'digitalobjects_thumbnail_large': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + + $element[$delta]['#markup'] = theme('digitalobjects_item_thumbnail_large', array("objid" => $item['objid'])); + #$element[$delta]['#markup'] .= theme('digitalobjects_item_tools', array("objid" => $item['objid'])); + } + } + break; + + + case 'digitalobjects_objid': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + + $element[$delta]['#markup'] = theme('digitalobjects_item_objid', array("objid" => $item['objid'])); + #$element[$delta]['#markup'] .= theme('digitalobjects_item_tools', array("objid" => $item['objid'])); + } + } + break; + + case 'digitalobjects_xml': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + $element[$delta]['#markup'] = theme('digitalobjects_item_xml', array("objid" => $item['objid'])); + } + } + break; + + case 'digitalobjects_collection_xml': + foreach ($items as $delta => $item) { + if ($item['objid']!=""){ + + $path=$item['objid']; + //path is node, d.h. beginnt mit node/ + + if (!strncmp($path, "node/", strlen("node/"))){ + $nid = str_replace("node/","",$path); + $entities = entity_load("node",array($nid)); + + $element[$delta]['#markup'] = theme('digitalobjects_collection_nodeLink_xml', array("entities" => $entities)); + + } else { + + + $element[$delta]['#markup'] = theme('digitalobjects_collection_simple_xml', array("objid" => $item['objid'])); + + } + } + } + break; + + + case 'digitalobjects_image_src_link_viewer': + case 'digitalobjects_image_src_link_viewer_large': + #nimmt den link aus dem link feld und macht unter der Annahme er geht auf diglib ein Bild daraus + foreach ($items as $delta => $item) { + + #title feld ist leer, dann: + #$scal="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?"; + + $scal = variable_get('digitalobjects_scaler_path'); + + #$img="http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html?"; + + $img=variable_get('digitalobjects_digilib_path'); + $src= str_replace($img, $scal, $item['url']); + + $src=$src . "&dw=500"; + + + + $element[$delta]['#markup'] = theme($display['type'], array("src" => $src,"link" => $item['url'])); + + + } + break; + + case 'digitalobjects_pdf_link_viewer': + #nimmt link aus link field und zeigt dieses mit externem pdf viewer an + foreach ($items as $delta => $item) { + #$pdfViewer="http://content.mpiwg-berlin.mpg.de/pdfViewer/pdf.js-master/web/viewer.html?file="; + $pdfViewer=variable_get('digitalobjects_pdfviewer_path'); + $pdfpath=variable_get('digitalobjects_repository_path'); + + #url contains $base root should be removed + global $base_root; + + $url = str_replace($base_root,"",$item['url']); + $pdfLink=$pdfViewer . $pdfpath . $url; + + $element[$delta]['#markup'] = theme('digitalobjects_pdf_link_viewer', array("title" => $item['title'],"link" => $pdfLink)); + } + break; + + + + + + } + return $element; + } + +function template_preprocess_digitalobjects_items(&$variables) { + $variables['search_results'] = ''; + + $viewMode="shortX"; + + foreach ($variables['results'] as $result) { + + switch ($viewMode) { + + case "short": + $variables['search_results'] .= theme('digitalobjects_item_tools', array("objid" => $result['objid'])); + $variables['search_results'] .= theme('digitalobjects_item_short', array('objid' => $result['objid'])); + + break; + + + default: + $variables['search_results'] .= theme('digitalobjects_item_tools', array("objid" => $result['objid'], 'objidcss' => digitalobjects_clean_css_identifier($result['objid']))); + $variables['search_results'] .= theme('digitalobjects_item', array('objid' => $result['objid'])); + + break; + } + + } + $variables['pager'] = theme('pager', array('tags' => NULL,'quantity'=> 2)); + + } + + + +function digitalobjects_field_widget_info() { + #TODO:both types should check if field is valid + return array( + 'digitalobject_default_textfield' => array( + 'label' => t('digitalobject id'), + 'field types' => array('digitalobjects_digitalobject'), + ), + 'digitalcollection_default_textfield' => array( + 'label' => t('digital collection id'), + 'field types' => array('digitalobjects_digitalcollection'), + ), + 'digitalobjects_objpager_default' => array( + 'label' => t('No edit widget'), + 'field types' => array('digitalobjects_itemView'), + 'behaviors' => array( + 'multiple values' => FIELD_BEHAVIOR_CUSTOM, + ) + ), + + ); + } + + function digitalobjects_field_postrender($string){ + /* String is: + *
+ +
+*/ + + // get value: + + preg_match('/value="([^"]*)"/',$string,$matches); + $value = $matches[1]; + $bib = digitalobjects_readMetadata($value,"short"); + $string = $string . "
" . $bib['bibdata'] . "
"; + return $string; + } + + function digitalobjects_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { + + + $field_name = $field['field_name']; + $field_type = $field['type']; + + + $value = isset($items[$delta]['objid']) ? $items[$delta]['objid'] : ''; + + $widget = $element; + $widget['#delta'] = $delta; + + switch ($instance['widget']['type']) { + + + + case 'digitalobject_default_textfield': + $widget += array( + '#type' => 'textfield', + '#default_value' => $value, + '#size' => 20, + '#maxlength' => 20, + '#post_render' => array('digitalobjects_field_postrender'), + ); + + + + $element['objid'] = $widget; + + break; + + case 'digitalcollection_default_textfield': + $widget += array( + '#type' => 'textfield', + '#default_value' => $value, + '#size' => 20, + '#maxlength' => 20, + ); + + $element['objid'] = $widget; + break; + + + } + + + + + return $element; + } + + + function digitalobjects_field_is_empty($item, $field){ + + return empty($item['objid']); + } + + + + /*admin current collection for a user */ + +function digitalobjects_user_admin_form_submit($form,$formstate){ + $value = $formstate['values']['digitalcollection']; + $userid = $formstate['values']['userid']; + + $user=user_load($userid); + + + $user->field_digitalobjects_cid['und'][0]['objid'] = $value; + + user_save($user); + +} + + +/* show current collection of the current user as block */ +function digitalobjects_block_info(){ + $blocks['digitalobjects_currentCollection'] = array( + 'info' => t('Current Collection'), + 'visibility' => BLOCK_VISIBILITY_PHP, + 'pages' => 'uid == 0) return FALSE; else return TRUE; ?>' + ); + + $blocks['digitalobjects_collection_usedIn'] = array( + 'info' => t('Collection used in') + ); + + $blocks['digitalobjects_block_items'] = array( + 'info' => t('Items of a collection (if page is a collection)') + ); + + + return $blocks; +} + +function digitalobjects_block_view($delta){ + + switch($delta){ + + case 'digitalobjects_currentCollection': + /* display current cullection */ + + global $user; + + $user_full=user_load($user->uid); + + if (isset($user_full->field_digitalobjects_cid['und'][0]['objid'])){ + $val = $user_full->field_digitalobjects_cid['und'][0]['objid']; + } else { + return; + } + $node = node_load($val); + + #$title = $node=>title; + + $block['content'] = theme('digitalobjects_currentCollection_block',array('node' => $node)); + + $form['submit'] = array('#type' => 'submit', '#value' => t('Save')); + $form['submit']['#submit'][] = 'digitalobjects_user_admin_collection'; + + $submitForm=drupal_get_form('digitalobjects_change_collection_button_form'); + $block['content'] .= drupal_render($submitForm); + return $block; + break; + + + case 'digitalobjects_collection_usedIn': + if ($node = menu_get_object()) { + // Get the nid + $nid = $node->nid; + $entities = digitalcollection_used_id($nid); + + $block['content'] = theme('digitalobjects_collection_usedIn',array('entities'=> $entities)); + return $block; + } + + case 'digitalobjects_block_items': + if ($entity = menu_get_object()) { + + #$element[$delta]['prefix']['#markup'] = '
    '; + + if(!isset($entity->field_objid[LANGUAGE_NONE])){ + break; + } + + $resultsAll = $entity->field_objid[LANGUAGE_NONE]; + + + + $nums_per_page = 10; + + $params = drupal_get_query_parameters(); + if (isset($params['page'])){ + $page = $params['page']; + } else { + $page = 0; + } + + + $start=$nums_per_page * intval($page); + + if ($resultsAll==null){ + break; + } + + $results = array_slice($resultsAll,$start,$nums_per_page); + + + + pager_default_initialize(sizeof($resultsAll),$nums_per_page); + + + + #foreach ($results as $entry) { + # $element[$delta][]['#markup'] = $entry; + #} + + #$element[$delta]['suffix']['#markup'] = '
' . theme('pager'); + + $block['content'] = theme('digitalobjects_items', array('results' => $results)); + + // Finally, display the pager controls, and return. + #$element[$delta]['#markup'] .= theme('pager'); + + + #dpm(theme('pager')); + return $block; + break; + } + + + } + + //return $block; +} + +function digitalobjects_change_collection_button_form(){ + include_once 'digitalobjects.collections.inc'; + global $user; + $form['userid'] = array( + + '#type' => 'hidden', + '#value' => $user->uid + ); + + $form['submit'] = array('#type' => 'submit', '#value' => t('change')); + $form['submit']['#submit'][] = 'digitalobjects_user_admin_collection_submit'; + + return $form; +} + +function digitalobjects_permission() { + return array( + 'manage private collections' => array( + 'title' => t('Manage private collections'), + 'description' => t('Allow users create and manage private collections.'), + ), + 'administrate digitalobjects' => array( + 'title' => t('Administrate digitalobjects'), + 'description' => t('Can add commentaries to digital objects.'), + ), + ); +} + + +function digitalobjects_pathologic_alter(&$url_params, $parts, $settings){ +#bilder ohne jegliche pfad angaben werden auf sites/default/files/.. + if (preg_match('~^([^/]*)\.(png|gif|jpe?g)$~', $url_params['path'])){ + + $url_params['path'] = 'sites/default/files/' . $url_params['path']; + } + + if (preg_match('~^./([^/]*)\.pt$~', $url_params['path'],$matches)){ + + $url_params['path'] = 'harriot/maps/' . $matches[1] . '.pt'; + } + +} + +function digitalobjects_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) { + + foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) { + $info = field_info_field($name); + #map the whole attr + + if ($info['type'] == 'digitalobjects_digitalobject') { + $targets[$name] = array( + 'name' => t('@name', array('@name' => $instance['label'])), + 'callback' => 'digitalobjects_feeds_set_target', + 'description' => t('The @label field of the entity.', array('@label' => $instance['label'])), + 'real_target' => $name, + ); + } + } +} + +function digitalobjects_feeds_set_target($source, $entity, $target, $value) { + + if (empty($value)) { + return; + } + + // Handle non-multiple value fields. + if (!is_array($value)) { + $value = array($value); + } + + // Iterate over all values. + #list($field_name, $column) = explode(':', $target); + + $field_name=$target; + $info = field_info_field($field_name); + + $field = isset($entity->$field_name) ? $entity->$field_name : array(); + $delta = 0; + + foreach ($value as $v) { + + if ($info['cardinality'] == $delta) { + break; + } + + if (is_object($v) && ($v instanceof FeedsElement)) { + $v = $v->getValue(); + } + + if (is_scalar($v)) { + $field['und'][$delta]['objid'] = $v; + $delta++; + } + + if (is_array($v)){ + $newVal = array(); + + $newVal['objid'] = $v; + $field['und'][$delta]= $newVal; + $delta++; + } + } + $entity->$field_name = $field; +} + +//Provide a function to generate a valid identifier from the objectid +//taken from views module + +function digitalobjects_clean_css_identifier($identifier, $filter = array(' ' => '-', '/' => '-', '[' => '-', ']' => '')) { + // By default, we filter using Drupal's coding standards. + $identifier = strtr($identifier, $filter); + + // Valid characters in a CSS identifier are: + // - the hyphen (U+002D) + // - a-z (U+0030 - U+0039) + // - A-Z (U+0041 - U+005A) + // - the underscore (U+005F) + // - 0-9 (U+0061 - U+007A) + // - ISO 10646 characters U+00A1 and higher + // We strip out any character not in the above list. + $identifier = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier); + + return $identifier; +} diff -r 000000000000 -r 6f6e07baad80 digitalobjects.user.inc diff -r 000000000000 -r 6f6e07baad80 maybedeprecated-Copy of digitalobjects-item.tpl.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maybedeprecated-Copy of digitalobjects-item.tpl.php Tue Jun 02 08:57:48 2015 +0200 @@ -0,0 +1,105 @@ + + +

Hello

+ + +

> + +

+ + + +
+ + +
+ +