Project

General

Profile

« Previous | Next » 

Revision e0d3e148

Added by Andreas Kohlbecker over 5 years ago

ref #7495 basic version of reference page implemented

View differences:

modules/cdm_dataportal/cdm_api/cdm_node.php
222 222
  return $nodes;
223 223
}
224 224

  
225
/**
226
 * Simulates the influence on the page layout by cdm_node_show().
227
 *
228
 * Adds a div as first element for the general part, which usually is empty in dataporal pages.
229
 *
230
 * @param $content
231
 */
232
function cdm_node_show_simulate($content)
233
{
234
  array_unshift($content, array("general-part" => markup_to_render_array("<div id=\"general\" class=\"page-part\"></div>")));
235
  return drupal_render($content);
236
}
237

  
238

  
225 239
/**
226 240
 * Sets the $content given a paramater to the $node object
227 241
 *
modules/cdm_dataportal/cdm_dataportal.module
501 501
    'access arguments' => array('access cdm content'),
502 502
    'type' => MENU_CALLBACK,
503 503
  );
504
  // Optional callback arguments: page.
505
  $items['cdm_dataportal/registration'] = array(
506
    'page callback' => 'cdm_dataportal_registration_page_view',
507
    'access arguments' => array('access cdm content'),
508
    'type' => MENU_CALLBACK,
509
    // Expected callback arguments: uuid.
510
  );
504 511

  
505 512
  /*
506 513
   $items['cdm/xml2json'] = array(
......
1809 1816
  }
1810 1817
}
1811 1818

  
1819
/**
1820
 * Returns a registration page as a Drupal node to be rendered by Drupal.
1821
 *
1822
 * @param string  $registration_identifier_encoded
1823
 *   The persistent identifier of the registration urlencoded.
1824
 * @return mixed
1825
 *   The formatted registration page as node.
1826
 */
1827
function cdm_dataportal_registration_page_view($registration_identifier_encoded) {
1828

  
1829
  cdm_check_valid_portal_page("/\/cdm_dataportal\/registration\/.*$/");
1830
  $registration_page = cdm_dataportal_registration_view($registration_identifier_encoded);
1831
  return cdm_node_show_simulate($registration_page);
1832
}
1833

  
1834
function cdm_dataportal_registration_view($registration_identifier_encoded) {
1835

  
1836
  $registration_identifier = urldecode($registration_identifier_encoded);
1837

  
1838

  
1839
  $render_array = array();
1840

  
1841
  $registration_dto = cdm_ws_get("registrationDTO/identifier/" . $registration_identifier_encoded);
1842
  if($registration_dto){
1843
    drupal_set_title(t('Registration') . ' ' . $registration_identifier, PASS_THROUGH);
1844

  
1845
    $render_array['citation'] = markup_to_render_array("<div class=\"" . html_class_attribute_ref(new TypedEntityReference("Reference", $registration_dto->citationUuid)) . "\">"
1846
      . l($registration_dto->bibliographicCitationString, path_to_registration_workingset($registration_dto->citationUuid))
1847
      . "</br>&nbsp;</div>");
1848
    $render_array['summary'] = markup_to_render_array("<div>" . cdm_tagged_text_to_markup($registration_dto->summaryTaggedText) . "</div>");
1849

  
1850
//    $registration = cdm_ws_get("registration/identifier/" . $registration_identifier_encoded);
1851
//    if(is_array($registration->typeDesignations)){
1852
//      $type_designations_markup = "";
1853
//      foreach ($registration->typeDesignations as $type_designation){
1854
//        $type_designations_markup .= render_cdm_specimen($type_designation);
1855
//      }
1856
//      $render_array['type_designations'] = markup_to_render_array($type_designations_markup);
1857
//    }
1858

  
1859
  } else {
1860
    drupal_set_title(t('Registration not found'), PASS_THROUGH);
1861
    $render_array['error'] = markup_to_render_array("A registration with the identifier  " . $registration_identifier . " does not exist.");
1862
  }
1863

  
1864
  return $render_array ;
1865
}
1866

  
1867

  
1868

  
1812 1869
/**
1813 1870
 * Creates a page with the advance search form.
1814 1871
 *
......
2040 2097
}
2041 2098

  
2042 2099
/**
2043
 * Compses the drupal path to the key identified by the uuid.
2100
 * Composes the drupal path to the key identified by the uuid.
2044 2101
 *
2045 2102
 * @param string $keyType
2046 2103
 *    the key typer corresponds to the specific class of the CDM
......
2048 2105
 *      -PolytomousKey
2049 2106
 *      -MultimediaKey
2050 2107
 *      - ...
2051
 * @param UUID $keyUuid
2108
 * @param string $keyUuid
2052 2109
 *   The UUID of the key
2053 2110
 */
2054 2111
function path_to_key($keyType, $keyUuid) {
......
2060 2117
}
2061 2118

  
2062 2119
/**
2063
 * @todo Please document this function.
2064
 * @see http://drupal.org/node/1354
2120
 * Composes the drupal path to the reference identified by the uuid.
2121
 *
2122
 * @param $uuid string String representation of the registration entity uuid.
2123
 *
2124
 * @return string
2125
 *  The drupal path
2126
 *
2065 2127
 */
