You are here

function date_tools_page in Date 7

Same name and namespace in other branches
  1. 8 date_tools/date_tools.module \date_tools_page()
  2. 6.2 date_tools/date_tools.module \date_tools_page()
  3. 7.3 date_tools/date_tools.module \date_tools_page()
  4. 7.2 date_tools/date_tools.module \date_tools_page()

Main Date Tools page

1 string reference to 'date_tools_page'
date_tools_menu in date_tools/date_tools.module
Implements hook_menu().

File

date_tools/date_tools.module, line 88

Code

function date_tools_page() {
  $choices = array();
  $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/structure/date/date_wizard'),
  ));
  $content = '<ul><li>' . implode('</li><li>', $choices) . '</li></ul>';
  if (module_exists('calendar')) {
    $calendar_options = variable_get('calendar_default_view_options', array());
    $calendars = array();
    $node_types = node_type_get_names();
    foreach ($calendar_options as $key => $option) {
      $bundle = str_replace('calendar_', '', $key);
      if (array_key_exists($bundle, $node_types)) {
        $type = $node_types[$bundle];
        $calendars[] = array(
          l($type, 'admin/structure/types/manage/' . $bundle . '/fields'),
          l($key, 'admin/structure/views/edit/' . $key),
          t('The calendar %view is a default calendar created for the content type %bundle. ', array(
            '%view' => $key,
            '%bundle' => $type,
          )),
          l(t('remove !view', array(
            '!view' => $key,
          )), 'admin/structure/date/remove/' . $key),
        );
      }
      else {

        // Do some cleanup while we're here if we have default calendars
        // for non-existent content types.
        calendar_remove($bundle);
      }
    }
    if (!empty($calendars)) {
      $header = array(
        t('Content Type'),
        t('Calendar'),
        t('Description'),
        t('Operations'),
      );
      $content .= theme('table', array(
        'header' => $header,
        'rows' => $calendars,
      ));
    }
  }
  return $content;
}