Source for file ALayout.php

Documentation is available at ALayout.php

  1. <?php
  2. require_once 'ARenderableInterface.php';
  3. require_once 'AWidgetCollection.php';
  4.  
  5.  
  6. /**
  7.  * ALayout
  8.  *
  9.  * The base class for all layouts
  10.  *
  11.  * @author Jordan Wambaugh <jordan@wambaugh.org>
  12.  * @package Alia
  13.  * @subpackage Core
  14.  *
  15.  */
  16. abstract class ALayout extends AObject implements ARenderableInterface 
  17. {
  18.  
  19.  
  20.     /**
  21.      * Children widgets added to the layout
  22.      * 
  23.      * @var mixed 
  24.      */
  25.     private $__widgetsarray();
  26.     
  27.     /**
  28.      * The main widget this layout lays out
  29.      *
  30.      * @var AWidget 
  31.      */
  32.     private $widget;
  33.  
  34.     
  35.     /**
  36.      * __construct
  37.      * 
  38.      * @param AWidget $parentWidget 
  39.      * @return void 
  40.      */
  41.     public function __construct(AWidget $parentWidget){
  42.         parent::__construct();
  43.         $this->widget = $parentWidget;
  44.     }
  45.  
  46.     
  47.     /**
  48.      * Returns the main widget
  49.      * 
  50.      * @return void 
  51.      */
  52.     public function getMainWidget(){
  53.         return $this->widget;
  54.     }
  55.     
  56.     /**
  57.      * returns the children widget(s)
  58.      * 
  59.      * @return mixed the children widget(s)
  60.      */
  61.     public function getWidgets({
  62.         return $this->__widgets;
  63.     // end of member function getWidgets
  64.  
  65.  
  66.     /**
  67.      * getWidget
  68.      * Returns one widget in the layout
  69.      * 
  70.      * @param mixed $key 
  71.      * @return void 
  72.      */
  73.     public function getWidget($key){
  74.         return $this->__widgets[$key];
  75.     }
  76.  
  77.     /**
  78.      * Adds a child widget
  79.      * 
  80.      * @param AWidget $widget 
  81.      * @return void 
  82.      */
  83.     public function addWidget(AWidget $widget$key=null){
  84.         if(!is_null($key)){
  85.             $this->__widgets[$key]=$widget;
  86.         }else{
  87.             $this->__widgets[]=$widget;
  88.         }
  89.     }
  90.  
  91.     /**
  92.      * renders the widget, returns the output as a string
  93.      * 
  94.      * @return string 
  95.      */
  96.     public function render){
  97.         return "default renderer";
  98.     }
  99.  
  100.     /**
  101.      * generates HTML for the main widget's attributes
  102.      * 
  103.      * @return void 
  104.      */
  105.     public function getAttributeHTML(){
  106.         $buffer='';
  107.         foreach ($this->widget->getAttributes(as $k=>$v){
  108.             if($v!='')$buffer.=" $k=\"$v\"";
  109.         }
  110.         return $buffer;
  111.     }
  112.     
  113.     /**
  114.      * Clears all child widgets
  115.      *
  116.      */
  117.     public function clearWidgets(){
  118.         $this->__widgets = array();
  119.     }
  120.  
  121.  
  122.     public function setWidgets($widgets){
  123.         if(!is_array($widgets)){
  124.             throw new Exception('setWidgets method only accepts an array as a parameter.');
  125.         }
  126.         $this->__widgets=$widgets;
  127.     }
  128.  
  129.  
  130. // end of ALayout
  131. ?>

Documentation generated on Fri, 11 Jul 2008 13:28:41 -0400 by phpDocumentor 1.4.2