You are here

function view_alias_admin_settings in View Alias 5

Same name and namespace in other branches
  1. 6 view_alias.module \view_alias_admin_settings()

Admin settings for module

1 string reference to 'view_alias_admin_settings'
view_alias_menu in ./view_alias.module
Implementation of hook_menu().

File

./view_alias.module, line 42
view_alias.module

Code

function view_alias_admin_settings() {
  $form = array();
  $form['view-alias-fs'] = array(
    '#type' => 'fieldset',
    '#title' => t('Generate Aliases'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  $form['view-alias-recur'] = array(
    '#type' => 'fieldset',
    '#title' => t('Recurring Aliases'),
    '#collapsed' => FALSE,
  );
  $views = _get_views_using_termid();

  //$form['header'] = array('#value' => "<h3>Alias $view->name</h3");
  foreach ($views as $view) {
    $form['view-alias-fs']['view_alias-' . $view->name] = array(
      '#type' => 'fieldset',
      '#title' => t("{$view->name}"),
      '#collapsed' => FALSE,
      '#collapsible' => FALSE,
    );
    $form['view-alias-fs']['view_alias-' . $view->name]['view_alias_view_' . $view->vid . '_vid'] = array(
      '#type' => 'hidden',
      '#value' => $view->vid,
    );

    // i dont think i need this. replace with link to the view edit page

    /**
        $form['view_alias-'. $view->name]['view_alias_view_'. $view->vid .'_url'] = array(
          '#type' => 'textfield',
          '#title' => t('View URL'),
          '#default_value' => variable_get('view_alias_view_url', $view->url),
          '#description' => t('Value defaults to the view url, but you can replace this if needed'),
        );
        **/
    $vocabs = taxonomy_get_vocabularies();
    $options = array(
      -999 => "NONE",
    );
    foreach ($vocabs as $vocab) {
      $options[$vocab->vid] = $vocab->name;
    }
    $form['view-alias-fs']['view_alias-' . $view->name]['view_alias_view_' . $view->vid . '_taxonomy'] = array(
      '#type' => 'select',
      '#title' => t('Vocabulary to alias'),
      '#default_value' => -999,
      '#options' => $options,
      '#description' => t('select the vocabulary that the view is intended to use as term id arguments'),
    );
    $form['view-alias-fs']['view_alias-' . $view->name]['view_alias_view_' . $view->vid . '_create'] = array(
      '#type' => 'checkbox',
      '#title' => t("Update aliases for <strong><i>{$view->name}</i></strong>."),
      '#default_value' => 0,
    );
  }

  // copied from pathauto admin form
  $actions = array(
    t('Do nothing. Leave the old alias intact.'),
    t('Create a new alias. Delete the old alias.'),
    t('Delete aliases for selected views.'),
  );
  $form['view-alias-fs']["view_alias_update_action"] = array(
    '#type' => 'radios',
    '#title' => t('Update action'),
    '#default_value' => VIEW_ALIAS_UPDATE_NOTHING,
    '#options' => $actions,
    '#description' => t('What should view alias do when updating an existing content item which already has an alias?'),
  );
  $form['view-alias-fs']['view-alias-update_btn'] = array(
    '#type' => 'submit',
    '#value' => t('Update Aliases'),
  );
  foreach ($views as $view) {
    $form['view-alias-recur']['view_alias-' . $view->name] = array(
      '#type' => 'fieldset',
      '#title' => t("{$view->name} (" . l($view->url, $view->url, array(
        "target" => "_blank",
      )) . ")"),
    );
    $form['view-alias-recur']['view_alias-' . $view->name]['view_alias_view_' . $view->vid . '_recur'] = array(
      '#type' => 'checkbox',
      '#title' => t("Create/Update/Delete aliases for <strong><i>{$view->name}</i></strong> on term creation."),
      '#default_value' => variable_get("view_alias_view_" . $view->vid . "_recur", 0),
    );
    $vocabs = taxonomy_get_vocabularies();
    $options = array(
      -999 => "NONE",
    );
    foreach ($vocabs as $vocab) {
      $options[$vocab->vid] = $vocab->name;
    }
    $form['view-alias-recur']['view_alias-' . $view->name]['view_alias_view_' . $view->vid . '_taxonomy_recur'] = array(
      '#type' => 'select',
      '#title' => t('Vocabulary to alias'),
      '#default_value' => variable_get('view_alias_view_' . $view->vid . '_taxonomy_recur', -999),
      '#options' => $options,
      '#description' => t('select the vocabulary that the view will be aliased with'),
    );
  }
  return system_settings_form($form);

  //return $form;
}