You are here

function asset_menu in Asset 5.2

Same name and namespace in other branches
  1. 5 asset.module \asset_menu()
  2. 6 asset.module \asset_menu()
  3. 7 asset.module \asset_menu()

Implementation of hook_menu().

Related topics

File

./asset.module, line 36
Main module.

Code

function asset_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'asset',
      'title' => t('Assets'),
      'callback' => 'asset_page_default',
      'access' => user_access('browse assets'),
      'type' => MENU_MODIFIABLE_BY_ADMIN,
    );
    $items[] = array(
      'path' => 'asset/add',
      'title' => t('Create assets'),
      'callback' => 'asset_add',
      'access' => user_access('access content'),
      'type' => MENU_ITEM_GROUPING,
      'weight' => 1,
    );
    foreach (asset_get_types() as $type) {
      $type_url_str = str_replace('_', '-', $type->type);
      $items[] = array(
        'path' => 'asset/add/' . $type_url_str,
        'title' => drupal_ucfirst($type->name),
        'access' => asset_access('create', $type->type),
      );
    }
    $items[] = array(
      'path' => 'admin/settings/asset',
      'title' => t('Assets'),
      'callback' => 'asset_admin_overview',
      'access' => user_access('administer assets'),
    );
    $items[] = array(
      'path' => 'admin/settings/asset/file',
      'title' => t('Files'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'asset_admin_file_settings',
      ),
      'access' => user_access('administer assets'),
    );
  }
  else {
    if (arg(0) == 'asset' && is_numeric(arg(1))) {
      $asset = asset_load(arg(1));
      if ($asset->aid) {
        $items[] = array(
          'path' => 'asset/' . arg(1),
          'title' => t('View'),
          'callback' => 'asset_page_view',
          'callback arguments' => array(
            $asset,
          ),
          'access' => asset_access('view', $asset),
          'type' => MENU_CALLBACK,
        );
        $items[] = array(
          'path' => 'asset/' . arg(1) . '/view',
          'title' => t('View'),
          'type' => MENU_DEFAULT_LOCAL_TASK,
          'weight' => -10,
        );
        $items[] = array(
          'path' => 'asset/' . arg(1) . '/edit',
          'title' => t('Edit'),
          'callback' => 'asset_page_edit',
          'callback arguments' => array(
            $asset,
          ),
          'access' => asset_access('update', $asset),
          'weight' => 1,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => 'asset/' . arg(1) . '/delete',
          'title' => t('Delete'),
          'callback' => 'drupal_get_form',
          'callback arguments' => array(
            'asset_delete_confirm',
            $asset,
          ),
          'access' => asset_access('delete', $asset),
          'weight' => 2,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => 'asset/' . arg(1) . '/format',
          'title' => t('Formats'),
          'callback' => 'asset_page_format',
          'callback arguments' => array(
            $asset,
          ),
          'access' => asset_access('view', $asset),
          'weight' => 1,
          'type' => MENU_LOCAL_TASK,
        );
        $items[] = array(
          'path' => 'asset/' . arg(1) . '/img',
          'callback' => 'asset_img_src',
          'callback arguments' => array(
            $asset,
            arg(3),
          ),
          'access' => asset_access('view', $asset),
          'type' => MENU_CALLBACK,
        );
        $items[] = array(
          'path' => 'asset/' . arg(1) . '/icon/ajax',
          'callback' => 'asset_icon_ajax',
          'callback arguments' => array(
            $asset,
          ),
          'access' => asset_access('view', $asset),
          'type' => MENU_CALLBACK,
        );
        if (module_exists('devel')) {
          $items[] = array(
            'path' => 'asset/' . arg(1) . '/load',
            'title' => t('Dev load'),
            'callback' => 'devel_print_object',
            'callback arguments' => array(
              $asset,
            ),
            'access' => user_access('access devel information'),
            'type' => MENU_LOCAL_TASK,
          );
        }
      }
    }
    drupal_add_css(drupal_get_path('module', 'asset') . '/asset.css');
  }
  return $items;
}