<?php

/**
 * @file
 * @todo.
 */

/**
 * Implements hook_help().
 */
function date_tools_help($section, $arg) {
  switch ($section) {
    case 'admin/config/date/tools':
      return '<p>' . t('<h2>Tools for Dates and Calendars</h2>') . '</p>';

    case 'admin/config/date/tools/change':
      return '<p>' . t('Change a date field from one type to another. Very experimental, use at your own risk!') . '</p>';

    case 'admin/config/date/tools/date_wizard':

      $output = t("Fill out the following form to auto-create a date content type, with a datetime field and matching pre-configured calendar. If the calendar module is enabled and the option to create a calendar is chosen, a calendar and upcoming events block will be created, an ical feed will be added to the calendar. 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. 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.") .
      '</p><p>' .
      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. You can also make changes to the calendar on the Views edit page.') .
      '</p>';
      return $output;
  }
}

/**
 * Implements hook_permission().
 */
function date_tools_permission() {
  return array(
    'administer date tools' => array(
      'title' => t('Administer date tools'),
    ),
  );
}

/**
 * Implements hook_menu().
 */
function date_tools_menu() {

  $items = array();
  $items['admin/config/date/tools'] = array(
    'title'    => 'Date Tools',
    'description' => 'Date Wizard and other tools to manage and create dates and calendars. ',
    'access arguments'   => array('administer date tools'),
    'page callback' => 'date_tools_page',
  );
  $items['admin/config/date/tools/about'] = array(
    'title' => 'About',
    'description' => 'Date Wizard and other tools to manage and create dates and calendars. ',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -5,
    'page callback' => 'date_tools_page',
    'access arguments' => array('administer date tools'),
  );
  $items['admin/config/date/tools/date_wizard'] = array(
    'title' => 'Date wizard',
    'description' => 'Easy creation of date content types and calendars. ',
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('date_tools_wizard_form'),
    'access arguments' => array('administer date tools'),
    'file' => 'date_tools.wizard.inc',
  );

  // @codingStandardsIgnoreStart
  /**
  $items['admin/config/date/tools/change'] = array(
    'title'    => 'Change type',
    'access arguments'   => array('administer date tools'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('date_tools_change_type_form'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 3,
    'file' => 'date_tools.change_type.inc',
  );
  */
  // @codingStandardsIgnoreEnd

  return $items;
}

/**
 * Main Date Tools page.
 */
function date_tools_page() {
  $content = '';

  $content .= 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/config/date/tools/date_wizard')));

  return $content;
}
