1<?php 2/** 3 * View helper class for smartmobile pages. 4 * 5 * Copyright 2012-2017 Horde LLC (http://www.horde.org/) 6 * 7 * See the enclosed file COPYING for license information (LGPL). If you 8 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 9 * 10 * @author Michael Slusarz <slusarz@horde.org> 11 * @category Horde 12 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 13 * @package Core 14 */ 15class Horde_Core_Smartmobile_View_Helper extends Horde_View_Helper_Base 16{ 17 /** 18 * Output the title bar. 19 * 20 * @param array $params A list of parameters: 21 * - backlink: (mixed) Show backlink. If an array, first is URL to link 22 * to, second is label. If true, shows a basic Back link. 23 * - logout: (boolean) If true, show logout link. 24 * - portal: (boolean) If true, show portal link. 25 * - taptoggle: (boolean) Enable tap-toggle? 26 * - title: (string) If given, used as the title. 27 * 28 * @return string Generated HTML code. 29 */ 30 public function smartmobileHeader(array $params = array()) 31 { 32 global $registry; 33 34 $out = '<div data-position="fixed" data-role="header" data-tap-toggle="' . 35 (empty($params['taptoggle']) ? 'false' : 'true') . 36 '">'; 37 38 if (!empty($params['backlink'])) { 39 if (is_array($params['backlink'])) { 40 $out .= '<a class="smartmobile-back ui-btn-left" href="' . 41 $params['backlink'][0] . 42 '" data-icon="arrow-l" data-direction="reverse">' . 43 $params['backlink'][1] . '</a>'; 44 } else { 45 $out .= '<a class="smartmobile-back ui-btn-left" href="#" ' . 46 'data-icon="arrow-l" data-rel="back">' . Horde_Core_Translation::t("Back") . '</a>'; 47 } 48 } 49 50 if (!empty($params['portal']) && 51 ($portal = $registry->getServiceLink('portal', 'horde')->setRaw(false))) { 52 $out .= '<a class="smartmobile-portal ui-btn-left" ' . 53 'data-ajax="false" href="' . $portal . '">' . 54 Horde_Core_Translation::t("Applications") . '</a>'; 55 } 56 57 if (isset($params['title']) && strlen($params['title'])) { 58 $out .= '<h1 class="smartmobile-title">' . $params['title'] . '</h1>'; 59 } 60 61 if (!empty($params['logout']) && 62 $registry->showService('logout') && 63 ($logout = $registry->getServiceLink('logout')->setRaw(false))) { 64 $out .= '<a class="smartmobile-logout ui-btn-right" href="' . 65 $logout . 66 '" data-ajax="false" data-theme="e" data-icon="delete">' . 67 Horde_Core_Translation::t("Log out") . '</a>'; 68 } 69 70 return $out . '</div>'; 71 } 72 73} 74