Author: Michael Slusarz (slusarz@horde.org)
Exemplo n.º 1
0
Arquivo: List.php Projeto: horde/horde
 /**
  * Renders the view.
  *
  * @param Horde_PageOutput $output  The output object.
  *
  * @return string  The HTML needed to render the view.
  */
 public function render($output)
 {
     global $injector, $prefs;
     $output->addScriptFile('tooltips.js', 'horde');
     $output->addScriptFile('scriptaculous/effects.js', 'horde');
     $output->addScriptFile('quickfinder.js', 'horde');
     $output->header(array('title' => $this->_title));
     $tabs = new Horde_Core_Ui_Tabs('tab_name', $this->_vars);
     if (!$GLOBALS['prefs']->isLocked('show_completed')) {
         $listurl = Horde::url('list.php');
         $tabs->addTab(_("_All tasks"), $listurl->add('show_completed', Nag::VIEW_ALL), Nag::VIEW_ALL);
         $tabs->addTab(_("Incom_plete tasks"), $listurl->add('show_completed', Nag::VIEW_INCOMPLETE), Nag::VIEW_INCOMPLETE);
         $tabs->addTab(_("_Future tasks"), $listurl->add('show_completed', Nag::VIEW_FUTURE), Nag::VIEW_FUTURE);
         $tabs->addTab(_("_Completed tasks"), $listurl->add('show_completed', Nag::VIEW_COMPLETE), Nag::VIEW_COMPLETE);
     }
     foreach (Nag::listTasklists() as $list) {
         if ($list->get('issmart')) {
             $tabs->addTab($list->get('name'), $listurl->add(array('actionID' => 'smart', 'list' => $list->getName())), array('img' => 'search.png', 'tabname' => $list->getName()));
         }
     }
     // Set up the view
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addHelper(new Nag_View_Helper_List($view));
     $view->tasks = $this->_tasks;
     $view->tabs = $tabs->render($this->_vars->get('tab_name', $prefs->getValue('show_completed')));
     $view->browser = empty($this->_smartShare) && $this->_showTagBrowser ? $this->_getRelatedTags() . $this->_getTagTrail() : '';
     $view->title = $this->_title;
     $view->sortby = $prefs->getValue('sortby');
     $view->sortdir = $prefs->getValue('sortdir');
     $view->sortdirclass = $view->sortdir ? 'sortup' : 'sortdown';
     $view->dateFormat = $prefs->getValue('date_format');
     $view->columns = @unserialize($prefs->getValue('tasklist_columns'));
     $view->smartShare = $this->_smartShare;
     $view->haveSearch = $this->_haveSearch;
     $view->tab_name = $this->_vars->get('tab_name', $prefs->getValue('show_completed'));
     if (empty($view->columns)) {
         $view->columns = array();
     }
     $view->dynamic_sort = true;
     $view->baseurl = Horde::url('list.php');
     if ($this->_vars->actionID == 'search_tasks') {
         $view->baseurl->add(array('actionID' => 'search_tasks', 'search_pattern' => $search_pattern, 'search_name' => $search_name ? 'on' : 'off', 'search_desc' => $search_desc ? 'on' : 'off'));
     }
     $view->tasks->reset();
     Horde::startBuffer();
     Nag::status();
     echo $view->render('list');
     $output->footer();
     return Horde::endBuffer();
 }
Exemplo n.º 2
0
Arquivo: List.php Projeto: horde/horde
 /**
  * Renders the view.
  *
  * @param Horde_PageOutput $output  The output object.
  *
  * @return string  The HTML needed to render the view.
  */
 public function render(Horde_PageOutput $output)
 {
     global $prefs, $injector, $registry, $mnemo_shares;
     $output->addScriptFile('tables.js', 'horde');
     $output->addScriptFile('quickfinder.js', 'horde');
     $output->addScriptFile('list.js');
     $output->header(array('title' => $this->_title));
     $view = $injector->createInstance('Horde_View');
     $view->count = count($this->_notes);
     $view->searchImg = Horde::img('search.png', _("Search"), '');
     $view->searchUrl = Horde::url('search.php');
     $view->title = $this->_title;
     $view->browser = $this->_showTagBrowser ? $this->_getRelatedTags() . $this->_getTagTrail() : '';
     if (count($this->_notes)) {
         $sortby = $prefs->getValue('sortby');
         $sortdir = $prefs->getValue('sortdir');
         $output->addInlineJsVars(array('Mnemo_List.ajaxUrl' => $registry->getServiceLink('ajax', 'mnemo')->url . 'setPrefValue'));
         $view->editImg = Horde::img('edit.png', _("Edit Note"), '');
         $view->showNotepad = $prefs->getValue('show_notepad');
         $view->sortdirclass = $sortdir ? 'sortup' : 'sortdown';
         $view->headers = array();
         if ($view->showNotepad) {
             $view->headers[] = array('id' => 's' . Mnemo::SORT_NOTEPAD, 'sorted' => $sortby == Mnemo::SORT_NOTEPAD, 'width' => '2%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', Mnemo::SORT_NOTEPAD), 'class' => 'sortlink', 'title' => _("Notepad"))));
         }
         $view->headers[] = array('id' => 's' . MNEMO::SORT_DESC, 'sorted' => $sortby == MNEMO::SORT_DESC, 'width' => '80%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', Mnemo::SORT_DESC), 'class' => 'sortlink', 'title' => _("No_te"))));
         $view->headers[] = array('id' => 's' . MNEMO::SORT_MOD_DATE, 'sorted' => $sortby == Mnemo::SORT_MOD_DATE, 'width' => '2%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', MNEMO::SORT_MOD_DATE), 'class' => 'sortlink', 'title' => _("Date"))));
         foreach ($this->_notes as $memo_id => &$memo) {
             try {
                 $share = $mnemo_shares->getShare($memo['memolist_id']);
             } catch (Horde_Share_Exception $e) {
                 $notification->push($e);
                 continue;
             }
             if ($view->showNotepad) {
                 $memo['notepad'] = Mnemo::getLabel($share);
             }
             if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $label = sprintf(_("Edit \"%s\""), $memo['desc']);
                 $memo['edit'] = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'], 'actionID' => 'modify_memo'))->link(array('title' => $label)) . Horde::img('edit.png', $label, '') . '</a>';
             }
             $memo['link'] = Horde::linkTooltip(Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a>';
             // Get memo's most recent modification date or, if nonexistent,
             // the creation (add) date
             if (isset($memo['modified'])) {
                 $modified = $memo['modified'];
             } elseif (isset($memo['created'])) {
                 $modified = $memo['created'];
             } else {
                 $modified = null;
             }
             if ($modified) {
                 $memo['modifiedStamp'] = $modified->timestamp();
                 $memo['modifiedString'] = $modified->strftime($prefs->getValue('date_format'));
             } else {
                 $memo['modifiedStamp'] = $memo['modifiedString'] = '';
             }
         }
     }
     Horde::startBuffer();
     echo $view->render('list/header');
     if (count($this->_notes)) {
         echo $view->render('list/memo_headers');
         echo $view->renderPartial('list/summary', array('collection' => array_values($this->_notes)));
         echo $view->render('list/memo_footers');
     } else {
         echo $view->render('list/empty');
     }
     $output->footer();
     return Horde::endBuffer();
 }