/[drupal]/contributions/modules/game_calendar/includes/game_calendar.admin.inc
ViewVC logotype

Diff of /contributions/modules/game_calendar/includes/game_calendar.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Sat Dec 20 00:53:21 2008 UTC revision 1.1.2.1, Fri Jan 2 03:42:06 2009 UTC
# Line 207  function game_calendar_delete_form_submi Line 207  function game_calendar_delete_form_submi
207  }  }
208    
209  /**  /**
  *  Reset confirmation form.  
  */  
 function game_calendar_reset_form(&$form_state, $calendars) {  
   if (is_object($calendars)) {  
     $title = t('Are you sure you wish to reset the %calendar game calendar?', array('%calendar' => $calendars->title));  
     $message = t('If you press %reset, then the %calendar game calendar will be reset to 0 turns, which may not be undone.', array('%reset' => t('Reset'), '%calendar' => $calendars->title));  
     $calendars = array($calendars->name => $calendars);  
   }  
   else if (is_array($calendars) && !empty($calendars)) {  
     $title = t('Are you sure you wish to reset these game calendars?');  
     $message = t('If you press %reset, then the following game calendars will be reset to 0 turns:', array('%reset' => t('Reset')));  
     $items = array();  
     foreach ($calendars as $state) {  
       $items[] = t('%calendar', array('%calendar' => $state->title));  
     }  
     $message .= theme('item_list', $items);  
     $message .= t('This action may not be undone.');  
   }  
   else {  
     drupal_not_found();  
   }  
   $form['calendars'] = array(  
     '#type' => 'value',  
     '#value' => $calendars,  
   );  
   $form['#submit'][] = 'game_calendar_reset_form_submit';  
   return confirm_form($form, $title, 'admin/settings/game_calendar', $message, t('Reset'));  
 }  
   
 /**  
  *  Reset the submitted game calendar(s).  
  */  
 function game_calendar_reset_form_submit($form, &$form_state) {  
   foreach ($form_state['values']['calendars'] as $calendar => $state) {  
     game_calendar_reset($calendar);  
   }  
   $form_state['redirect'] = 'admin/settings/game_calendar';  
 }  
   
 /**  
210   *  Callback for admin/settings/game_calendar/%game_calendar.   *  Callback for admin/settings/game_calendar/%game_calendar.
211   *  This displays the edit game calendar form.   *  This displays the edit game calendar form.
212   */   */
# Line 259  function game_calendar_edit_page($calend Line 219  function game_calendar_edit_page($calend
219  }  }
220    
221  /**  /**
  *  Callback for admin/settings/game_calendar/%game_calendar/pause.  
  *  This pauses the game calendar.  
  */  
 function game_calendar_pause_page($calendar) {  
   game_calendar_pause($calendar->name);  
   drupal_set_message(t("Paused the %calendar game calendar.", array('%calendar' => $calendar->title)));  
   drupal_goto('admin/settings/game_calendar');  
 }  
   
 /**  
  *  Callback for admin/settings/game_calendar/%game_calendar/start.  
  *  This pauses the game calendar.  
  */  
 function game_calendar_start_page($calendar) {  
   game_calendar_start($calendar->name);  
   drupal_set_message(t("Started the %calendar game calendar.", array('%calendar' => $calendar->title)));  
   drupal_goto('admin/settings/game_calendar');  
 }  
   
 /**  
222   *  Define the form to create a new game calendar.   *  Define the form to create a new game calendar.
223   */   */
224  function game_calendar_form($form_state, $calendar = NULL) {  function game_calendar_form($form_state, $calendar = NULL) {
# Line 287  function game_calendar_form($form_state, Line 227  function game_calendar_form($form_state,
227    $form['calendar'] = array(    $form['calendar'] = array(
228      '#type' => 'fieldset',      '#type' => 'fieldset',
229      '#title' => !isset($calendar->cid) ? t('Create new game calendar') : t('Game calendar'),      '#title' => !isset($calendar->cid) ? t('Create new game calendar') : t('Game calendar'),
230      '#collapsible' => !isset($calendar->cid) && (arg(3) != 'add'),      '#collapsible' => !isset($calendar->calid) && (arg(3) != 'add'),
231      '#collapsed' => !isset($calendar->cid) && (arg(3) != 'add'),      '#collapsed' => !isset($calendar->calid) && (arg(3) != 'add'),
232      '#description' => t('Game calendars can be useful for tracking game turns, special effects, and the like. You can also create calendars programmatically. See the !help page for more information.', array('!help' => l('game calendar help', 'admin/help/game_calendar'))),      '#description' => t('Game calendars generally progress at a different rate and/or time from the real date. See the !help page for more information.', array('!help' => l('game calendar help', 'admin/help/game_calendar'))),
233    );    );
234    $form['calendar']['name'] = array(    $form['calendar']['name'] = array(
235      '#type' => 'textfield',      '#type' => 'textfield',
# Line 305  function game_calendar_form($form_state, Line 245  function game_calendar_form($form_state,
245      '#default_value' => isset($calendar->title) ? $calendar->title : '',      '#default_value' => isset($calendar->title) ? $calendar->title : '',
246      '#required' => TRUE,      '#required' => TRUE,
247    );    );
248    $form['calendar']['type'] = array(    $options = array();
249      '#type' => 'textfield',    foreach (game_clock_type_states('game_calendar') as $state) {
250      '#title' => t('Type'),      $options[$state->cid] = $state->title;
251      '#description' => t('The optional type of the game calendar. This is useful for sorting and filtering game calendars on the listing page. Additionally, some modules may act on or affect only calendars of this type.'),    }
252      '#default_value' => isset($calendar->type) ? $calendar->type : '',    $form['calendar']['cid'] = array(
253    );      '#type' => 'select',
254    $form['calendar']['status'] = array(      '#title' => t('Game clock'),
255      '#type' => 'checkbox',      '#options' => $options,
256      '#title' => t('Start calendar'),      '#default_value' => isset($calendar->cid) ? $calendar->cid : 0,
257      '#description' => t('If checked, then this game calendar will begin started. Otherwise, it will be paused.'),      '#description' => t('What game clock is this calendar tied to?'),
     '#default_value' => isset($calendar->status) ? $calendar->status : TRUE,  
258    );    );
259    $form['calendar']['turn'] = array(    $form['calendar']['turn'] = array(
260      '#type' => 'textfield',      '#type' => 'textfield',
# Line 326  function game_calendar_form($form_state, Line 265  function game_calendar_form($form_state,
265    $form['calendar']['increment'] = array(    $form['calendar']['increment'] = array(
266      '#type' => 'select',      '#type' => 'select',
267      '#title' => t('Increment'),      '#title' => t('Increment'),
268      '#options' => _game_calendar_selections(),  //     '#options' => _game_calendar_selections(),
269      '#default_value' => isset($calendar->increment) ? $calendar->increment : variable_get('game_calendar_increment_default', 5),      '#default_value' => isset($calendar->increment) ? $calendar->increment : variable_get('game_calendar_increment_default', 5),
270      '#required' => TRUE,      '#required' => TRUE,
271      '#description' => t('The calendar will wait at least this much time before incrementing to the next tick.'),      '#description' => t('The calendar will wait at least this much time before incrementing to the next tick.'),
# Line 347  function game_calendar_form($form_state, Line 286  function game_calendar_form($form_state,
286      '#type' => 'submit',      '#type' => 'submit',
287      '#value' => isset($calendar->cid) ? t('Save changes') : t('Create calendar'),      '#value' => isset($calendar->cid) ? t('Save changes') : t('Create calendar'),
288    );    );
289    $form['calendar']['cid'] = array(    $form['calendar']['calid'] = array(
290      '#type' => 'value',      '#type' => 'value',
291      '#value' => $calendar->cid,      '#value' => $calendar->calid,
292    );    );
293    return $form;    return $form;
294  }  }
# Line 372  function game_calendar_settings() { Line 311  function game_calendar_settings() {
311      '#type' => 'select',      '#type' => 'select',
312      '#title' => t('Increment default'),      '#title' => t('Increment default'),
313      '#description' => t('This determines the default increment value for a newly created calendar. This value may easily be set when creating calendars, and is simply provided as a convenience for administrators and developers who need to create a large number of similar calendars.'),      '#description' => t('This determines the default increment value for a newly created calendar. This value may easily be set when creating calendars, and is simply provided as a convenience for administrators and developers who need to create a large number of similar calendars.'),
314      '#options' => _game_calendar_selections(),  //     '#options' => _game_calendar_selections(),
315      '#default_value' => variable_get('game_calendar_increment_default', 5),      '#default_value' => variable_get('game_calendar_increment_default', 5),
316    );    );
317    $form['game_calendar_limit_on_init'] = array(    $form['game_calendar_limit_on_init'] = array(
# Line 453  function game_calendar_form_submit($form Line 392  function game_calendar_form_submit($form
392  }  }
393    
394  /**  /**
  *  Build an array of increment times, suitable for a select drop-down list.  
  *  @param $increment  
  *    (optional) The number of seconds for which we wish to see a description.  
  *  @return  
  *    If $increment is NULL, then return the entire array.  
  *    If it's a key in the array, then return the resulting description.  
  *    Otherwise, return a translated string of '@increment seconds'.  
  */  
 function _game_calendar_selections($increment = NULL) {  
   static $selections;  
   if (is_null($selections)) {  
     $selections = array(  
       0 => t('Never'),  
       1 => t('1 seconds'),  
       2 => t('2 seconds'),  
       3 => t('3 seconds'),  
       4 => t('4 seconds'),  
       5 => t('5 seconds'),  
       10 => t('10 seconds'),  
       15 => t('15 seconds'),  
       30 => t('30 seconds'),  
       60 => t('1 minute'),  
       120 => t('2 minutes'),  
       180 => t('3 minutes'),  
       240 => t('4 minutes'),  
       300 => t('5 minutes'),  
       600 => t('10 minutes'),  
       900 => t('15 minutes'),  
       1800 => t('30 minutes'),  
       3600 => t('1 hour'),  
       (3600 * 2) => t('2 hours'),  
       (3600 * 3) => t('3 hours'),  
       (3600 * 4) => t('4 hours'),  
       (3600 * 5) => t('5 hours'),  
       (3600 * 6) => t('6 hours'),  
       (3600 * 8) => t('8 hours'),  
       (3600 * 10) => t('10 hours'),  
       (3600 * 12) => t('12 hours'),  
       (3600 * 24) => t('1 day'),  
       (3600 * 24 * 2) => t('2 days'),  
       (3600 * 24 * 3) => t('3 days'),  
       (3600 * 24 * 4) => t('4 days'),  
       (3600 * 24 * 5) => t('5 days'),  
       (3600 * 24 * 6) => t('6 days'),  
       (3600 * 24 * 7) => t('7 days'),  
     );  
   }  
   if (is_null($increment)) {  
     return $selections;  
   }  
   if (isset($selections[$increment])) {  
     return $selections[$increment];  
   }  
   return t('@increment seconds', array('@increment' => $increment));  
 }  
   
 /**  
395   *  Render the form as a table of calendar settings and ops.   *  Render the form as a table of calendar settings and ops.
396   */   */
397  function theme_game_calendar_settings_form($form) {  function theme_game_calendar_settings_form($form) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2