PageRenderTime 41ms CodeModel.GetById 36ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/zf/library/Zend/Form/Decorator/Tooltip.php

http://github.com/eryx/php-framework-benchmark
PHP | 58 lines | 15 code | 4 blank | 39 comment | 2 complexity | 1ef88b942f5c929546c07314b9c45403 MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-2-Clause
 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_Form
17 * @subpackage Decorator
18 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20 */
21
22/** Zend_Form_Decorator_Abstract */
23require_once 'Zend/Form/Decorator/Abstract.php';
24
25/**
26 * Zend_Form_Decorator_Tooltip
27 *
28 * Will translate the title attribute, if available
29 *
30 * @category   Zend
31 * @package    Zend_Form
32 * @subpackage Decorator
33 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
34 * @license    http://framework.zend.com/license/new-bsd     New BSD License
35 * @version    $Id: Tooltip.php$
36 */
37class Zend_Form_Decorator_Tooltip extends Zend_Form_Decorator_Abstract
38{
39    /**
40     * Translates the title attribute if it is available, if the translator is available
41     * and if the translator is not disable on the element being rendered.
42     *
43     * @param string $content
44     * @return string
45     */
46    public function render($content)
47    {
48        if (null !== ($title = $this->getElement()->getAttrib('title'))) {
49            if (null !== ($translator = $this->getElement()->getTranslator())) {
50                $title = $translator->translate($title);
51            }
52        }
53
54        $this->getElement()->setAttrib('title', $title);
55        return $content;
56    }
57
58}