1: <?php
2: 3:
4: class Mnemo_Block_Summary extends Horde_Core_Block
5: {
6: 7:
8: public function __construct($app, $params = array())
9: {
10: parent::__construct($app, $params);
11:
12: $this->_name = _("Notes Summary");
13: }
14:
15: 16:
17: protected function _title()
18: {
19: global $registry;
20:
21: $label = !empty($this->_params['block_title'])
22: ? $this->_params['block_title']
23: : $registry->get('name');
24:
25: return Horde::link(Horde::url($registry->getInitialPage(), true))
26: . htmlspecialchars($label) . '</a>';
27: }
28:
29: 30:
31: protected function _params()
32: {
33: $cManager = new Horde_Prefs_CategoryManager();
34: $categories = array();
35: foreach ($cManager->get() as $c) {
36: $categories[$c] = $c;
37: }
38:
39: return array(
40: 'show_actions' => array(
41: 'type' => 'checkbox',
42: 'name' => _("Show action buttons?"),
43: 'default' => 1
44: ),
45: 'show_notepad' => array(
46: 'type' => 'checkbox',
47: 'name' => _("Show notepad name?"),
48: 'default' => 1
49: ),
50: 'show_categories' => array(
51: 'type' => 'multienum',
52: 'name' => _("Show notes from these categories"),
53: 'default' => array(),
54: 'values' => $categories
55: )
56: );
57: }
58:
59: 60:
61: protected function _content()
62: {
63: global $registry, $prefs;
64:
65: $cManager = new Horde_Prefs_CategoryManager();
66: $colors = $cManager->colors();
67: $fgcolors = $cManager->fgColors();
68:
69: if (!empty($this->_params['show_notepad'])) {
70: $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create();
71: }
72:
73: $html = '';
74: $memos = Mnemo::listMemos($prefs->getValue('sortby'),
75: $prefs->getValue('sortdir'));
76: foreach ($memos as $id => $memo) {
77: if (!empty($this->_params['show_categories']) &&
78: !in_array($memo['category'], $this->_params['show_categories'])) {
79: continue;
80: }
81:
82: $html .= '<tr>';
83:
84: if (!empty($this->_params['show_actions'])) {
85: $editImg = Horde_Themes::img('edit.png');
86: $editurl = Horde_Util::addParameter(
87: 'memo.php',
88: array('memo' => $memo['memo_id'],
89: 'memolist' => $memo['memolist_id']));
90: $html .= '<td width="1%">'
91: . Horde::link(htmlspecialchars(Horde::url(Horde_Util::addParameter($editurl, 'actionID', 'modify_memo'), true)), _("Edit Note"))
92: . Horde::img($editImg, _("Edit Note"))
93: . '</a></td>';
94: }
95:
96: if (!empty($this->_params['show_notepad'])) {
97: $owner = $memo['memolist_id'];
98: $share = $shares->getShare($owner);
99: $owner = $share->get('name');
100: $html .= '<td>' . htmlspecialchars($owner) . '</td>';
101: }
102:
103: $viewurl = Horde_Util::addParameter(
104: 'view.php',
105: array('memo' => $memo['memo_id'],
106: 'memolist' => $memo['memolist_id']));
107:
108: $html .= '<td>'
109: . Horde::linkTooltip(
110: htmlspecialchars(Horde::url($viewurl, true)),
111: '', '', '', '',
112: $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '')
113: . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>')
114: . '</a></td><td width="1%" class="base-category" style="'
115: . Mnemo::getCssStyle($memo['category']) . '">'
116: . htmlspecialchars($memo['category'] ? $memo['category'] : _("Unfiled"))
117: . "</td></tr>\n";
118: }
119:
120: if (!$memos) {
121: return '<p><em>' . _("No notes to display") . '</em></p>';
122: }
123:
124: return '<table cellspacing="0" width="100%" class="linedRow">' . $html
125: . '</table>';
126: }
127:
128: }
129: