Index: monument.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/monument/monument.module,v retrieving revision 1.3 diff -u -p -r1.3 monument.module --- monument.module 21 Oct 2006 22:38:05 -0000 1.3 +++ monument.module 22 Oct 2006 13:52:01 -0000 @@ -5,7 +5,9 @@ define ("_ASCENT_SOFTWARE_LIMITED_DEBUG_ /** * @file - * Manage data for Iron Age Broch Monument structures found in the north of Scotland. + * Manage data and photos for ancient monuments, especially where a circular + * arrangement of photos is useful. Based originally on data relevant to Iron + * Age Broch structures found in the north of Scotland. */ /** @@ -202,6 +204,7 @@ function monument_delete(&$node) { db_query('DELETE FROM {monument} WHERE nid = %d', $node->nid); //Suspect the following is wrong and that we should be getting //the relevant modules to do the work via various hook_delete() functions. + //Perhaps can also use nodeapi case 'delete' for this instead of hook_delete //see comment_delete() for example db_query('DELETE FROM {file_revisions} WHERE nid = %d', $node->nid); db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); @@ -215,19 +218,29 @@ function monument_delete(&$node) { function monument_form(&$node, &$param) { $form['title'] = array( '#type' => 'textfield', - '#title' => t('Monument'), + '#title' => t('Monument\'s name'), '#description' => t('Name of this Monument'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -10 ); + + $form['alt_names'] = array( + '#type' => 'textfield', + '#title' => t('Alternative names'), + '#description' => t('Provide any alternate names for this monument in a' . + ' comma separated list'), + '#required' => FALSE, + '#default_value' => $node->alt_names, + '#weight' => -9, + ); $form['catalogue'] = array( '#type' => 'textfield', - '#title' => t('catalogue'), + '#title' => t('Catalogue number'), '#required' => TRUE, '#default_value' => $node->catalogue, - '#weight' => -9, + '#weight' => -8, '#size' => 3, '#maxlength' => 3, '#description' => t('RockStanza catalogue number') @@ -235,83 +248,83 @@ function monument_form(&$node, &$param) $form['SAT_PRN'] = array( '#type' => 'textfield', - '#title' => t('SAT_PRN'), + '#title' => t('SAT\'s PRN'), '#required' => FALSE, '#default_value' => $node->SAT_PRN, - '#weight' => -8, + '#weight' => -7, '#description' => t('Shetland Amenity Trust PRN') ); $form['RCAMS_orig'] = array( '#type' => 'textfield', - '#title' => t('RCAMS_orig'), + '#title' => t('RCAMS original'), '#required' => FALSE, '#default_value' => $node->RCAMS_orig, - '#weight' => -7, + '#weight' => -6, '#description' => t('Original RCAMS survey number') ); $form['RCAHMS_NMR'] = array( '#type' => 'textfield', - '#title' => t('RCAHMS_NMR'), + '#title' => t('RCAHMS NMR'), '#required' => FALSE, '#default_value' => $node->RCAHMS_NMR, - '#weight' => -6, + '#weight' => -5, '#description' => t('RCAHMS NMR') ); $form['HS_monnum'] = array( '#type' => 'textfield', - '#title' => t('HS_monnum'), + '#title' => t('Historic Scotland'), '#required' => FALSE, '#default_value' => $node->HS_monnum, - '#weight' => -6, + '#weight' => -5, '#description' => t('Historic Scotland monument number') ); $form['district'] = array( '#type' => 'textfield', - '#title' => t('district'), + '#title' => t('District'), '#required' => FALSE, '#default_value' => $node->district, - '#weight' => -5, + '#weight' => -4, '#description' => t('District where Monument is located') ); $form['mapsheet'] = array( '#type' => 'textfield', - '#title' => t('mapsheet'), + '#title' => t('OS Mapsheet'), '#required' => FALSE, '#default_value' => $node->mapsheet, - '#weight' => -4, + '#weight' => -3, '#description' => t('Ordnance Survey mapsheet') ); $form['gridref'] = array( '#type' => 'textfield', - '#title' => t('gridref'), + '#title' => t('Grid reference'), '#required' => FALSE, '#default_value' => $node->gridref, - '#weight' => -3, + '#weight' => -2, '#description' => t('6 or 8 figure grid reference') ); $form['original_diameter_metre'] = array( '#type' => 'textfield', - '#title' => t('original_diameter_metre'), + '#title' => t('Original diameter /metre'), '#required' => FALSE, '#default_value' => $node->original_diameter_metre, - '#weight' => -2, + '#weight' => -1, '#description' => t('Estimated external original diameter / metres ') ); $form['last_visited'] = array( '#type' => 'textfield', //'#attributes' => array('class' => 'jscalendar'), //adjust format dd/mm/yyyy - '#title' => t('last_visited'), + '#title' => t('Last visited'), '#required' => FALSE, '#default_value' => $node->last_visited, - '#weight' => -1, + '#weight' => 0, '#description' => t('Date when this site was last visited ' . 'by a site member') ); @@ -321,7 +334,7 @@ function monument_form(&$node, &$param) '#title' => t('Description'), '#required' => FALSE, '#default_value' => $node->body, - '#weight' => 0, + '#weight' => 1, '#description' => t('Detailed description of monument') ); $form['body_filter']['format'] = filter_form($node->format); @@ -391,7 +404,6 @@ function monument_validate($form, $value form_set_error( 'gridref', t('Please quote either a 4,6 or 8 figure grid-reference')); } - if ( ($values['catalogue']['#value']!=NULL) && (!((string)$values['catalogue']['#value'] === (string)(int)$values['catalogue']['#value']) @@ -414,13 +426,13 @@ function monument_insert($node) { preg_match('/^(\d\d)\/(\d\d)\/(\d\d\d\d)$/', $node->last_visited, $m); $ts = mktime(0, 0, 0, $m[2], $m[1], $m[3]); } - db_query("INSERT INTO {monument} (nid, catalogue, SAT_PRN, RCAMS_orig," . - " RCAHMS_NMR, HS_monnum, district, mapsheet, gridref, " . + db_query("INSERT INTO {monument} (nid, catalogue, alt_names, SAT_PRN, " . + "RCAMS_orig, RCAHMS_NMR, HS_monnum, district, mapsheet, gridref, " . "original_diameter_metre, last_visited) " . - "VALUES (%d, %d, %d, %d, '%s', %d, '%s', '%s', %d, %d, %d)", - $node->nid, $node->catalogue, $node->SAT_PRN, $node->RCAMS_orig, - $node->RCAHMS_NMR, $node->HS_monnum, $node->district, - strtoupper($node->mapsheet), $node->gridref, + "VALUES (%d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', %d, %d, %d)", + $node->nid, $node->catalogue, $node->alt_names, + $node->SAT_PRN, $node->RCAMS_orig, $node->RCAHMS_NMR, $node->HS_monnum, + $node->district, strtoupper($node->mapsheet), $node->gridref, $node->original_diameter_metre, $ts); } @@ -429,8 +441,8 @@ function monument_insert($node) { * Implementation of hook_load(). */ function monument_load($node) { - $t = db_fetch_object(db_query('SELECT catalogue, SAT_PRN, RCAMS_orig, ' . - 'RCAHMS_NMR, HS_monnum, district, mapsheet, gridref, ' . + $t = db_fetch_object(db_query('SELECT catalogue, alt_names, SAT_PRN, ' . + 'RCAMS_orig, RCAHMS_NMR, HS_monnum, district, mapsheet, gridref, ' . 'original_diameter_metre, last_visited ' . 'FROM {monument} WHERE {monument}.{nid} = %d', $node->nid)); return $t; @@ -449,6 +461,7 @@ function monument_prepare(&$node) { $node->last_visited = ""; } //ensure that any other null fields are not re-interpreted as 0 during edit + if (!$node->alt_names) $node->alt_names = ""; if (!$node->SAT_PRN) $node->SAT_PRN = ""; if (!$node->RCAHMS_NMR) $node->RCAHMS_NMR = ""; if (!$node->RCAMS_orig) $node->RCAMS_orig = ""; @@ -470,7 +483,7 @@ function monument_node_info() { /** * Implementation of hook_update(). */ -function monument_update($node) { +function monument_update($node) { if ($node->revision) { monument_insert($node); } @@ -482,10 +495,11 @@ function monument_update($node) { preg_match('/^(\d\d)\/(\d\d)\/(\d\d\d\d)$/', $node->last_visited, $m); $ts = mktime(0, 0, 0, $m[2], $m[1], $m[3]); } - db_query("UPDATE {monument} SET catalogue=%d, SAT_PRN=%d, RCAMS_orig=%d, " . - "RCAHMS_NMR='%s', HS_monnum=%d, district='%s', mapsheet='%s', " . - "gridref=%d, original_diameter_metre=%d, last_visited=%d " . - "WHERE nid=%d", $node->catalogue, $node->SAT_PRN, $node->RCAMS_orig, + db_query("UPDATE {monument} SET catalogue=%d, alt_names='%s', SAT_PRN=%d, " . + "RCAMS_orig=%d, RCAHMS_NMR='%s', HS_monnum=%d, district='%s', " . + "mapsheet='%s', gridref=%d, original_diameter_metre=%d, " . + "last_visited=%d WHERE nid=%d", + $node->catalogue, $node->alt_names, $node->SAT_PRN, $node->RCAMS_orig, $node->RCAHMS_NMR, $node->HS_monnum, $node->district, strtoupper($node->mapsheet), $node->gridref, $node->original_diameter_metre, $ts, $node->nid); @@ -527,6 +541,11 @@ function theme_monument_basic_view($node $nid = $keyimage['nid']; $file = $keyimage['filepath']; $bearing = $keyimage['face_bearing']; + //show any alternative names + if ($node->alt_names) { + $output .= t( 'Also known as: %alt_names', + array('%alt_names' => $node->alt_names)); + } //create the key_img as a link to a full size image $output .= t("