You are here

function page_manager_page_import_subtask_validate in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 page_manager/plugins/tasks/page.admin.inc \page_manager_page_import_subtask_validate()

Ensure we got a valid page.

File

page_manager/plugins/tasks/page.admin.inc, line 1313
Administrative functions for the page subtasks.

Code

function page_manager_page_import_subtask_validate(&$form, &$form_state) {
  ob_start();
  eval($form_state['values']['object']);
  ob_end_clean();
  if (!isset($page) || !is_object($page)) {
    $errors = ob_get_contents();
    if (empty($errors)) {
      $errors = t('No handler found.');
    }
    form_error($form['object'], t('Unable to get a page from the import. Errors reported: @errors', array(
      '@errors' => $errors,
    )));
  }
  if (empty($form_state['values']['name'])) {
    $form_state['values']['name'] = $page->name;
  }
  $task_name = page_manager_make_task_name('page', $form_state['values']['name']);
  $form_state['cache'] = page_manager_get_page_cache($task_name);
  if ($form_state['cache'] && $form_state['cache']->locked) {
    form_error($form['name'], t('That page name is in use and locked by another user. You must <a href="!break">break the lock</a> on that page before proceeding, or choose a different name.', array(
      '!break' => url(page_manager_edit_url($task_name, array(
        'actions',
        'break-lock',
      ))),
    )));
    return;
  }
  if (empty($form_state['values']['path'])) {
    $form_state['values']['path'] = $page->path;
  }
  if (empty($form_state['values']['overwrite'])) {
    $page->name = NULL;
  }
  $form_state['page'] = new stdClass();
  $form_state['page']->subtask['subtask'] = $page;
  page_manager_page_form_basic_validate($form, $form_state);
}