| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Implementation of hook_help(). 5 */ 6 function date_tools_help($section, $arg) { 7 switch ($section) { 8 case 'admin/content/date/tools': 9 return '<p>'. t('Tools for creating and importing dates and calendars.') .'</p>'; 10 11 case 'admin/content/date/tools/change': 12 return '<p>'. t('Change a date field from one type to another. Very experimental, use at your own risk!') .'</p>'; 13 14 case 'admin/content/date/tools/date_wizard': 15 $disabled_modules = date_tools_wizard_disabled_modules(array('popup', 'repeat', 'linked')); 16 if (!empty($disabled_modules)) { 17 drupal_set_message(t('The following modules are required for the wizard to work:') .'<ul><li>'. implode('</li><li>', $disabled_modules) .'</li></ul>', 'error'); 18 } 19 $output = 20 t('Fill out the following form to auto-create a date content type, with a datetime field and matching pre-configured calendar. A calendar and upcoming events block will be created, an ical feed will be added to the calendar, and the mini calendar, calendar legend, and upcoming events blocks will be added to the sidebar of the default theme. Nodes created from this new content type will include a link to the calendar, and the calendar will have a link to the \'add new date\' form. If the Signup module is enabled, Signups will also be enabled for this field. You can also add new date fields to an existing content type by entering the existing content type name instead of creating a new one.') . 21 '</p><p>'. 22 t('Only a limited set of options are displayed here to make this easy to set up. Once the date has been created you will be able to make other changes to the date settings and add other fields to your new content type on the Manage fields screen, and make changes to the calendar on the Views edit page.') . 23 '</p>'; 24 return $output; 25 } 26 } 27 28 function date_tools_perm() { 29 return array('administer date tools'); 30 } 31 32 function date_tools_menu() { 33 34 $items = array(); 35 $items['admin/content/date/tools'] = array( 36 'title' => 'Date Tools', 37 'description' => 'Tools to import and auto-create dates and calendars.', 38 'access arguments' => array('administer date tools'), 39 'page callback' => 'date_tools_page', 40 'type' => MENU_NORMAL_ITEM, 41 ); 42 $items['admin/content/date/tools/about'] = array( 43 'title' => 'About', 44 'description' => 'Tools to import and auto-create dates and calendars.', 45 'type' => MENU_DEFAULT_LOCAL_TASK, 46 'weight' => -5, 47 'priority' => 1, 48 'page callback' => 'date_tools_page', 49 'access arguments' => array('administer date tools'), 50 ); 51 $items['admin/content/date/tools/date_wizard'] = array( 52 'title' => 'Date wizard', 53 'description' => 'Easy creation of date content types and calendars.', 54 'type' => MENU_LOCAL_TASK, 55 'weight' => 1, 56 'priority' => 1, 57 'page callback' => 'drupal_get_form', 58 'page arguments' => array('date_tools_wizard_form'), 59 'access arguments' => array('administer date tools'), 60 'file' => 'date_tools.wizard.inc', 61 'path' => drupal_get_path('module', 'date_tools'), 62 ); 63 $items['admin/content/date/tools/import'] = array( 64 'title' => 'Import', 65 'access arguments' => array('administer date tools'), 66 'page callback' => 'drupal_get_form', 67 'page arguments' => array('date_tools_copy_import_event_form'), 68 'type' => MENU_LOCAL_TASK, 69 'weight' => 2, 70 'file' => 'date_tools.event.inc', 71 'path' => drupal_get_path('module', 'date_tools'), 72 ); 73 $items['admin/content/date/tools/import/event'] = array( 74 'title' => 'Event import', 75 'access arguments' => array('administer date tools'), 76 'page callback' => 'drupal_get_form', 77 'page arguments' => array('date_tools_copy_import_event_form'), 78 'type' => MENU_LOCAL_TASK, 79 'weight' => 3, 80 'file' => 'date_tools.event.inc', 81 'path' => drupal_get_path('module', 'date_tools'), 82 ); 83 $items['date/tools/remove'] = array( 84 'title' => 'Remove calendar', 85 'access arguments' => array('administer date tools'), 86 'page callback' => 'drupal_get_form', 87 'page arguments' => array('date_tools_remove_form', 3), 88 'type' => MENU_CALLBACK, 89 ); 90 $items['admin/content/date/tools/change'] = array( 91 'title' => 'Change', 92 'access arguments' => array('administer date tools'), 93 'page callback' => 'drupal_get_form', 94 'page arguments' => array('date_tools_change_type_form'), 95 'type' => MENU_LOCAL_TASK, 96 'weight' => 3, 97 'file' => 'date_tools.change_type.inc', 98 'path' => drupal_get_path('module', 'date_tools'), 99 ); 100 return $items; 101 } 102 103 /** 104 * Main Date Tools page 105 */ 106 function date_tools_page() { 107 $choices = array(); 108 $choices[] = t('Dates and calendars can be complicated to set up. The !date_wizard makes it easy to create a simple date content type and related calendar.', array('!date_wizard' => l(t('Date wizard'), 'admin/content/date/tools/date_wizard'))); 109 $content = '<ul><li>'. implode('</li><li>', $choices) .'</li></ul>'; 110 111 if (module_exists('calendar')) { 112 $calendar_options = variable_get('calendar_default_view_options', array()); 113 $calendars = array(); 114 $node_types = node_get_types(); 115 foreach ($calendar_options as $key => $option) { 116 $type_name = str_replace('calendar_', '', $key); 117 if (array_key_exists($type_name, $node_types)) { 118 $type = $node_types[$type_name]; 119 $calendars[] = array( 120 l($type->name, 'admin/content/node-type/'. $type_name .'/fields'), 121 l($key, 'admin/build/views/edit/'. $key), 122 t('The calendar %view is a default calendar created for the content type %type_name.', array('%view' => $key, '%type_name' => $type->name)), 123 l(t('remove !view', array('!view' => $key)), 'date/tools/remove/' . $key), 124 ); 125 } 126 else { 127 // Do some cleanup while we're here if we have default calendars 128 // for non-existent content types. 129 calendar_remove($type_name); 130 } 131 } 132 if (!empty($calendars)) { 133 $headers = array(t('Content Type'), t('Calendar'), t('Description'), t('Operations')); 134 $content .= theme('table', $headers, $calendars); 135 } 136 } 137 138 return $content; 139 } 140 141 /** 142 * Menu callback; present a form for removing a field from a content type. 143 */ 144 function date_tools_remove_form(&$form_state, $view_name) { 145 $form = array(); 146 $form['view_name'] = array( 147 '#type' => 'value', 148 '#value' => $view_name, 149 ); 150 $output = confirm_form($form, 151 t('Are you sure you want to remove the view %view?', array('%view' => $view_name)), 152 'admin/content/date/tools', 153 t('This action cannot be undone.'), 154 t('Remove'), t('Cancel') 155 ); 156 157 return $output; 158 } 159 160 /** 161 * Remove a field from a content type. 162 */ 163 function date_tools_remove_form_submit($form, &$form_state) { 164 $form_values = $form_state['values']; 165 $view_name = $form_values['view_name']; 166 167 if ($view_name && $form_values['confirm']) { 168 calendar_remove($view_name); 169 drupal_set_message(t('Removed calendar %calendar.', array( 170 '%calendar' => $view_name))); 171 } 172 $form_state['redirect'] = 'admin/content/date/tools'; 173 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |