DialogContainer.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 ZendX
  16. * @package ZendX_JQuery
  17. * @subpackage View
  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. * @version $Id$
  21. */
  22. /**
  23. * @see ZendX_JQuery_View_Helper_UiWidget
  24. */
  25. require_once "ZendX/JQuery/View/Helper/UiWidget.php";
  26. /**
  27. * jQuery Dialog View Helper
  28. *
  29. * @package ZendX_JQuery
  30. * @subpackage View
  31. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class ZendX_JQuery_View_Helper_DialogContainer extends ZendX_JQuery_View_Helper_UiWidget
  35. {
  36. /**
  37. * Create a jQuery UI Dialog filled with the given content
  38. *
  39. * @link http://docs.jquery.com/UI/Dialog
  40. * @param string $id
  41. * @param string $content
  42. * @param array $params
  43. * @param array $attribs
  44. * @return string
  45. */
  46. public function dialogContainer($id, $content, $params=array(), $attribs=array())
  47. {
  48. if (!array_key_exists('id', $attribs)) {
  49. $attribs['id'] = $id;
  50. }
  51. if(count($params) > 0) {
  52. $params = ZendX_JQuery::encodeJson($params);
  53. } else {
  54. $params = "{}";
  55. }
  56. $js = sprintf('%s("#%s").dialog(%s);',
  57. ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
  58. $attribs['id'],
  59. $params
  60. );
  61. $this->jquery->addOnLoad($js);
  62. $html = '<div'
  63. . $this->_htmlAttribs($attribs)
  64. . '>'
  65. . $content
  66. . '</div>';
  67. return $html;
  68. }
  69. }