00001 <?php
00002
00012 class TKHBox extends TKContainer {
00013 const ALIGN_LEFT = 0;
00014 const ALIGN_RIGHT = 1;
00015
00019 public function __construct() {
00020 parent::__construct();
00021 $this->addProperty('cell_class', self::PROP_CLASS);
00022 }
00023
00025 protected function renderContainer($class, $style, $events, $id) {
00026 $collect = "<div $id$class[0]$style[0]$events>\n";
00027 foreach($this->getChildrenBySlot('main') as $id => $comp) {
00028 $params = $this->getChildParams('main', $id);
00029
00030 if(isset($params['align']) && $params['align'] == self::ALIGN_RIGHT)
00031 $align = "right";
00032 else
00033 $align = "left";
00034
00035 $ts = "";
00036 if(isset($params['style'])) {
00037 if($class['cell'] == "")
00038 $params['style']['float'] = $align;
00039 $ts = Toolkit::styleToString($params['style']);
00040 }
00041 else if($class['cell'] == "")
00042 $ts = " style=\"float:$align\"";
00043
00044
00045 $tc = "";
00046 if(isset($params['class'])) {
00047 if($class['cell'] != "")
00048 $tc = ' class="' . substr($class['cell'], 8, -1) . ' ' . implode(' ', $params['class']) . '"';
00049 else
00050 $tc = Toolkit::classToString($params['class']);
00051 }
00052 else if($class['cell'] != "")
00053 $tc = $class['cell'];
00054
00055 $html = is_object($comp) ? $comp->render() : $comp;
00056 $collect .= "<div$tc$ts>$html</div>\n";
00057 }
00058 $collect .= "<div style=\"clear:both\"></div></div>\n";
00059
00060 return $collect;
00061 }
00062
00064 public static function convertFromXML($attrs, $contents, $node) {
00065 $obj = new TKHBox();
00066 $children = $node['children'];
00067 self::convertStdAttributes($obj, $attrs);
00068 self::convertStdEvents($obj, $node);
00069 self::convertStdChildren($obj, $node['children']);
00070 return $obj;
00071 }
00072 }
00073
00074 ?>