display simple error message 'Error'
Message::error()->display();
get simple success message 'Success'
$message = Message::success();
get special notice
$message = Message::notice(__('This is a localized notice'));
more advanced usage example:
create another message, a hint, with a localized string which expects
$hint = Message::notice('Read the %smanual%s');
replace placeholders with the following params
$hint->addParam('[doc@cfg_Example]');
$hint->addParam('[/doc]');
add this hint as a tooltip
$hint = showHint($hint);
add the retrieved tooltip reference to the original message
$message->addMessage($hint);
Exibir arquivo
Open project: phpmyadmin/phpmyadmin
Class Usage Examples
Property | Type | Description | |
---|---|---|---|
$level | array | message levels |
Property | Type | Description | |
---|---|---|---|
$addedMessages | array | holds additional messages | |
$hash | string | Unique id | |
$isDisplayed | boolean | Whether the message was already displayed | |
$message | string | The formatted message | |
$number | integer | The message number | |
$params | array | holds parameters | |
$string | string | The locale string identifier | |
$useBBCode | boolean | Whether to use BB code when displaying. |
Method | Description | |
---|---|---|
__construct ( string $string = '', integer $number = Message::NOTICE, array $params = [], integer $sanitize = Message::SANITIZE_NONE ) | Constructor | |
__toString ( ) : string | magic method: return string representation for this object | |
addHtml ( string $message, string $separator = ' ' ) : void | add another html message to be concatenated on displaying | |
addMessage ( |
add another raw message to be concatenated on displaying | |
addMessages ( |
add a bunch of messages at once | |
addMessagesString ( string[] $messages, string $separator = ' ' ) : void | add a bunch of messages at once | |
addParam ( mixed $param ) : void | add string or Message parameter | |
addParamHtml ( string $param ) : void | add parameter as raw HTML, usually in conjunction with strings | |
addText ( string $message, string $separator = ' ' ) : void | add another raw message to be concatenated on displaying | |
decodeBB ( string $message ) : string | decode $message, taking into account our special codes for formatting | |
display ( ) : void | Displays the message in HTML | |
error ( string $string = '' ) : |
get Message of type error | |
format ( ) : string | wrapper for sprintf() | |
getAddedMessages ( ) : array | return all added messages | |
getDisplay ( ) : string | returns HTML code for displaying this message | |
getHash ( ) : string | returns unique Message::$hash, if not exists it will be created | |
getLevel ( ) : string | returns level of message | |
getMessage ( ) : string | returns compiled message | |
getMessageForAffectedRows ( integer $rows ) : |
get Message for number of affected rows | |
getMessageForDeletedRows ( integer $rows ) : |
get Message for number of deleted rows | |
getMessageForInsertedRows ( integer $rows ) : |
get Message for number of inserted rows | |
getMessageWithIcon ( string $message ) : string | Returns the message with corresponding image icon | |
getNumber ( ) : integer | returns Message::$number | |
getOnlyMessage ( ) : string | Returns only message string without image & other HTML. | |
getParams ( ) : array | return all parameters | |
getString ( ) : string | returns Message::$string | |
isDisplayed ( boolean $isDisplayed = false ) : boolean | sets and returns whether the message was displayed or not | |
isError ( boolean $set = false ) : boolean | returns whether this message is an error message or not and optionally makes this message an error message | |
isNotice ( boolean $set = false ) : boolean | returns whether this message is a notice message or not and optionally makes this message a notice message | |
isSuccess ( boolean $set = false ) : boolean | returns whether this message is a success message or not and optionally makes this message a success message | |
notice ( string $string ) : |
get Message of type notice | |
raw ( string $message, integer $type = Message::NOTICE ) : |
get Message with customized content | |
rawError ( string $message ) : |
get Message of type error with custom content | |
rawNotice ( string $message ) : |
get Message of type notice with custom content | |
rawSuccess ( string $message ) : |
get Message of type success with custom content | |
sanitize ( mixed $message ) : mixed | Sanitizes $message | |
setBBCode ( boolean $useBBCode ) : void | Set whether we should use BB Code when rendering. | |
setMessage ( string $message, boolean $sanitize = false ) : void | set raw message (overrides string) | |
setNumber ( integer $number ) : void | set message type number | |
setParams ( array | string $params, boolean $sanitize = false ) : void | set all params at once, usually used in conjunction with string | |
setString ( string $string, boolean $sanitize = true ) : void | set string (does not take effect if raw message is set) | |
success ( string $string = '' ) : |
get Message of type success |
Method | Description | |
---|---|---|
_addMessage ( mixed $message, string $separator ) : void | Real implementation of adding message |
public __construct ( string $string = '', integer $number = Message::NOTICE, array $params = [], integer $sanitize = Message::SANITIZE_NONE ) | ||
$string | string | The message to be displayed |
$number | integer | A numeric representation of the type of message |
$params | array | An array of parameters to use in the message |
$sanitize | integer | A flag to indicate what to sanitize, see constant definitions above |
public __toString ( ) : string | ||
return | string |
public addMessage ( |
||
$message | to be added | |
$separator | string | to use between this and previous string/message |
return | void |
public addMessages ( |
||
$messages | to be added | |
$separator | string | to use between this and previous string/message |
return | void |
public addMessagesString ( string[] $messages, string $separator = ' ' ) : void | ||
$messages | string[] | to be added |
$separator | string | to use between this and previous string/message |
return | void |
$message->addParam('[em]some string[/em]');
$message->addParamHtml('');
public addParamHtml ( string $param ) : void | ||
$param | string | parameter to add |
return | void |
public getAddedMessages ( ) : array | ||
return | array |
public getDisplay ( ) : string | ||
return | string | whole message box |
public getMessage ( ) : string | ||
return | string | complete message |
public static getMessageForAffectedRows ( integer $rows ) : |
||
$rows | integer | Number of rows |
return |
public static getMessageForDeletedRows ( integer $rows ) : |
||
$rows | integer | Number of rows |
return |
public static getMessageForInsertedRows ( integer $rows ) : |
||
$rows | integer | Number of rows |
return |
public getMessageWithIcon ( string $message ) : string | ||
$message | string | the message(s) |
return | string | message with icon |
public getOnlyMessage ( ) : string | ||
return | string |
public isDisplayed ( boolean $isDisplayed = false ) : boolean | ||
$isDisplayed | boolean | whether to set displayed flag |
return | boolean | Message::$isDisplayed |
public static rawSuccess ( string $message ) : |
||
$message | string | A localized string |
return |
protected array $addedMessages | ||
return | array |
protected bool $isDisplayed | ||
return | boolean |
protected bool $useBBCode | ||
return | boolean |