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