aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/MessageBox.class.php
diff options
context:
space:
mode:
authorPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
committerPhilipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de>2024-09-24 10:53:31 +0200
commit4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch)
tree5c07151ae61276d334e88f6309c30d439a85c12e /lib/classes/MessageBox.class.php
parentda0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff)
parent97a188592c679890a25c37ab78463add76a52ff7 (diff)
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/classes/MessageBox.class.php')
-rw-r--r--lib/classes/MessageBox.class.php158
1 files changed, 0 insertions, 158 deletions
diff --git a/lib/classes/MessageBox.class.php b/lib/classes/MessageBox.class.php
deleted file mode 100644
index 450851f..0000000
--- a/lib/classes/MessageBox.class.php
+++ /dev/null
@@ -1,158 +0,0 @@
-<?php
-# Lifter010: TODO
-/**
- * MessageBox.class.php
- *
- * html boxes for different kinds of messages
- *
- * 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 Michael Riehemann <michael.riehemann@uni-oldenburg.de>
- * @license http://www.gnu.org/licenses/gpl-2.0.html GPL Licence 2
- * @category Stud.IP
- * @package layout
- * @since 1.10
- *
- */
-
-/**
- * class MessageBox
- *
- * usage:
- *
- * echo MessageBox::error('Nachricht', ['optional details']);
- *
- * use the optional parameter $close_details for displaying the message box with
- * closed details
- *
- * echo MessageBox::success('Nachricht', ['optional details'], true);
- *
- */
-class MessageBox implements LayoutMessage
-{
- /**
- * type and contents of the message box
- */
- public $class;
- public $message;
- public $details;
- public $close_details;
- protected $hide_close = false;
-
- /**
- * This function returns an exception message box. Use it only for system errors
- * or security related problems.
- *
- * @param string $message
- * @param array $details
- * @param boolean $close_details
- * @return object MessageBox object
- */
- public static function exception($message, $details = [], $close_details = false)
- {
- return new MessageBox('exception', $message, $details, $close_details);
- }
-
- /**
- * This function returns an error message box. Use it for validation errors,
- * problems and other wrong user input.
- *
- * @param string $message
- * @param array $details (optional)
- * @param boolean $close_details (optional)
- * @return object MessageBox object
- */
- public static function error($message, $details = [], $close_details = false)
- {
- return new MessageBox('error', $message, $details, $close_details);
- }
-
- /**
- * This function returns a success message box. Use it for confirmation of user
- * interaction.
- *
- * @param string $message
- * @param array $details (optional)
- * @param boolean $close_details (optional)
- * @return object MessageBox object
- */
- public static function success($message, $details = [], $close_details = false)
- {
- return new MessageBox('success', $message, $details, $close_details);
- }
-
- /**
- * This function returns an info message box. Use it to report neutral
- * informations.
- *
- * @param string $message
- * @param array $details (optional)
- * @param boolean $close_details (optional)
- * @return object MessageBox object
- */
- public static function info($message, $details = [], $close_details = false)
- {
- return new MessageBox('info', $message, $details, $close_details);
- }
-
- /**
- * This function returns a warning message box. Use it to report potentially
- * wrong behaviour.
- *
- * @param string $message
- * @param array $details (optional)
- * @param boolean $close_details (optional)
- * @return object MessageBox object
- */
- public static function warning($message, $details = [], $close_details = false)
- {
- return new MessageBox('warning', $message, $details, $close_details);
- }
-
- /**
- * Initializes a new MessageBox object of the given class.
- *
- * @param string $class the type of this message
- * @param string $message
- * @param array $details (optional)
- * @param boolean $close_details (optional)
- */
- protected function __construct($class, $message, $details = [], $close_details = false)
- {
- $this->class = $class;
- $this->message = $message;
- $this->details = $details;
- $this->close_details = $close_details;
- }
-
- /**
- * Sets the state whether the close button should be hidden or not.
- *
- * @param boolean $state Whether the close button should be hidden or not
- * @return MessageBox instance to allow chaining
- */
- public function hideClose($state = true)
- {
- $this->hide_close = (bool) $state;
- return $this;
- }
-
- /**
- * This method renders a MessageBox object to a string.
- *
- * @return string html output of the message box
- */
- public function __toString()
- {
- return $GLOBALS['template_factory']->render('shared/message_box', [
- 'class' => $this->class,
- 'message' => $this->message,
- 'details' => is_array($this->details) ? $this->details : [],
- 'close_details' => $this->close_details,
- 'hide_close' => $this->hide_close,
- ]);
- }
-}