Source for file button.php

Documentation is available at button.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.  * Button base class
  14.  *
  15.  * The JButton is the base class for all JButton types
  16.  *
  17.  * @package     Joomla.Libraries
  18.  * @subpackage  Toolbar
  19.  * @since       3.0
  20.  */
  21. abstract class JToolbarButton
  22. {
  23.     /**
  24.      * element name
  25.      *
  26.      * This has to be set in the final renderer classes.
  27.      *
  28.      * @var    string 
  29.      */
  30.     protected $_name = null;
  31.  
  32.     /**
  33.      * reference to the object that instantiated the element
  34.      *
  35.      * @var    JButton 
  36.      */
  37.     protected $_parent = null;
  38.  
  39.     /**
  40.      * Constructor
  41.      *
  42.      * @param   object  $parent  The parent
  43.      */
  44.     public function __construct($parent null)
  45.     {
  46.         $this->_parent = $parent;
  47.     }
  48.  
  49.     /**
  50.      * Get the element name
  51.      *
  52.      * @return  string   type of the parameter
  53.      *
  54.      * @since   3.0
  55.      */
  56.     public function getName()
  57.     {
  58.         return $this->_name;
  59.     }
  60.  
  61.     /**
  62.      * Get the HTML to render the button
  63.      *
  64.      * @param   array  &$definition  Parameters to be passed
  65.      *
  66.      * @return  string 
  67.      *
  68.      * @since   3.0
  69.      */
  70.     public function render(&$definition)
  71.     {
  72.         /*
  73.          * Initialise some variables
  74.          */
  75.         $id call_user_func_array(array(&$this'fetchId')$definition);
  76.         $action call_user_func_array(array(&$this'fetchButton')$definition);
  77.  
  78.         // Build id attribute
  79.         if ($id)
  80.         {
  81.             $id ' id="' $id '"';
  82.         }
  83.  
  84.         // Build the HTML Button
  85.         $options array();
  86.         $options['id'$id;
  87.         $options['action'$action;
  88.  
  89.         $layout new JLayoutFile('joomla.toolbar.base');
  90.  
  91.         return $layout->render($options);
  92.     }
  93.  
  94.     /**
  95.      * Method to get the CSS class name for an icon identifier
  96.      *
  97.      * Can be redefined in the final class
  98.      *
  99.      * @param   string  $identifier  Icon identification string
  100.      *
  101.      * @return  string  CSS class name
  102.      *
  103.      * @since   3.0
  104.      */
  105.     public function fetchIconClass($identifier)
  106.     {
  107.         // It's an ugly hack, but this allows templates to define the icon classes for the toolbar
  108.         $layout new JLayoutFile('joomla.toolbar.iconclass');
  109.  
  110.         return $layout->render(array('icon' => $identifier));
  111.     }
  112.  
  113.     /**
  114.      * Get the button
  115.      *
  116.      * Defined in the final button class
  117.      *
  118.      * @return  string 
  119.      *
  120.      * @since   3.0
  121.      */
  122.     abstract public function fetchButton();
  123. }
  124.  
  125. /**
  126.  * Deprecated class placeholder. You should use JToolbarButton instead.
  127.  *
  128.  * @package     Joomla.Legacy
  129.  * @subpackage  Toolbar
  130.  * @since       1.5
  131.  * @deprecated  4.0  Use JToolbarButton instead.
  132.  * @codeCoverageIgnore
  133.  */
  134. abstract class JButton extends JToolbarButton
  135. {
  136.     /**
  137.      * Constructor
  138.      *
  139.      * @param   object  $parent  The parent
  140.      *
  141.      * @deprecated  4.0  Use JToolbarButton instead.
  142.      */
  143.     public function __construct($parent null)
  144.     {
  145.         JLog::add('JButton is deprecated. Use JToolbarButton instead.'JLog::WARNING'deprecated');
  146.         parent::__construct($parent);
  147.     }
  148. }

Documentation generated on Tue, 19 Nov 2013 14:54:48 +0100 by phpDocumentor 1.4.3