You are here

function contentanalysisexample_analyzer in Content Analysis 7

Same name and namespace in other branches
  1. 8 APIEXAMPLE/contentanalysisexample.module \contentanalysisexample_analyzer()
  2. 6 APIEXAMPLE/contentanalysisexample.module \contentanalysisexample_analyzer()

Implements hook_analyzer() via custom define callback

Performs the analysis. callback is defined in hook_contentanalysis_analyzers ['callback']

Parameters

unknown_type $context: Array context format defined by contentanalysis.module

unknown_type $analysis: Array analysis format defined by contentanalysis.module

unknown_type $params: Array customer defined paramters

Return value

\unknown_type

1 string reference to 'contentanalysisexample_analyzer'
contentanalysisexample_contentanalysis_analyzers in APIEXAMPLE/contentanalysisexample.module
Implements hook_contentanalysis_analyzers(). register contentanalysisexample with contentanalysis analyzers registry

File

APIEXAMPLE/contentanalysisexample.module, line 73
An example content analyzer using the Content Analysis API

Code

function contentanalysisexample_analyzer($context, $analysis, $params) {
  $subject = t('World');
  $name = $context['inputs']['analyzer_options']['contentanalysisexample']['name'];
  if ($name) {
    $subject = $name;
    $analysis['messages'][] = contentanalysis_format_message(t('Good job, you submitted your name.'), 'complete');
    $analysis['#status'] = 'complete';
  }
  else {
    $analysis['messages'][] = contentanalysis_format_message(t('Your name was not entered in the options field. Please enter it to make this warning go away.'), 'warning');
    $analysis['#status'] = 'warning';
  }
  $analysis['content'][] = contentanalysis_format_content('<strong>' . t('Hello ' . $subject) . '</strong>', -5);
  return $analysis;
}