File indexing completed on 2024-12-22 05:36:42

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_Form
0017  * @subpackage Decorator
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_Form_Decorator_Abstract */
0023 // require_once 'Zend/Form/Decorator/Abstract.php';
0024 
0025 /**
0026  * Zend_Form_Decorator_Tooltip
0027  *
0028  * Will translate the title attribute, if available
0029  *
0030  * @category   Zend
0031  * @package    Zend_Form
0032  * @subpackage Decorator
0033  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0034  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0035  * @version    $Id: Tooltip.php$
0036  */
0037 class Zend_Form_Decorator_Tooltip extends Zend_Form_Decorator_Abstract
0038 {
0039     /**
0040      * Translates the title attribute if it is available, if the translator is available
0041      * and if the translator is not disable on the element being rendered.
0042      *
0043      * @param string $content
0044      * @return string
0045      */
0046     public function render($content)
0047     {
0048         if (null !== ($title = $this->getElement()->getAttrib('title'))) {
0049             if (null !== ($translator = $this->getElement()->getTranslator())) {
0050                 $title = $translator->translate($title);
0051             }
0052         }
0053 
0054         $this->getElement()->setAttrib('title', $title);
0055         return $content;
0056     }
0057 
0058 }