You are here

function _coder_page_form_includes in Coder 5.2

Same name and namespace in other branches
  1. 5 coder.module \_coder_page_form_includes()
  2. 6.2 coder.module \_coder_page_form_includes()
  3. 6 coder.module \_coder_page_form_includes()

Add results to form array for display on form page.

Parameters

$form: Form array variable to be modified.

$coder_args: Coder settings, see do_coder_reviews() for details.

$name: Name of form element.

$files: Array of file objects to check and display the results of, see file_scan_directory().

$offset: Integer offset to munge filenames with.

Return value

Statistics array in form: string filename => array value of '#stats' from do_coder_reviews().

1 call to _coder_page_form_includes()
coder_page_form in ./coder.module
Implementation of hook_form().

File

./coder.module, line 731
Developer Module that assists with code review and version upgrade that supports a plug-in extensible hook system so contributed modules can define additional review standards.

Code

function _coder_page_form_includes(&$form, $coder_args, $name, $files, $offset) {
  $stats = array();
  $coder_args['#name'] = $name;
  $weight = 0;
  foreach ($files as $file) {
    $filename = drupal_substr($file->filename, $offset);
    $coder_args['#filename'] = $filename;
    $results = do_coder_reviews($coder_args);
    $stats[$filename] = $results['#stats'];
    unset($results['#stats']);

    // Output the results in a collapsible fieldset.
    $form[$name][$filename] = array(
      '#type' => 'fieldset',
      '#title' => $filename,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => ++$weight,
    );
    if (empty($results)) {
      $results[] = t('No Problems Found');
    }
    else {
      $form[$name][$filename]['#collapsed'] = FALSE;
      $form[$name]['#collapsed'] = FALSE;
    }
    $form[$name][$filename]['output'] = array(
      '#value' => theme('coder', $name, $filename, $results),
    );
  }
  return $stats;
}