function customfilter_menu in Custom filter 5
Same name and namespace in other branches
- 6 customfilter.module \customfilter_menu()
- 7.2 customfilter.module \customfilter_menu()
- 7 customfilter.module \customfilter_menu()
Implements hook_menu().
File
- ./
customfilter.module, line 104
Code
function customfilter_menu($may_cache) {
$access = user_access('administer customfilter');
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/customfilter',
'title' => t('Custom Filter'),
'description' => t('User defined filters.'),
'callback' => 'customfilter_settings',
'access' => $access,
'type' => MENU_NORMAL_ITEM,
);
// Customfilter: List
$items[] = array(
'path' => 'admin/settings/customfilter/list',
'title' => t('List'),
'access' => $access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
// Customfilter: Add filterset
$items[] = array(
'path' => 'admin/settings/customfilter/add',
'title' => t('Add filter set'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'customfilter_set_edit',
'add',
),
'access' => $access,
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
// Customfilter: Export
$items[] = array(
'path' => 'admin/settings/customfilter/export',
'title' => t('Export'),
'callback' => 'drupal_get_form',
'access' => $access,
'callback arguments' => array(
'customfilter_export_form',
),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
// Customfilter: Import
$items[] = array(
'path' => 'admin/settings/customfilter/import',
'title' => t('Import'),
'callback' => 'drupal_get_form',
'access' => $access,
'callback arguments' => array(
'customfilter_import_form',
),
'type' => MENU_LOCAL_TASK,
'weight' => 4,
);
// Customfilter: Get XML
$items[] = array(
'path' => 'admin/settings/customfilter/export/xml',
'title' => t('XML'),
'callback' => 'customfilter_xml_export',
'access' => $access,
'type' => MENU_CALLBACK,
);
}
else {
$arg0 = arg(0);
$arg1 = arg(1);
$arg2 = arg(2);
$arg3 = arg(3);
$arg4 = arg(4);
$bool = isset($arg0) && $arg0 == 'admin' && isset($arg1) && $arg1 == 'settings' && isset($arg2) && $arg2 == 'customfilter' && isset($arg3) && is_numeric($arg3);
if ($bool) {
$sid = $arg3;
$set = customfilter_get_set($sid, 'name');
if ($set) {
// Filterset: List filters
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}",
'title' => t("Custom filter: {$set['name']}"),
'callback' => 'customfilter_filters',
'callback arguments' => array(
arg(3),
),
'access' => $access,
'type' => MENU_CALLBACK,
);
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/list",
'title' => t('List'),
'access' => $access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
// Filterset: Edit filterset
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/edit",
'title' => t('Edit'),
'callback' => 'drupal_get_form',
'access' => $access,
'callback arguments' => array(
'customfilter_set_edit',
'edit',
$sid,
),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
// Filterset: Delete filterset
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/delete",
'title' => t('Delete'),
'callback' => 'drupal_get_form',
'access' => $access,
'callback arguments' => array(
'customfilter_set_delete',
$sid,
),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
// Filterset: Add filter
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/add",
'title' => t('Add filter'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'customfilter_filter_edit',
'add',
$sid,
),
'access' => $access,
'type' => MENU_LOCAL_TASK,
'weight' => 4,
);
if (isset($arg4) && is_numeric($arg4)) {
$fid = $arg4;
// Select * if using static filters array as filter is cached for editing
$filter = customfilter_get_filter($fid, '*');
// Filter: List
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/{$fid}",
'title' => t("Filter: {$filter['name']}"),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'customfilter_filter_edit',
'edit',
$sid,
$fid,
),
'access' => $access,
'type' => MENU_CALLBACK,
);
// Filter: Edit filter
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/{$fid}/edit",
'title' => t('Edit'),
'access' => $access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
// Filter: Delete filter
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/{$fid}/delete",
'title' => t('Delete filter'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'customfilter_filter_delete',
$fid,
),
'access' => $access,
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
// Filter: Add subfilter
$items[] = array(
'path' => "admin/settings/customfilter/{$sid}/{$fid}/add",
'title' => t('Add subfilter'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'customfilter_filter_edit',
'add',
$sid,
$fid,
),
'access' => $access,
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
}
}
}
}
return $items;
}