phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Class: Log

Source Location: /qp_inc/_core/model/_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 /qp_inc/_core/model/_log.class.php [line 48]



		
		
		
		

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
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.
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 ]
string   $foot = '' [line 74]

to display after messages


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

string or array to display before messages


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

The stored messages (by category).

array of arrays


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

Cache for Log::count()


[ Top ]
Methods
Constructor Log  [line 88]

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

Constructor.

Parameters:
string   $category:  sets default category


[ Top ]
add  [line 130]

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

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

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

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

  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?

API Tags:
Usedby:  messages()
Uses:  Log::display()

Information Tags:
Todo:  (legacy): 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)
Todo:  (legacy): optimize

[ Top ]
display  [line 316]

  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)
Usedby:  messages()
Usedby:  Log::disp()

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

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

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

  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 ]