Bug #21207 ยป 12154.diff
t3lib/class.t3lib_flashmessage.php (Arbeitskopie) | ||
---|---|---|
const WARNING = 1;
|
||
const ERROR = 2;
|
||
protected $title = '';
|
||
protected $message = '';
|
||
/**
|
||
* The message's title
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $title = '';
|
||
/**
|
||
* The message
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $message = '';
|
||
/**
|
||
* The message's severity
|
||
*
|
||
* @var integer
|
||
*/
|
||
protected $severity = self::OK;
|
||
/**
|
||
* defines whether the message should be stored in the session (to survive redirects) or only for one request (default)
|
||
*
|
||
* @var bool
|
||
*/
|
||
protected $storeInSession = FALSE;
|
||
/**
|
||
* 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.
|
||
* @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.
|
||
* @param bool Optional, defines whether the message should be stored in the session or only for one request (default)
|
||
* @return void
|
||
*/
|
||
public function __construct($message, $title = '', $severity = self::OK) {
|
||
public function __construct($message, $title = '', $severity = self::OK, $storeInSession = FALSE) {
|
||
$this->setMessage($message);
|
||
$this->setTitle($title);
|
||
$this->setSeverity($severity);
|
||
$this->setStoreInSession($storeInSession);
|
||
}
|
||
/**
|
||
... | ... | |
$this->title = (string) $title;
|
||
}
|
||
/**
|
||
* Gets the message's storeInSession flag.
|
||
*
|
||
* @return bool The persistence flag.
|
||
*/
|
||
public function getStoreInSession() {
|
||
return $this->storeInSession;
|
||
}
|
||
/**
|
||
* Sets the message's storeInSession flag
|
||
*
|
||
* @param bool The persistence flag
|
||
* @return void
|
||
*/
|
||
public function setStoreInSession($storeInSession) {
|
||
$this->storeInSession = (bool) $storeInSession;
|
||
}
|
||
/**
|
||
* Gets the message.
|
||
*
|
||
* @return string The message.
|
t3lib/class.t3lib_messagequeue.php (Revision 0) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2009 Rupert Germann <rupi@gmx.li>
|
||
* 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 which collects and renders flash messages.
|
||
*
|
||
* @author Rupert Germann <rupi@gmx.li>
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*/
|
||
class t3lib_MessageQueue {
|
||
static $messages = array();
|
||
/**
|
||
* Static class, no instances allowed.
|
||
*/
|
||
protected function __construct() {}
|
||
/**
|
||
* Adds a message either to the BE_USER session (if the $message has the storeInSession flag set)
|
||
* or it adds the message to self::$messages.
|
||
*
|
||
* @param object instance of t3lib_FlashMessage, representing a message
|
||
* @return void
|
||
*/
|
||
public static function addMessage(t3lib_FlashMessage $message) {
|
||
if ($message->getStoreInSession() === TRUE) {
|
||
$queuedFlashMessages = self::getFlashMessagesFromSession();
|
||
$queuedFlashMessages[] = $message;
|
||
$GLOBALS['BE_USER']->setAndSaveSessionData(
|
||
'core.template.flashMessages',
|
||
$queuedFlashMessages
|
||
);
|
||
} else {
|
||
self::$messages[] = $message;
|
||
}
|
||
}
|
||
/**
|
||
* Returns all messages from the current php session and from the current request
|
||
*
|
||
* @return array array of t3lib_FlashMessage objects
|
||
*/
|
||
public static function getMessages() {
|
||
// get messages from user session
|
||
$queuedFlashMessagesFromSession = self::getFlashMessagesFromSession();
|
||
if (!empty($queuedFlashMessagesFromSession)) {
|
||
// reset messages in user session
|
||
$GLOBALS['BE_USER']->setAndSaveSessionData(
|
||
'core.template.flashMessages',
|
||
null
|
||
);
|
||
}
|
||
$queuedFlashMessages = array_merge($queuedFlashMessagesFromSession, self::$messages);
|
||
// reset internal messages
|
||
self::$messages = array();
|
||
return $queuedFlashMessages;
|
||
}
|
||
/**
|
||
* Returns current flash messages from the session, making sure to always
|
||
* return an array.
|
||
*
|
||
* @return array An array of t3lib_FlashMessage flash messages.
|
||
*/
|
||
protected static 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.
|
||
*/
|
||
public static function renderFlashMessages() {
|
||
$content = '';
|
||
$flashMessages = self::getMessages();
|
||
if (count($flashMessages)) {
|
||
foreach ($flashMessages as $flashMessage) {
|
||
$content .= $flashMessage->render();
|
||
}
|
||
}
|
||
return $content;
|
||
}
|
||
}
|
||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_messagequeue.php']) {
|
||
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_messagequeue.php']);
|
||
}
|
||
?>
|
t3lib/core_autoload.php (Arbeitskopie) | ||
---|---|---|
'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_messagequeue' => PATH_t3lib . 'class.t3lib_messagequeue.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',
|
typo3/template.php (Arbeitskopie) | ||
---|---|---|
}
|
||
/**
|
||
* Adds 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>
|
||
*/
|
||
public function popFlashMessages() {
|
||
$queuedFlashMessages = $this->getFlashMessagesFromSession();
|
||
if (!empty($queuedFlashMessages)) {
|
||
$GLOBALS['BE_USER']->setAndSaveSessionData(
|
||
'core.template.flashMessages',
|
||
null
|
||
);
|
||
}
|
||
return $queuedFlashMessages;
|
||
}
|
||
/**
|
||
* Returns current flash messages from the session, 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.
|
||
* When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html')
|
||
*
|
||
... | ... | |
}
|
||
// adding flash messages
|
||
$flashMessages = $this->renderFlashMessages();
|
||
$flashMessages = t3lib_messageQueue::renderFlashMessages();
|
||
if (!empty($flashMessages)) {
|
||
$flashMessages = '<div id="typo3-messages">' . $flashMessages . '</div>';
|
||
}
|
typo3/alt_doc.php (Arbeitskopie) | ||
---|---|---|
'',
|
||
t3lib_FlashMessage::WARNING
|
||
);
|
||
$this->doc->pushFlashMessage($lockedMessage);
|
||
t3lib_messageQueue::addMessage($lockedMessage);
|
||
}
|
||
// Combine it all:
|
typo3/mod/web/perm/index.php (Arbeitskopie) | ||
---|---|---|
$LANG->getLL('WorkspaceWarning'),
|
||
t3lib_FlashMessage::WARNING
|
||
);
|
||
$this->doc->pushFlashMessage($lockedMessage);
|
||
t3lib_messageQueue::addMessage($lockedMessage);
|
||
}
|
||
// Get usernames and groupnames
|
typo3/sysext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php (Arbeitskopie) | ||
---|---|---|
$GLOBALS['LANG']->getLL('badProperty'),
|
||
t3lib_FlashMessage::ERROR
|
||
);
|
||
$this->pObj->doc->pushFlashMessage($badPropertyMessage);
|
||
t3lib_messageQueue::addMessage($badPropertyMessage);
|
||
} else {
|
||
$pline = $name . '.' . $property . ' = '
|
||
. trim($POST['data'][$name]['propertyValue']);
|
||
... | ... | |
htmlspecialchars($pline),
|
||
$GLOBALS['LANG']->getLL('propertyAdded')
|
||
);
|
||
$this->pObj->doc->pushFlashMessage($propertyAddedMessage);
|
||
t3lib_messageQueue::addMessage($propertyAddedMessage);
|
||
$line.=chr(10).$pline;
|
||
}
|
||
... | ... | |
htmlspecialchars($pline),
|
||
$GLOBALS['LANG']->getLL('valueUpdated')
|
||
);
|
||
$this->pObj->doc->pushFlashMessage($updatedMessage);
|
||
t3lib_messageQueue::addMessage($updatedMessage);
|
||
$line .= chr(10) . $pline;
|
||
} elseif ($POST['clear_object']) {
|
||
... | ... | |
htmlspecialchars($pline),
|
||
$GLOBALS['LANG']->getLL('objectCleared')
|
||
);
|
||
$this->pObj->doc->pushFlashMessage($objectClearedMessage);
|
||
t3lib_messageQueue::addMessage($objectClearedMessage);
|
||
$line .= chr(10) . $pline;
|
||
}
|
||
... | ... | |
t3lib_FlashMessage::ERROR
|
||
);
|
||
$this->pObj->doc->pushFlashMessage($noTemplateMessage);
|
||
t3lib_messageQueue::addMessage($noTemplateMessage);
|
||
}
|
||
// Links:
|
||
$out = '';
|
typo3/sysext/cms/layout/db_layout.php (Arbeitskopie) | ||
---|---|---|
'',
|
||
t3lib_FlashMessage::WARNING
|
||
);
|
||
$this->doc->pushFlashMessage($lockedMessage);
|
||
t3lib_messageQueue::addMessage($lockedMessage);
|
||
}
|
||
// Add whole form as a document section:
|
typo3/sysext/scheduler/mod1/index.php (Arbeitskopie) | ||
---|---|---|
$severity
|
||
);
|
||
$this->doc->pushFlashMessage($message);
|
||
t3lib_messageQueue::addMessage($message);
|
||
}
|
||
/**
|