00001 <?php
00002
00018 class TKList extends TKContainer {
00019 private static $itemCnt = 0;
00020
00021 const LIST_DEFAULT = 0;
00022 const LIST_NUMBERED = 1;
00023
00029 public function __construct($listType = self::LIST_DEFAULT) {
00030 parent::__construct();
00031
00032 $this->addProperty('item_class', self::PROP_CLASS);
00033 $this->addProperty('item_style', self::PROP_STYLE);
00034
00035 $this->addProperty('list_type', self::PROP_NUMERIC);
00036 $this->set('list_type', $listType);
00037 }
00038
00050 protected function renderContainer($class, $style, $events, $id) {
00051 $collect = "";
00052 foreach($this->getChildrenBySlot('main') as $cid => $comp) {
00053 $params = $this->getChildParams('main', $cid);
00054 $collect .= $this->renderListItem($comp, $class, $style, $params);
00055 }
00056 $collect = $this->renderListOuter($collect, $class, $style, $events, $id);
00057
00058 return $collect;
00059 }
00060
00073 protected function renderListOuter($collect, $class, $style, $events, $id) {
00074 $listType = $this->getListType();
00075 switch($listType) {
00076 default:
00077 case self::LIST_DEFAULT:
00078 $collect = "<ul $id$class[0]$style[0]$events>\n$collect</ul>\n";
00079 break;
00080 case self::LIST_NUMBERED:
00081 $collect = "<ol $id$class[0]$style[0]$events>\n$collect</ol>\n";
00082 break;
00083 }
00084 return $collect;
00085 }
00086
00098 protected function renderListItem($item, $class, $style, $params) {
00099 $html = is_object($item) ? $item->render() : $item;
00100 if(isset($params['class']))
00101 $class['item'] = $this->translateClass('item', $params['class']);
00102 if(isset($params['style']))
00103 $style['item'] = $this->translateStyle('item', $params['style']);
00104 if(isset($params['id']))
00105 $id = " id=\"$params[id]\"";
00106 else
00107 $id = '';
00108 $ret = '<li' . $id . $class['item'] . $style['item'] . '>' . $html . '</li>';
00109 self::$itemCnt++;
00110 return $ret;
00111 }
00112
00123 public static function createFromXML($attrs, $contents, $node) {
00124 $obj = new TKList();
00125 $children = $node['children'];
00126 self::convertStdAttributes($obj, $attrs);
00127 self::convertStdEvents($obj, $node);
00128 self::convertStdChildren($obj, $node['children']);
00129 return $obj;
00130 }
00131 }
00132
00133 ?>