You are here

function views_ui_clone_form in Views (for Drupal 7) 7.3

Form callback to edit an exportable item using the wizard.

This simply loads the object defined in the plugin and hands it off.

1 string reference to 'views_ui_clone_form'
views_ui::clone_page in plugins/export_ui/views_ui.class.php
Main entry point to clone an item.

File

plugins/export_ui/views_ui.class.php, line 466
Contains the CTools Export UI integration code.

Code

function views_ui_clone_form($form, &$form_state) {
  $counter = 1;
  if (!isset($form_state['item'])) {
    $view = views_get_view($form_state['original name']);
  }
  else {
    $view = $form_state['item'];
  }
  do {
    if (empty($form_state['item']->is_template)) {
      $name = format_plural($counter, 'Clone of', 'Clone @count of') . ' ' . $view
        ->get_human_name();
    }
    else {
      $name = $view
        ->get_human_name();
      if ($counter > 1) {
        $name .= ' ' . $counter;
      }
    }
    $counter++;
    $machine_name = preg_replace('/[^a-z0-9_]+/', '_', drupal_strtolower($name));
  } while (ctools_export_crud_load($form_state['plugin']['schema'], $machine_name));
  $form['human_name'] = array(
    '#type' => 'textfield',
    '#title' => t('View name'),
    '#default_value' => $name,
    '#size' => 32,
    '#maxlength' => 255,
  );
  $form['name'] = array(
    '#title' => t('View name'),
    '#type' => 'machine_name',
    '#required' => TRUE,
    '#maxlength' => 128,
    '#size' => 128,
    '#machine_name' => array(
      'exists' => 'ctools_export_ui_edit_name_exists',
      'source' => array(
        'human_name',
      ),
    ),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Continue'),
  );
  return $form;
}