You are here

function insight_contentanalysis_analysis_alter in Insight 7

File

./insight.module, line 694

Code

function insight_contentanalysis_analysis_alter(&$analysis, $context) {

  //dsm($analysis);

  //dsm($context);
  $analyzer_defs = insight_insight_analyzer_info();
  $report_defs = $analyzer_defs['insight_content']['reports'];

  //dsm($report_defs);

  // process internal analyzers
  if (!isset($analysis['insight_content']['messages']['apikey_missing'])) {
    foreach ($report_defs as $report_name => $report_def) {
      if (isset($analysis['insight_content'][$report_name])) {
        $analysis[$report_name] = $analysis['insight_content'][$report_name];
        $analysis[$report_name]['#title'] = $report_def['title'];
        $report = insight_ca_report_to_insight_report($context, $analysis[$report_name], $report_name, $report_name);
        $report = insight_report_save($report);
        $alerts = insight_ca_report_to_insight_alerts($context, $analysis[$report_name], $report);
        insight_report_alerts_save($alerts, $analyzer_name);
      }
    }
    unset($analysis['insight_content']);
  }
  else {
  }

  // process in
  // process other analyzers
  $analyzer_defs = insight_analyzer_info();

  //dsm($analyzer_defs);

  //dsm($analysis);
  foreach ($analyzer_defs as $analyzer_name => $analyzer_def) {
    if ($analyzer_name == 'insight_content') {
      continue;
    }
    foreach ($analyzer_def['reports'] as $report_name => $def) {
      if (isset($analysis[$analyzer_def['contentanalyzer']])) {
        $report = insight_ca_report_to_insight_report($context, $analysis[$analyzer_def['contentanalyzer']], $analyzer_def['contentanalyzer'], $report_name);
        $report = insight_report_save($report);
        $alerts = insight_ca_report_to_insight_alerts($context, $analysis[$analyzer_def['contentanalyzer']], $report);
        insight_report_alerts_save($alerts, $analyzer_name);
      }
    }
  }

  //dsm($analysis);
}