Feature #20858 » 11684_v4_final.diff
typo3/stylesheet.css (working copy) | ||
---|---|---|
/* - - - - - - - - - - - - - - - - - - - - -
|
||
Flash Messages (template.php)
|
||
- - - - - - - - - - - - - - - - - - - - - */
|
||
#typo3-messages {
|
||
margin-bottom: 10px;
|
||
}
|
||
.typo3-message {
|
||
padding: 6px;
|
||
padding-left: 26px;
|
||
margin-bottom: 4px;
|
||
background-repeat: no-repeat;
|
||
background-position: 4px 4px;
|
||
border: 1px solid;
|
||
}
|
||
.typo3-message .message-header {
|
||
display: block;
|
||
margin-bottom: 5px;
|
||
margin-top: -1px;
|
||
font-size: 11px;
|
||
font-weight: bold;
|
||
}
|
||
.message-notice {
|
||
background-color: #fff;
|
||
border-color: #dee0e1;
|
||
}
|
||
.message-information {
|
||
background-image: url(gfx/information.png);
|
||
background-color: #dfedf8;
|
||
border-color: #bccfe4;
|
||
}
|
||
.message-ok {
|
||
background-image: url(gfx/ok.png);
|
||
background-color: #dfd;
|
||
border-color: #beb;
|
||
}
|
||
.message-warning {
|
||
background-image: url(gfx/warning.png);
|
||
background-color: #ffd;
|
||
border-color: #f6ea68;
|
||
}
|
||
.message-error {
|
||
background-image: url(gfx/error.png);
|
||
background-color: #fcc;
|
||
border-color: #ebb;
|
||
}
|
||
/* - - - - - - - - - - - - - - - - - - - - -
|
||
User settings
|
||
- - - - - - - - - - - - - - - - - - - - - */
|
typo3/template.php (working copy) | ||
---|---|---|
}
|
||
}
|
||
/**
|
||
* Add a flash message to the queue. It will live until the next call to
|
||
* popFlashMessages() in the current session.
|
||
*
|
||
* @param t3lib_FlashMessage A flash message object.
|
||
* @return void
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
*/
|
||
public function pushFlashMessage(t3lib_FlashMessage $message) {
|
||
$queuedFlashMessages = $this->getFlashMessagesFromSession();
|
||
$queuedFlashMessages[] = $message;
|
||
$GLOBALS['BE_USER']->setAndSaveSessionData(
|
||
'core.template.flashMessages',
|
||
$queuedFlashMessages
|
||
);
|
||
}
|
||
/**
|
||
* Returns queued flash messages and clears the queue.
|
||
*
|
||
* @return array An array with t3lib_FlashMessage flash messages.
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
*/
|
||
protected function popFlashMessages() {
|
||
$queuedFlashMessages = $this->getFlashMessagesFromSession();
|
||
if (!empty($queuedFlashMessages)) {
|
||
$GLOBALS['BE_USER']->setAndSaveSessionData(
|
||
'core.template.flashMessages',
|
||
null
|
||
);
|
||
}
|
||
return $queuedFlashMessages;
|
||
}
|
||
/**
|
||
* Returns current flash messages from the seesion, making sure to always
|
||
* return an array.
|
||
*
|
||
* @return array An array of t3lib_FlashMessage flash messages.
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
*/
|
||
protected function getFlashMessagesFromSession() {
|
||
$flashMessages = $GLOBALS['BE_USER']->getSessionData('core.template.flashMessages');
|
||
return is_array($flashMessages) ? $flashMessages : array();
|
||
}
|
||
/**
|
||
* Renders all available flash messages in the queue
|
||
*
|
||
* @return string All flash messages in the queue rendered as HTML
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
*/
|
||
public function renderFlashMessages() {
|
||
$content = '';
|
||
$flashMessages = $this->popFlashMessages();
|
||
foreach ($flashMessages as $flashMessage) {
|
||
$content .= $flashMessage->render();
|
||
}
|
||
return $content;
|
||
}
|
||
/**
|
||
* Function to load a HTML template file with markers.
|
||
... | ... | |
foreach ($subpartArray as $marker => $content) {
|
||
$moduleBody = t3lib_parsehtml::substituteSubpart($moduleBody, $marker, $content);
|
||
}
|
||
// adding flash messages
|
||
$flashMessages = $this->renderFlashMessages();
|
||
if (!empty($flashMessages)) {
|
||
$flashMessages = '<div id="typo3-messages">' . $flashMessages . '</div>';
|
||
}
|
||
if (strstr($moduleBody, '###FLASHMESSAGES###')) {
|
||
// either replace a dedicated marker for the messages if present
|
||
$moduleBody = str_replace(
|
||
'###FLASHMESSAGES###',
|
||
$flashMessages,
|
||
$moduleBody
|
||
);
|
||
} else {
|
||
// or force them to appear before the content
|
||
$moduleBody = str_replace(
|
||
'###CONTENT###',
|
||
$flashMessages . '###CONTENT###',
|
||
$moduleBody
|
||
);
|
||
}
|
||
// replacing all markers with the finished markers and return the HTML content
|
||
return t3lib_parsehtml::substituteMarkerArray($moduleBody, $markerArray, '###|###');
|
||
ChangeLog (working copy) | ||
---|---|---|
2009-08-14 Ingo Renner <ingo@typo3.org>
|
||
* Added feature #11684: Add support for flash messages in the backend
|
||
2009-08-24 Rupert Germann <rupi@gmx.li>
|
||
* Fixed bug #11764: Performance improvement: speed up list module by improving internal handling of localisations
|
t3lib/core_autoload.php (working copy) | ||
---|---|---|
't3lib_extfilefunctions' => PATH_t3lib . 'class.t3lib_extfilefunc.php',
|
||
't3lib_extmgm' => PATH_t3lib . 'class.t3lib_extmgm.php',
|
||
't3lib_extobjbase' => PATH_t3lib . 'class.t3lib_extobjbase.php',
|
||
't3lib_flashmessage' => PATH_t3lib . 'class.t3lib_flashmessage.php',
|
||
't3lib_flexformtools' => PATH_t3lib . 'class.t3lib_flexformtools.php',
|
||
't3lib_foldertree' => PATH_t3lib . 'class.t3lib_foldertree.php',
|
||
't3lib_formmail' => PATH_t3lib . 'class.t3lib_formmail.php',
|
t3lib/class.t3lib_flashmessage.php (revision 0) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2009 Ingo Renner <ingo@typo3.org>
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project 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.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* A class representing flash messages.
|
||
*
|
||
* @author Ingo Renner <ingo@typo3.org>
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*/
|
||
class t3lib_FlashMessage {
|
||
const NOTICE = -2;
|
||
const INFO = -1;
|
||
const OK = 0;
|
||
const WARNING = 1;
|
||
const ERROR = 2;
|
||
protected $title = '';
|
||
protected $message = '';
|
||
protected $severity = self::OK;
|
||
/**
|
||
* Constructor for a flash message
|
||
*
|
||
* @param string The message.
|
||
* @param string Optional message title.
|
||
* @param integer Optional severity, must be either of t3lib_FlashMessage::INFO, t3lib_FlashMessage::OK, t3lib_FlashMessage::WARNING or t3lib_FlashMessage::ERROR. Default is t3lib_FlashMessage::OK.
|
||
* @return void
|
||
*/
|
||
public function __construct($message, $title = '', $severity = self::OK) {
|
||
$this->setMessage($message);
|
||
$this->setTitle($title);
|
||
$this->setSeverity($severity);
|
||
}
|
||
/**
|
||
* Gets the message's title.
|
||
*
|
||
* @return string The message's title.
|
||
*/
|
||
public function getTitle() {
|
||
return $this->title;
|
||
}
|
||
/**
|
||
* Sets the message's title
|
||
*
|
||
* @param string The message's title
|
||
* @return void
|
||
*/
|
||
public function setTitle($title) {
|
||
$this->title = (string) $title;
|
||
}
|
||
/**
|
||
* Gets the message.
|
||
*
|
||
* @return string The message.
|
||
*/
|
||
public function getMessage() {
|
||
return $this->message;
|
||
}
|
||
/**
|
||
* Sets the message
|
||
*
|
||
* @param string The message
|
||
* @return void
|
||
*/
|
||
public function setMessage($message) {
|
||
$this->message = (string) $message;
|
||
}
|
||
/**
|
||
* Gets the message' severity.
|
||
*
|
||
* @return integer The message' severity, either of t3lib_FlashMessage::INFO, t3lib_FlashMessage::OK, t3lib_FlashMessage::WARNING or t3lib_FlashMessage::ERROR
|
||
*/
|
||
public function getSeverity() {
|
||
return $this->severity;
|
||
}
|
||
/**
|
||
* Sets the message' severity
|
||
*
|
||
* @param string The severity, must be either of t3lib_FlashMessage::INFO, t3lib_FlashMessage::OK, t3lib_FlashMessage::WARNING or t3lib_FlashMessage::ERROR. Default is t3lib_FlashMessage::OK.
|
||
* @return void
|
||
*/
|
||
public function setSeverity($severity = self::OK) {
|
||
$this->severity = t3lib_div::intInRange(
|
||
$severity,
|
||
self::NOTICE, // minimum
|
||
self::ERROR, // maximum
|
||
self::OK // default if out of bounds
|
||
);
|
||
}
|
||
/**
|
||
* Renders the flash message.
|
||
*
|
||
* @return string The flash message as HTML.
|
||
*/
|
||
public function render() {
|
||
$classes = array(
|
||
t3lib_FlashMessage::NOTICE => 'notice',
|
||
t3lib_FlashMessage::INFO => 'information',
|
||
t3lib_FlashMessage::OK => 'ok',
|
||
t3lib_FlashMessage::WARNING => 'warning',
|
||
t3lib_FlashMessage::ERROR => 'error',
|
||
);
|
||
$title = '';
|
||
if (!empty($this->title)) {
|
||
$title = '<div class="message-header">' . $this->title . '</div>';
|
||
}
|
||
$message = '<div class="typo3-message message-' . $classes[$this->severity] . '">'
|
||
. $title
|
||
. '<div class="message-body">' . $this->message . '</div>'
|
||
. '</div>';
|
||
return $message;
|
||
}
|
||
/**
|
||
* Creates a string representation of the flash message. Useful for command
|
||
* line use.
|
||
*
|
||
* @return string A string representation of the flash message.
|
||
*/
|
||
public function __toString() {
|
||
$severities = array(
|
||
t3lib_FlashMessage::INFO => 'INFO',
|
||
t3lib_FlashMessage::OK => 'OK',
|
||
t3lib_FlashMessage::WARNING => 'WARNING',
|
||
t3lib_FlashMessage::ERROR => 'ERROR',
|
||
);
|
||
$title = '';
|
||
if (!empty($this->title)) {
|
||
$title = ' - ' . $this->title;
|
||
}
|
||
return $severities[$this->severity] . $title . ': ' . $this->message;
|
||
}
|
||
}
|
||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_flashmessage.php']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_flashmessage.php']);
|
||
}
|
||
?>
|
- « Previous
- 1
- …
- 6
- 7
- 8
- Next »