Source for file actionsdropdown.php

Documentation is available at actionsdropdown.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  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.  * HTML utility class for building a dropdown menu
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  HTML
  17.  * @since       3.2
  18.  */
  19. abstract class JHtmlActionsDropdown
  20. {
  21.     /**
  22.      * @var    string  HTML markup for the dropdown list
  23.      * @since  3.2
  24.      */
  25.     protected static $dropDownList array();
  26.  
  27.     /**
  28.      * Method to render current dropdown menu
  29.      *
  30.      * @param   string  $item  An item to render.
  31.      *
  32.      * @return  string  HTML markup for the dropdown list
  33.      *
  34.      * @since   3.2
  35.      */
  36.     public static function render($item '')
  37.     {
  38.         $html array();
  39.  
  40.         $html['<button data-toggle="dropdown" class="dropdown-toggle btn btn-micro">';
  41.         $html['<span class="caret"></span>';
  42.  
  43.         if ($item)
  44.         {
  45.             $html['<span class="element-invisible">' JText::sprintf('JACTIONS'$item'</span>';
  46.         }
  47.  
  48.         $html['</button>';
  49.         $html['<ul class="dropdown-menu">';
  50.         $html[implode(''static::$dropDownList);
  51.         $html['</ul></div>';
  52.  
  53.         static::$dropDownList null;
  54.  
  55.         return implode(''$html);
  56.     }
  57.  
  58.     /**
  59.      * Append a publish item to the current dropdown menu
  60.      *
  61.      * @param   string  $id      ID of corresponding checkbox of the record
  62.      * @param   string  $prefix  The task prefix
  63.      *
  64.      * @return  void 
  65.      *
  66.      * @since   3.2
  67.      */
  68.     public static function publish($id$prefix '')
  69.     {
  70.         $task ($prefix $prefix '.' '''publish';
  71.         static::addCustomItem(JText::_('JTOOLBAR_PUBLISH')'publish'$id$task);
  72.     }
  73.  
  74.     /**
  75.      * Append an unpublish item to the current dropdown menu
  76.      *
  77.      * @param   string  $id      ID of corresponding checkbox of the record
  78.      * @param   string  $prefix  The task prefix
  79.      *
  80.      * @return  void 
  81.      *
  82.      * @since   3.2
  83.      */
  84.     public static function unpublish($id$prefix '')
  85.     {
  86.         $task ($prefix $prefix '.' '''unpublish';
  87.         static::addCustomItem(JText::_('JTOOLBAR_UNPUBLISH')'unpublish'$id$task);
  88.     }
  89.  
  90.     /**
  91.      * Append a feature item to the current dropdown menu
  92.      *
  93.      * @param   string  $id      ID of corresponding checkbox of the record
  94.      * @param   string  $prefix  The task prefix
  95.      *
  96.      * @return  void 
  97.      *
  98.      * @since   3.2
  99.      */
  100.     public static function feature($id$prefix '')
  101.     {
  102.         $task ($prefix $prefix '.' '''featured';
  103.         static::addCustomItem(JText::_('JFEATURE')'featured'$id$task);
  104.     }
  105.  
  106.     /**
  107.      * Append an unfeature item to the current dropdown menu
  108.      *
  109.      * @param   string  $id      ID of corresponding checkbox of the record
  110.      * @param   string  $prefix  The task prefix
  111.      *
  112.      * @return  void 
  113.      *
  114.      * @since   3.2
  115.      */
  116.     public static function unfeature($id$prefix '')
  117.     {
  118.         $task ($prefix $prefix '.' '''unfeatured';
  119.         static::addCustomItem(JText::_('JUNFEATURE')'unfeatured'$id$task);
  120.     }
  121.  
  122.     /**
  123.      * Append an archive item to the current dropdown menu
  124.      *
  125.      * @param   string  $id      ID of corresponding checkbox of the record
  126.      * @param   string  $prefix  The task prefix
  127.      *
  128.      * @return  void 
  129.      *
  130.      * @since   3.2
  131.      */
  132.     public static function archive($id$prefix '')
  133.     {
  134.         $task ($prefix $prefix '.' '''archive';
  135.         static::addCustomItem(JText::_('JTOOLBAR_ARCHIVE')'archive'$id$task);
  136.     }
  137.  
  138.     /**
  139.      * Append an unarchive item to the current dropdown menu
  140.      *
  141.      * @param   string  $id      ID of corresponding checkbox of the record
  142.      * @param   string  $prefix  The task prefix
  143.      *
  144.      * @return  void 
  145.      *
  146.      * @since   3.2
  147.      */
  148.     public static function unarchive($id$prefix '')
  149.     {
  150.         $task ($prefix $prefix '.' '''unpublish';
  151.         static::addCustomItem(JText::_('JTOOLBAR_UNARCHIVE')'unarchive'$id$task);
  152.     }
  153.  
  154.     /**
  155.      * Append a duplicate item to the current dropdown menu
  156.      *
  157.      * @param   string  $id      ID of corresponding checkbox of the record
  158.      * @param   string  $prefix  The task prefix
  159.      *
  160.      * @return  void 
  161.      *
  162.      * @since   3.2
  163.      */
  164.     public static function duplicate($id$prefix '')
  165.     {
  166.         $task ($prefix $prefix '.' '''duplicate';
  167.         static::addCustomItem(JText::_('JTOOLBAR_DUPLICATE')'copy'$id$task);
  168.     }
  169.  
  170.     /**
  171.      * Append a trash item to the current dropdown menu
  172.      *
  173.      * @param   string  $id      ID of corresponding checkbox of the record
  174.      * @param   string  $prefix  The task prefix
  175.      *
  176.      * @return  void 
  177.      *
  178.      * @since   3.2
  179.      */
  180.     public static function trash($id$prefix '')
  181.     {
  182.         $task ($prefix $prefix '.' '''trash';
  183.         static::addCustomItem(JText::_('JTOOLBAR_TRASH')'trash'$id$task);
  184.     }
  185.  
  186.     /**
  187.      * Append an untrash item to the current dropdown menu
  188.      *
  189.      * @param   string  $id      ID of corresponding checkbox of the record
  190.      * @param   string  $prefix  The task prefix
  191.      *
  192.      * @return  void 
  193.      *
  194.      * @since   3.2
  195.      */
  196.     public static function untrash($id$prefix '')
  197.     {
  198.         self::publish($id$prefix);
  199.     }
  200.  
  201.     /**
  202.      * Writes a divider between dropdown items
  203.      *
  204.      * @return  void 
  205.      *
  206.      * @since   3.0
  207.      */
  208.     public static function divider()
  209.     {
  210.         static::$dropDownList['<li class="divider"></li>';
  211.     }
  212.  
  213.     /**
  214. /**
  215.      * Append a custom item to current dropdown menu.
  216.      *
  217.      * @param   string  $label  The label of the item.
  218.      * @param   string  $icon   The icon classname.
  219.      * @param   string  $id     The item id.
  220.      * @param   string  $task   The task.
  221.      *
  222.      * @return  void 
  223.      *
  224.      * @since   3.2
  225.      */
  226.     public static function addCustomItem($label$icon ''$id ''$task '')
  227.     {
  228.         static::$dropDownList['<li>'
  229.             . '<a href = "javascript://" onclick="listItemTask(\'' $id '\', \'' $task '\')">'
  230.             . ($icon '<span class="icon-' $icon '"></span> ' '')
  231.             . $label
  232.             . '</a>'
  233.             . '</li>';
  234.     }
  235. }

Documentation generated on Tue, 19 Nov 2013 14:53:21 +0100 by phpDocumentor 1.4.3