You are here

public function SiteAuditCheckContentVocabularies::calculateScore in Site Audit 7

Same name and namespace in other branches
  1. 8.2 Check/Content/Vocabularies.php \SiteAuditCheckContentVocabularies::calculateScore()

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

Overrides SiteAuditCheckAbstract::calculateScore

File

Check/Content/Vocabularies.php, line 90
Contains \SiteAudit\Check\Content\Vocabularies.

Class

SiteAuditCheckContentVocabularies
Class SiteAuditCheckContentVocabularies.

Code

public function calculateScore() {
  if (!module_exists('taxonomy')) {
    $this->abort = TRUE;
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
  }
  $sql_query = 'SELECT COUNT(tid) AS count, {taxonomy_vocabulary}.name AS name ';
  $sql_query .= 'FROM {taxonomy_vocabulary} ';
  $sql_query .= 'LEFT JOIN {taxonomy_term_data} ON {taxonomy_vocabulary}.vid = {taxonomy_term_data}.vid ';
  $sql_query .= 'GROUP BY {taxonomy_vocabulary}.name ';
  $sql_query .= 'ORDER BY count DESC ';
  $result = db_query($sql_query);
  $this->registry['vocabulary_counts'] = $this->registry['vocabulary_unused'] = array();
  foreach ($result as $row) {
    if ($row->count == 0) {
      $this->registry['vocabulary_unused'][] = $row->name;
    }
    elseif (!drush_get_option('detail')) {
      continue;
    }
    $this->registry['vocabulary_counts'][$row->name] = $row->count;
  }

  // No need to check for unused vocabularies if there aren't any.
  if (empty($this->registry['vocabulary_counts'])) {
    $this->abort = TRUE;
  }
  return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}