You are here

function checklistapi_menu in Checklist API 7

Implements hook_menu().

1 call to checklistapi_menu()
checklistapi_init in ./checklistapi.module
Implements hook_init().

File

./checklistapi.module, line 107
An API for creating fillable, persistent checklists.

Code

function checklistapi_menu() {
  $items = array();

  // Checklists report.
  $items['admin/reports/checklistapi'] = array(
    'title' => 'Checklists',
    'page callback' => 'checklistapi_report_form',
    'access arguments' => array(
      'view checklistapi checklists report',
    ),
    'description' => 'Get an overview of your installed checklists with progress details.',
    'file' => 'checklistapi.admin.inc',
  );

  // Individual checklists.
  foreach (checklistapi_get_checklist_info() as $id => $definition) {
    if (empty($definition['#path']) || empty($definition['#title'])) {
      continue;
    }

    // View/edit checklist.
    $items[$definition['#path']] = array(
      'title' => $definition['#title'],
      'description' => !empty($definition['#description']) ? $definition['#description'] : '',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'checklistapi_checklist_form',
        $id,
      ),
      'access callback' => 'checklistapi_checklist_access',
      'access arguments' => array(
        $id,
      ),
      'file' => 'checklistapi.pages.inc',
    );
    if (!empty($definition['#menu_name'])) {
      $items[$definition['#path']]['menu_name'] = $definition['#menu_name'];
    }

    // Clear saved progress.
    $items[$definition['#path'] . '/clear'] = array(
      'title' => 'Clear',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'checklistapi_checklist_clear_confirm',
        $id,
      ),
      'access callback' => 'checklistapi_checklist_access',
      'access arguments' => array(
        $id,
        'edit',
      ),
      'file' => 'checklistapi.pages.inc',
      'type' => MENU_CALLBACK,
    );

    // Toggle compact mode.
    $items[$definition['#path'] . '/compact'] = array(
      'title' => 'Compact mode',
      'page callback' => 'checklistapi_compact_page',
      'access callback' => 'checklistapi_checklist_access',
      'access arguments' => array(
        $id,
      ),
      'file' => 'checklistapi.pages.inc',
      'type' => MENU_CALLBACK,
    );
  }
  return $items;
}