function _coder_review_page_form_includes in Coder 7
Same name and namespace in other branches
- 7.2 coder_review/coder_review.module \_coder_review_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.
$exclusions: Exclusions that should be ignored in $files.
$ignores: Array of lines per file to be skipped for defined reviews.
Return value
Statistics array in form: string filename => array value of '#stats' from do_coder_reviews().
1 call to _coder_review_page_form_includes()
- coder_review_page_form in coder_review/
coder_review.module - Implements hook_form().
File
- coder_review/
coder_review.module, line 1010
Code
function _coder_review_page_form_includes(&$form, $coder_args, $name, $files, $offset, $exclusions, $ignores) {
$stats = array();
$coder_args['#name'] = $name;
$weight = 0;
$exclusions = str_replace(array(
"\r\n",
"\r",
"\n",
'/',
'*',
'.',
), array(
'|',
'|',
'|',
'\\/',
'.*',
'\\.',
), $exclusions);
foreach ($files as $file) {
if (!empty($exclusions) && preg_match("/{$exclusions}/", $file->uri)) {
continue;
// Don't review this file.
}
$filename = drupal_substr($file->uri, $offset);
$php_extensions = variable_get('coder_review_php_ext', array(
'inc',
'php',
'install',
'test',
));
$coder_args['#filename'] = $filename;
$coder_args['#php_extensions'] = $php_extensions;
$coder_args['#ignore_lines'] = isset($ignores[$filename]) && is_array($ignores[$filename]) ? $ignores[$filename] : array();
$results = do_coder_reviews($coder_args);
$stats[$filename] = $results['#stats'];
unset($results['#stats']);
module_invoke_all('coder_review_results_view', $results);
// 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;
}
if (function_exists('_coder_review_drush_is_option') && _coder_review_drush_is_option('drush')) {
theme('coder_review', array(
'name' => $name,
'filename' => $filename,
'results' => $results,
));
}
else {
$form[$name][$filename]['output'] = array(
'#theme' => 'coder_review',
'#name' => $name,
'#filename' => $filename,
'#results' => $results,
);
}
}
return $stats;
}