You are here

function kwresearch_format_report_data_value in Keyword Research 7

Same name and namespace in other branches
  1. 6 kwresearch.module \kwresearch_format_report_data_value()

@todo Please document this function.

See also

http://drupal.org/node/1354

2 calls to kwresearch_format_report_data_value()
kwresearch_keywords_list_page in includes/site_report.inc
Generates site keywords report page
theme_keyword_stats_report in includes/stats_report.inc
Themes keyword stats report

File

./kwresearch.module, line 1436

Code

function kwresearch_format_report_data_value($values, $keyword = '', $type = 'term') {
  switch ($type) {
    case 'term':
      $output = '<span class="kwresearch_keyword">' . $values['term'] . '</div>';
      break;

    //case 'wordtracker_count':

    //  $output = ($values['wordtracker_count']=='NA') ? 'NA': number_format($values['wordtracker_count']);
    //  break;
    case 'site_priority':
      $output = '-';
      if ($values['priority'] >= 0) {
        $options = kwresearch_get_priority_options();
        $output = $options[$values['priority']];
      }
      break;
    case 'site_value':
      $output = $values['value'] > 0 ? t('$') . number_format($values['value'], 2) : '-';
      $type = 'value';
      break;
    case 'page_priority':
      $output = '-';
      if ($values['page_priority'] > 0) {
        $options = kwresearch_get_priority_options();
        $output = $options[$values['page_priority']];
      }
      break;
    case 'daily_volume':
    case 'total_dailyest':
      $coefs = kwresearch_get_report_coefs();
      if (is_null($values['_searches']) || $values['_searches'] < 0) {
        $output = 'NA';
      }
      else {
        $output = '<div class="stats-indicator">';
        $output .= '  <div class="searches-indicator-bar" style="width: ' . 100 * $values['_searches'] / $values['_meta']['searches_max'] . '%;" title="' . number_format($values['_searches']) . '">';
        $output .= '    <div class="stats-indicator-text">' . number_format($values['_searches']) . '</div>';
        $output .= '  </div>';
        $output .= '</div>';
      }
      break;
    case 'competition':
      if (!isset($values['_competition']) || $values['_competition'] < 0) {
        $output = 'NA';
      }
      else {
        $output = '<div class="stats-indicator">';
        $output .= '  <div class="competition-indicator-bar" style="width: ' . $values['_competition'] . '%;" title="' . number_format($values['_competition']) . '">';
        $output .= '    <div class="stats-indicator-text">' . number_format($values['_competition']) . '%</div>';
        $output .= '  </div>';
        $output .= '</div>';
      }
      break;
    case 'bid':
      $output = isset($values['_bid']) && $values['_bid'] > 0 ? t('$') . number_format($values['_bid'], 2) : '-';
      if (!isset($values['_bid']) || $values['_bid'] < 0) {
        $output = 'NA';
      }
      elseif ($values['_bid'] == 0) {
        $output = '-';
      }
      else {
        $output = '<div class="stats-indicator">';
        $output .= '  <div class="bid-indicator-bar" style="width: ' . 100 * $values['_bid'] / $values['_meta']['bid_max'] . '%;" title="' . number_format($values['_bid']) . '">';
        $output .= '    <div class="stats-indicator-text">' . t('$') . number_format($values['_bid'], 2) . '</div>';
        $output .= '  </div>';
        $output .= '</div>';
      }
      break;
      break;
    case 'google_dailyest':
      $coefs = kwresearch_get_report_coefs();
      $v = $values['_searches'] == 0 ? 'NA' : number_format($values['_searches'] * $coefs['google_search_share']);
      $output = l($v, 'http://www.google.com/search?btnG=Google+Search&q=' . $keyword, array(
        'attributes' => array(
          'target' => $type,
        ),
      ));
      break;
    case 'yahoo_dailyest':
      $coefs = kwresearch_get_report_coefs();
      $v = $values['_searches'] == 0 ? 'NA' : number_format($values['_searches'] * $coefs['yahoo_search_share']);
      $output = l($v, 'http://search.yahoo.com/search?fr=ytff-&ei=UTF-8&rs=all&p=' . $keyword, array(
        'attributes' => array(
          'target' => $type,
        ),
      ));
      break;
    case 'bing_dailyest':
      $coefs = kwresearch_get_report_coefs();
      $v = $values['_searches'] == 0 ? 'NA' : number_format($values['_searches'] * $coefs['bing_search_share']);
      $output = l($v, 'http://www.bing.com/search?q=' . $keyword, array(
        'attributes' => array(
          'target' => $type,
        ),
      ));
      break;
    default:
      return FALSE;
  }
  $output = array(
    'data' => $output,
    'class' => array(
      $type,
    ),
  );
  return $output;
}