Source for file popup.php

Documentation is available at popup.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Toolbar
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Renders a modal window button
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Toolbar
  17.  * @since       3.0
  18.  */
  19. {
  20.     /**
  21.      * Button type
  22.      *
  23.      * @var    string 
  24.      */
  25.     protected $_name = 'Popup';
  26.  
  27.     /**
  28.      * Fetch the HTML for the button
  29.      *
  30.      * @param   string   $type     Unused string, formerly button type.
  31.      * @param   string   $name     Modal name, used to generate element ID
  32.      * @param   string   $text     The link text
  33.      * @param   string   $url      URL for popup
  34.      * @param   integer  $width    Width of popup
  35.      * @param   integer  $height   Height of popup
  36.      * @param   integer  $top      Top attribute.  [@deprecated  Unused, will be removed in 4.0]
  37.      * @param   integer  $left     Left attribute. [@deprecated  Unused, will be removed in 4.0]
  38.      * @param   string   $onClose  JavaScript for the onClose event.
  39.      * @param   string   $title    The title text
  40.      *
  41.      * @return  string  HTML string for the button
  42.      *
  43.      * @since   3.0
  44.      */
  45.     public function fetchButton($type 'Modal'$name ''$text ''$url ''$width 640$height 480$top 0$left 0,
  46.         $onClose ''$title '')
  47.     {
  48.         // If no $title is set, use the $text element
  49.         if (strlen($title== 0)
  50.         {
  51.             $title $text;
  52.         }
  53.  
  54.         // Store all data to the options array for use with JLayout
  55.         $options array();
  56.         $options['name'trim(JText::_($name)'*?');
  57.         $options['text'JText::_($text);
  58.         $options['title'JText::_($title);
  59.         $options['class'$this->fetchIconClass($name);
  60.         $options['doTask'$this->_getCommand($url);
  61.  
  62.         // Instantiate a new JLayoutFile instance and render the layout
  63.         $layout new JLayoutFile('joomla.toolbar.popup');
  64.  
  65.         $html array();
  66.         $html[$layout->render($options);
  67.  
  68.         // Place modal div and scripts in a new div
  69.         $html['<div class="btn-group" style="width: 0; margin: 0">';
  70.  
  71.         // Build the options array for the modal
  72.         $params array();
  73.         $params['title']  $options['title'];
  74.         $params['url']    $options['doTask'];
  75.         $params['height'$height;
  76.         $params['width']  $width;
  77.         $html[JHtml::_('bootstrap.renderModal''modal-' $name$params);
  78.  
  79.         // If an $onClose event is passed, add it to the modal JS object
  80.         if (strlen($onClose>= 1)
  81.         {
  82.             $html['<script>'
  83.                 . 'jQuery(\'#modal-' $name '\').on(\'hide\', function () {' $onClose ';});'
  84.                 . '</script>';
  85.         }
  86.  
  87.         $html['</div>';
  88.  
  89.         return implode("\n"$html);
  90.     }
  91.  
  92.     /**
  93.      * Get the button id
  94.      *
  95.      * @param   string  $type  Button type
  96.      * @param   string  $name  Button name
  97.      *
  98.      * @return  string    Button CSS Id
  99.      *
  100.      * @since   3.0
  101.      */
  102.     public function fetchId($type$name)
  103.     {
  104.         return $this->_parent->getName('-popup-' $name;
  105.     }
  106.  
  107.     /**
  108.      * Get the JavaScript command for the button
  109.      *
  110.      * @param   string  $url  URL for popup
  111.      *
  112.      * @return  string  JavaScript command string
  113.      *
  114.      * @since   3.0
  115.      */
  116.     private function _getCommand($url)
  117.     {
  118.         if (substr($url04!== 'http')
  119.         {
  120.             $url JUri::base($url;
  121.         }
  122.  
  123.         return $url;
  124.     }
  125. }

Documentation generated on Tue, 19 Nov 2013 15:10:54 +0100 by phpDocumentor 1.4.3