From 9ee941ec5a58c9f24f22ee0a75078dde1c95174e Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Thu, 15 Dec 2022 10:27:54 +0000
Subject: [PATCH] remove unused code, fixes #564

Closes #564

Merge request studip/studip!1244
---
 lib/classes/ContentGroupMenu.php        | 45 +----------------
 templates/shared/contentgroup-table.php | 64 -------------------------
 2 files changed, 1 insertion(+), 108 deletions(-)
 delete mode 100644 templates/shared/contentgroup-table.php

diff --git a/lib/classes/ContentGroupMenu.php b/lib/classes/ContentGroupMenu.php
index 7f3ba5c9a2f..877ebe6bf8f 100644
--- a/lib/classes/ContentGroupMenu.php
+++ b/lib/classes/ContentGroupMenu.php
@@ -10,11 +10,6 @@ class ContentGroupMenu
 {
     const THRESHOLD = 1;
 
-    const TEMPLATE_FILE_SINGLE   = 'shared/action-menu-single.php';
-    const TEMPLATE_FILE_MULTIPLE = 'shared/action-menu.php';
-    const TEMPLATE_FILE_ROWS     = 'shared/contentgroup-row.php';
-    const TEMPLATE_FILE_TABLE    = 'shared/contentgroup-table.php';
-
     /**
      * Returns an instance.
      *
@@ -29,8 +24,6 @@ class ContentGroupMenu
     private $condition_all = null;
     private $condition     = true;
 
-    private $rows    = 1;
-    private $columns = 1;
     private $image   = null;
     private $image_link_attributes = [];
     private $label;
@@ -203,12 +196,7 @@ class ContentGroupMenu
             return '';
         }
 
-        //if ($this->rows > 1 || $this->columns > 1 || $this->image) {
-        if ($this->rows > 1 || $this->columns > 1) {
-            $template_file = self::TEMPLATE_FILE_TABLE;
-        } else {
-            $template_file = self::TEMPLATE_FILE_ROWS;
-        }
+        $template_file = 'shared/contentgroup-row.php';
         $template = $GLOBALS['template_factory']->open($template_file);
         $template->actions = $this->actions;
 
@@ -221,9 +209,6 @@ class ContentGroupMenu
         }
         $template->has_link_icons = $has_link_icons;
 
-        $template->rows    = $this->rows;
-        $template->columns = $this->columns;
-
         if ($this->image) {
             $template->image = $this->image;
             $template->image_link_attributes = $this->image_link_attributes;
@@ -236,37 +221,9 @@ class ContentGroupMenu
 
         $template->attributes = $this->attributes;
 
-        /*} else {
-            $template_file = count($this->actions) <= self::THRESHOLD
-            ? self::TEMPLATE_FILE_SINGLE
-            : self::TEMPLATE_FILE_MULTIPLE;
-            $template = $GLOBALS['template_factory']->open($template_file);
-            $template->actions = $this->actions;
-        }*/
-
         return $template->render();
     }
 
-    /**
-     * Sets the number of rows to layout the elements.
-     *
-     * @param integer $rows number of rows
-     */
-    public function setRows($rows)
-    {
-        $this->rows = $rows;
-    }
-
-    /**
-     * Sets the number of columns to layout the elements.
-     *
-     * @param integer $columns number of columns
-     */
-    public function setcolumns($columns)
-    {
-        $this->columns = $columns;
-    }
-
     /**
      * Sets the icon of the menu.
      *
diff --git a/templates/shared/contentgroup-table.php b/templates/shared/contentgroup-table.php
deleted file mode 100644
index 69e9245018e..00000000000
--- a/templates/shared/contentgroup-table.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-$table_rows = 0;
-$table_cols = 0;
-$max_rows   = 0;
-$max_cols   = 0;
-if ($rows > 1) {
-    $max_rows = $rows;
-} else {
-    $max_cols = $columns;
-}
-?>
-
-<? // class "action-menu" will be set from API ?>
-<nav <?= arrayToHtmlAttributes($attributes) ?>>
-    <a class="action-menu-icon" title="<?= htmlReady($label) ?>"
-       aria-expanded="false" aria-label="<?= htmlReady($aria_label) ?>">
-        <?= $image ?>
-    </a>
-    <div class="action-menu-content">
-        <div class="action-menu-title">
-            <?= htmlReady($label) ?>
-        </div>
-
-        <table class="action-menu-table">
-            <tr>
-            <? foreach ($actions as $action): ?>
-                <td>
-                <? if ($action['type'] === 'link'): ?>
-                    <a href="<?= $action['link'] ?>" <?= arrayToHtmlAttributes($action['attributes']) ?>>
-                    <? if ($action['icon']): ?>
-                        <?= $action['icon'] ?>
-                    <? else: ?>
-                        <span class="action-menu-no-icon"></span>
-                    <? endif; ?>
-                        <br>
-                        <div class="navtitle"><?= htmlReady($action['label']) ?></div>
-                    </a>
-                <? elseif ($action['type'] === 'button'): ?>
-                    <label>
-                    <? if ($action['icon']): ?>
-                        <?= $action['icon']->asInput(['name' => $action['name']]) ?>
-                    <? else: ?>
-                        <span class="action-menu-no-icon"></span>
-                        <button type="submit" name="<?= htmlReady($action['name']) ?>" style="display: none;"></button>
-                    <? endif; ?>
-                        <?= htmlReady($action['label']) ?>
-                    </label>
-                <? elseif ($action['type'] === 'multi-person-search'): ?>
-                    <?= $action['object']->render() ?>
-                <? endif; ?>
-                </td>
-            <?php
-                $table_cols += 1;
-                if ($table_cols >= $max_cols) {
-                    $table_rows += 1;
-                    $table_cols = 0;
-                    echo '</tr><tr>'; // Open next row
-                }
-            ?>
-            <? endforeach; ?>
-            </tr>
-        </table>
-    </div>
-</nav>
-- 
GitLab