Select Git revision
ActionMenu.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ActionMenu.php 10.87 KiB
<?php
/**
* This class represents the action menu used to group actions.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL2 or any later version
* @since Stud.IP 3.5
*/
class ActionMenu
{
const TEMPLATE_FILE_SINGLE = 'shared/action-menu-single.php';
const TEMPLATE_FILE_MULTIPLE = 'shared/action-menu.php';
const RENDERING_MODE_ICONS = 'icons';
const RENDERING_MODE_MENU = 'menu';
/**
* Returns an instance.
*
* @return ActionMenu
*/
public static function get()
{
return new self();
}
private $actions = [];
private $attributes = [];
private $condition_all = null;
private $condition = true;
/**
* @var string $context The context for the action menu.
*/
protected $context = '';
/**
* @var string|null $rendering_mode The forced rendering mode
*/
protected $rendering_mode = null;
/**
* Private constructur.
*
* @see ActionMenu::get()
*/
private function __construct()
{
$this->addCSSClass('action-menu');
}
/**
* Set condition for the next added item. If condition is false,
* the item will not be added.
*
* @param bool $state State of the condition
* @return ActionMenu instance to allow chaining
*/
public function condition($state)
{
$this->condition = (bool)$state;
return $this;
}
/**
* Set condition for all the next added items. If condition is false,
* no items will be added.
*