HtmlObject.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_View_Helper_HtmlElement
  24. */
  25. require_once 'Zend/View/Helper/HtmlElement.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_View
  29. * @subpackage Helper
  30. * @copyright Copyright (c) 2005-2015 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_HtmlObject extends Zend_View_Helper_HtmlElement
  34. {
  35. /**
  36. * Output an object set
  37. *
  38. * @param string $data The data file
  39. * @param string $type Data file type
  40. * @param array $attribs Attribs for the object tag
  41. * @param array $params Params for in the object tag
  42. * @param string $content Alternative content for object
  43. * @return string
  44. */
  45. public function htmlObject($data, $type, array $attribs = array(), array $params = array(), $content = null)
  46. {
  47. // Merge data and type
  48. $attribs = array_merge(array('data' => $data,
  49. 'type' => $type), $attribs);
  50. // Params
  51. $paramHtml = array();
  52. $closingBracket = $this->getClosingBracket();
  53. foreach ($params as $param => $options) {
  54. if (is_string($options)) {
  55. $options = array('value' => $options);
  56. }
  57. $options = array_merge(array('name' => $param), $options);
  58. $paramHtml[] = '<param' . $this->_htmlAttribs($options) . $closingBracket;
  59. }
  60. // Content
  61. if (is_array($content)) {
  62. $content = implode(self::EOL, $content);
  63. }
  64. // Object header
  65. $xhtml = '<object' . $this->_htmlAttribs($attribs) . '>' . self::EOL
  66. . implode(self::EOL, $paramHtml) . self::EOL
  67. . ($content ? $content . self::EOL : '')
  68. . '</object>';
  69. return $xhtml;
  70. }
  71. }