/libraries/cms/toolbar/button/popup.php
PHP | 104 lines | 32 code | 10 blank | 62 comment | 1 complexity | 766713d410cd6ac49fff94b0e8c3da56 MD5 | raw file
Possible License(s): LGPL-2.1
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 10defined('JPATH_PLATFORM') or die; 11 12/** 13 * Renders a popup window button 14 * 15 * @package Joomla.Libraries 16 * @subpackage Toolbar 17 * @since 3.0 18 */ 19class JToolbarButtonPopup extends JToolbarButton 20{ 21 /** 22 * Button type 23 * 24 * @var string 25 */ 26 protected $_name = 'Popup'; 27 28 /** 29 * Fetch the HTML for the button 30 * 31 * @param string $type Unused string, formerly button type. 32 * @param string $name Button name 33 * @param string $text The link text 34 * @param string $url URL for popup 35 * @param integer $width Width of popup 36 * @param integer $height Height of popup 37 * @param integer $top Top attribute. 38 * @param integer $left Left attribute 39 * @param string $onClose JavaScript for the onClose event. 40 * 41 * @return string HTML string for the button 42 * 43 * @since 3.0 44 */ 45 public function fetchButton($type = 'Popup', $name = '', $text = '', $url = '', $width = 640, $height = 480, $top = 0, $left = 0, $onClose = '') 46 { 47 JHtml::script('jui/cms.js', false, true); 48 49 $text = JText::_($text); 50 $class = 'cog'; 51 $doTask = $this->_getCommand($name, $url, $width, $height, $top, $left); 52 53 $html = "<button class=\"btn btn-small\" data-toggle=\"collapse\" data-target=\"#modal-" . $name . "\" rel=\"{onClose: function() {" . $onClose 54 . "}}\" onClick=\"Joomla.setcollapse('$url', '$name', '$height');\">\n"; 55 $html .= "<i class=\"icon-$class\">\n"; 56 $html .= "</i>\n"; 57 $html .= "$text\n"; 58 59 $html .= "</button>\n"; 60 61 return $html; 62 } 63 64 /** 65 * Get the button id 66 * 67 * Redefined from JButton class 68 * 69 * @param string $type Button type 70 * @param string $name Button name 71 * 72 * @return string Button CSS Id 73 * 74 * @since 3.0 75 */ 76 public function fetchId($type, $name) 77 { 78 return $this->_parent->getName() . '-' . "popup-$name"; 79 } 80 81 /** 82 * Get the JavaScript command for the button 83 * 84 * @param string $name Button name 85 * @param string $url URL for popup 86 * @param integer $width Unused formerly width. 87 * @param integer $height Unused formerly height. 88 * @param integer $top Unused formerly top attribute. 89 * @param integer $left Unused formerly left attribure. 90 * 91 * @return string JavaScript command string 92 * 93 * @since 3.0 94 */ 95 protected function _getCommand($name, $url, $width, $height, $top, $left) 96 { 97 if (substr($url, 0, 4) !== 'http') 98 { 99 $url = JURI::base() . $url; 100 } 101 102 return $url; 103 } 104}