1: <?php
2: require_once('../qcubed.inc.php');
3:
4: class DataRepeaterExample extends QForm {
5:
6: protected $dtrPersons;
7: protected $dtrBig;
8:
9: protected function Form_Create() {
10:
11:
12: $this->dtrPersons = new QDataRepeater($this);
13:
14:
15:
16:
17: $this->dtrPersons->Paginator = new QPaginator($this);
18: $this->dtrPersons->ItemsPerPage = 6;
19:
20:
21: $this->dtrPersons->PaginatorAlternate = new QPaginator($this);
22:
23:
24:
25: $this->dtrPersons->Template = 'dtr_persons.tpl.php';
26:
27:
28: $this->dtrPersons->SetDataBinder('dtrPersons_Bind');
29:
30:
31: $this->dtrBig = new QDataRepeater($this);
32: $this->dtrBig->Paginator = new QPaginator($this);
33: $this->dtrBig->ItemsPerPage = 10;
34: $this->dtrBig->SetDataBinder('dtrBig_Bind');
35: $this->dtrBig->TagName = 'ul';
36: $this->dtrBig->ItemTagName = 'li';
37: $this->dtrBig->ItemInnerHtmlCallback = 'BigItem_Render';
38: }
39:
40: protected function dtrPersons_Bind() {
41:
42: $this->dtrPersons->TotalItemCount = Person::CountAll();
43: $this->dtrPersons->DataSource = Person::LoadAll(QQ::Clause($this->dtrPersons->LimitClause));
44: }
45:
46: protected function dtrBig_Bind() {
47:
48: $this->dtrBig->TotalItemCount = 1000;
49: for ($i = 1; $i <= 10; $i++) {
50: $a[] = 'Item number ' . ($i + ($this->dtrBig->PageNumber - 1 ) * 10);
51: }
52: $this->dtrBig->DataSource = $a;
53: }
54:
55: public function BigItem_Render ($objItem, $intIndex) {
56: if ($intIndex % 2) {
57: return '<b>' . $objItem . '</b>';
58: } else {
59: return '<i>' . $objItem . '</i>';
60: }
61: }
62:
63: }
64:
65: DataRepeaterExample::Run('DataRepeaterExample');
66: ?>