Skip to content
Snippets Groups Projects
Select Git revision
  • e52179db320054b1ee2bfcea0da28bd640c87d56
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

ActionMenu.php

Blame
  • 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.
         *