You are here

function patterns_edit in Patterns 5

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_edit()
  2. 6 patterns.module \patterns_edit()
  3. 7.2 includes/forms/editor.inc \patterns_edit()
  4. 7 includes/forms/editor.inc \patterns_edit()

Menu callback to edit a patterns data

1 string reference to 'patterns_edit'
patterns_menu in ./patterns.module
Implementation of hook_menu().

File

./patterns.module, line 388
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_edit($pid = null) {
  if (!is_numeric($pid)) {
    drupal_set_message(t('You must specify a pattern to edit.'));
    return;
  }
  $pattern = patterns_get_pattern($pid);

  // TODO: Turn php into xml here.
  // For now just allow modifying the original xml, which
  // means the modification cannot be further modified
  if (!$pattern->file) {
    drupal_set_message(t('This pattern does not seem to have an XML source file to base the modifications off of.'), 'error');
    return;
  }
  $xml = file_get_contents($pattern->file);
  $form['name'] = array(
    '#type' => 'value',
    '#value' => $pattern->name,
  );
  $form['pid'] = array(
    '#type' => 'value',
    '#value' => $pattern->pid,
  );
  if ($pattern->enabled <= $pattern->updated) {
    $form['revert'] = array(
      '#type' => 'markup',
      '#value' => l(t('Undo update changes to the state when you enabled the pattern.'), 'admin/build/patterns/revert/' . $pid, array(), drupal_get_destination()),
    );
  }
  $form['xml'] = array(
    '#type' => 'textarea',
    '#title' => t('Pattern\'s XML'),
    '#rows' => 25,
    '#default_value' => $xml,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}