[#] Blok - Najczęściej szukane (Drupal)

( Ostatnio zmieniony pon., 16/06/2008 - 10:58 )
 
<?php
  /* CONF */

    $limit = variable_get('most_search_limit', 5);
    $limit_days = variable_get('most_search_days_limit', 3);
    $show_dots = variable_get('most_search_show_dots', TRUE);
    $limit_znakow = variable_get('most_search_chars_limit', 25);

  /* END CONF */

  // because dots have 4 chars ( word....)
  ($show_dots) ? $limit_znakow += 4 : '';

  // link, timestamp
  //$time = time();
  $time = $_SERVER['REQUEST_TIME'];
  $sql  = 'SELECT COUNT(wid) AS count, message, location, variables FROM {watchdog} ';
  $sql .= 'WHERE type = "search" AND timestamp > (%d - 86400 * %d) ';
  $sql .= 'GROUP BY message, location, variables ORDER BY count DESC';
  $result = db_query_range($sql, $time, $limit_days, 0, $limit);

  $rows = array();
  while ($dblog = db_fetch_object($result)) {
    if ($dblog->variables === 'N;') { // Legacy messages and user specified text - not used here?
      $message = $dblog->message;
    }
    else { // Message to translate with injected variables
      $a = unserialize($dblog->variables);
      $message = $a['%keys'];
    }
    // prepare link to search result
    $fixed_keywords = truncate_utf8($message, $limit_znakow, TRUE, $show_dots);
    $search_link = l($fixed_keywords, $dblog->location);

    $rows[] = array($dblog->count, $search_link);
  }

  if (!empty($rows)) {
    $output  = theme('table', array('#', t('phrase')), $rows);
    return $output;
  }
?>
5
Twoja ocena: Brak Średnio: 5 (1 vote)