View source
<?php
class CaseTrackerProjectUIController extends EntityDefaultUIController {
public function hook_menu() {
$items = array();
$wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%' . $this->entityType;
$operations_path = 'projects';
$items[$operations_path . '/add'] = array(
'title' => t('Add a project'),
'description' => t('Add a new project'),
'page callback' => 'casetracker_project_add_page',
'access callback' => 'casetracker_project_access',
'access arguments' => array(
'edit',
),
'type' => MENU_NORMAL_ITEM,
'weight' => 20,
'file' => 'casetracker_project.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
foreach (casetracker_project_get_types() as $type) {
$items[$operations_path . '/add/' . $type->type] = array(
'title' => t('Add @bundle', array(
'@bundle' => $type->label,
)),
'page callback' => 'casetracker_project_form_wrapper',
'page arguments' => array(
casetracker_project_create(array(
'type' => $type->type,
)),
),
'access callback' => 'casetracker_project_access',
'access arguments' => array(
'edit',
'edit ' . $type->type,
),
'file' => 'casetracker_project.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
}
$project_path = 'project';
$items[$project_path . '/' . $wildcard . '/edit'] = array(
'title' => t('Edit'),
'page callback' => 'casetracker_project_form_wrapper',
'page arguments' => array(
1,
),
'access callback' => 'casetracker_project_access',
'access arguments' => array(
'edit',
1,
),
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
);
$items[$project_path . '/' . $wildcard . '/delete'] = array(
'title' => t('Delete'),
'page callback' => 'casetracker_project_delete_form_wrapper',
'page arguments' => array(
1,
),
'access callback' => 'casetracker_project_access',
'access arguments' => array(
'edit',
1,
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 10,
'file' => 'casetracker_project.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
$items[$project_path . '/' . $wildcard] = array(
'page callback' => 'casetracker_project_page_view',
'page arguments' => array(
1,
),
'access callback' => 'casetracker_project_access',
'access arguments' => array(
'view',
1,
),
);
$items[$project_path . '/' . $wildcard . '/view'] = array(
'title' => t('View'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
return $items;
}
public function addPage() {
$item = menu_get_item();
$content = system_admin_menu_block($item);
if (count($content) == 0) {
drupal_set_message(t('There isn\'t any Project Type configured. To setup now, go to the <a href="@link">@link_text</a>.', array(
'@link' => base_path() . 'admin/structure/casetracker/project-types',
'@link_text' => 'administrative page',
)), 'error');
}
if (count($content) == 1) {
$item = array_shift($content);
drupal_goto($item['href']);
}
return theme('casetracker_project_add_list', array(
'content' => $content,
));
}
}