Overview

Packages

  • Mnemo
  • None

Classes

  • Mnemo_Application
  • Mnemo_Block_Note
  • Mnemo_Block_Summary
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  */
  4: class Mnemo_Block_Note extends Horde_Core_Block
  5: {
  6:     /**
  7:      */
  8:     private $_notename = '';
  9: 
 10:     /**
 11:      */
 12:     public function __construct($app, $params = array())
 13:     {
 14:         parent::__construct($app, $params);
 15: 
 16:         $this->_name = _("View note");
 17:     }
 18: 
 19:     /**
 20:      */
 21:     protected function _params()
 22:     {
 23:         global $prefs;
 24:         $memos = Mnemo::listMemos($prefs->getValue('sortby'),
 25:                                   $prefs->getValue('sortdir'));
 26:         $notes = array();
 27:         foreach ($memos as $memo) {
 28:             $notes[$memo['uid']] = $memo['desc'];
 29:         }
 30: 
 31:         return array(
 32:             'note_uid' => array(
 33:                 'type' => 'enum',
 34:                 'name' => _("Show this note"),
 35:                 'values' => $notes,
 36:             )
 37:         );
 38:     }
 39: 
 40:     /**
 41:      */
 42:     protected function _title()
 43:     {
 44:         return htmlspecialchars($this->_getTitle());
 45:     }
 46: 
 47:     /**
 48:      */
 49:     protected function _content()
 50:     {
 51:         $memo = $this->_getNote();
 52:         $html = '<div id="noteBody' . $memo['memo_id'] . '" class="noteBody">';
 53:         $body = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
 54:         try {
 55:             $body = Horde::callHook('format_description', array($body), 'mnemo', $body);
 56:         } catch (Horde_Exception_HookNotSet $e) {}
 57:         $html .= $body . '</div>';
 58:         $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create(array('mnemo', 'EditNote'), array(
 59:             'domid' => 'noteBody' . $memo['memo_id'],
 60:             'id' => $this->_params['note_uid'],
 61:             'rows' => substr_count($memo['body'], "\n"),
 62:         ));
 63:         return $html;
 64:     }
 65: 
 66:     /**
 67:      */
 68:     private function _getNote()
 69:     {
 70:         if (!isset($this->_params['note_uid'])) {
 71:             throw new Horde_Exception(_("No note loaded"));
 72:         }
 73: 
 74:         $uid = $this->_params['note_uid'];
 75:         $storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create();
 76:         try {
 77:             $memo = $storage->getByUID($uid);
 78:         } catch (Mnemo_Exception $e) {
 79:             if (!empty($this->_notename)) {
 80:                 $msg = sprintf(_("An error occurred displaying %s"), $this->_notename);
 81:             } else {
 82:                 $msg = _("An error occurred displaying the note");
 83:             }
 84:             throw new Horde_Exception($msg);
 85:         }
 86: 
 87:         return $memo;
 88:     }
 89: 
 90:     /**
 91:      */
 92:     private function _getTitle()
 93:     {
 94:         if (empty($this->_notename)) {
 95:             $note = $this->_getNote();
 96:             $this->_notename = $note['desc'];
 97:         }
 98:         return $this->_notename;
 99:     }
100: }
101: 
API documentation generated by ApiGen