File indexing completed on 2024-12-22 05:37:14
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_View 0017 * @subpackage Helper 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** Zend_View_Helper_Abstract */ 0023 // require_once 'Zend/View/Helper/Abstract.php'; 0024 0025 /** 0026 * Helper for interacting with UserAgent instance 0027 * 0028 * @package Zend_View 0029 * @subpackage Helper 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_View_Helper_UserAgent extends Zend_View_Helper_Abstract 0034 { 0035 /** 0036 * UserAgent instance 0037 * 0038 * @var Zend_Http_UserAgent 0039 */ 0040 protected $_userAgent = null; 0041 0042 /** 0043 * Helper method: retrieve or set UserAgent instance 0044 * 0045 * @param null|Zend_Http_UserAgent $userAgent 0046 * @return Zend_Http_UserAgent 0047 */ 0048 public function userAgent(Zend_Http_UserAgent $userAgent = null) 0049 { 0050 if (null !== $userAgent) { 0051 $this->setUserAgent($userAgent); 0052 } 0053 return $this->getUserAgent(); 0054 } 0055 0056 /** 0057 * Set UserAgent instance 0058 * 0059 * @param Zend_Http_UserAgent $userAgent 0060 * @return Zend_View_Helper_UserAgent 0061 */ 0062 public function setUserAgent(Zend_Http_UserAgent $userAgent) 0063 { 0064 $this->_userAgent = $userAgent; 0065 return $this; 0066 } 0067 0068 /** 0069 * Retrieve UserAgent instance 0070 * 0071 * If none set, instantiates one using no configuration 0072 * 0073 * @return Zend_Http_UserAgent 0074 */ 0075 public function getUserAgent() 0076 { 0077 if (null === $this->_userAgent) { 0078 // require_once 'Zend/Http/UserAgent.php'; 0079 $this->setUserAgent(new Zend_Http_UserAgent()); 0080 } 0081 return $this->_userAgent; 0082 } 0083 }