Source for file confirm.php

Documentation is available at confirm.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 standard button with a confirm dialog
  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 = 'Confirm';
  26.  
  27.     /**
  28.      * Fetch the HTML for the button
  29.      *
  30.      * @param   string   $type      Unused string.
  31.      * @param   string   $msg       Message to render
  32.      * @param   string   $name      Name to be used as apart of the id
  33.      * @param   string   $text      Button text
  34.      * @param   string   $task      The task associated with the button
  35.      * @param   boolean  $list      True to allow use of lists
  36.      * @param   boolean  $hideMenu  True to hide the menu on click
  37.      *
  38.      * @return  string   HTML string for the button
  39.      *
  40.      * @since   3.0
  41.      */
  42.     public function fetchButton($type 'Confirm'$msg ''$name ''$text ''$task ''$list true$hideMenu false)
  43.     {
  44.         // Store all data to the options array for use with JLayout
  45.         $options array();
  46.         $options['text'JText::_($text);
  47.         $options['msg'JText::_($msgtrue);
  48.         $options['class'$this->fetchIconClass($name);
  49.         $options['doTask'$this->_getCommand($options['msg']$name$task$list);
  50.  
  51.         // Instantiate a new JLayoutFile instance and render the layout
  52.         $layout new JLayoutFile('joomla.toolbar.confirm');
  53.  
  54.         return $layout->render($options);
  55.     }
  56.  
  57.     /**
  58.      * Get the button CSS Id
  59.      *
  60.      * @param   string   $type      Button type
  61.      * @param   string   $name      Name to be used as apart of the id
  62.      * @param   string   $text      Button text
  63.      * @param   string   $task      The task associated with the button
  64.      * @param   boolean  $list      True to allow use of lists
  65.      * @param   boolean  $hideMenu  True to hide the menu on click
  66.      *
  67.      * @return  string  Button CSS Id
  68.      *
  69.      * @since   3.0
  70.      */
  71.     public function fetchId($type 'Confirm'$name ''$text ''$task ''$list true$hideMenu false)
  72.     {
  73.         return $this->_parent->getName('-' $name;
  74.     }
  75.  
  76.     /**
  77.      * Get the JavaScript command for the button
  78.      *
  79.      * @param   object   $msg   The message to display.
  80.      * @param   string   $name  Not used.
  81.      * @param   string   $task  The task used by the application
  82.      * @param   boolean  $list  True is requires a list confirmation.
  83.      *
  84.      * @return  string  JavaScript command string
  85.      *
  86.      * @since   3.0
  87.      */
  88.     protected function _getCommand($msg$name$task$list)
  89.     {
  90.         JHtml::_('behavior.framework');
  91.         $message JText::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
  92.         $message addslashes($message);
  93.  
  94.         if ($list)
  95.         {
  96.             $cmd "if (document.adminForm.boxchecked.value==0){alert('$message');}else{if (confirm('$msg')){Joomla.submitbutton('$task');}}";
  97.         }
  98.         else
  99.         {
  100.             $cmd "if (confirm('$msg')){Joomla.submitbutton('$task');}";
  101.         }
  102.  
  103.         return $cmd;
  104.     }
  105. }

Documentation generated on Tue, 19 Nov 2013 14:56:31 +0100 by phpDocumentor 1.4.3