web/lib/Zend/View/Helper/UserAgent.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_View
       
    17  * @subpackage Helper
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  */
       
    21 
       
    22 /** Zend_View_Helper_Abstract */
       
    23 require_once 'Zend/View/Helper/Abstract.php';
       
    24 
       
    25 /**
       
    26  * Helper for interacting with UserAgent instance
       
    27  *
       
    28  * @package    Zend_View
       
    29  * @subpackage Helper
       
    30  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    32  */
       
    33 class Zend_View_Helper_UserAgent extends Zend_View_Helper_Abstract
       
    34 {
       
    35     /**
       
    36      * Helper method: retrieve or set UserAgent instance
       
    37      * 
       
    38      * @param  null|Zend_Http_UserAgent $userAgent 
       
    39      * @return Zend_Http_UserAgent
       
    40      */
       
    41     public function userAgent(Zend_Http_UserAgent $userAgent = null)
       
    42     {
       
    43         if (null !== $userAgent) {
       
    44             $this->setUserAgent($userAgent);
       
    45         }
       
    46         return $this->getUserAgent();
       
    47     }
       
    48 
       
    49     /**
       
    50      * Set UserAgent instance
       
    51      * 
       
    52      * @param  Zend_Http_UserAgent $userAgent 
       
    53      * @return Zend_View_Helper_UserAgent
       
    54      */
       
    55     public function setUserAgent(Zend_Http_UserAgent $userAgent)
       
    56     {
       
    57         $this->_userAgent = $userAgent;
       
    58         return $this;
       
    59     }
       
    60 
       
    61     /**
       
    62      * Retrieve UserAgent instance
       
    63      *
       
    64      * If none set, instantiates one using no configuration
       
    65      * 
       
    66      * @return Zend_Http_UserAgent
       
    67      */
       
    68     public function getUserAgent()
       
    69     {
       
    70         if (null === $this->_userAgent) {
       
    71             require_once 'Zend/Http/UserAgent.php';
       
    72             $this->setUserAgent(new Zend_Http_UserAgent());
       
    73         }
       
    74         return $this->_userAgent;
       
    75     }
       
    76 }