1: <?php
2: /**
3: * <p>This control is used to display a simple html table.
4: *
5: * <p>The control itself will display things based off of an array of objects that gets set as the "Data Source".
6: * It is particularly useful when combined with the Class::LoadArrayByXXX() functions or the Class::LoadAll()
7: * that is generated by the CodeGen framework, or when combined with custom Class ArrayLoaders that you define
8: * youself, but who's structure is based off of the CodeGen framework.</p>
9: *
10: * <p>For each item in a datasource's Array, a row (<tr>) will be generated.
11: * You can define any number of QHtmlTableColumns which will result in a <td> for each row.
12: * Using the QHtmlTableColumn's Accessor property, you can specify how the data for each cell should be
13: * fetched from the datasource.</p>
14: *
15: * @package Controls
16: * @property string $Caption string to use as the caption of the table
17: * @property string $RowCssClass class to be given to the row tag
18: * @property string $AlternateRowCssClass class to be given to each alternate row tag
19: * @property string $HeaderRowCssClass class to be given the header row
20: * @property boolean $ShowHeader true to show the header row
21: * @property boolean $ShowFooter true to show the footer row
22: * @property boolean $RenderColumnTags true to include col tags in the table output
23: * @property boolean $HideIfEmpty true to completely hide the table if there is no data, vs. drawing the table with no rows.
24: * @property-write Callable $RowParamsCallback Set to a callback function to fetch custom attributes for row tags.
25: * @property-read integer $CurrentRowIndex The visual index of the row currently being drawn.
26: * @throws QCallerException
27: *
28: */
29: abstract class QHtmlTableBase extends QPaginatedControl {
30: /** @var QAbstractHtmlTableColumn[] */
31: protected $objColumnArray = [];
32:
33: /** @var string|null CSS class to be applied to for even rows */
34: protected $strRowCssClass = null;
35: /** @var string|null CSS class to be applied to for odd rows */
36: protected $strAlternateRowCssClass = null;
37: /** @var string|null CSS class to be applied to the header row */
38: protected $strHeaderRowCssClass = null;
39: /** @var bool Show the table header or not? */
40: protected $blnShowHeader = true;
41: /** @var bool Show the table footer or not? */
42: protected $blnShowFooter = false;
43: /** @var bool Column tags have to be rendered or not? */
44: protected $blnRenderColumnTags = false;
45: /** @var string|null Table caption, if applicable */
46: protected $strCaption = null;
47: /** @var bool When set, the table is hidden/not rendered when the data source is empty */
48: protected $blnHideIfEmpty = false;
49:
50: /** @var integer */
51: protected $intHeaderRowCount = 1;
52: /** @var integer Used during rendering to report which header row is being drawn in a multi-row header. */
53: protected $intCurrentHeaderRowIndex;
54:
55: /** @var integer Used during rendering to report which visible row is being drawn. */
56: protected $intCurrentRowIndex;
57:
58: /** @var callable */
59: protected $objRowParamsCallback;
60:
61: /**
62: * Constructor method
63: *
64: * @param QControl|QControlBase|QForm $objParentObject
65: * @param null $strControlId
66: *
67: * @throws Exception
68: * @throws QCallerException
69: */
70: public function __construct($objParentObject, $strControlId = null) {
71: try {
72: parent::__construct($objParentObject, $strControlId);
73: } catch (QCallerException $objExc) {
74: $objExc->IncrementOffset();
75: throw $objExc;
76: }
77: }
78:
79: /**
80: * Nothing to parse in current implementation
81: */
82: public function ParsePostData() {
83: if ($this->objColumnArray) {
84: foreach($this->objColumnArray as $objColumn) {
85: $objColumn->ParsePostData();
86: }
87: }
88: }
89:
90: /**
91: * Add an Index column and return it.
92: * Index columns assume that each data item is an array, and mixIndex is an offset in the array.
93: *
94: * @param string $strName column name
95: * @param mixed $mixIndex the index to use to access the cell date. i.e. $item[$index]
96: * @param integer $intColumnIndex column position
97: *
98: * @return QHtmlTableIndexedColumn
99: */
100: public function CreateIndexedColumn($strName = '', $mixIndex = null, $intColumnIndex = -1) {
101: if (is_null($mixIndex)) {
102: $mixIndex = count($this->objColumnArray);
103: }
104: $objColumn = new QHtmlTableIndexedColumn($strName, $mixIndex);
105: $this->AddColumnAt($intColumnIndex, $objColumn);
106: return $objColumn;
107: }
108:
109: /**
110: * Add a property column and return it. The assumption is that each row's data is an object.
111: *
112: * @param string $strName name of column
113: * @param string $strProperty property to use to get the cell data. i.e. $item->$property
114: * @param integer $intColumnIndex column position
115: * @param object $objBaseNode a query node from which the property descends, if you are using the sorting capabilities
116: *
117: * @return QHtmlTablePropertyColumn
118: */
119: public function CreatePropertyColumn($strName, $strProperty, $intColumnIndex = -1, $objBaseNode = null) {
120: $objColumn = new QHtmlTablePropertyColumn($strName, $strProperty, $objBaseNode);
121: $this->AddColumnAt($intColumnIndex, $objColumn);
122: return $objColumn;
123: }
124:
125: /**
126: * @param string $strName
127: * @param mixed $objNodes
128: * @param int $intColumnIndex
129: * @return QHtmlTableNodeColumn
130: * @throws Exception
131: * @throws QInvalidCastException
132: */
133: public function CreateNodeColumn($strName, $objNodes, $intColumnIndex = -1) {
134: $objColumn = new QHtmlTableNodeColumn($strName, $objNodes);
135: $this->AddColumnAt($intColumnIndex, $objColumn);
136: return $objColumn;
137: }
138:
139: /**
140: * Add a callable column and return it.
141: *
142: * @param string $strName column name
143: * @param callable|array $objCallable a callable object. Note that this can be an array.
144: * @param integer $intColumnIndex column position
145: *
146: * @return QHtmlTableCallableColumn
147: */
148: public function CreateCallableColumn($strName, $objCallable, $intColumnIndex = -1) {
149: $objColumn = new QHtmlTableCallableColumn($strName, $objCallable);
150: $this->AddColumnAt($intColumnIndex, $objColumn);
151: return $objColumn;
152: }
153:
154: /**
155: * Add a virtual attribute column.
156: *
157: * @param $strName
158: * @param $strAttribute
159: * @param $intColumnIndex
160: * @return QVirtualAttributeColumn
161: */
162: public function CreateVirtualAttributeColumn ($strName, $strAttribute, $intColumnIndex = -1) {
163: $objColumn = new QVirtualAttributeColumn($strName, $strAttribute);
164: $this->AddColumnAt($intColumnIndex, $objColumn);
165: return $objColumn;
166: }
167:
168: /**
169: * Add a link column.
170: *
171: * @param string $strName Column name to be displayed in the table header.
172: * @param null|string|array $mixText The text to display as the label of the anchor, a callable callback to get the text,
173: * a string that represents a property chain or a multi-dimensional array, or an array that represents the same. Depends on
174: * what time of row item is passed.
175: * @param null|string|array|QControlProxy $mixDestination The text representing the destination of the anchor, a callable callback to get the destination,
176: * a string that represents a property chain or a multi-dimensional array, or an array that represents the same,
177: * or a QControlProxy. Depends on what type of row item is passed.
178: * @param null|string|array $getVars An array of key=>value pairs to use as the GET variables in the link URL,
179: * or in the case of a QControlProxy, possibly a string to represent the action parameter. In either case, each item
180: * can be a property chain, an array index list, or a callable callback as specified above. If the destination is a
181: * QControlProxy, this would be what to use as the action parameter.
182: * @param null|array $tagAttributes An array of key=>value pairs to use as additional attributes in the tag.
183: * For example, could be used to add a class or an id to each tag.
184: * @param bool $blnAsButton Only used if this is drawing a QControlProxy. Will draw the proxy as a button.
185: * @param int $intColumnIndex
186: * @return QHtmlTableLinkColumn
187: * @throws QInvalidCastException
188: */
189: public function CreateLinkColumn ($strName,
190: $mixText,
191: $mixDestination = null,
192: $getVars = null,
193: $tagAttributes = null,
194: $blnAsButton = false,
195: $intColumnIndex = -1) {
196: $objColumn = new QHtmlTableLinkColumn($strName,
197: $mixText,
198: $mixDestination,
199: $getVars,
200: $tagAttributes,
201: $blnAsButton);
202: $this->AddColumnAt($intColumnIndex, $objColumn);
203: return $objColumn;
204: }
205:
206:
207: /**
208: * Move the named column to the given position
209: *
210: * @param string $strName column name
211: * @param integer $intColumnIndex new position
212: * @param string $strNewName new column name
213: *
214: * @return QAbstractHtmlTableColumn
215: */
216: public function MoveColumn($strName, $intColumnIndex = -1, $strNewName = null) {
217: $col = $this->RemoveColumnByName($strName);
218: $this->AddColumnAt($intColumnIndex, $col);
219: if ($strNewName !== null) {
220: $col->Name = $strNewName;
221: }
222: return $col;
223: }
224:
225: /**
226: * Rename a named column
227: *
228: * @param string $strOldName
229: * @param string $strNewName
230: *
231: * @return QAbstractHtmlTableColumn
232: */
233: public function RenameColumn($strOldName, $strNewName) {
234: $col = $this->GetColumnByName($strOldName);
235: $col->Name = $strNewName;
236: return $col;
237: }
238:
239: /**
240: * Add a column to the end of the column array.
241: *
242: * @param QAbstractHtmlTableColumn $objColumn
243: *
244: * @return QAbstractHtmlTableColumn
245: */
246: public function AddColumn(QAbstractHtmlTableColumn $objColumn) {
247: $this->AddColumnAt(-1, $objColumn);
248: return $objColumn;
249: }
250:
251: /**
252: * Add a column at the given position. All column adds bottle neck through here
253: * so that subclasses can reliably override the column add process if needed.
254: * Use AddColumn to add a column to the end.
255: *
256: * @param integer $intColumnIndex column position. -1 to add to the end.
257: * @param QAbstractHtmlTableColumn $objColumn
258: *
259: * @throws QInvalidCastException
260: */
261: public function AddColumnAt($intColumnIndex, QAbstractHtmlTableColumn $objColumn) {
262: try {
263: $intColumnIndex = QType::Cast($intColumnIndex, QType::Integer);
264: } catch (QInvalidCastException $objExc) {
265: $objExc->IncrementOffset();
266: throw $objExc;
267: }
268: $this->blnModified = true;
269: $objColumn->_ParentTable = $this;
270: if ($intColumnIndex < 0 || $intColumnIndex > count($this->objColumnArray)) {
271: $this->objColumnArray[] = $objColumn;
272: }
273: elseif ($intColumnIndex == 0) {
274: $this->objColumnArray = array_merge(array($objColumn), $this->objColumnArray);
275: } else {
276: $this->objColumnArray = array_merge(array_slice($this->objColumnArray, 0, $intColumnIndex),
277: array($objColumn),
278: array_slice($this->objColumnArray, $intColumnIndex));
279: }
280: }
281:
282: /**
283: * Removes a column from the table
284: *
285: * @param int $intColumnIndex 0-based index of the column to remove
286: *
287: * @return QAbstractHtmlTableColumn the removed column
288: * @throws QIndexOutOfRangeException|QInvalidCastException
289: */
290: public function RemoveColumn($intColumnIndex) {
291: $this->blnModified = true;
292: try {
293: $intColumnIndex = QType::Cast($intColumnIndex, QType::Integer);
294: } catch (QInvalidCastException $objExc) {
295: $objExc->IncrementOffset();
296: throw $objExc;
297: }
298: if ($intColumnIndex < 0 || $intColumnIndex > count($this->objColumnArray)) {
299: throw new QIndexOutOfRangeException($intColumnIndex, "RemoveColumn()");
300: }
301:
302: $col = $this->objColumnArray[$intColumnIndex];
303: array_splice($this->objColumnArray, $intColumnIndex, 1);
304: return $col;
305: }
306:
307: /**
308: * Removes the column by column id. Assumes the ids are unique.
309: *
310: * @param $strId
311: */
312: public function RemoveColumnById($strId) {
313: if ($this->objColumnArray && ($count = count($this->objColumnArray))) {
314: for ($i = 0; $i < $count; $i++) {
315: if ($this->objColumnArray[$i]->Id === $strId) {
316: $this->RemoveColumn($i);
317: return;
318: }
319: }
320: }
321: }
322:
323: /**
324: * Remove the first column that has the given name
325: *
326: * @param string $strName name of the column to remove
327: *
328: * @return QAbstractHtmlTableColumn the removed column or null of no column with the given name was found
329: */
330: public function RemoveColumnByName($strName) {
331: $this->blnModified = true;
332: for ($intIndex = 0; $intIndex < count($this->objColumnArray); $intIndex++) {
333: if ($this->objColumnArray[$intIndex]->Name == $strName) {
334: $col = $this->objColumnArray[$intIndex];
335: array_splice($this->objColumnArray, $intIndex, 1);
336: return $col;
337: }
338: }
339: return null;
340: }
341:
342: /**
343: * Remove all the columns that have the given name
344: *
345: * @param string $strName name of the columns to remove
346: *
347: * @return QAbstractHtmlTableColumn[] the array of columns removed
348: */
349: public function RemoveColumnsByName($strName/*...*/) {
350: return $this->RemoveColumns(func_get_args());
351: }
352:
353: /**
354: * Remove all the columns that have any of the names in $strNamesArray
355: *
356: * @param string[] $strNamesArray names of the columns to remove
357: *
358: * @return QAbstractHtmlTableColumn[] the array of columns removed
359: */
360: public function RemoveColumns($strNamesArray) {
361: $this->blnModified = true;
362: $kept = array();
363: $removed = array();
364: foreach ($this->objColumnArray as $objColumn) {
365: if (array_search($objColumn->Name, $strNamesArray) === false) {
366: $kept[] = $objColumn;
367: } else {
368: $removed[] = $objColumn;
369: }
370: }
371: $this->objColumnArray = $kept;
372: return $removed;
373: }
374:
375: /**
376: * Remove all columns from the grid.
377: */
378: public function RemoveAllColumns() {
379: $this->blnModified = true;
380: $this->objColumnArray = array();
381: }
382:
383: /**
384: * Hide all columns without removing them from the grid. They will not display in the html, but they will
385: * still be part of the form state.
386: */
387: public function HideAllColumns() {
388: foreach ($this->objColumnArray as $objColumn) {
389: $objColumn->Visible = false;
390: }
391: $this->blnModified = true;
392: }
393:
394: /**
395: * Show all columns.
396: */
397: public function ShowAllColumns() {
398: foreach ($this->objColumnArray as $objColumn) {
399: $objColumn->Visible = true;
400: }
401: $this->blnModified = true;
402: }
403:
404:
405:
406: /**
407: * Returns all columns in the table
408: *
409: * @return QAbstractHtmlTableColumn[]
410: */
411: public function GetAllColumns() {
412: return $this->objColumnArray;
413: }
414:
415: /**
416: * Get the column at the given index, or null if the index is not valid
417: *
418: * @param integer $intColumnIndex
419: * @param boolean $blnVisible true to only count the visible columns
420: *
421: * @return QAbstractHtmlTableColumn
422: */
423: public function GetColumn($intColumnIndex, $blnVisible = false) {
424: if (!$blnVisible) {
425: if (array_key_exists($intColumnIndex, $this->objColumnArray)) {
426: return $this->objColumnArray[$intColumnIndex];
427: }
428: } else {
429: $i = 0;
430: foreach ($this->objColumnArray as $objColumn) {
431: if ($objColumn->Visible) {
432: if ($i == $intColumnIndex) {
433: return $objColumn;
434: }
435: $i++;
436: }
437: }
438: }
439: return null;
440: }
441:
442: /**
443: * Get the first column that has the given name, or null if a column with the given name does not exist
444: *
445: * @param string $strName column name
446: *
447: * @return QAbstractHtmlTableColumn
448: */
449: public function GetColumnByName($strName) {
450: if ($this->objColumnArray) foreach ($this->objColumnArray as $objColumn)
451: if ($objColumn->Name == $strName)
452: return $objColumn;
453: return null;
454: }
455:
456: /**
457: * @param $strId
458: *
459: * @return null|QAbstractHtmlTableColumn
460: */
461: public function GetColumnById($strId) {
462: if ($this->objColumnArray) foreach ($this->objColumnArray as $objColumn)
463: if ($objColumn->Id === $strId)
464: return $objColumn;
465: return null;
466: }
467:
468:
469: /**
470: * Get the first column that has the given name, or null if a column with the given name does not exist
471: *
472: * @param string $strName column name
473: *
474: * @return QAbstractHtmlTableColumn
475: */
476: public function GetColumnIndex($strName) {
477: $intIndex = -1;
478: if ($this->objColumnArray) foreach ($this->objColumnArray as $objColumn) {
479: ++$intIndex;
480: if ($objColumn->Name == $strName)
481: return $intIndex;
482: }
483: return $intIndex;
484: }
485:
486: /**
487: * Get all the columns that have the given name
488: *
489: * @param string $strName column name
490: *
491: * @return QAbstractHtmlTableColumn[]
492: */
493: public function GetColumnsByName($strName) {
494: $objColumnArrayToReturn = array();
495: if ($this->objColumnArray) foreach ($this->objColumnArray as $objColumn)
496: if ($objColumn->Name == $strName)
497: array_push($objColumnArrayToReturn, $objColumn);
498: return $objColumnArrayToReturn;
499: }
500:
501: /**
502: * Returns the HTML for the header row, including the <<tr>> and <</tr>> tags
503: */
504: protected function GetHeaderRowHtml() {
505: $strToReturn = '';
506: for ($i = 0; $i < $this->intHeaderRowCount; $i++) {
507: $this->intCurrentHeaderRowIndex = $i;
508:
509: $strCells = '';
510: if ($this->objColumnArray) foreach ($this->objColumnArray as $objColumn) {
511: $strCells .= $objColumn->RenderHeaderCell();
512: }
513: $strToReturn .= QHtml::RenderTag('tr', $this->GetHeaderRowParams(), $strCells);
514: }
515:
516: return $strToReturn;
517: }
518:
519: /**
520: * Returns a key=>val array of parameters to insert inside of the header row's <<tr>> tag.
521: *
522: * @return array
523: */
524: protected function GetHeaderRowParams () {
525: $strParamArray = array();
526: if ($strClass = $this->strHeaderRowCssClass) {
527: $strParamArray['class'] = $strClass;
528: }
529: return $strParamArray;
530: }
531:
532:
533: /**
534: * Get the html for the row, from the opening <<tr>> to the closing <</tr>> inclusive
535: *
536: * @param object $objObject Current object from the DataSource array
537: * @param integer $intCurrentRowIndex Current visual row index being output.
538: * This is NOT the index of the data source,
539: * only the visual row number currently on screen.
540: *
541: * @return string
542: * @throws Exception
543: * @throws QCallerException
544: */
545: protected function GetDataGridRowHtml($objObject, $intCurrentRowIndex) {
546: $strCells = '';
547: foreach ($this->objColumnArray as $objColumn) {
548: try {
549: $strCells .= $objColumn->RenderCell($objObject);
550: } catch (QCallerException $objExc) {
551: $objExc->IncrementOffset();
552: throw $objExc;
553: }
554: }
555:
556: return QHtml::RenderTag('tr', $this->GetRowParams($objObject, $intCurrentRowIndex), $strCells);
557: }
558:
559: /**
560: * Returns a key/val array of params that will be inserted inside the <<tr>> tag for this row.
561: *
562: * Handles class, style, and id by default. Override to add additional types of parameters,
563: * like an 'onclick' paramater for example. No checking is done on these params, the raw strings are output.
564: *
565: * @param mixed $objObject The object of data being used as the row.
566: * @param integer $intCurrentRowIndex
567: * @return array Array of key/value pairs that will be used as attributes for the row tag.
568: */
569: protected function GetRowParams ($objObject, $intCurrentRowIndex) {
570: $strParamArray = array();
571: if ($this->objRowParamsCallback) {
572: $strParamArray = call_user_func($this->objRowParamsCallback, $objObject, $intCurrentRowIndex);
573: }
574: if ($strClass = $this->GetRowClass ($objObject, $intCurrentRowIndex)) {
575: $strParamArray['class'] = $strClass;
576: }
577:
578: if ($strId = $this->GetRowId ($objObject, $intCurrentRowIndex)) {
579: $strParamArray['id'] = $strId;
580: }
581:
582: if ($strStyle = $this->GetRowStyle ($objObject, $intCurrentRowIndex)) {
583: $strParamArray['style'] = $strStyle;
584: }
585: return $strParamArray;
586: }
587:
588:
589: /**
590: * Return the html row id.
591: * Override this to give the row an id.
592: *
593: * @param object $objObject object associated with this row
594: * @param integer $intRowIndex index of the row
595: *
596: * @return null
597: */
598: protected function GetRowId ($objObject, $intRowIndex) {
599: return null;
600: }
601:
602: /**
603: * Return the style string for this row.
604: *
605: * @param object $objObject
606: * @param integer $intRowIndex
607: *
608: * @return null
609: */
610: protected function GetRowStyle ($objObject, $intRowIndex) {
611: return null;
612: }
613:
614: /**
615: * Return the class string of this row.
616: *
617: * @param object $objObject
618: * @param integer $intRowIndex
619: *
620: * @return null
621: */
622: protected function GetRowClass ($objObject, $intRowIndex) {
623: if (($intRowIndex % 2) == 1 && $this->strAlternateRowCssClass) {
624: return $this->strAlternateRowCssClass;
625: } else if ($this->strRowCssClass) {
626: return $this->strRowCssClass;
627: }
628: else {
629: return null;
630: }
631: }
632:
633: /**
634: * Override to return the footer row html
635: */
636: protected function GetFooterRowHtml() { }
637:
638: /**
639: * Returns column tags. Only called if blnRenderColumnTags is true.
640: * @return string Column tag html
641: */
642: protected function GetColumnTagsHtml() {
643: $strToReturn = '';
644: $len = count($this->objColumnArray);
645: $i = 0;
646: while ($i < $len) {
647: $objColumn = $this->objColumnArray[$i];
648: if ($objColumn->Visible) {
649: $strToReturn .= $objColumn->RenderColTag() . _nl();
650: }
651: $i += $objColumn->Span;
652: }
653: return $strToReturn;
654: }
655:
656: /**
657: * Returns the caption string which can be used for the table.
658: *
659: * @return string
660: */
661: protected function RenderCaption() {
662: $strHtml = '';
663: if ($this->strCaption) {
664: $strHtml .= '<caption>' . QApplication::HtmlEntities($this->strCaption) . '</caption>' . _nl();
665: }
666: return $strHtml;
667: }
668:
669: /**
670: * Return the html for the table.
671: *
672: * @return string
673: */
674: protected function GetControlHtml() {
675: $this->DataBind();
676:
677: if (empty ($this->objDataSource) && $this->blnHideIfEmpty) {
678: $this->objDataSource = null;
679: return '';
680: }
681:
682:
683: $strHtml = $this->RenderCaption();
684:
685: // Column tags (if applicable)
686: if ($this->blnRenderColumnTags) {
687: $strHtml .= $this->GetColumnTagsHtml();
688: }
689:
690: // Header Row (if applicable)
691: if ($this->blnShowHeader) {
692: $strHtml .= QHtml::RenderTag ('thead', null, $this->GetHeaderRowHtml());
693: }
694:
695: // Footer Row (if applicable)
696: if ($this->blnShowFooter) {
697: $strHtml .= QHtml::RenderTag ('tfoot', null, $this->GetFooterRowHtml());
698: }
699:
700: // DataGrid Rows
701: $strRows = '';
702: $this->intCurrentRowIndex = 0;
703: if ($this->objDataSource) {
704: foreach ($this->objDataSource as $objObject) {
705: $strRows .= $this->GetDataGridRowHtml($objObject, $this->intCurrentRowIndex);
706: $this->intCurrentRowIndex++;
707: }
708: }
709: $strHtml .= QHtml::RenderTag('tbody', null, $strRows);
710:
711: $strHtml = $this->RenderTag('table', null, null, $strHtml);
712:
713: $this->objDataSource = null;
714: return $strHtml;
715: }
716:
717: /**
718: * Preserialize the columns, since some columns might have references to the form.
719: */
720: public function Sleep() {
721: if ($this->objColumnArray) {
722: foreach ($this->objColumnArray as $objColumn) {
723: $objColumn->Sleep();
724: }
725: }
726: $this->objRowParamsCallback = QControl::SleepHelper($this->objRowParamsCallback);
727: parent::Sleep();
728: }
729:
730: /**
731: * Restore references.
732: *
733: * @param QForm $objForm
734: */
735: public function Wakeup(QForm $objForm) {
736: parent::Wakeup($objForm);
737: $this->objRowParamsCallback = QControl::WakeupHelper($objForm, $this->objRowParamsCallback);
738: if ($this->objColumnArray) {
739: foreach ($this->objColumnArray as $objColumn) {
740: $objColumn->Wakeup($objForm);
741: }
742: }
743: }
744:
745: /**
746: * PHP magic method
747: *
748: * @param string $strName
749: *
750: * @return bool|int|mixed|null
751: * @throws Exception
752: * @throws QCallerException
753: */
754: public function __get($strName) {
755: switch ($strName) {
756: case 'RowCssClass':
757: return $this->strRowCssClass;
758: case 'AlternateRowCssClass':
759: return $this->strAlternateRowCssClass;
760: case 'HeaderRowCssClass':
761: return $this->strHeaderRowCssClass;
762: case 'ShowHeader':
763: return $this->blnShowHeader;
764: case 'ShowFooter':
765: return $this->blnShowFooter;
766: case 'RenderColumnTags':
767: return $this->blnRenderColumnTags;
768: case 'Caption':
769: return $this->strCaption;
770: case 'HeaderRowCount':
771: return $this->intHeaderRowCount;
772: case 'CurrentHeaderRowIndex':
773: return $this->intCurrentHeaderRowIndex;
774: case 'HideIfEmpty':
775: return $this->blnHideIfEmpty;
776: case 'CurrentRowIndex':
777: return $this->intCurrentRowIndex;
778:
779: default:
780: try {
781: return parent::__get($strName);
782: } catch (QCallerException $objExc) {
783: $objExc->IncrementOffset();
784: throw $objExc;
785: }
786: }
787: }
788:
789: /**
790: * PHP magic method
791: *
792: * @param string $strName
793: * @param string $mixValue
794: *
795: * @return mixed|void
796: * @throws Exception
797: * @throws QCallerException
798: * @throws QInvalidCastException
799: */
800: public function __set($strName, $mixValue) {
801: switch ($strName) {
802: case "RowCssClass":
803: try {
804: $this->strRowCssClass = QType::Cast($mixValue, QType::String);
805: break;
806: } catch (QInvalidCastException $objExc) {
807: $objExc->IncrementOffset();
808: throw $objExc;
809: }
810:
811: case "AlternateRowCssClass":
812: try {
813: $this->strAlternateRowCssClass = QType::Cast($mixValue, QType::String);
814: break;
815: } catch (QInvalidCastException $objExc) {
816: $objExc->IncrementOffset();
817: throw $objExc;
818: }
819:
820: case "HeaderRowCssClass":
821: try {
822: $this->strHeaderRowCssClass = QType::Cast($mixValue, QType::String);
823: break;
824: } catch (QInvalidCastException $objExc) {
825: $objExc->IncrementOffset();
826: throw $objExc;
827: }
828:
829: case "ShowHeader":
830: try {
831: $this->blnShowHeader = QType::Cast($mixValue, QType::Boolean);
832: break;
833: } catch (QInvalidCastException $objExc) {
834: $objExc->IncrementOffset();
835: throw $objExc;
836: }
837:
838: case "ShowFooter":
839: try {
840: $this->blnShowFooter = QType::Cast($mixValue, QType::Boolean);
841: break;
842: } catch (QInvalidCastException $objExc) {
843: $objExc->IncrementOffset();
844: throw $objExc;
845: }
846:
847: case "RenderColumnTags":
848: try {
849: $this->blnRenderColumnTags = QType::Cast($mixValue, QType::Boolean);
850: break;
851: } catch (QInvalidCastException $objExc) {
852: $objExc->IncrementOffset();
853: throw $objExc;
854: }
855:
856: case "Caption":
857: try {
858: $this->strCaption = QType::Cast($mixValue, QType::String);
859: break;
860: } catch (QInvalidCastException $objExc) {
861: $objExc->IncrementOffset();
862: throw $objExc;
863: }
864:
865: case "HeaderRowCount":
866: try {
867: $this->intHeaderRowCount = QType::Cast($mixValue, QType::Integer);
868: break;
869: } catch (QInvalidCastException $objExc) {
870: $objExc->IncrementOffset();
871: throw $objExc;
872: }
873:
874: case "HideIfEmpty":
875: try {
876: $this->blnHideIfEmpty = QType::Cast($mixValue, QType::Boolean);
877: break;
878: } catch (QInvalidCastException $objExc) {
879: $objExc->IncrementOffset();
880: throw $objExc;
881: }
882:
883: case "RowParamsCallback":
884: try {
885: assert (is_callable($mixValue));
886: $this->objRowParamsCallback = $mixValue;
887: break;
888: } catch (QInvalidCastException $objExc) {
889: $objExc->IncrementOffset();
890: throw $objExc;
891: }
892:
893:
894: default:
895: try {
896: parent::__set($strName, $mixValue);
897: break;
898: } catch (QCallerException $objExc) {
899: $objExc->IncrementOffset();
900: throw $objExc;
901: }
902: }
903: }
904:
905: /**
906: * Returns an description of the options available to modify by the designer for the code generator.
907: *
908: * @return QModelConnectorParam[]
909: */
910: public static function GetModelConnectorParams() {
911: return array_merge(parent::GetModelConnectorParams(), array(
912: new QModelConnectorParam (get_called_class(), 'RowCssClass', 'Css class given to each row', QType::String),
913: new QModelConnectorParam (get_called_class(), 'AlternateRowCssClass', 'Css class given to every other row', QType::String),
914: new QModelConnectorParam (get_called_class(), 'HeaderRowCssClass', 'Css class given to the header rows', QType::String),
915: new QModelConnectorParam (get_called_class(), 'ShowHeader', 'Whether or not to show the header. Default is true.', QType::Boolean),
916: new QModelConnectorParam (get_called_class(), 'ShowFooter', 'Whether or not to show the footer. Default is false.', QType::Boolean),
917: new QModelConnectorParam (get_called_class(), 'RenderColumnTags', 'Whether or not to render html column tags for the columns. Column tags are only needed in special situations. Default is false.', QType::Boolean),
918: new QModelConnectorParam (get_called_class(), 'Caption', 'Text to print in the caption tag of the table.', QType::String),
919: new QModelConnectorParam (get_called_class(), 'HideIfEmpty', 'Whether to draw nothing if there is no data, or draw the table tags with no cells instead. Default is to drag the table tags.', QType::Boolean)
920: ));
921: }
922: }
923: