You are here

public function SiteAuditCheckFrontEndTemplateFiles::calculateScore in Site Audit 7

Implements \SiteAudit\Check\Abstract\calculateScore().

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/FrontEnd/TemplateFiles.php, line 97
Contains \SiteAudit\Check\BestPractices\TemplateFiles.

Class

SiteAuditCheckFrontEndTemplateFiles
Class SiteAuditCheckFrontEndTemplateFiles.

Code

public function calculateScore() {
  $theme_path = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT') . '/' . path_to_theme();
  $command = 'find ' . $theme_path . ' -iname "*.tpl.php" ';
  $command .= '-exec grep -n -H "db_select\\|db_query\\|mysql_query\\|drupal_goto\\|new .*(\\|drupal_set_message\\|drupal_get_messages\\|cache_clear_all\\|function .*(\\|exit\\|die\\|arg(" {} \\;';
  $output = array();
  exec($command, $output);
  foreach ($output as $line) {
    $line = explode(':', $line);
    $this->registry['template_logic'][$this
      ->getRelativePath($line[0])][] = array(
      $line[1],
      $line[2],
    );
  }
  if (!empty($this->registry['template_logic'])) {
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}