.

BlockBase Class Reference
[Controller]

Represents a block. More...

Inheritance diagram for BlockBase:
IBlock IRenderer

List of all members.

Public Member Functions

  __construct ($name, $title, $content, $index=1000, $position=self::LEFT)
  Constructor.
  compare ($other)
  Compare this block to another.
  get_content ()
  Get content of block (HTML).
  get_index ()
  An index to sort blocks.
  get_name ()
  Name (used as CSS class).
  get_position ()
  One of LEFT, RIGHT, CONTENT etc.
  get_title ()
  Get title of block (heading).
  is_valid ()
  Returns true if this block is valid.
  render ($policy=self::NONE)
  Renders what should be rendered.
  set_content ($content)
  Set content of block (HTML).
  set_index ($index)
  Set index to sort blocks.
  set_name ($name)
  Sets Name (used as CSS class).
  set_position ($position)
  Set position.
  set_title ($title)
  Set title of block (heading).

Public Attributes

  $content
  $index
  $name
  $position
  $title

Detailed Description

Represents a block.

if you are familiar with Drupal (http://drupal.org), the concept of blocks is not new to you. A block represents a snipppet of HTML that is grouped along with other blocks and placed in a location (left, right, too..) on a page.

Most common use is to build dynamic site bars or footers.

Author:
Gerd Riesselmann

Definition at line 14 of file blockbase.cls.php.


Constructor & Destructor Documentation

BlockBase::__construct ( name,
title,
content,
index = 1000,
position = self::LEFT  
)

Constructor.

Parameters:
string  The name of this block. Used as class, too
string  The title of the block. Displayed as heading, e.g.
string  The block's content
integer  The block's index. A block with lowest index will be displayed first
enum  Where the block is to be dispalyed.

Definition at line 55 of file blockbase.cls.php.

00055                                                                                                   {
00056                 $this->set_title($title);
00057                 $this->set_content($content);
00058                 $this->set_index($index);
00059                 $this->set_name($name);
00060                 $this->set_position($position);
00061         }

Member Function Documentation

BlockBase::compare ( other  ) 

Compare this block to another.

Returns:
int 0 if index of this is equal to other's index, -1 if this index is less than and +1 if it is more than other's index

Implements IBlock.

Definition at line 167 of file blockbase.cls.php.

00167                                         {
00168                 $t_idx = $this->get_index();
00169                 $o_idx = $other->get_index();
00170                 if ($t_idx == $o_idx) {
00171                         return 0;
00172                 }
00173         
00174                 return ($t_idx < $o_idx) ? -1 : 1;
00175         }
BlockBase::get_content (  ) 

Get content of block (HTML).

Returns:
string

Implements IBlock.

Definition at line 86 of file blockbase.cls.php.

00086                                       {
00087                 return $this->content;
00088         }
BlockBase::get_index (  ) 

An index to sort blocks.

Returns:
integer

Implements IBlock.

Definition at line 104 of file blockbase.cls.php.

00104                                     {
00105                 return $this->index;
00106         }
BlockBase::get_name (  ) 

Name (used as CSS class).

Returns:
string

Implements IBlock.

Definition at line 122 of file blockbase.cls.php.

00122                                    {
00123                 return $this->name;
00124         }
BlockBase::get_position (  ) 

One of LEFT, RIGHT, CONTENT etc.

..

Returns:
string

Implements IBlock.

Definition at line 140 of file blockbase.cls.php.

00140                                        {
00141                 return $this->position;
00142         }
BlockBase::get_title (  ) 

Get title of block (heading).

Returns:
string

Implements IBlock.

Definition at line 68 of file blockbase.cls.php.

00068                                     {
00069                 return $this->title;
00070         }
BlockBase::is_valid (  ) 

Returns true if this block is valid.

Returns:
boolean True if this block has content

Implements IBlock.

Definition at line 158 of file blockbase.cls.php.

00158                                    {
00159                 return ($this->get_content() !== '');
00160         }
BlockBase::render ( policy = self::NONE  ) 

Renders what should be rendered.

Parameters:
int  $policy Defines how to render, meaning depends on implementation
Returns:
string The rendered content

Implements IRenderer.

Definition at line 183 of file blockbase.cls.php.

00183                                                    {
00184                 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/block');
00185                 $view->assign('block', $this);
00186                 $view->assign('policy', $policy);
00187                 return $view->render();         
00188         }       
BlockBase::set_content ( content  ) 

Set content of block (HTML).

Parameters:
string 

Implements IBlock.

Definition at line 95 of file blockbase.cls.php.

00095                                               {
00096                 $this->content = trim($content);
00097         }
BlockBase::set_index ( index  ) 

Set index to sort blocks.

Parameters:
integer 

Implements IBlock.

Definition at line 113 of file blockbase.cls.php.

00113                                           {
00114                 $this->index = $index;
00115         }
BlockBase::set_name ( name  ) 

Sets Name (used as CSS class).

Parameters:
string 

Implements IBlock.

Definition at line 131 of file blockbase.cls.php.

00131                                         {
00132                 $this->name = $name;
00133         }
BlockBase::set_position ( position  ) 

Set position.

Parameters:
string 

Implements IBlock.

Definition at line 149 of file blockbase.cls.php.

00149                                                 {
00150                 $this->position = $position;
00151         }
BlockBase::set_title ( title  ) 

Set title of block (heading).

Parameters:
string 

Implements IBlock.

Definition at line 77 of file blockbase.cls.php.

00077                                           {
00078                 $this->title = trim($title);
00079         }

Member Data Documentation

BlockBase::$content

Definition at line 26 of file blockbase.cls.php.

BlockBase::$index

Definition at line 32 of file blockbase.cls.php.

BlockBase::$name

Definition at line 38 of file blockbase.cls.php.

BlockBase::$position

Definition at line 44 of file blockbase.cls.php.

BlockBase::$title

Definition at line 20 of file blockbase.cls.php.


The documentation for this class was generated from the following file: