'fieldset', '#title' => t('Coder Review'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $reviews = _coder_review_settings_form(_coder_review_get_default_settings('files'), $system = array(), $files = array()); $form['engine']['coder_review']['reviews'] = array_merge($reviews['coder_reviews_group'], array( '#collapsed' => TRUE, )); $form['engine']['coder_review']['review'] = array( '#type' => 'container', '#prefix' => '
', '#suffix' => '
', ); $form['engine']['coder_review']['button'] = array( '#type' => 'button', '#value' => t('Review'), '#ajax' => array( 'callback' => 'custom_formatters_coder_review', 'wrapper' => 'coder-review-wrapper', ), ); } } /** * Ajax callback for Custom Formatters Coder Review integration. */ function custom_formatters_coder_review(&$form, $form_state) { $directory = 'public://custom_formatters/coder_review'; if (file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) { global $base_url; $md5 = md5($form_state['values']['code']); file_unmanaged_save_data(" array( 'coder_reviews' => $form_state['values']['coder_reviews'], 'coder_severity' => $form_state['values']['coder_severity'], 'coder_file_list' => $file, 'coder_files' => 1, ) ); $review = coder_review_page_form(array(), $form_state, 'files'); $form['engine']['coder_review']['review'][$file] = $review[$file]['output']; foreach ($form['engine']['coder_review']['review'][$file]['#results'] as &$result) { // Adjust the line numbering. $result = preg_replace('/\/\>Line (\d+):(.*?
)/e', '"/>Line " . ($1 - 5) . ":$2"', $result);
    }
    unset($form['engine']['coder_review']['review'][$file]['#filename']);

    file_unmanaged_delete("{$directory}/{$md5}.php");
  }

  drupal_get_messages(NULL, TRUE);
  return $form['engine']['coder_review']['review'];
}