[Cdb-cvs] entry entry.module,1.2,1.3
Status: Pre-Alpha
Brought to you by:
kenrickturner
|
From: Kenrick <ken...@us...> - 2006-02-09 00:20:20
|
Update of /cvsroot/cdb/entry In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9593 Modified Files: entry.module Log Message: Added starting order editing features Index: entry.module =================================================================== RCS file: /cvsroot/cdb/entry/entry.module,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** entry.module 8 Feb 2006 23:29:10 -0000 1.2 --- entry.module 9 Feb 2006 00:20:12 -0000 1.3 *************** *** 114,117 **** --- 114,118 ---- array('data' => t('Boat'), 'field' => 'category'), array('data' => t('Event'), 'field' => 'friendly_name'), + array('data' => t('Start'), 'field' => 'start_position'), array('data' => t('Deadline'), 'field' => 'entries_close'), array('data' => t('Paid'), 'field' => 'paid'), *************** *** 135,139 **** $entry->category, $entry->friendly_name, ! gmdate('H:i d-M-y', $entry->entries_close), $entry->paid); $row[] = l(t('view'), 'crews/' . $entry->id); --- 136,141 ---- $entry->category, $entry->friendly_name, ! $entry->start_position, ! gmdate('H:i d-m-y', $entry->entries_close), $entry->paid); $row[] = l(t('view'), 'crews/' . $entry->id); *************** *** 236,239 **** --- 238,242 ---- if (user_access('administer entry')) { $form .= form_checkbox(t('Paid?'), 'paid', 'Y', FALSE, 'Tick *only* if money has been received.', NULL, FALSE); + $form .= form_textfield(t('Starting Position'), 'start_position', '', 4, 3, 'e.g. 42', NULL, FALSE); } *************** *** 404,407 **** --- 407,412 ---- } $form .= form_checkbox(t('Paid?'), 'paid', 'Y', $check, 'Tick *only* if money has been received.', NULL, FALSE); + + $form .= form_textfield(t('Starting Position'), 'start_position', $entry->start_position, 4, 3, 'e.g. 42', NULL, FALSE); } *************** *** 463,468 **** function display_crew($id) { $entry = get_nice_entry($id); $output = ''; ! $output .= '<h1>'.$entry->name.' '.$entry->mw.$entry->category.' for the '.$entry->friendly_name.'</h1>'; $output .= '<h2>Crew</h2>'; $output .= '<p><strong>Bow:</strong> '.$entry->bow.'</p>'; --- 468,480 ---- function display_crew($id) { $entry = get_nice_entry($id); + + if ($entry->mw == 'M') { + $gen = 'Men\'s VIII'; + } else { + $gen = 'Women\'s VIII'; + } + $output = ''; ! $output .= '<h1>'.$entry->name.' '.ordinalize($entry->category).' '.$gen.' for the '.$entry->friendly_name.'</h1>'; $output .= '<h2>Crew</h2>'; $output .= '<p><strong>Bow:</strong> '.$entry->bow.'</p>'; *************** *** 477,487 **** $output .= '<h2>Details</h2>'; ! $output .= '<p><strong>Starting Position:</strong> '.$entry->start_position.'</p>'; ! $output .= '<p><strong>Finishing Position:</strong> '.$entry->finish_position.'</p>'; return $output; } ! function _show_crew($id) { if (!user_access('view crew')) { return message_access(); --- 489,500 ---- $output .= '<h2>Details</h2>'; ! $output .= '<p><strong>Crew ID:</strong> '. $id .'</p>'; ! $output .= '<p><strong>Starting Position:</strong> '.bumps_position($entry->start_position,$entry->mw).'</p>'; ! $output .= '<p><strong>Finishing Position:</strong> '.bumps_position($entry->finish_position,$entry->mw).'</p>'; return $output; } ! function _show_crew() { if (!user_access('view crew')) { return message_access(); *************** *** 496,498 **** --- 509,555 ---- print theme('page', $output); } + + // Ordinalizes a given number + function ordinalize($num) { + + if (!is_numeric($num)) { + return $num; + } + + if ($num >= 11 and $num <= 19) + return $num."th"; + elseif ( $num % 10 == 1 ) + return $num."st"; + elseif ( $num % 10 == 2 ) + return $num."nd"; + elseif ( $num % 10 == 3 ) + return $num."rd"; + else + return $num."th"; + } + + // Retuns a string describing the bumps position of a crew. + function bumps_position($num,$mw) { + if (empty($num) OR empty($mw)) { + return; + } + // First work out which division it is in + $div = $num / 17; + $div = ceil($div); + + // Work out where in the division it is + $pos_num = $num % 17; + $pos_div = ordinalize($pos_num).' in '; + $pos_overall = ordinalize($num).' overall'; + + if ($num == 1) { + $pos_overall = 'Head of the River'; + } + if ($pos_num == 1) { + $pos_div = 'Head of '; + } + + $output = $pos_div.$mw.$div.' ('.$pos_overall.')'; + return $output; + } ?> \ No newline at end of file |