Complex classes like TDataList often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use TDataList, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 151 | class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUser |
||
| 152 | { |
||
| 153 | /** |
||
| 154 | * Command name that TDataList understands. They are case-insensitive. |
||
| 155 | */ |
||
| 156 | const CMD_SELECT='Select'; |
||
| 157 | const CMD_EDIT='Edit'; |
||
| 158 | const CMD_UPDATE='Update'; |
||
| 159 | const CMD_DELETE='Delete'; |
||
| 160 | const CMD_CANCEL='Cancel'; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @var TDataListItemCollection item list |
||
| 164 | */ |
||
| 165 | private $_items=null; |
||
| 166 | /** |
||
| 167 | * @var Itemplate various item templates |
||
| 168 | */ |
||
| 169 | private $_itemTemplate=null; |
||
| 170 | private $_emptyTemplate=null; |
||
| 171 | private $_alternatingItemTemplate=null; |
||
| 172 | private $_selectedItemTemplate=null; |
||
| 173 | private $_editItemTemplate=null; |
||
| 174 | private $_headerTemplate=null; |
||
| 175 | private $_footerTemplate=null; |
||
| 176 | private $_separatorTemplate=null; |
||
| 177 | /** |
||
| 178 | * @var TControl header item |
||
| 179 | */ |
||
| 180 | private $_header=null; |
||
| 181 | /** |
||
| 182 | * @var TControl footer item |
||
| 183 | */ |
||
| 184 | private $_footer=null; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @return TDataListItemCollection item list |
||
| 188 | */ |
||
| 189 | public function getItems() |
||
| 195 | |||
| 196 | /** |
||
| 197 | * @return integer number of items |
||
| 198 | */ |
||
| 199 | public function getItemCount() |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @return string the class name for datalist items. Defaults to empty, meaning not set. |
||
| 206 | * @since 3.1.0 |
||
| 207 | */ |
||
| 208 | public function getItemRenderer() |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Sets the item renderer class. |
||
| 215 | * |
||
| 216 | * If not empty, the class will be used to instantiate as datalist items. |
||
| 217 | * This property takes precedence over {@link getItemTemplate ItemTemplate}. |
||
| 218 | * |
||
| 219 | * @param string the renderer class name in namespace format. |
||
| 220 | * @see setItemTemplate |
||
| 221 | * @since 3.1.0 |
||
| 222 | */ |
||
| 223 | public function setItemRenderer($value) |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @return string the class name for alternative datalist items. Defaults to empty, meaning not set. |
||
| 230 | * @since 3.1.0 |
||
| 231 | */ |
||
| 232 | public function getAlternatingItemRenderer() |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Sets the alternative item renderer class. |
||
| 239 | * |
||
| 240 | * If not empty, the class will be used to instantiate as alternative datalist items. |
||
| 241 | * This property takes precedence over {@link getAlternatingItemTemplate AlternatingItemTemplate}. |
||
| 242 | * |
||
| 243 | * @param string the renderer class name in namespace format. |
||
| 244 | * @see setAlternatingItemTemplate |
||
| 245 | * @since 3.1.0 |
||
| 246 | */ |
||
| 247 | public function setAlternatingItemRenderer($value) |
||
| 251 | |||
| 252 | /** |
||
| 253 | * @return string the class name for the datalist item being editted. Defaults to empty, meaning not set. |
||
| 254 | * @since 3.1.0 |
||
| 255 | */ |
||
| 256 | public function getEditItemRenderer() |
||
| 260 | |||
| 261 | /** |
||
| 262 | * Sets the renderer class for the datalist item being editted. |
||
| 263 | * |
||
| 264 | * If not empty, the class will be used to instantiate as the datalist item. |
||
| 265 | * This property takes precedence over {@link getEditItemTemplate EditItemTemplate}. |
||
| 266 | * |
||
| 267 | * @param string the renderer class name in namespace format. |
||
| 268 | * @see setEditItemTemplate |
||
| 269 | * @since 3.1.0 |
||
| 270 | */ |
||
| 271 | public function setEditItemRenderer($value) |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @return string the class name for the datalist item being selected. Defaults to empty, meaning not set. |
||
| 278 | * @since 3.1.0 |
||
| 279 | */ |
||
| 280 | public function getSelectedItemRenderer() |
||
| 284 | |||
| 285 | /** |
||
| 286 | * Sets the renderer class for the datalist item being selected. |
||
| 287 | * |
||
| 288 | * If not empty, the class will be used to instantiate as the datalist item. |
||
| 289 | * This property takes precedence over {@link getSelectedItemTemplate SelectedItemTemplate}. |
||
| 290 | * |
||
| 291 | * @param string the renderer class name in namespace format. |
||
| 292 | * @see setSelectedItemTemplate |
||
| 293 | * @since 3.1.0 |
||
| 294 | */ |
||
| 295 | public function setSelectedItemRenderer($value) |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @return string the class name for datalist item separators. Defaults to empty, meaning not set. |
||
| 302 | * @since 3.1.0 |
||
| 303 | */ |
||
| 304 | public function getSeparatorRenderer() |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Sets the datalist item separator renderer class. |
||
| 311 | * |
||
| 312 | * If not empty, the class will be used to instantiate as datalist item separators. |
||
| 313 | * This property takes precedence over {@link getSeparatorTemplate SeparatorTemplate}. |
||
| 314 | * |
||
| 315 | * @param string the renderer class name in namespace format. |
||
| 316 | * @see setSeparatorTemplate |
||
| 317 | * @since 3.1.0 |
||
| 318 | */ |
||
| 319 | public function setSeparatorRenderer($value) |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @return string the class name for datalist header item. Defaults to empty, meaning not set. |
||
| 326 | * @since 3.1.0 |
||
| 327 | */ |
||
| 328 | public function getHeaderRenderer() |
||
| 332 | |||
| 333 | /** |
||
| 334 | * Sets the datalist header renderer class. |
||
| 335 | * |
||
| 336 | * If not empty, the class will be used to instantiate as datalist header item. |
||
| 337 | * This property takes precedence over {@link getHeaderTemplate HeaderTemplate}. |
||
| 338 | * |
||
| 339 | * @param string the renderer class name in namespace format. |
||
| 340 | * @see setHeaderTemplate |
||
| 341 | * @since 3.1.0 |
||
| 342 | */ |
||
| 343 | public function setHeaderRenderer($value) |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @return string the class name for datalist footer item. Defaults to empty, meaning not set. |
||
| 350 | * @since 3.1.0 |
||
| 351 | */ |
||
| 352 | public function getFooterRenderer() |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Sets the datalist footer renderer class. |
||
| 359 | * |
||
| 360 | * If not empty, the class will be used to instantiate as datalist footer item. |
||
| 361 | * This property takes precedence over {@link getFooterTemplate FooterTemplate}. |
||
| 362 | * |
||
| 363 | * @param string the renderer class name in namespace format. |
||
| 364 | * @see setFooterTemplate |
||
| 365 | * @since 3.1.0 |
||
| 366 | */ |
||
| 367 | public function setFooterRenderer($value) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @return string the class name for empty datalist item. Defaults to empty, meaning not set. |
||
| 374 | * @since 3.1.0 |
||
| 375 | */ |
||
| 376 | public function getEmptyRenderer() |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Sets the datalist empty renderer class. |
||
| 383 | * |
||
| 384 | * The empty renderer is created as the child of the datalist |
||
| 385 | * if data bound to the datalist is empty. |
||
| 386 | * This property takes precedence over {@link getEmptyTemplate EmptyTemplate}. |
||
| 387 | * |
||
| 388 | * @param string the renderer class name in namespace format. |
||
| 389 | * @see setEmptyTemplate |
||
| 390 | * @since 3.1.0 |
||
| 391 | */ |
||
| 392 | public function setEmptyRenderer($value) |
||
| 396 | |||
| 397 | /** |
||
| 398 | * @return ITemplate the template for item |
||
| 399 | */ |
||
| 400 | public function getItemTemplate() |
||
| 404 | |||
| 405 | /** |
||
| 406 | * @param ITemplate the template for item |
||
| 407 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 408 | */ |
||
| 409 | public function setItemTemplate($value) |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @return TTableItemStyle the style for item |
||
| 419 | */ |
||
| 420 | public function getItemStyle() |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @return ITemplate the template for each alternating item |
||
| 432 | */ |
||
| 433 | public function getAlternatingItemTemplate() |
||
| 437 | |||
| 438 | /** |
||
| 439 | * @param ITemplate the template for each alternating item |
||
| 440 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 441 | */ |
||
| 442 | public function setAlternatingItemTemplate($value) |
||
| 449 | |||
| 450 | /** |
||
| 451 | * @return TTableItemStyle the style for each alternating item |
||
| 452 | */ |
||
| 453 | public function getAlternatingItemStyle() |
||
| 462 | |||
| 463 | /** |
||
| 464 | * @return ITemplate the selected item template |
||
| 465 | */ |
||
| 466 | public function getSelectedItemTemplate() |
||
| 470 | |||
| 471 | /** |
||
| 472 | * @param ITemplate the selected item template |
||
| 473 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 474 | */ |
||
| 475 | public function setSelectedItemTemplate($value) |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @return TTableItemStyle the style for selected item |
||
| 485 | */ |
||
| 486 | public function getSelectedItemStyle() |
||
| 495 | |||
| 496 | /** |
||
| 497 | * @return ITemplate the edit item template |
||
| 498 | */ |
||
| 499 | public function getEditItemTemplate() |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @param ITemplate the edit item template |
||
| 506 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 507 | */ |
||
| 508 | public function setEditItemTemplate($value) |
||
| 515 | |||
| 516 | /** |
||
| 517 | * @return TTableItemStyle the style for edit item |
||
| 518 | */ |
||
| 519 | public function getEditItemStyle() |
||
| 528 | |||
| 529 | /** |
||
| 530 | * @return ITemplate the header template |
||
| 531 | */ |
||
| 532 | public function getHeaderTemplate() |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @param ITemplate the header template |
||
| 539 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 540 | */ |
||
| 541 | public function setHeaderTemplate($value) |
||
| 548 | |||
| 549 | /** |
||
| 550 | * @return TTableItemStyle the style for header |
||
| 551 | */ |
||
| 552 | public function getHeaderStyle() |
||
| 561 | |||
| 562 | /** |
||
| 563 | * @return TControl the header item |
||
| 564 | */ |
||
| 565 | public function getHeader() |
||
| 569 | |||
| 570 | /** |
||
| 571 | * @return ITemplate the footer template |
||
| 572 | */ |
||
| 573 | public function getFooterTemplate() |
||
| 577 | |||
| 578 | /** |
||
| 579 | * @param ITemplate the footer template |
||
| 580 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 581 | */ |
||
| 582 | public function setFooterTemplate($value) |
||
| 589 | |||
| 590 | /** |
||
| 591 | * @return TTableItemStyle the style for footer |
||
| 592 | */ |
||
| 593 | public function getFooterStyle() |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @return TControl the footer item |
||
| 605 | */ |
||
| 606 | public function getFooter() |
||
| 610 | |||
| 611 | /** |
||
| 612 | * @return ITemplate the template applied when no data is bound to the datalist |
||
| 613 | */ |
||
| 614 | public function getEmptyTemplate() |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @param ITemplate the template applied when no data is bound to the datalist |
||
| 621 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 622 | */ |
||
| 623 | public function setEmptyTemplate($value) |
||
| 630 | |||
| 631 | /** |
||
| 632 | * @return ITemplate the separator template |
||
| 633 | */ |
||
| 634 | public function getSeparatorTemplate() |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @param ITemplate the separator template |
||
| 641 | * @throws TInvalidDataTypeException if the input is not an {@link ITemplate} or not null. |
||
| 642 | */ |
||
| 643 | public function setSeparatorTemplate($value) |
||
| 650 | |||
| 651 | /** |
||
| 652 | * @return TTableItemStyle the style for separator |
||
| 653 | */ |
||
| 654 | public function getSeparatorStyle() |
||
| 663 | |||
| 664 | /** |
||
| 665 | * @return integer the zero-based index of the selected item in {@link getItems Items}. |
||
| 666 | * A value -1 means no item selected. |
||
| 667 | */ |
||
| 668 | public function getSelectedItemIndex() |
||
| 672 | |||
| 673 | /** |
||
| 674 | * Selects an item by its index in {@link getItems Items}. |
||
| 675 | * Previously selected item will be un-selected. |
||
| 676 | * If the item to be selected is already in edit mode, it will remain in edit mode. |
||
| 677 | * If the index is less than 0, any existing selection will be cleared up. |
||
| 678 | * @param integer the selected item index |
||
| 679 | */ |
||
| 680 | public function setSelectedItemIndex($value) |
||
| 703 | |||
| 704 | /** |
||
| 705 | * @return TControl the selected item, null if no item is selected. |
||
| 706 | */ |
||
| 707 | public function getSelectedItem() |
||
| 716 | |||
| 717 | /** |
||
| 718 | * @return mixed the key value of the currently selected item |
||
| 719 | * @throws TInvalidOperationException if {@link getDataKeyField DataKeyField} is empty. |
||
| 720 | */ |
||
| 721 | public function getSelectedDataKey() |
||
| 732 | |||
| 733 | /** |
||
| 734 | * @return integer the zero-based index of the edit item in {@link getItems Items}. |
||
| 735 | * A value -1 means no item is in edit mode. |
||
| 736 | */ |
||
| 737 | public function getEditItemIndex() |
||
| 741 | |||
| 742 | /** |
||
| 743 | * Edits an item by its index in {@link getItems Items}. |
||
| 744 | * Previously editting item will change to normal item state. |
||
| 745 | * If the index is less than 0, any existing edit item will be cleared up. |
||
| 746 | * @param integer the edit item index |
||
| 747 | */ |
||
| 748 | public function setEditItemIndex($value) |
||
| 763 | |||
| 764 | /** |
||
| 765 | * @return TControl the edit item |
||
| 766 | */ |
||
| 767 | public function getEditItem() |
||
| 776 | |||
| 777 | /** |
||
| 778 | * @return boolean whether the header should be shown. Defaults to true. |
||
| 779 | */ |
||
| 780 | public function getShowHeader() |
||
| 784 | |||
| 785 | /** |
||
| 786 | * @param boolean whether to show header |
||
| 787 | */ |
||
| 788 | public function setShowHeader($value) |
||
| 792 | |||
| 793 | /** |
||
| 794 | * @return boolean whether the footer should be shown. Defaults to true. |
||
| 795 | */ |
||
| 796 | public function getShowFooter() |
||
| 800 | |||
| 801 | /** |
||
| 802 | * @param boolean whether to show footer |
||
| 803 | */ |
||
| 804 | public function setShowFooter($value) |
||
| 808 | |||
| 809 | /** |
||
| 810 | * @return TRepeatInfo repeat information (primarily used by control developers) |
||
| 811 | */ |
||
| 812 | protected function getRepeatInfo() |
||
| 821 | |||
| 822 | /** |
||
| 823 | * @return string caption of the table layout |
||
| 824 | */ |
||
| 825 | public function getCaption() |
||
| 829 | |||
| 830 | /** |
||
| 831 | * @param string caption of the table layout |
||
| 832 | */ |
||
| 833 | public function setCaption($value) |
||
| 837 | |||
| 838 | /** |
||
| 839 | * @return TTableCaptionAlign alignment of the caption of the table layout. Defaults to TTableCaptionAlign::NotSet. |
||
| 840 | */ |
||
| 841 | public function getCaptionAlign() |
||
| 845 | |||
| 846 | /** |
||
| 847 | * @return TTableCaptionAlign alignment of the caption of the table layout. |
||
| 848 | */ |
||
| 849 | public function setCaptionAlign($value) |
||
| 853 | |||
| 854 | /** |
||
| 855 | * @return integer the number of columns that the list should be displayed with. Defaults to 0 meaning not set. |
||
| 856 | */ |
||
| 857 | public function getRepeatColumns() |
||
| 861 | |||
| 862 | /** |
||
| 863 | * @param integer the number of columns that the list should be displayed with. |
||
| 864 | */ |
||
| 865 | public function setRepeatColumns($value) |
||
| 869 | |||
| 870 | /** |
||
| 871 | * @return TRepeatDirection the direction of traversing the list, defaults to TRepeatDirection::Vertical |
||
| 872 | */ |
||
| 873 | public function getRepeatDirection() |
||
| 877 | |||
| 878 | /** |
||
| 879 | * @param TRepeatDirection the direction of traversing the list |
||
| 880 | */ |
||
| 881 | public function setRepeatDirection($value) |
||
| 885 | |||
| 886 | /** |
||
| 887 | * @return TRepeatLayout how the list should be displayed, using table or using line breaks. Defaults to TRepeatLayout::Table. |
||
| 888 | */ |
||
| 889 | public function getRepeatLayout() |
||
| 893 | |||
| 894 | /** |
||
| 895 | * @param TRepeatLayout how the list should be displayed, using table or using line breaks |
||
| 896 | */ |
||
| 897 | public function setRepeatLayout($value) |
||
| 901 | |||
| 902 | /** |
||
| 903 | * This method overrides parent's implementation to handle |
||
| 904 | * {@link onItemCommand OnItemCommand} event which is bubbled from |
||
| 905 | * datalist items and their child controls. |
||
| 906 | * If the event parameter is {@link TDataListCommandEventParameter} and |
||
| 907 | * the command name is a recognized one, which includes 'select', 'edit', |
||
| 908 | * 'delete', 'update', and 'cancel' (case-insensitive), then a |
||
| 909 | * corresponding command event is also raised (such as {@link onEditCommand OnEditCommand}). |
||
| 910 | * This method should only be used by control developers. |
||
| 911 | * @param TControl the sender of the event |
||
| 912 | * @param TEventParameter event parameter |
||
| 913 | * @return boolean whether the event bubbling should stop here. |
||
| 914 | */ |
||
| 915 | public function bubbleEvent($sender,$param) |
||
| 951 | |||
| 952 | |||
| 953 | /** |
||
| 954 | * Raises <b>OnItemCreated</b> event. |
||
| 955 | * This method is invoked after a data list item is created and instantiated with |
||
| 956 | * template, but before added to the page hierarchy. |
||
| 957 | * The datalist item control responsible for the event |
||
| 958 | * can be determined from the event parameter. |
||
| 959 | * If you override this method, be sure to call parent's implementation |
||
| 960 | * so that event handlers have chance to respond to the event. |
||
| 961 | * @param TDataListItemEventParameter event parameter |
||
| 962 | */ |
||
| 963 | public function onItemCreated($param) |
||
| 967 | |||
| 968 | /** |
||
| 969 | * Raises <b>OnItemDataBound</b> event. |
||
| 970 | * This method is invoked right after an item is data bound. |
||
| 971 | * The datalist item control responsible for the event |
||
| 972 | * can be determined from the event parameter. |
||
| 973 | * If you override this method, be sure to call parent's implementation |
||
| 974 | * so that event handlers have chance to respond to the event. |
||
| 975 | * @param TDataListItemEventParameter event parameter |
||
| 976 | */ |
||
| 977 | public function onItemDataBound($param) |
||
| 981 | |||
| 982 | /** |
||
| 983 | * Raises <b>OnItemCommand</b> event. |
||
| 984 | * This method is invoked when a child control of the data list |
||
| 985 | * raises an <b>OnCommand</b> event. |
||
| 986 | * @param TDataListCommandEventParameter event parameter |
||
| 987 | */ |
||
| 988 | public function onItemCommand($param) |
||
| 992 | |||
| 993 | /** |
||
| 994 | * Raises <b>OnEditCommand</b> event. |
||
| 995 | * This method is invoked when a child control of the data list |
||
| 996 | * raises an <b>OnCommand</b> event and the command name is 'edit' (case-insensitive). |
||
| 997 | * @param TDataListCommandEventParameter event parameter |
||
| 998 | */ |
||
| 999 | public function onEditCommand($param) |
||
| 1003 | |||
| 1004 | /** |
||
| 1005 | * Raises <b>OnDeleteCommand</b> event. |
||
| 1006 | * This method is invoked when a child control of the data list |
||
| 1007 | * raises an <b>OnCommand</b> event and the command name is 'delete' (case-insensitive). |
||
| 1008 | * @param TDataListCommandEventParameter event parameter |
||
| 1009 | */ |
||
| 1010 | public function onDeleteCommand($param) |
||
| 1014 | |||
| 1015 | /** |
||
| 1016 | * Raises <b>OnUpdateCommand</b> event. |
||
| 1017 | * This method is invoked when a child control of the data list |
||
| 1018 | * raises an <b>OnCommand</b> event and the command name is 'update' (case-insensitive). |
||
| 1019 | * @param TDataListCommandEventParameter event parameter |
||
| 1020 | */ |
||
| 1021 | public function onUpdateCommand($param) |
||
| 1025 | |||
| 1026 | /** |
||
| 1027 | * Raises <b>OnCancelCommand</b> event. |
||
| 1028 | * This method is invoked when a child control of the data list |
||
| 1029 | * raises an <b>OnCommand</b> event and the command name is 'cancel' (case-insensitive). |
||
| 1030 | * @param TDataListCommandEventParameter event parameter |
||
| 1031 | */ |
||
| 1032 | public function onCancelCommand($param) |
||
| 1036 | |||
| 1037 | /** |
||
| 1038 | * Returns a value indicating whether this control contains header item. |
||
| 1039 | * This method is required by {@link IRepeatInfoUser} interface. |
||
| 1040 | * @return boolean whether the datalist has header |
||
| 1041 | */ |
||
| 1042 | public function getHasHeader() |
||
| 1046 | |||
| 1047 | /** |
||
| 1048 | * Returns a value indicating whether this control contains footer item. |
||
| 1049 | * This method is required by {@link IRepeatInfoUser} interface. |
||
| 1050 | * @return boolean whether the datalist has footer |
||
| 1051 | */ |
||
| 1052 | public function getHasFooter() |
||
| 1056 | |||
| 1057 | /** |
||
| 1058 | * Returns a value indicating whether this control contains separator items. |
||
| 1059 | * This method is required by {@link IRepeatInfoUser} interface. |
||
| 1060 | * @return boolean always false. |
||
| 1061 | */ |
||
| 1062 | public function getHasSeparators() |
||
| 1066 | |||
| 1067 | /** |
||
| 1068 | * Returns a style used for rendering items. |
||
| 1069 | * This method is required by {@link IRepeatInfoUser} interface. |
||
| 1070 | * @param string item type (Header,Footer,Item,AlternatingItem,SelectedItem,EditItem,Separator,Pager) |
||
| 1071 | * @param integer index of the item being rendered |
||
| 1072 | * @return TStyle item style |
||
| 1073 | */ |
||
| 1074 | public function generateItemStyle($itemType,$index) |
||
| 1085 | |||
| 1086 | /** |
||
| 1087 | * Renders an item in the list. |
||
| 1088 | * This method is required by {@link IRepeatInfoUser} interface. |
||
| 1089 | * @param THtmlWriter writer for rendering purpose |
||
| 1090 | * @param TRepeatInfo repeat information |
||
| 1091 | * @param string item type (Header,Footer,Item,AlternatingItem,SelectedItem,EditItem,Separator,Pager) |
||
| 1092 | * @param integer zero-based index of the item in the item list |
||
| 1093 | */ |
||
| 1094 | public function renderItem($writer,$repeatInfo,$itemType,$index) |
||
| 1101 | |||
| 1102 | /** |
||
| 1103 | * @param TListItemType item type |
||
| 1104 | * @param integer item index |
||
| 1105 | * @return TControl data list item with the specified item type and index |
||
| 1106 | */ |
||
| 1107 | private function getItem($itemType,$index) |
||
| 1128 | |||
| 1129 | /** |
||
| 1130 | * Creates a datalist item. |
||
| 1131 | * This method invokes {@link createItem} to create a new datalist item. |
||
| 1132 | * @param integer zero-based item index. |
||
| 1133 | * @param TListItemType item type |
||
| 1134 | * @return TControl the created item, null if item is not created |
||
| 1135 | */ |
||
| 1136 | private function createItemInternal($itemIndex,$itemType) |
||
| 1148 | |||
| 1149 | /** |
||
| 1150 | * Creates a datalist item and performs databinding. |
||
| 1151 | * This method invokes {@link createItem} to create a new datalist item. |
||
| 1152 | * @param integer zero-based item index. |
||
| 1153 | * @param TListItemType item type |
||
| 1154 | * @param mixed data to be associated with the item |
||
| 1155 | * @return TControl the created item, null if item is not created |
||
| 1156 | */ |
||
| 1157 | private function createItemWithDataInternal($itemIndex,$itemType,$dataItem) |
||
| 1173 | |||
| 1174 | private function getAlternatingItemDisplay() |
||
| 1181 | |||
| 1182 | private function getSelectedItemDisplay($itemIndex) |
||
| 1194 | |||
| 1195 | private function getEditItemDisplay($itemIndex) |
||
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Creates a datalist item instance based on the item type and index. |
||
| 1205 | * @param integer zero-based item index |
||
| 1206 | * @param TListItemType item type |
||
| 1207 | * @return TControl created datalist item |
||
| 1208 | */ |
||
| 1209 | protected function createItem($itemIndex,$itemType) |
||
| 1264 | |||
| 1265 | /** |
||
| 1266 | * Creates empty datalist content. |
||
| 1267 | */ |
||
| 1268 | protected function createEmptyContent() |
||
| 1275 | |||
| 1276 | /** |
||
| 1277 | * Applies styles to items, header, footer and separators. |
||
| 1278 | * Item styles are applied in a hierarchical way. Style in higher hierarchy |
||
| 1279 | * will inherit from styles in lower hierarchy. |
||
| 1280 | * Starting from the lowest hierarchy, the item styles include |
||
| 1281 | * item's own style, {@link getItemStyle ItemStyle}, {@link getAlternatingItemStyle AlternatingItemStyle}, |
||
| 1282 | * {@link getSelectedItemStyle SelectedItemStyle}, and {@link getEditItemStyle EditItemStyle}. |
||
| 1283 | * Therefore, if background color is set as red in {@link getItemStyle ItemStyle}, |
||
| 1284 | * {@link getEditItemStyle EditItemStyle} will also have red background color |
||
| 1285 | * unless it is set to a different value explicitly. |
||
| 1286 | */ |
||
| 1287 | protected function applyItemStyles() |
||
| 1355 | |||
| 1356 | /** |
||
| 1357 | * Saves item count in viewstate. |
||
| 1358 | * This method is invoked right before control state is to be saved. |
||
| 1359 | */ |
||
| 1360 | public function saveState() |
||
| 1368 | |||
| 1369 | /** |
||
| 1370 | * Loads item count information from viewstate. |
||
| 1371 | * This method is invoked right after control state is loaded. |
||
| 1372 | */ |
||
| 1373 | public function loadState() |
||
| 1380 | |||
| 1381 | /** |
||
| 1382 | * Clears up all items in the data list. |
||
| 1383 | */ |
||
| 1384 | public function reset() |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Creates data list items based on viewstate information. |
||
| 1394 | */ |
||
| 1395 | protected function restoreItemsFromViewState() |
||
| 1423 | |||
| 1424 | /** |
||
| 1425 | * Performs databinding to populate data list items from data source. |
||
| 1426 | * This method is invoked by dataBind(). |
||
| 1427 | * You may override this function to provide your own way of data population. |
||
| 1428 | * @param Traversable the data |
||
| 1429 | */ |
||
| 1430 | protected function performDataBinding($data) |
||
| 1469 | |||
| 1470 | /** |
||
| 1471 | * Renders the data list control. |
||
| 1472 | * This method overrides the parent implementation. |
||
| 1473 | * @param THtmlWriter writer for rendering purpose. |
||
| 1474 | */ |
||
| 1475 | public function render($writer) |
||
| 1489 | } |
||
| 1490 | |||
| 1761 |
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.