2066 2128
function path_to_reference($uuid) {
2067 2129
  if (!$uuid) {
......
2070 2132
  return 'cdm_dataportal/reference/' . $uuid;
2071 2133
}
2072 2134

  
2135
/**
2136
 * Composes the drupal path to the reference identified by the uuid.
2137
 *
2138
 * @param string $identifier
2139
 *  The persistent identifier of the registration entity (Registration.identifier).
2140
 * @return string
2141
 *  The drupal path
2142
 */
2143
function path_to_registration($identifier) {
2144

  
2145
  return 'cdm_dataportal/registration/' . urlencode($identifier);
2146
}
2147

  
2148

  
2149
/**
2150
 * Composes the drupal path to the reference identified by the uuid.
2151
 *
2152
 * @param $uuid string
2153
 *    The uuid of the reference which is the base entity for registration workingset..
2154
 *
2155
 * @return string
2156
 *  The drupal path
2157
 */
2158
function path_to_registration_workingset($identifier) {
2159

  
2160
  return 'cdm_dataportal/reference/' . urlencode($identifier);
2161
}
2162

  
2073 2163
/**
2074 2164
 * Creates the path to a cdm_dataportal taxon name page.
2075 2165
 *
2076
 * @param UUID $taxon_name_uuid
2077
 *   The uuid of the CDM TaxonName to show a name page for
2078
 * @param UUID $taxon_to_hide_uuid
2079
 *   A taxon which should not be displayed in the taxon list
2080
 * @param UUID $highlite_synonym_uuid
2081
 *   Optinal parameter wich takes another taxon uuid, if given the
2082
 *   target taxon pages will show the syonymy tab where the taxon
2083
 *   refenrenced by the $highlite_synonym_uuid will be highlighted
2166
 * @param string $taxon_name_uuid
2167
 *   The uuid as string of the CDM TaxonName to show a name page for
2168
 * @param string $taxon_to_hide_uuid
2169
 *   The uuid as string of a taxon which should not be displayed in the taxon list
2170
 * @param string $highlite_synonym_uuid
2171
 *   Optional parameter which takes another taxon uuid, if given the
2172
 *   target taxon pages will show the synonymy tab where the taxon
2173
 *   referenced by the $highlite_synonym_uuid will be highlighted
2084 2174
 *   in case it is found on this page.
2085 2175
 *
2086
 * @return a URI path element as string
2176
 * @return string
2177
 *  URI path element as string
2087 2178
 */
2088 2179
function path_to_name($name_uuid, $taxon_to_hide_uuid = NULL, $synonym_uuid  = NULL) {
2089 2180
  $res = FALSE;
......
2100 2191
}
2101 2192

  
2102 2193
/**
2103
 * @todo Please document this function.
2104
 * @see http://drupal.org/node/1354
2194
 * Composes the drupal path to the media entity identified by the uuid.
2195
 *
2196
 * @param string $uuid
2197
 *  The persistent identifier of the entity entity
2198
 * @return string
2199
 *  The drupal path
2105 2200
 */
2106 2201
function path_to_media($uuid, $representaion_uuid = FALSE, $partId = FALSE) {
2107 2202
  if (!$uuid) {
......
2540 2635
}
2541 2636

  
2542 2637
/**
2543
 * Checks if the current page is a valid portal page and responds with HTTP status 404 (not found) otherwise
2638
 * Checks if the current page is a valid portal page and responds with HTTP status 404 (not found) otherwise.
2639
 * The test applied by default it a check for the query parameter 'q' ending with a file suffix like '*.*'
2544 2640
 *
2545
 * @param $chapter
2546
 *   The taxon page chapter or part
2641
 * @param $preg_pattern
2642
 *   Optional regular expression pattern to be used in preg_match().
2547 2643
 */
2548
function cdm_check_valid_portal_page(){
2644
function cdm_check_valid_portal_page($preg_pattern = null){
2549 2645
  $ends_with_file_suffix_pattern = '/\/[^\.\/]*[\.][^\.\/]*$/';
2550
  if(preg_match($ends_with_file_suffix_pattern, $_GET['q'])){
2646
  if($preg_pattern === null){
2647
    $preg_pattern = $ends_with_file_suffix_pattern;
2648
  }
2649
  if(preg_match($preg_pattern, $_GET['q'])){
2551 2650
    // oops this urls ends with a file_suffix and thus does not refer to a portal page
2552 2651
    http_response_code(404); // 404 = Not Found
2553 2652
    exit('HTTP 404');
modules/cdm_dataportal/cdm_dataportal.search.php
834 834
      $items_render_array[]  = markup_to_render_array(
835 835
        "<div class=\"item\"><div class=\"" . html_class_attribute_ref(new TypedEntityReference("Registration", $registration->uuid)) . "\">"
836 836
          . "<div class=\"identifier\">"
837
          . l($registration->identifier, $registration->identifier, array('absolute' => true, 'attributes' => array('class' => array('identifier'))))
837
          . l($registration->identifier, path_to_registration($registration->identifier), array('absolute' => true, 'attributes' => array('class' => array('identifier'))))
838 838
          . "</div>"
839 839
          . $summary_markup
840 840
          . "</div></div>"

Also available in: Unified diff