| 16 |
* |
* |
| 17 |
* Capture author date fields and add the YUI calendar to them. |
* Capture author date fields and add the YUI calendar to them. |
| 18 |
*/ |
*/ |
| 19 |
function yuicalendar_form_alter($form_id, &$form) { |
function yuicalendar_form_alter(&$form, $form_state, $form_id) { |
| 20 |
if ($form_id === 'comment_form' && isset($form['admin']) && isset($form['admin']['date'])) { |
if ($form_id === 'comment_form' && isset($form['admin']) && isset($form['admin']['date'])) { |
| 21 |
$form['admin']['author']['#weight'] = -4; |
$form['admin']['author']['#weight'] = -4; |
| 22 |
yuicalendar_build_form($form['admin'], 'date', strtotime($form['admin']['date']['#default_value']), -3, variable_get('yuicalendar_edit_drop_down', '1'), NULL); |
yuicalendar_build_form($form['admin'], 'date', strtotime($form['admin']['date']['#default_value']), -3, variable_get('yuicalendar_edit_drop_down', '1'), NULL); |
| 24 |
elseif (isset($form['type']) && $form['type']['#value'].'_node_form' === $form_id && isset($form['author']) && isset($form['author']['date'])) { |
elseif (isset($form['type']) && $form['type']['#value'].'_node_form' === $form_id && isset($form['author']) && isset($form['author']['date'])) { |
| 25 |
yuicalendar_build_form($form['author'], 'date', $form['created']['#value'], 5, variable_get('yuicalendar_edit_drop_down', '1'), NULL); |
yuicalendar_build_form($form['author'], 'date', $form['created']['#value'], 5, variable_get('yuicalendar_edit_drop_down', '1'), NULL); |
| 26 |
} |
} |
| 27 |
|
$form['yuicalendar'] = Array('#type' => 'weight'); |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
function yuicalendar_nodeapi($node, $op) { |
| 31 |
|
switch ($op) { |
| 32 |
|
case 'validate': |
| 33 |
|
if (isset($node->yuicalendar)) { |
| 34 |
|
yuicalendar_load(); |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
} |
} |
| 38 |
|
|
| 39 |
/** |
/** |
| 88 |
$years[$year] = $year; |
$years[$year] = $year; |
| 89 |
$year--; |
$year--; |
| 90 |
} |
} |
| 91 |
|
|
| 92 |
$form[$id . '-year'] = Array( |
$form[$id . '-year'] = Array( |
| 93 |
'#type' => 'select', |
'#type' => 'select', |
| 94 |
'#weight' => $weight + .05, |
'#weight' => $weight + .05, |
| 147 |
/** |
/** |
| 148 |
* Implemention of hook_menu(). |
* Implemention of hook_menu(). |
| 149 |
*/ |
*/ |
| 150 |
function yuicalendar_menu($may_cache) { |
function yuicalendar_menu() { |
| 151 |
if (!$may_cache) { |
$items['admin/settings/yuicalendar'] = array( |
|
// Nothing yet. |
|
|
} |
|
|
else { |
|
|
$items[] = array( |
|
|
'path' => 'admin/settings/yuicalendar', |
|
| 152 |
'title' => t('YUI Calendar Settings'), |
'title' => t('YUI Calendar Settings'), |
| 153 |
'callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 154 |
'callback arguments' => 'yuicalendar_admin_settings', |
'page arguments' => array('yuicalendar_admin_settings'), |
| 155 |
'access' => user_access('access administration pages'), |
'access callback' => 'user_access', |
| 156 |
|
'access arguments' => array('access administration pages'), |
| 157 |
'type' => MENU_NORMAL_ITEM, |
'type' => MENU_NORMAL_ITEM, |
| 158 |
); |
); |
|
} |
|
| 159 |
|
|
| 160 |
return $items; |
return $items; |
| 161 |
} |
} |