/libraries/cms/toolbar/button/popup.php

https://bitbucket.org/eternaware/joomus · PHP · 104 lines · 32 code · 10 blank · 62 comment · 1 complexity · 766713d410cd6ac49fff94b0e8c3da56 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Libraries
  4. * @subpackage Toolbar
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * Renders a popup window button
  12. *
  13. * @package Joomla.Libraries
  14. * @subpackage Toolbar
  15. * @since 3.0
  16. */
  17. class JToolbarButtonPopup extends JToolbarButton
  18. {
  19. /**
  20. * Button type
  21. *
  22. * @var string
  23. */
  24. protected $_name = 'Popup';
  25. /**
  26. * Fetch the HTML for the button
  27. *
  28. * @param string $type Unused string, formerly button type.
  29. * @param string $name Button name
  30. * @param string $text The link text
  31. * @param string $url URL for popup
  32. * @param integer $width Width of popup
  33. * @param integer $height Height of popup
  34. * @param integer $top Top attribute.
  35. * @param integer $left Left attribute
  36. * @param string $onClose JavaScript for the onClose event.
  37. *
  38. * @return string HTML string for the button
  39. *
  40. * @since 3.0
  41. */
  42. public function fetchButton($type = 'Popup', $name = '', $text = '', $url = '', $width = 640, $height = 480, $top = 0, $left = 0, $onClose = '')
  43. {
  44. JHtml::script('jui/cms.js', false, true);
  45. $text = JText::_($text);
  46. $class = 'cog';
  47. $doTask = $this->_getCommand($name, $url, $width, $height, $top, $left);
  48. $html = "<button class=\"btn btn-small\" data-toggle=\"collapse\" data-target=\"#modal-" . $name . "\" rel=\"{onClose: function() {" . $onClose
  49. . "}}\" onClick=\"Joomla.setcollapse('$url', '$name', '$height');\">\n";
  50. $html .= "<i class=\"icon-$class\">\n";
  51. $html .= "</i>\n";
  52. $html .= "$text\n";
  53. $html .= "</button>\n";
  54. return $html;
  55. }
  56. /**
  57. * Get the button id
  58. *
  59. * Redefined from JButton class
  60. *
  61. * @param string $type Button type
  62. * @param string $name Button name
  63. *
  64. * @return string Button CSS Id
  65. *
  66. * @since 3.0
  67. */
  68. public function fetchId($type, $name)
  69. {
  70. return $this->_parent->getName() . '-' . "popup-$name";
  71. }
  72. /**
  73. * Get the JavaScript command for the button
  74. *
  75. * @param string $name Button name
  76. * @param string $url URL for popup
  77. * @param integer $width Unused formerly width.
  78. * @param integer $height Unused formerly height.
  79. * @param integer $top Unused formerly top attribute.
  80. * @param integer $left Unused formerly left attribure.
  81. *
  82. * @return string JavaScript command string
  83. *
  84. * @since 3.0
  85. */
  86. protected function _getCommand($name, $url, $width, $height, $top, $left)
  87. {
  88. if (substr($url, 0, 4) !== 'http')
  89. {
  90. $url = JURI::base() . $url;
  91. }
  92. return $url;
  93. }
  94. }