Skip to content
Snippets Groups Projects
Select Git revision
  • 9e13d2f5fa4726b54efe8ad046d0b53aadb543bf
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

BreadCrumb.class.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.
    BreadCrumb.class.php 2.64 KiB
    <?php
    /**
     * breadcrumb.php - Provides bread crumb navigation
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * @author      Peter Thienel <thienel@data-quest.de>
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     * @since       3.5
     */
    class BreadCrumb
    {
    
        /**
         * Array with parts of bread crumb navigation.
         *
         * @var array
         */
        private $trail = [];
    
        public function __construct()
        {
            URLHelper::bindLinkParam('trail', $this->trail);
        }
    
        /**
         * Appends a new element to the end of the bread crumb navigation.
         *
         * @param MvvTreeItem $object The MvvTreeItem object of the current view
         * to append.
         * @param string $action The url to the current view.
         */
        public function append($object, $action)
        {
            $trail = $this->getTrail();
            $id = '';
            if (is_object($object)) {
                $type = get_class($object);
                $id = $object->id;
                $trail[$type] = [
                    'id' => $object->id,
                    'actn' => $action
                ];
            } else if (is_array($object)) {
                $id = reset($object)->id;
                $type = get_class(reset($object));
                foreach ($object as $obj) {
                    if ($obj && $obj->id != $id) {
                        $additional_objects[get_class($obj)] = $obj->id;
                    }
                }
                $trail[$type] = [
                    'id' => $id,
                    'add' => $additional_objects,
                    'actn' => $action
                ];
            } else {
                $trail[$action] = [
                    'name' => $object,
                    'actn' => $action
                ];
            }
            $newTrail = [];
            $lastElement = false;
            foreach ($trail as $key => $trail_item) {
                if ($lastElement) break;