Classes | Functions

plugins/export_ui/views_ui.class.php File Reference

Contains the CTools Export UI integration code. More...

Go to the source code of this file.

Classes

class  views_ui
 CTools Export UI class handler for Views UI. More...

Functions

 views_ui_clone_form ($form, &$form_state)
 Form callback to edit an exportable item using the wizard.

Detailed Description

Contains the CTools Export UI integration code.

Note that this is only a partial integration.

Definition in file views_ui.class.php.


Function Documentation

views_ui_clone_form ( form,
&$  form_state 
)

Form callback to edit an exportable item using the wizard.

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

Definition at line 393 of file views_ui.class.php.

References views_get_view().

                                                  {
  $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;
}