From e7ba4e2b2ebeb23751af731aa1717cbcc9b4c4d0 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 18 Jul 2010 16:17:18 -0400 Subject: [PATCH] Initial note display block (for "pinning" a specific note to a portal page) Anyone up for adding ajax edit capability to it? --- mnemo/lib/Block/note.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 mnemo/lib/Block/note.php diff --git a/mnemo/lib/Block/note.php b/mnemo/lib/Block/note.php new file mode 100644 index 000000000..4c1ff4488 --- /dev/null +++ b/mnemo/lib/Block/note.php @@ -0,0 +1,84 @@ +getValue('sortby'), + $prefs->getValue('sortdir')); + $notes = array(); + foreach ($memos as $memo) { + $notes[$memo['uid']] = $memo['desc']; + } + + return array( + 'note_uid' => array( + 'type' => 'enum', + 'name' => _("Show this note"), + 'values' => $notes, + ), + 'note_name' => array( + 'type' => 'hidden', + ), + ); + } + + protected function _title() + { + return htmlspecialchars($this->_getTitle()); + } + + protected function _content() + { + $memo = $this->_getNote(); + + $html = '
'; + $body = Horde_Text_Filter::filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'class' => null)); + try { + $body = Horde::callHook('format_description', array($body), 'mnemo', $body); + } catch (Horde_Exception_HookNotSet $e) {} + $html .= $body . '
'; + + return $html; + } + + private function _getNote() + { + if (!isset($this->_params['note_uid'])) { + throw new Horde_Block_Exception(_("No note loaded")); + } + + $uid = $this->_params['note_uid']; + $storage = Mnemo_Driver::singleton(); + $memo = $storage->getByUID($uid); + if (is_a($memo, 'PEAR_Error')) { + if (!empty($this->_params['note_name'])) { + $msg = sprintf(_("An error occurred displaying %s"), $this->_params['note_name']); + } else { + $msg = _("An error occurred displaying the note"); + } + throw new Horde_Block_Exception($msg); + } + + return $memo; + } + + private function _getTitle() + { + if (empty($this->_params['note_name'])) { + $note = $this->_getNote(); + $this->_params['note_name'] = $note['desc']; + } + return $this->_params['note_name']; + } +} -- 2.11.0