public function testConstruct() { $a = array(1, 2, 3); $list = new TList($a); $this->assertEquals(3, $list->getCount()); $list2 = new TList($this->list); $this->assertEquals(2, $list2->getCount()); }
/** * Restores datagrid content from viewstate. */ protected function restoreGridFromViewState() { $this->reset(); $allowPaging = $this->getAllowPaging(); $itemCount = $this->getViewState('ItemCount', 0); $dsIndex = $this->getViewState('DataSourceIndex', 0); $columns = new TList($this->getColumns()); $columns->mergeWith($this->_autoColumns); $this->_allColumns = $columns; $items = $this->getItems(); if ($columns->getCount()) { foreach ($columns as $column) { $column->initialize(); } $selectedIndex = $this->getSelectedItemIndex(); $editIndex = $this->getEditItemIndex(); for ($index = 0; $index < $itemCount; ++$index) { if ($index === 0) { if ($allowPaging) { $this->_topPager = $this->createPager(); } $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, false, null, $columns); } if ($index === $editIndex) { $itemType = TListItemType::EditItem; } else { if ($index === $selectedIndex) { $itemType = TListItemType::SelectedItem; } else { if ($index % 2) { $itemType = TListItemType::AlternatingItem; } else { $itemType = TListItemType::Item; } } } $items->add($this->createItemInternal($index, $dsIndex, $itemType, false, null, $columns)); $dsIndex++; } if ($index > 0) { $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, false, null, $columns); if ($allowPaging) { $this->_bottomPager = $this->createPager(); } } } if (!$dsIndex && $this->_emptyTemplate !== null) { $this->_useEmptyTemplate = true; $this->_emptyTemplate->instantiateIn($this); } }