.

WidgetYAMLSubtemplates Class Reference

Prints YAML subtemplates. More...

Inheritance diagram for WidgetYAMLSubtemplates:
IWidget IRenderer

List of all members.

Public Member Functions

  __construct ($arr_data, $arr_slotswidths, $cls)
  render ($policy=self::NONE)

Static Public Member Functions

static  output ($arr_data, $arr_slotswidths, $cls= '')
  Output a subtemplate.

Public Attributes

const  SLOTS_2_25_75 = '25_75'
  Two cols à 25% and 75%.
const  SLOTS_2_33_66 = '33_66'
  Two cols à 33% and 66%.
const  SLOTS_2_50 = '2'
  Two cols à 50%.
const  SLOTS_2_66_33 = '66_33'
  Two cols à 33% and 66%.
const  SLOTS_2_75_25 = '75_25'
  Two cols à 75% and 25%.
const  SLOTS_2_GOLDEN_RATIO_LEFT = 'golden_ratio_left'
  Two cols with golden ratio, smaler col on the left.
const  SLOTS_2_GOLDEN_RATIO_RIGHT = 'golden_ratio_right'
  Two cols with golden ratio, smaler col on the right.
const  SLOTS_3_33 = '3'
  Three cols à 33%.
const  SLOTS_4_25 = '4'
  Four cols à 25%.
const  SLOTS_5_20 = '5'
  Five cols à 20%.
const  SLOTS_AUTO = 'AUTO'
  Automatically detect (= 100/count(data)).

Protected Member Functions

  create_slots ($slotwidths)
  translate_slot ($slot)

Protected Attributes

  $cls
  $data
  $slotwidths

Detailed Description

Prints YAML subtemplates.

Definition at line 5 of file yamlsubtemplates.widget.php.


Constructor & Destructor Documentation

WidgetYAMLSubtemplates::__construct ( arr_data,
arr_slotswidths,
cls  
)

Definition at line 66 of file yamlsubtemplates.widget.php.

00066                                                                        {
00067                 $this->data = $arr_data;
00068                 if (is_array($arr_slotswidths)) {
00069                         $this->slotwidths = $arr_slotswidths;
00070                 }
00071                 else {
00072                         $this->slotwidths = $this->translate_slot($arr_slotswidths);
00073                 }
00074                 $this->cls = $cls;
00075         }

Member Function Documentation

WidgetYAMLSubtemplates::create_slots ( slotwidths  )  [protected]

Definition at line 124 of file yamlsubtemplates.widget.php.

00124                                                      {
00125                 $ret = array();
00126                 $c = count($slotwidths);
00127                 for($i = 0; $i < $c; $i++) {
00128                         $appendix = 'l';
00129                         $appendix_sub = '';
00130                         if ($i == ($c - 1)) {
00131                                 $appendix = 'r';
00132                                 $appendix_sub = 'r';
00133                         } else if ($i == 0) {
00134                                 $appendix_sub = 'l';
00135                         }
00136                         $ret[] = array('cls' => 'c' . $slotwidths[$i] . $appendix, 'subc' => 'subc'. $appendix_sub);
00137                 }
00138                 return $ret;
00139         } 
static WidgetYAMLSubtemplates::output ( arr_data,
arr_slotswidths,
cls = ''  
) [static]

Output a subtemplate.

Parameters:
$arr_data  Array of HTML elemtns for subtemplates
$arr_slotwidths  Either array of slot widths, or One of the SLOT_* constants

Definition at line 61 of file yamlsubtemplates.widget.php.

00061                                                                               {
00062                 $w = new WidgetYAMLSubtemplates($arr_data, $arr_slotswidths, $cls);
00063                 return $w->render();
00064         }
WidgetYAMLSubtemplates::render ( policy = self::NONE  ) 

Implements IRenderer.

Definition at line 110 of file yamlsubtemplates.widget.php.

00110                                                    {
00111                 $slots = $this->create_slots($this->slotwidths);
00112                 $ret = '';
00113                 while(count($this->data)) {
00114                         $row = '';
00115                         foreach($slots as $slot) {
00116                                 $row .= html::div(html::div(array_shift($this->data), $slot['subc']), $slot['cls']);
00117                                 $row .= "\n";
00118                         }
00119                         $ret .= html::div($row, 'subcolumns ' . $this->cls) . "\n";
00120                 }
00121                 return $ret;
00122         }
WidgetYAMLSubtemplates::translate_slot ( slot  )  [protected]

Definition at line 77 of file yamlsubtemplates.widget.php.

00077                                                  {
00078                 switch ($slot) {
00079                         case self::SLOTS_AUTO:
00080                                 $c = count($this->data);
00081                                 if ($c > 0) {
00082                                         return array_fill(0, $c, floor(100/$c));
00083                                 } else {
00084                                         return array(50, 50);
00085                                 }
00086                         case self::SLOTS_2_33_66:
00087                                 return array(33, 66);
00088                         case self::SLOTS_2_66_33:
00089                                 return array(66, 33);
00090                         case self::SLOTS_2_25_75:
00091                                 return array(25, 75);
00092                         case self::SLOTS_2_75_25:
00093                                 return array(75, 25);
00094                         case self::SLOTS_2_GOLDEN_RATIO_LEFT:
00095                                 return array(38, 62);                                           
00096                         case self::SLOTS_2_GOLDEN_RATIO_RIGHT:
00097                                 return array(62, 38);                                           
00098                         case self::SLOTS_3_33:
00099                                 return array(33, 33, 33);
00100                         case self::SLOTS_4_25:
00101                                 return array(25, 25, 25, 25);
00102                         case self::SLOTS_5_20:
00103                                 return array(20, 20, 20, 20, 20);               
00104                         case self::SLOTS_2_50:
00105                         default:
00106                                 return array(50, 50);           
00107                 }
00108         }

Member Data Documentation

WidgetYAMLSubtemplates::$cls [protected]

Definition at line 53 of file yamlsubtemplates.widget.php.

WidgetYAMLSubtemplates::$data [protected]

Definition at line 52 of file yamlsubtemplates.widget.php.

WidgetYAMLSubtemplates::$slotwidths [protected]

Definition at line 51 of file yamlsubtemplates.widget.php.

Two cols à 25% and 75%.

Definition at line 13 of file yamlsubtemplates.widget.php.

Two cols à 33% and 66%.

Definition at line 21 of file yamlsubtemplates.widget.php.

Two cols à 50%.

Definition at line 9 of file yamlsubtemplates.widget.php.

Two cols à 33% and 66%.

Definition at line 25 of file yamlsubtemplates.widget.php.

Two cols à 75% and 25%.

Definition at line 17 of file yamlsubtemplates.widget.php.

Two cols with golden ratio, smaler col on the left.

Definition at line 29 of file yamlsubtemplates.widget.php.

Two cols with golden ratio, smaler col on the right.

Definition at line 33 of file yamlsubtemplates.widget.php.

Three cols à 33%.

Definition at line 37 of file yamlsubtemplates.widget.php.

Four cols à 25%.

Definition at line 41 of file yamlsubtemplates.widget.php.

Five cols à 20%.

Definition at line 45 of file yamlsubtemplates.widget.php.

Automatically detect (= 100/count(data)).

Definition at line 49 of file yamlsubtemplates.widget.php.


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