/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

  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. /** Zend_Form_Decorator_Abstract */
  22. require_once 'Zend/Form/Decorator/Abstract.php';
  23. /**
  24. * Zend_Form_Decorator_Tooltip
  25. *
  26. * Will translate the title attribute, if available
  27. *
  28. * @category Zend
  29. * @package Zend_Form
  30. * @subpackage Decorator
  31. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. * @version $Id: Tooltip.php$
  34. */
  35. class Zend_Form_Decorator_Tooltip extends Zend_Form_Decorator_Abstract
  36. {
  37. /**
  38. * Translates the title attribute if it is available, if the translator is available
  39. * and if the translator is not disable on the element being rendered.
  40. *
  41. * @param string $content
  42. * @return string
  43. */
  44. public function render($content)
  45. {
  46. if (null !== ($title = $this->getElement()->getAttrib('title'))) {
  47. if (null !== ($translator = $this->getElement()->getTranslator())) {
  48. $title = $translator->translate($title);
  49. }
  50. }
  51. $this->getElement()->setAttrib('title', $title);
  52. return $content;
  53. }
  54. }