You are here

function asset_wizard_menu in Asset 6

Same name and namespace in other branches
  1. 5.2 asset_wizard.module \asset_wizard_menu()

Implementation of hook_menu().

File

./asset_wizard.module, line 23
Wizard-style interface for Asset.

Code

function asset_wizard_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'asset/wizard',
      'title' => t('Asset Wizard'),
      'type' => MENU_CALLBACK,
      'callback' => 'asset_wizard_main',
      'access' => user_access('access asset wizard'),
    );
    foreach (asset_get_types() as $type) {
      $type_url_str = str_replace('_', '-', $type->type);
      $items[] = array(
        'path' => 'asset/wizard/add/' . $type_url_str,
        'title' => drupal_ucfirst($type->name),
        'access' => asset_access('create', $type->type),
        'type' => MENU_CALLBACK,
        'callback' => 'asset_wizard_add',
        'callback arguments' => array(
          $type,
        ),
      );
    }
  }
  else {
    if (arg(0) == 'asset' && arg(1) == 'wizard') {

      //      $items[] = array(
      //        'path' => 'asset/wizard/browse',
      //        'title' => t('Asset Wizard - Browse'),
      //        'type' => MENU_CALLBACK,
      //        'callback' => 'asset_wizard_browse',
      //        'callback arguments' => array(),
      //        'access' => user_access('access asset wizard'),
      //      );
      foreach (asset_wizard_methods() as $key => $method) {
        $items[] = array(
          'path' => 'asset/wizard/method/' . $key,
          'title' => t('Asset Wizard') . ' - ' . $method['name'],
          'type' => MENU_CALLBACK,
          'callback' => $method['callback'],
          'access' => user_access('access asset wizard'),
        );
      }
      if (is_numeric(arg(2))) {
        $aid = arg(2);
        $asset = asset_load($aid);
        if (!$asset || $asset->type == 'directory') {
          $items[] = array(
            'path' => 'asset/wizard/' . $aid,
            'title' => t('Asset Wizard - Browse'),
            'type' => MENU_CALLBACK,
            'callback' => 'asset_wizard_browse',
            'callback arguments' => array(
              $asset,
            ),
            'access' => user_access('access asset wizard'),
          );
        }
        else {
          $items[] = array(
            'path' => 'asset/wizard/' . $aid,
            'title' => t('Asset Wizard - Select Format'),
            'type' => MENU_CALLBACK,
            'callback' => 'asset_wizard_formats',
            'callback arguments' => array(
              $asset,
            ),
            'access' => user_access('access asset wizard'),
          );
          $format = arg(3);
          if ($format && $asset->formatters[$format]) {
            $attr = array();
            if ($macro = arg(4)) {
              $macros = asset_get_macros($macro);
              $attr = $macros[$macro];
            }
            else {
              $attr = array(
                'format' => $format,
              );
            }
            $items[] = array(
              'path' => 'asset/wizard/' . $aid . '/' . $format,
              'title' => t('Asset Wizard - Options'),
              'type' => MENU_CALLBACK,
              'callback' => 'asset_wizard_format_options',
              'callback arguments' => array(
                $asset,
                $attr,
              ),
              'access' => user_access('access asset wizard'),
            );
          }
          if (arg(3) == 'finish') {
            $macro = urldecode(arg(4));
            $items[] = array(
              'path' => 'asset/wizard/' . $aid . '/finish',
              'title' => t('Asset Wizard - Finish'),
              'type' => MENU_CALLBACK,
              'callback' => 'asset_wizard_preview',
              'callback arguments' => array(
                $asset,
                $macro,
              ),
              'access' => user_access('access asset wizard'),
            );
          }
        }
      }
    }
    elseif (arg(0) == 'assetfield' && is_numeric(arg(1))) {
      $asset = asset_load(arg(1));
      $items[] = array(
        'path' => 'assetfield/' . $asset->aid,
        'type' => MENU_CALLBACK,
        'callback' => 'assetfield_js_callback',
        'callback arguments' => array(
          $asset,
        ),
        'access' => user_access('access asset wizard'),
      );
    }
  }
  return $items;
}