You are here

public function yoast_seo_handler_rating::render in Real-time SEO for Drupal 7

Renders the field handler.

Overrides views_handler_field::render

File

views/yoast_seo_handler_rating.inc, line 22

Class

yoast_seo_handler_rating
View handler class yoast_seo_handler_rating.

Code

public function render($values) {
  $output = '';
  if (user_access('use yoast seo')) {

    // Add our own CSS.
    drupal_add_css(drupal_get_path('module', 'yoast_seo') . '/css/yoast_seo.css');

    // Check if entity has SEO availability otherwise show a message.
    if (yoast_seo_entity_supports_yoast_seo('node', strtolower($values->node_type))) {

      // Score will be either 0 or a higher int. 0 is default.
      $score = yoast_seo_get_score($values->nid);

      // Class will represent classname for current score. Like poor or bad
      // it's used for theming purposes.
      $class = yoast_seo_score_rating($score);

      // Add Yoast score to the overview.
      $output = '<div id="yoast-overallscore" class="overallScore ' . $class . '"><div class="score_circle"></div></div>';
    }
    else {
      $output = '';
    }
  }
  return $output;
}