Example #1
0
}
$limit = appconf('limit');
$q = db_query('SELECT * FROM digger_linkstory
	WHERE status = "enabled" ' . $cat . '
	ORDER BY posted_on desc, score desc');
if ($q->execute()) {
    $total = $q->rows();
    $res = $q->fetch($cgi->offset, $limit);
    $q->free();
} else {
    die($q->error());
}
// has voted?
foreach (array_keys($res) as $k) {
    if (digger_has_voted($res[$k]->id)) {
        $res[$k]->voted = 'style="display: none"';
    }
}
// pager
loader_import('saf.GUI.Pager');
$pg = new Pager($cgi->offset, $limit, $total);
$pg->setUrl(site_prefix() . '/index/digger-app?category=' . $cgi->category);
$pg->getInfo();
// output
if (!empty($cgi->category)) {
    page_title(appconf('digger_title') . ' - ' . db_shift('select category from digger_category where id = ?', $cgi->category));
} else {
    page_title(appconf('digger_title'));
}
template_simple_register('pager', $pg);
echo template_simple('index.spt', array('category' => $cgi->category, 'results' => $res, 'banned_score' => appconf('ban_threshold')));
Example #2
0
 function draw()
 {
     global $cgi;
     if (!isset($cgi->orderBy)) {
         $cgi->orderBy = array_shift(array_keys($this->fields));
     }
     if (!isset($cgi->sort)) {
         $cgi->sort = 'asc';
     }
     if (!isset($cgi->offset)) {
         $cgi->offset = 0;
     }
     $list = $this->getList();
     if (!$list) {
         return false;
     }
     if (!$this->primary_key) {
         $this->primary_key = array_shift(array_keys($this->fields));
     }
     $this->list = array();
     foreach ($list as $row) {
         if (!is_object($row)) {
             $row = (object) $row;
         }
         $this->list[$row->{$this->primary_key}] = $row;
     }
     $pg = new Pager($cgi->offset, $this->limit, $this->total);
     $pg->setUrl(site_current() . '?orderBy=%s&sort=%s' . $this->rememberParams(), $cgi->orderBy, $cgi->sort);
     $pg->getInfo();
     $headers = array();
     foreach ($this->fields as $name => $display) {
         $headers[$name] = new TableHeader($name, $display);
     }
     $this->headers =& $headers;
     $this->first_field = array_shift(array_keys($this->fields));
     template_simple_register('pager', $pg);
     return template_simple($this->template, $this);
 }