You are here

public function SiteAuditCheckContentDuplicateTitles::getResultWarn in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Content/DuplicateTitles.php \SiteAuditCheckContentDuplicateTitles::getResultWarn()

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

Overrides SiteAuditCheckAbstract::getResultWarn

File

Check/Content/DuplicateTitles.php, line 50
Contains \SiteAudit\Check\Content\DuplicateTitles.

Class

SiteAuditCheckContentDuplicateTitles
Class SiteAuditCheckContentDuplicateTitles.

Code

public function getResultWarn() {
  if (!drush_get_option('detail')) {
    return dt('There are @count duplicate titles in the following types: @types', array(
      '@count' => $this->registry['nodes_duplicate_title_count'],
      '@types' => implode(', ', array_keys($this->registry['nodes_duplicate_titles'])),
    ));
  }
  $ret_val = '';
  if (drush_get_option('html') == TRUE) {
    $ret_val .= '<table class="table table-condensed">';
    $ret_val .= '<thead><tr><th>' . dt('Content Type') . '</th><th>' . dt('Title') . '</th><th>' . dt('Count') . '</th></tr></thead>';
    foreach ($this->registry['nodes_duplicate_titles'] as $content_type => $title_counts) {
      foreach ($title_counts as $title => $count) {
        $ret_val .= "<tr><td>{$content_type}</td><td>{$title}</td><td>{$count}</td></tr>";
      }
    }
    $ret_val .= '</table>';
  }
  else {
    $ret_val = dt('Content Type: "Title" (Count)') . PHP_EOL;
    if (!drush_get_option('json')) {
      $ret_val .= str_repeat(' ', 4);
    }
    $ret_val .= '-----------------------------';
    foreach ($this->registry['nodes_duplicate_titles'] as $content_type => $title_counts) {
      foreach ($title_counts as $title => $count) {
        $ret_val .= PHP_EOL;
        if (!drush_get_option('json')) {
          $ret_val .= str_repeat(' ', 4);
        }
        $ret_val .= "{$content_type}: \"{$title}\" ({$count})";
      }
    }
  }
  return $ret_val;
}