b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.10) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Class: Log

Source Location: /blogs/inc/_misc/_log.class.php

Class Log

Class Overview

Log class. Logs notes and errors.

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.

Located in /blogs/inc/_misc/_log.class.php [line 50]



		
		
		
		

Properties

Methods

[ Top ]
Property Summary
string   $defaultcategory   Default category for messages.
boolean   $dump_add  
strinf   $foot  
mixed   $head  
array   $messages   The stored messages (by category).
array   $_count  

[ Top ]
Method Summary
Log   Log()   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.
boolean   display_cond()   Wrapper for Log::display(): use header/footer dependent on message count (one or more).
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 62]

Default category for messages.


[ Top ]
boolean   $dump_add = false [line 77]

[ Top ]
strinf   $foot = '' [line 72]

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

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

The stored messages (by category).


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

[ Top ]
Methods
Constructor Log  [line 90]

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

Constructor.

Parameters:
string   $category:  sets default category


[ Top ]
add  [line 132]

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

Add a message to the Log.

Parameters:
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.
boolean   $dump_this_add:  Dump (output) this directly?


[ Top ]
add_messages  [line 170]

  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 104]

  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 521]

  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>'], [ $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
   $skip_if_preview: 

Information Tags:
Todo:  optimize

[ Top ]
display  [line 325]

  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').
You can also call this function static (without creating an object), like:
  1.    Log::display'head''foot''message' );
Please note: when called static, it will always display, because $display equals true.

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' (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 ovject and you should instanciate separate logs instead.

[ Top ]
display_cond  [line 456]

  boolean display_cond( [string $head1 = ''], [string|NULL $head_more = ''], [string $foot1 = ''], [string|NULL $foot_more = ''], [boolean $display = true], [mixed $category = 'all'], [string $cssclass = NULL], [string $style = NULL], [mixed $outerdivclass = 'log_container']  )

Wrapper for Log::display(): use header/footer dependent on message count (one or more).

Parameters:
string   $head1:  header/title for one message (default: empty), might be array ( category => msg ), 'container' is then top
string|NULL   $head_more:  header/title (if more than one message) - NULL means "use $head1"
string   $foot1:  footer (if one message) (default: empty), might be array ( category => msg ), 'container' is then bottom
string|NULL   $foot_more:  footer (if more than one message) - NULL means "use $foot1"
boolean   $display:  to display or return (default: true)
mixed   $category:  the category of messages to use (category, 'all', or list of categories (array); NULL for default category)
string   $cssclass:  the CSS class of the messages div tag (default: 'log_'.$category)
string   $style:  the style to use, 'ul', 'p', 'br' (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)


[ Top ]
display_paragraphs  [line 248]

  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 557]

  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 492]

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

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: 

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


[ Top ]

Documentation generated on Tue, 20 May 2008 01:42:40 +0200 by phpDocumentor 1.4.2