1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12: class Trean_Block_Highestrated extends Horde_Core_Block
13: {
14: 15:
16: public function __construct($app, $params = array())
17: {
18: parent::__construct($app, $params);
19:
20: $this->_name = _("Highest-rated Bookmarks");
21: }
22:
23: 24:
25: protected function _params()
26: {
27: return array(
28: 'rows' => array(
29: 'name' => _("Number of bookmarks to show"),
30: 'type' => 'enum',
31: 'default' => '10',
32: 'values' => array(
33: '10' => _("10 rows"),
34: '15' => _("15 rows"),
35: '25' => _("25 rows")
36: )
37: ),
38: 'template' => array(
39: 'name' => _("Template"),
40: 'type' => 'enum',
41: 'default' => '1line',
42: 'values' => array(
43: 'standard' => _("3 Line"),
44: '2line' => _("2 Line"),
45: '1line' => _("1 Line")
46: )
47: )
48: );
49: }
50:
51: 52:
53: protected function _title()
54: {
55: return Horde::url($GLOBALS['registry']->getInitialPage(), true)->link() . $this->getName() . '</a>';
56: }
57:
58: 59:
60: protected function _content()
61: {
62: require_once dirname(__FILE__) . '/../base.php';
63: require_once TREAN_TEMPLATES . '/star_rating_helper.php';
64:
65: $template = TREAN_TEMPLATES . '/block/' . $this->_params['template'] . '.inc';
66:
67: $html = '';
68: $bookmarks = $GLOBALS['trean_shares']->sortBookmarks('rating', 1, 0, $this->_params['rows']);
69: foreach ($bookmarks as $bookmark) {
70: ob_start();
71: require $template;
72: $html .= '<div class="linedRow">' . ob_get_clean() . '</div>';
73: }
74:
75: if (!$bookmarks) {
76: return '<p><em>' . _("No bookmarks to display") . '</em></p>';
77: }
78:
79: return $html;
80: }
81:
82: }
83: