Skip to content
Snippets Groups Projects
Select Git revision
  • 953de28bb8cdbb8edbf14c7f0ce81d0f5abbd8a8
  • 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

ContentBoxHelper.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.
    ContentBoxHelper.php 2.14 KiB
    <?php
    /**
     * ContentBoxHelper.php
     *
     * The ContentBoxHelper controls ids of contentboxes
     *
     * 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      Florian Bieringer <florian.bieringer@uni-passau.de>
     * @copyright   2013 Stud.IP Core-Group
     * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
     * @category    Stud.IP
     * @since       3.0
     */
    class ContentBoxHelper {
    
        /**
         * Returns the class open if the id was clicked
         *
         * @param String $id id of the content box
         * @param int $chdate last change of the displayed article
         * @return String open if the contentbox is open otherwise an empty String
         */
        public static function classes($id, $is_new = false) {
    
            // Init
            $classes = [];
    
            // Check if open
            if (Request::get('contentbox_open') == $id) {
                $classes[] = 'open';
            }
    
            // Check if new
            if ($is_new) {
                $classes[] = 'new';
            }
    
            // Return classes
            return join(' ', $classes);
        }
    
        /**
         * Produces an html link to open a contentbox if javascript is not active
         *
         * @param String $id Id of the content box
         * @param Array $params other needed parameters
         * @return String Url to open the contentbox
         */
        public static function switchhref($id, $params = []) {
            if (Request::get('contentbox_open') != $id || $params) {
                $params['contentbox_open'] = $id;
            } else {
                $params['contentbox_close'] = $id;
            }
            return URLHelper::getURL("#$id", $params);
        }
    
        /**
         * Link to the contentbox (Required when some action should take place)
         *
         * @param String $id Id of the content box
         * @param Array $params other needed parameters
         * @return String Url to the contentbox
         */
        public static function href($id, $params = []) {
            $params['contentbox_open'] = $id;
            return URLHelper::getURL("#$id", $params);
        }
    }