b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: Messages

Source Location: /blogs/inc/_core/model/_messages.class.php

Class Messages

Class Overview

Messages class. For displaying notes, successful actions & errors.

Located in /blogs/inc/_core/model/_messages.class.php [line 52]



		
				Author(s):
		
Information Tags:
Todo:  

CLEAN UP A LOT because of previous over factorization with Log class.

Messages can be logged into different categories (aka levels) Examples: 'note', 'error'. Note: 'all' is reserved to display all categories together. Messages can later be displayed grouped by category/level.

Properties

Methods

[ Top ]
Property Summary
string   $defaultcategory   Default category for messages.
string   $foot   to display after messages
mixed   $head   string or array to display before messages
array   $messages   The stored messages (by category).
array   $_count   Cache for Log::count()

[ Top ]
Method Summary
Messages   Messages()   Constructor.
void   add()   Add a message to the Log.
void   add_messages()   Add an array of messages.
void   clear()   Clears the Log (all or specified category).
number   count()   Counts messages of a given category
void   disp()   TEMPLATE TAG
boolean   display()   Display messages of the Log object.
void   display_paragraphs()   Wrapper to display messages as simple paragraphs.
array   get_messages()   Returns array of messages of a single category or group of categories.
string   get_string()   Concatenates messages of a given category to a string

[ Top ]
Properties
string   $defaultcategory = 'error' [line 66]

Default category for messages.


[ Top ]
string   $foot = '' [line 78]

to display after messages


[ Top ]
mixed   $head = '' [line 72]

string or array to display before messages


[ Top ]
array   $messages = array() [line 60]

The stored messages (by category).

array of arrays


[ Top ]
array   $_count = array() [line 84]

Cache for Log::count()


[ Top ]
Methods
Constructor Messages  [line 92]

  Messages Messages( [string $category = 'error']  )

Constructor.

Parameters:
string   $category:  sets default category


[ Top ]
add  [line 134]

  void add( string $message, [string|array $category = NULL], boolean 2  )

Add a message to the Log.

Parameters:
boolean   2:  Dump (output) this directly?
string   $message:  the message
string|array   $category:  the category, default is to use the object's default category. Can also be an array of categories to add the same message to.


[ Top ]
add_messages  [line 166]

  void add_messages( array $messages  )

Add an array of messages.

Parameters:
array   $messages:  Array of messages where the keys are the categories and hold an array of messages.


[ Top ]
clear  [line 106]

  void clear( [string $category = NULL]  )

Clears the Log (all or specified category).

Parameters:
string   $category:  category, use 'all' to unset all categories


[ Top ]
count  [line 483]

  number count( [string|array $category = NULL]  )

Counts messages of a given category

Parameters:
string|array   $category:  the category, NULL=default, 'all' = all

API Tags:
Return:  of messages

Information Tags:
Todo:  this seems a bit weird (not really relying on the cache ($_count) and unsetting 'all') -> write testcases to safely be able to change it.

[ Top ]
disp  [line 269]

  void disp( [string $before = '<div class="action_messages">'], [string $after = '</div>'], [boolean $skip_if_preview = true]  )

TEMPLATE TAG

The purpose here is to have a tag which is simple yet flexible. the display function is WAAAY too bloated.

Parameters:
string   $before:  HTML to display before the log when there is something to display
string   $after:  HTML to display after the log when there is something to display
boolean   $skip_if_preview:  Skip if previewing? TODO: dh> This appears to not display e.g. errors which got inserted?!! I also don't see how this is a "simple" param (in the sense of useful/required)

Information Tags:
Todo:  optimize

[ Top ]
display  [line 319]

  boolean display( [string|NULL $head = NULL], [string|NULL $foot = NULL], [boolean $display = true], [mixed $category = 'all'], [string $cssclass = NULL], [string $style = NULL], [mixed $outerdivclass = 'log_container']  )

Display messages of the Log object.

  • You can either output/get the messages of a category (string), all categories ('all') or category groups (array of strings) (defaults to 'all').
  • Head/Foot will be displayed on top/bottom of the messages. You can pass an array as head/foot with the category as key and this will be displayed on top of the category's messages.
  • You can choose from various styles for message groups ('ul', 'p', 'br') and set a css class for it (by default 'log_'.$category gets used).
  • You can suppress the outer div or set a css class for it (defaults to 'log_container').

Parameters:
string|NULL   $head:  Header/title, might be array ( category => msg ), 'container' is then top. NULL for object's default (Log::$head.
string|NULL   $foot:  Footer, might be array ( category => msg ), 'container' is then bottom. NULL for object's default (Log::$foot.
boolean   $display:  to display or return (default: display)
mixed   $category:  the category of messages to use (category, 'all', list of categories (array) or NULL for $defaultcategory).
string   $cssclass:  the CSS class of the messages div tag (default: 'log_'.$category)
string   $style:  the style to use, 'ul', 'p', 'br', 'raw' (default: 'br' for single message, 'ul' for more)
mixed   $outerdivclass:  the outer div, may be false

API Tags:
Return:  false, if no messages; else true (and outputs if $display)

Information Tags:
Todo:  Make this simple! start by getting rid of the $category selection and the special cases for 'all'. If you don't want to display ALL messages, then you should not log them in the same Log object and you should instantiate separate logs instead.

[ Top ]
display_paragraphs  [line 244]

  void display_paragraphs( [mixed $category = 'all'], [mixed $outerdivclass = 'panelinfo'], [mixed $cssclass = NULL]  )

Wrapper to display messages as simple paragraphs.

Parameters:
mixed   $category:  the category of messages, see display(). NULL for default category.
mixed   $outerdivclass:  the outer div, see display()
mixed   $cssclass:  the css class for inner paragraphs


[ Top ]
get_messages  [line 519]

  array get_messages( [string|array $category = NULL], [boolean $singleDimension = false]  )

Returns array of messages of a single category or group of categories.

If the category is an array, those categories will be used (where 'all' will be translated with the not already processed categories).

  1. get_messagesarray('error''note''all') )
would return 'errors', 'notes' and the remaining messages, in that order.

Parameters:
string|array   $category:  the category, NULL=default, 'all' = all
boolean   $singleDimension:  if true will use subarrays for each category

API Tags:
Return:  the messages, one or two dimensions (depends on second param)


[ Top ]
get_string  [line 440]

  string get_string( [string $head = ''], [string $foot = ''], [string $category = NULL], [ $implodeBy = ', '], [ $format = 'striptags']  )

Concatenates messages of a given category to a string

Parameters:
string   $head:  prefix of the string
string   $foot:  suffic of the string
string   $category:  the category
   $implodeBy: 
   $format: 

API Tags:
Return:  the messages, imploded. Tags stripped.


[ Top ]

Documentation generated on Sat, 06 Mar 2010 04:19:07 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).