You are here

function patterns_editor in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/forms/editor.inc \patterns_editor()

Builds up a pattern editing environment. Loads additional javascript libraries, and supplies AJAX validation on the fly.

Parameters

mixed $pattern:

Return value

@todo Doc.

2 calls to patterns_editor()
patterns_editor_create_page in includes/forms/editor.inc
Display the page for creating a new pattern.
patterns_edit_page in includes/forms/editor.inc
Display the page for editing a pattern.
1 string reference to 'patterns_editor'
patterns_menu in ./patterns.module
Implements hook_menu().

File

includes/forms/editor.inc, line 43
Functions, forms related to the Patterns editor.

Code

function patterns_editor($form_id, $pattern = array()) {
  $pattern = patterns_get_pattern_obj($pattern);
  $form = drupal_get_form($form_id, $pattern);
  if (($form_id == "patterns_quickrun" || $form_id == "patterns_import_source") && !patterns_parser_ready()) {
    $messages = t('No available patterns parser was found.</br>');
    $messages .= t(' Go to the !modules page to enable more Patterns parsers.', array(
      '!modules' => l(t('modules'), 'admin/modules'),
    ));
    drupal_set_message($messages, 'warning');
    return $form;
  }
  $editor = drupal_render($form);
  if (!patterns_load_codemirror($form['format']['#default_value'])) {
    $cm = l(t('Codemirror 3'), 'http://codemirror.net/');
    $editor .= t('Install !cm in sites/all/libraries/codemirror for a better editor experience.', array(
      '!cm' => $cm,
    ));
  }

  // Load the JS of for the ajax validation.
  drupal_add_js(drupal_get_path('module', 'patterns') . '/js/ajax_validation.js');
  return $editor;
}