diff --git a/db/migrations/5.2.3_add_action_menu_threshold.php b/db/migrations/5.2.3_add_action_menu_threshold.php new file mode 100644 index 0000000000000000000000000000000000000000..fd6c1ce881a59ca139dbe927fb3bd505c9ca8b73 --- /dev/null +++ b/db/migrations/5.2.3_add_action_menu_threshold.php @@ -0,0 +1,31 @@ +<?php + +class AddActionMenuThreshold extends Migration +{ + public function description() + { + return 'add option for when to render action menu as separate icons'; + } + + public function up() + { + $query = 'INSERT INTO `config` (`field`, `value`, `type`, `section`, `mkdate`, `chdate`, `description`) + VALUES (:name, :value, :type, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)'; + $statement = DBManager::get()->prepare($query); + $statement->execute([ + 'name' => 'ACTION_MENU_THRESHOLD', + 'description' => 'Obergrenze an Einträgen, bis zu der ein Aktionsmenü als Icons dargestellt wird', + 'section' => 'global', + 'type' => 'integer', + 'value' => '1' + ]); + } + + public function down() + { + $query = "DELETE `config`, `config_values` + FROM `config` LEFT JOIN `config_values` USING (`field`) + WHERE `field` = 'ACTION_MENU_THRESHOLD'"; + DBManager::get()->exec($query); + } +} diff --git a/lib/classes/ActionMenu.php b/lib/classes/ActionMenu.php index e90c77309c41d9683f14adb46a978319dc7951dc..ed6b36a157ae0a55d6a6c6f6cde4dd388f13d5e9 100644 --- a/lib/classes/ActionMenu.php +++ b/lib/classes/ActionMenu.php @@ -8,7 +8,6 @@ */ class ActionMenu { - const THRESHOLD = 1; const TEMPLATE_FILE_SINGLE = 'shared/action-menu-single.php'; const TEMPLATE_FILE_MULTIPLE = 'shared/action-menu.php'; @@ -242,7 +241,7 @@ class ActionMenu return ''; } - $template_file = count($this->actions) <= self::THRESHOLD + $template_file = count($this->actions) <= Config::get()->ACTION_MENU_THRESHOLD ? self::TEMPLATE_FILE_SINGLE : self::TEMPLATE_FILE_MULTIPLE;