1<?php 2/** 3 * Base class for minimal view pages. 4 * 5 * Copyright 2012-2017 Horde LLC (http://www.horde.org/) 6 * 7 * See the enclosed file COPYING for license information (GPL). If you 8 * did not receive this file, see http://www.horde.org/licenses/gpl. 9 * 10 * @author Michael Slusarz <slusarz@horde.org> 11 * @category Horde 12 * @license http://www.horde.org/licenses/gpl GPL 13 * @package IMP 14 */ 15abstract class IMP_Minimal_Base 16{ 17 /** 18 * @var IMP_Indices_Mailbox 19 */ 20 public $indices; 21 22 /** 23 * @var string 24 */ 25 public $title; 26 27 /** 28 * @var Horde_Variables 29 */ 30 public $vars; 31 32 /** 33 * @var Horde_View 34 */ 35 public $view; 36 37 /** 38 * @var array 39 */ 40 protected $_pages = array( 41 'header' 42 ); 43 44 /** 45 */ 46 public function __construct(Horde_Variables $vars) 47 { 48 $this->vars = $vars; 49 50 $this->indices = new IMP_Indices_Mailbox($vars); 51 52 $this->view = new Horde_View(array( 53 'templatePath' => IMP_TEMPLATES . '/minimal' 54 )); 55 $this->view->addHelper('Text'); 56 57 $this->_init(); 58 } 59 60 /** 61 */ 62 public function render() 63 { 64 foreach ($this->_pages as $val) { 65 echo $this->view->render($val); 66 } 67 } 68 69 /** 70 * Output the menu. 71 * 72 * @param string $page The current page ('compose', 'folders', 'mailbox', 73 * 'message', 'search'). 74 * @param array $items Additional menu items to add to the menu. First 75 * element is label, second is URL to link to. 76 * 77 * @return string The menu. 78 */ 79 public function getMenu($page, $items = array()) 80 { 81 if (!in_array($page, array('mailbox', 'message')) || 82 !$this->indices->mailbox->inbox) { 83 $items[] = array(_("Inbox"), IMP_Minimal_Mailbox::url(array('mailbox' => 'INBOX'))); 84 } 85 86 if (!in_array($page, array('compose', 'search')) && 87 IMP_Compose::canCompose()) { 88 $items[] = array(_("New Message"), IMP_Minimal_Compose::url()); 89 } 90 91 if (!in_array($page, array('folders', 'search')) && 92 $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)) { 93 $items[] = array(_("Folders"), IMP_Minimal_Folders::url()); 94 } 95 96 $items[] = array(_("Log out"), $GLOBALS['registry']->getServiceLink('logout', 'imp')->setRaw(false)); 97 98 $menu = new Horde_Menu(); 99 foreach ($menu->getSiteLinks() as $menuitem) { 100 if ($menuitem != 'separator') { 101 $items[] = array($menuitem['text'], $menuitem['url']); 102 } 103 } 104 105 return $items; 106 } 107 108 /** 109 */ 110 abstract protected function _init(); 111 112 /** 113 */ 114 static public function url(array $opts = array()) 115 { 116 } 117 118} 119