@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function addParsedObject($object) |
226 | 226 | { |
227 | - if($object instanceof TDataGridColumn) |
|
227 | + if ($object instanceof TDataGridColumn) |
|
228 | 228 | $this->getColumns()->add($object); |
229 | 229 | else |
230 | - parent::addParsedObject($object); // this is needed by EmptyTemplate |
|
230 | + parent::addParsedObject($object); // this is needed by EmptyTemplate |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function getColumns() |
237 | 237 | { |
238 | - if(!$this->_columns) |
|
238 | + if (!$this->_columns) |
|
239 | 239 | $this->_columns = new TDataGridColumnCollection($this); |
240 | 240 | return $this->_columns; |
241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function getAutoColumns() |
247 | 247 | { |
248 | - if(!$this->_autoColumns) |
|
248 | + if (!$this->_autoColumns) |
|
249 | 249 | $this->_autoColumns = new TDataGridColumnCollection($this); |
250 | 250 | return $this->_autoColumns; |
251 | 251 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function getItems() |
257 | 257 | { |
258 | - if(!$this->_items) |
|
258 | + if (!$this->_items) |
|
259 | 259 | $this->_items = new TDataGridItemCollection; |
260 | 260 | return $this->_items; |
261 | 261 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function getItemCount() |
267 | 267 | { |
268 | - return $this->_items?$this->_items->getCount():0; |
|
268 | + return $this->_items ? $this->_items->getCount() : 0; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function getItemStyle() |
301 | 301 | { |
302 | - if(($style = $this->getViewState('ItemStyle', null)) === null) |
|
302 | + if (($style = $this->getViewState('ItemStyle', null)) === null) |
|
303 | 303 | { |
304 | 304 | $style = new TTableItemStyle; |
305 | 305 | $this->setViewState('ItemStyle', $style, null); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function getAlternatingItemStyle() |
314 | 314 | { |
315 | - if(($style = $this->getViewState('AlternatingItemStyle', null)) === null) |
|
315 | + if (($style = $this->getViewState('AlternatingItemStyle', null)) === null) |
|
316 | 316 | { |
317 | 317 | $style = new TTableItemStyle; |
318 | 318 | $this->setViewState('AlternatingItemStyle', $style, null); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function getSelectedItemStyle() |
327 | 327 | { |
328 | - if(($style = $this->getViewState('SelectedItemStyle', null)) === null) |
|
328 | + if (($style = $this->getViewState('SelectedItemStyle', null)) === null) |
|
329 | 329 | { |
330 | 330 | $style = new TTableItemStyle; |
331 | 331 | $this->setViewState('SelectedItemStyle', $style, null); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function getEditItemStyle() |
340 | 340 | { |
341 | - if(($style = $this->getViewState('EditItemStyle', null)) === null) |
|
341 | + if (($style = $this->getViewState('EditItemStyle', null)) === null) |
|
342 | 342 | { |
343 | 343 | $style = new TTableItemStyle; |
344 | 344 | $this->setViewState('EditItemStyle', $style, null); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function getHeaderStyle() |
353 | 353 | { |
354 | - if(($style = $this->getViewState('HeaderStyle', null)) === null) |
|
354 | + if (($style = $this->getViewState('HeaderStyle', null)) === null) |
|
355 | 355 | { |
356 | 356 | $style = new TTableItemStyle; |
357 | 357 | $this->setViewState('HeaderStyle', $style, null); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function getFooterStyle() |
366 | 366 | { |
367 | - if(($style = $this->getViewState('FooterStyle', null)) === null) |
|
367 | + if (($style = $this->getViewState('FooterStyle', null)) === null) |
|
368 | 368 | { |
369 | 369 | $style = new TTableItemStyle; |
370 | 370 | $this->setViewState('FooterStyle', $style, null); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function getPagerStyle() |
379 | 379 | { |
380 | - if(($style = $this->getViewState('PagerStyle', null)) === null) |
|
380 | + if (($style = $this->getViewState('PagerStyle', null)) === null) |
|
381 | 381 | { |
382 | 382 | $style = new TDataGridPagerStyle; |
383 | 383 | $this->setViewState('PagerStyle', $style, null); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function getTableHeadStyle() |
393 | 393 | { |
394 | - if(($style = $this->getViewState('TableHeadStyle', null)) === null) |
|
394 | + if (($style = $this->getViewState('TableHeadStyle', null)) === null) |
|
395 | 395 | { |
396 | 396 | $style = new TStyle; |
397 | 397 | $this->setViewState('TableHeadStyle', $style, null); |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | public function getTableBodyStyle() |
407 | 407 | { |
408 | - if(($style = $this->getViewState('TableBodyStyle', null)) === null) |
|
408 | + if (($style = $this->getViewState('TableBodyStyle', null)) === null) |
|
409 | 409 | { |
410 | 410 | $style = new TStyle; |
411 | 411 | $this->setViewState('TableBodyStyle', $style, null); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getTableFootStyle() |
421 | 421 | { |
422 | - if(($style = $this->getViewState('TableFootStyle', null)) === null) |
|
422 | + if (($style = $this->getViewState('TableFootStyle', null)) === null) |
|
423 | 423 | { |
424 | 424 | $style = new TStyle; |
425 | 425 | $this->setViewState('TableFootStyle', $style, null); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | { |
499 | 499 | $index = $this->getSelectedItemIndex(); |
500 | 500 | $items = $this->getItems(); |
501 | - if($index >= 0 && $index < $items->getCount()) |
|
501 | + if ($index >= 0 && $index < $items->getCount()) |
|
502 | 502 | return $items->itemAt($index); |
503 | 503 | else |
504 | 504 | return null; |
@@ -522,23 +522,23 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function setSelectedItemIndex($value) |
524 | 524 | { |
525 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
525 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
526 | 526 | $value = -1; |
527 | - if(($current = $this->getSelectedItemIndex()) !== $value) |
|
527 | + if (($current = $this->getSelectedItemIndex()) !== $value) |
|
528 | 528 | { |
529 | 529 | $this->setViewState('SelectedItemIndex', $value, -1); |
530 | 530 | $items = $this->getItems(); |
531 | 531 | $itemCount = $items->getCount(); |
532 | - if($current >= 0 && $current < $itemCount) |
|
532 | + if ($current >= 0 && $current < $itemCount) |
|
533 | 533 | { |
534 | 534 | $item = $items->itemAt($current); |
535 | - if($item->getItemType() !== TListItemType::EditItem) |
|
536 | - $item->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
535 | + if ($item->getItemType() !== TListItemType::EditItem) |
|
536 | + $item->setItemType($current % 2 ?TListItemType::AlternatingItem : TListItemType::Item); |
|
537 | 537 | } |
538 | - if($value >= 0 && $value < $itemCount) |
|
538 | + if ($value >= 0 && $value < $itemCount) |
|
539 | 539 | { |
540 | 540 | $item = $items->itemAt($value); |
541 | - if($item->getItemType() !== TListItemType::EditItem) |
|
541 | + if ($item->getItemType() !== TListItemType::EditItem) |
|
542 | 542 | $item->setItemType(TListItemType::SelectedItem); |
543 | 543 | } |
544 | 544 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | { |
552 | 552 | $index = $this->getEditItemIndex(); |
553 | 553 | $items = $this->getItems(); |
554 | - if($index >= 0 && $index < $items->getCount()) |
|
554 | + if ($index >= 0 && $index < $items->getCount()) |
|
555 | 555 | return $items->itemAt($index); |
556 | 556 | else |
557 | 557 | return null; |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function setEditItemIndex($value) |
576 | 576 | { |
577 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
577 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
578 | 578 | $value = -1; |
579 | - if(($current = $this->getEditItemIndex()) !== $value) |
|
579 | + if (($current = $this->getEditItemIndex()) !== $value) |
|
580 | 580 | { |
581 | 581 | $this->setViewState('EditItemIndex', $value, -1); |
582 | 582 | $items = $this->getItems(); |
583 | 583 | $itemCount = $items->getCount(); |
584 | - if($current >= 0 && $current < $itemCount) |
|
585 | - $items->itemAt($current)->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
586 | - if($value >= 0 && $value < $itemCount) |
|
584 | + if ($current >= 0 && $current < $itemCount) |
|
585 | + $items->itemAt($current)->setItemType($current % 2 ?TListItemType::AlternatingItem : TListItemType::Item); |
|
586 | + if ($value >= 0 && $value < $itemCount) |
|
587 | 587 | $items->itemAt($value)->setItemType(TListItemType::EditItem); |
588 | 588 | } |
589 | 589 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | */ |
667 | 667 | public function setEmptyTemplate($value) |
668 | 668 | { |
669 | - if($value instanceof ITemplate || $value === null) |
|
669 | + if ($value instanceof ITemplate || $value === null) |
|
670 | 670 | $this->_emptyTemplate = $value; |
671 | 671 | else |
672 | 672 | throw new TInvalidDataTypeException('datagrid_template_required', 'EmptyTemplate'); |
@@ -687,51 +687,51 @@ discard block |
||
687 | 687 | */ |
688 | 688 | public function bubbleEvent($sender, $param) |
689 | 689 | { |
690 | - if($param instanceof TDataGridCommandEventParameter) |
|
690 | + if ($param instanceof TDataGridCommandEventParameter) |
|
691 | 691 | { |
692 | 692 | $this->onItemCommand($param); |
693 | 693 | $command = $param->getCommandName(); |
694 | - if(strcasecmp($command, self::CMD_SELECT) === 0) |
|
694 | + if (strcasecmp($command, self::CMD_SELECT) === 0) |
|
695 | 695 | { |
696 | 696 | $this->setSelectedItemIndex($param->getItem()->getItemIndex()); |
697 | 697 | $this->onSelectedIndexChanged($param); |
698 | 698 | return true; |
699 | 699 | } |
700 | - elseif(strcasecmp($command, self::CMD_EDIT) === 0) |
|
700 | + elseif (strcasecmp($command, self::CMD_EDIT) === 0) |
|
701 | 701 | { |
702 | 702 | $this->onEditCommand($param); |
703 | 703 | return true; |
704 | 704 | } |
705 | - elseif(strcasecmp($command, self::CMD_DELETE) === 0) |
|
705 | + elseif (strcasecmp($command, self::CMD_DELETE) === 0) |
|
706 | 706 | { |
707 | 707 | $this->onDeleteCommand($param); |
708 | 708 | return true; |
709 | 709 | } |
710 | - elseif(strcasecmp($command, self::CMD_UPDATE) === 0) |
|
710 | + elseif (strcasecmp($command, self::CMD_UPDATE) === 0) |
|
711 | 711 | { |
712 | 712 | $this->onUpdateCommand($param); |
713 | 713 | return true; |
714 | 714 | } |
715 | - elseif(strcasecmp($command, self::CMD_CANCEL) === 0) |
|
715 | + elseif (strcasecmp($command, self::CMD_CANCEL) === 0) |
|
716 | 716 | { |
717 | 717 | $this->onCancelCommand($param); |
718 | 718 | return true; |
719 | 719 | } |
720 | - elseif(strcasecmp($command, self::CMD_SORT) === 0) |
|
720 | + elseif (strcasecmp($command, self::CMD_SORT) === 0) |
|
721 | 721 | { |
722 | 722 | $this->onSortCommand(new TDataGridSortCommandEventParameter($sender, $param)); |
723 | 723 | return true; |
724 | 724 | } |
725 | - elseif(strcasecmp($command, self::CMD_PAGE) === 0) |
|
725 | + elseif (strcasecmp($command, self::CMD_PAGE) === 0) |
|
726 | 726 | { |
727 | 727 | $p = $param->getCommandParameter(); |
728 | - if(strcasecmp($p, self::CMD_PAGE_NEXT) === 0) |
|
728 | + if (strcasecmp($p, self::CMD_PAGE_NEXT) === 0) |
|
729 | 729 | $pageIndex = $this->getCurrentPageIndex() + 1; |
730 | - elseif(strcasecmp($p, self::CMD_PAGE_PREV) === 0) |
|
730 | + elseif (strcasecmp($p, self::CMD_PAGE_PREV) === 0) |
|
731 | 731 | $pageIndex = $this->getCurrentPageIndex() - 1; |
732 | - elseif(strcasecmp($p, self::CMD_PAGE_FIRST) === 0) |
|
732 | + elseif (strcasecmp($p, self::CMD_PAGE_FIRST) === 0) |
|
733 | 733 | $pageIndex = 0; |
734 | - elseif(strcasecmp($p, self::CMD_PAGE_LAST) === 0) |
|
734 | + elseif (strcasecmp($p, self::CMD_PAGE_LAST) === 0) |
|
735 | 735 | $pageIndex = $this->getPageCount() - 1; |
736 | 736 | else |
737 | 737 | $pageIndex = TPropertyValue::ensureInteger($p) - 1; |
@@ -857,25 +857,25 @@ discard block |
||
857 | 857 | public function saveState() |
858 | 858 | { |
859 | 859 | parent::saveState(); |
860 | - if(!$this->getEnableViewState(true)) |
|
860 | + if (!$this->getEnableViewState(true)) |
|
861 | 861 | return; |
862 | - if($this->_items) |
|
862 | + if ($this->_items) |
|
863 | 863 | $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
864 | 864 | else |
865 | 865 | $this->clearViewState('ItemCount'); |
866 | - if($this->_autoColumns) |
|
866 | + if ($this->_autoColumns) |
|
867 | 867 | { |
868 | 868 | $state = []; |
869 | - foreach($this->_autoColumns as $column) |
|
869 | + foreach ($this->_autoColumns as $column) |
|
870 | 870 | $state[] = $column->saveState(); |
871 | 871 | $this->setViewState('AutoColumns', $state, []); |
872 | 872 | } |
873 | 873 | else |
874 | 874 | $this->clearViewState('AutoColumns'); |
875 | - if($this->_columns) |
|
875 | + if ($this->_columns) |
|
876 | 876 | { |
877 | 877 | $state = []; |
878 | - foreach($this->_columns as $column) |
|
878 | + foreach ($this->_columns as $column) |
|
879 | 879 | $state[] = $column->saveState(); |
880 | 880 | $this->setViewState('Columns', $state, []); |
881 | 881 | } |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | public function loadState() |
891 | 891 | { |
892 | 892 | parent::loadState(); |
893 | - if(!$this->getEnableViewState(true)) |
|
893 | + if (!$this->getEnableViewState(true)) |
|
894 | 894 | return; |
895 | - if(!$this->getIsDataBound()) |
|
895 | + if (!$this->getIsDataBound()) |
|
896 | 896 | { |
897 | 897 | $state = $this->getViewState('AutoColumns', []); |
898 | - if(!empty($state)) |
|
898 | + if (!empty($state)) |
|
899 | 899 | { |
900 | 900 | $this->_autoColumns = new TDataGridColumnCollection($this); |
901 | - foreach($state as $st) |
|
901 | + foreach ($state as $st) |
|
902 | 902 | { |
903 | 903 | $column = new $this->AutoGenerateColumnName; |
904 | 904 | $column->loadState($st); |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | else |
909 | 909 | $this->_autoColumns = null; |
910 | 910 | $state = $this->getViewState('Columns', []); |
911 | - if($this->_columns && $this->_columns->getCount() === count($state)) |
|
911 | + if ($this->_columns && $this->_columns->getCount() === count($state)) |
|
912 | 912 | { |
913 | 913 | $i = 0; |
914 | - foreach($this->_columns as $column) |
|
914 | + foreach ($this->_columns as $column) |
|
915 | 915 | { |
916 | 916 | $column->loadState($state[$i]); |
917 | 917 | $i++; |
@@ -953,39 +953,39 @@ discard block |
||
953 | 953 | |
954 | 954 | $items = $this->getItems(); |
955 | 955 | |
956 | - if($columns->getCount()) |
|
956 | + if ($columns->getCount()) |
|
957 | 957 | { |
958 | - foreach($columns as $column) |
|
958 | + foreach ($columns as $column) |
|
959 | 959 | $column->initialize(); |
960 | 960 | $selectedIndex = $this->getSelectedItemIndex(); |
961 | 961 | $editIndex = $this->getEditItemIndex(); |
962 | - for($index = 0;$index < $itemCount;++$index) |
|
962 | + for ($index = 0; $index < $itemCount; ++$index) |
|
963 | 963 | { |
964 | - if($index === 0) |
|
964 | + if ($index === 0) |
|
965 | 965 | { |
966 | - if($allowPaging) |
|
966 | + if ($allowPaging) |
|
967 | 967 | $this->_topPager = $this->createPager(); |
968 | 968 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, false, null, $columns); |
969 | 969 | } |
970 | - if($index === $editIndex) |
|
970 | + if ($index === $editIndex) |
|
971 | 971 | $itemType = TListItemType::EditItem; |
972 | - elseif($index === $selectedIndex) |
|
972 | + elseif ($index === $selectedIndex) |
|
973 | 973 | $itemType = TListItemType::SelectedItem; |
974 | - elseif($index % 2) |
|
974 | + elseif ($index % 2) |
|
975 | 975 | $itemType = TListItemType::AlternatingItem; |
976 | 976 | else |
977 | 977 | $itemType = TListItemType::Item; |
978 | 978 | $items->add($this->createItemInternal($index, $dsIndex, $itemType, false, null, $columns)); |
979 | 979 | $dsIndex++; |
980 | 980 | } |
981 | - if($index > 0) |
|
981 | + if ($index > 0) |
|
982 | 982 | { |
983 | 983 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, false, null, $columns); |
984 | - if($allowPaging) |
|
984 | + if ($allowPaging) |
|
985 | 985 | $this->_bottomPager = $this->createPager(); |
986 | 986 | } |
987 | 987 | } |
988 | - if(!$dsIndex && $this->_emptyTemplate !== null) |
|
988 | + if (!$dsIndex && $this->_emptyTemplate !== null) |
|
989 | 989 | { |
990 | 990 | $this->_useEmptyTemplate = true; |
991 | 991 | $this->_emptyTemplate->instantiateIn($this); |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | $keyField = $this->getDataKeyField(); |
1007 | 1007 | |
1008 | 1008 | // get all columns |
1009 | - if($this->getAutoGenerateColumns()) |
|
1009 | + if ($this->getAutoGenerateColumns()) |
|
1010 | 1010 | { |
1011 | 1011 | $columns = new TList($this->getColumns()); |
1012 | 1012 | $autoColumns = $this->createAutoColumns($data); |
@@ -1020,32 +1020,32 @@ discard block |
||
1020 | 1020 | |
1021 | 1021 | $index = 0; |
1022 | 1022 | $allowPaging = $this->getAllowPaging() && ($data instanceof TPagedDataSource); |
1023 | - $dsIndex = $allowPaging?$data->getFirstIndexInPage():0; |
|
1023 | + $dsIndex = $allowPaging ? $data->getFirstIndexInPage() : 0; |
|
1024 | 1024 | $this->setViewState('DataSourceIndex', $dsIndex, 0); |
1025 | - if($columns->getCount()) |
|
1025 | + if ($columns->getCount()) |
|
1026 | 1026 | { |
1027 | - foreach($columns as $column) |
|
1027 | + foreach ($columns as $column) |
|
1028 | 1028 | $column->initialize(); |
1029 | 1029 | |
1030 | 1030 | $selectedIndex = $this->getSelectedItemIndex(); |
1031 | 1031 | $editIndex = $this->getEditItemIndex(); |
1032 | - foreach($data as $key => $row) |
|
1032 | + foreach ($data as $key => $row) |
|
1033 | 1033 | { |
1034 | - if($keyField !== '') |
|
1034 | + if ($keyField !== '') |
|
1035 | 1035 | $keys->add($this->getDataFieldValue($row, $keyField)); |
1036 | 1036 | else |
1037 | 1037 | $keys->add($key); |
1038 | - if($index === 0) |
|
1038 | + if ($index === 0) |
|
1039 | 1039 | { |
1040 | - if($allowPaging) |
|
1040 | + if ($allowPaging) |
|
1041 | 1041 | $this->_topPager = $this->createPager(); |
1042 | 1042 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, true, null, $columns); |
1043 | 1043 | } |
1044 | - if($index === $editIndex) |
|
1044 | + if ($index === $editIndex) |
|
1045 | 1045 | $itemType = TListItemType::EditItem; |
1046 | - elseif($index === $selectedIndex) |
|
1046 | + elseif ($index === $selectedIndex) |
|
1047 | 1047 | $itemType = TListItemType::SelectedItem; |
1048 | - elseif($index % 2) |
|
1048 | + elseif ($index % 2) |
|
1049 | 1049 | $itemType = TListItemType::AlternatingItem; |
1050 | 1050 | else |
1051 | 1051 | $itemType = TListItemType::Item; |
@@ -1053,15 +1053,15 @@ discard block |
||
1053 | 1053 | $index++; |
1054 | 1054 | $dsIndex++; |
1055 | 1055 | } |
1056 | - if($index > 0) |
|
1056 | + if ($index > 0) |
|
1057 | 1057 | { |
1058 | 1058 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, true, null, $columns); |
1059 | - if($allowPaging) |
|
1059 | + if ($allowPaging) |
|
1060 | 1060 | $this->_bottomPager = $this->createPager(); |
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | $this->setViewState('ItemCount', $index, 0); |
1064 | - if(!$dsIndex && $this->_emptyTemplate !== null) |
|
1064 | + if (!$dsIndex && $this->_emptyTemplate !== null) |
|
1065 | 1065 | { |
1066 | 1066 | $this->_useEmptyTemplate = true; |
1067 | 1067 | $this->_emptyTemplate->instantiateIn($this); |
@@ -1075,37 +1075,37 @@ discard block |
||
1075 | 1075 | */ |
1076 | 1076 | private function groupCells() |
1077 | 1077 | { |
1078 | - if(($columns = $this->_allColumns) === null) |
|
1078 | + if (($columns = $this->_allColumns) === null) |
|
1079 | 1079 | return; |
1080 | 1080 | $items = $this->getItems(); |
1081 | - foreach($columns as $id => $column) |
|
1081 | + foreach ($columns as $id => $column) |
|
1082 | 1082 | { |
1083 | - if(!$column->getEnableCellGrouping()) |
|
1083 | + if (!$column->getEnableCellGrouping()) |
|
1084 | 1084 | continue; |
1085 | 1085 | $prevCell = null; |
1086 | 1086 | $prevCellText = null; |
1087 | - foreach($items as $item) |
|
1087 | + foreach ($items as $item) |
|
1088 | 1088 | { |
1089 | 1089 | $itemType = $item->getItemType(); |
1090 | 1090 | $cell = $item->getCells()->itemAt($id); |
1091 | - if(!$cell->getVisible()) |
|
1091 | + if (!$cell->getVisible()) |
|
1092 | 1092 | continue; |
1093 | - if($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) |
|
1093 | + if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) |
|
1094 | 1094 | { |
1095 | - if(($cellText = $this->getCellText($cell)) === '') |
|
1095 | + if (($cellText = $this->getCellText($cell)) === '') |
|
1096 | 1096 | { |
1097 | 1097 | $prevCell = null; |
1098 | 1098 | $prevCellText = null; |
1099 | 1099 | continue; |
1100 | 1100 | } |
1101 | - if($prevCell === null || $prevCellText !== $cellText) |
|
1101 | + if ($prevCell === null || $prevCellText !== $cellText) |
|
1102 | 1102 | { |
1103 | 1103 | $prevCell = $cell; |
1104 | 1104 | $prevCellText = $cellText; |
1105 | 1105 | } |
1106 | 1106 | else |
1107 | 1107 | { |
1108 | - if(($rowSpan = $prevCell->getRowSpan()) === 0) |
|
1108 | + if (($rowSpan = $prevCell->getRowSpan()) === 0) |
|
1109 | 1109 | $rowSpan = 1; |
1110 | 1110 | $prevCell->setRowSpan($rowSpan + 1); |
1111 | 1111 | $cell->setVisible(false); |
@@ -1117,12 +1117,12 @@ discard block |
||
1117 | 1117 | |
1118 | 1118 | private function getCellText($cell) |
1119 | 1119 | { |
1120 | - if(($data = $cell->getText()) === '' && $cell->getHasControls()) |
|
1120 | + if (($data = $cell->getText()) === '' && $cell->getHasControls()) |
|
1121 | 1121 | { |
1122 | 1122 | $controls = $cell->getControls(); |
1123 | - foreach($controls as $control) |
|
1123 | + foreach ($controls as $control) |
|
1124 | 1124 | { |
1125 | - if($control instanceof \Prado\IDataRenderer) |
|
1125 | + if ($control instanceof \Prado\IDataRenderer) |
|
1126 | 1126 | return $control->getData(); |
1127 | 1127 | } |
1128 | 1128 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | $item = $this->createItem($itemIndex, $dataSourceIndex, $itemType); |
1146 | 1146 | $this->initializeItem($item, $columns); |
1147 | 1147 | $param = new TDataGridItemEventParameter($item); |
1148 | - if($dataBind) |
|
1148 | + if ($dataBind) |
|
1149 | 1149 | { |
1150 | 1150 | $item->setData($dataItem); |
1151 | 1151 | $this->onItemCreated($param); |
@@ -1171,13 +1171,13 @@ discard block |
||
1171 | 1171 | $cells = $item->getCells(); |
1172 | 1172 | $itemType = $item->getItemType(); |
1173 | 1173 | $index = 0; |
1174 | - foreach($columns as $column) |
|
1174 | + foreach ($columns as $column) |
|
1175 | 1175 | { |
1176 | - if($itemType === TListItemType::Header) |
|
1176 | + if ($itemType === TListItemType::Header) |
|
1177 | 1177 | $cell = new TTableHeaderCell; |
1178 | 1178 | else |
1179 | 1179 | $cell = new TTableCell; |
1180 | - if(($id = $column->getID()) !== '') |
|
1180 | + if (($id = $column->getID()) !== '') |
|
1181 | 1181 | $item->registerObject($id, $cell); |
1182 | 1182 | $cells->add($cell); |
1183 | 1183 | $column->initializeCell($cell, $index, $itemType); |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | */ |
1201 | 1201 | protected function buildPager($pager) |
1202 | 1202 | { |
1203 | - switch($this->getPagerStyle()->getMode()) |
|
1203 | + switch ($this->getPagerStyle()->getMode()) |
|
1204 | 1204 | { |
1205 | 1205 | case TDataGridPagerMode::NextPrev: |
1206 | 1206 | $this->buildNextPrevPager($pager); |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | */ |
1227 | 1227 | protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter) |
1228 | 1228 | { |
1229 | - if($buttonType === TDataGridPagerButtonType::LinkButton) |
|
1229 | + if ($buttonType === TDataGridPagerButtonType::LinkButton) |
|
1230 | 1230 | { |
1231 | - if($enabled) |
|
1231 | + if ($enabled) |
|
1232 | 1232 | $button = new TLinkButton; |
1233 | 1233 | else |
1234 | 1234 | { |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | else |
1241 | 1241 | { |
1242 | 1242 | $button = new TButton; |
1243 | - if(!$enabled) |
|
1243 | + if (!$enabled) |
|
1244 | 1244 | $button->setEnabled(false); |
1245 | 1245 | } |
1246 | 1246 | $button->setText($text); |
@@ -1260,9 +1260,9 @@ discard block |
||
1260 | 1260 | $buttonType = $style->getButtonType(); |
1261 | 1261 | $controls = $pager->getControls(); |
1262 | 1262 | $currentPageIndex = $this->getCurrentPageIndex(); |
1263 | - if($currentPageIndex === 0) |
|
1263 | + if ($currentPageIndex === 0) |
|
1264 | 1264 | { |
1265 | - if(($text = $style->getFirstPageText()) !== '') |
|
1265 | + if (($text = $style->getFirstPageText()) !== '') |
|
1266 | 1266 | { |
1267 | 1267 | $label = $this->createPagerButton($pager, $buttonType, false, $text, '', ''); |
1268 | 1268 | $controls->add($label); |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | } |
1275 | 1275 | else |
1276 | 1276 | { |
1277 | - if(($text = $style->getFirstPageText()) !== '') |
|
1277 | + if (($text = $style->getFirstPageText()) !== '') |
|
1278 | 1278 | { |
1279 | 1279 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_FIRST); |
1280 | 1280 | $controls->add($button); |
@@ -1285,11 +1285,11 @@ discard block |
||
1285 | 1285 | $controls->add($button); |
1286 | 1286 | } |
1287 | 1287 | $controls->add("\n"); |
1288 | - if($currentPageIndex === $this->getPageCount() - 1) |
|
1288 | + if ($currentPageIndex === $this->getPageCount() - 1) |
|
1289 | 1289 | { |
1290 | 1290 | $label = $this->createPagerButton($pager, $buttonType, false, $style->getNextPageText(), '', ''); |
1291 | 1291 | $controls->add($label); |
1292 | - if(($text = $style->getLastPageText()) !== '') |
|
1292 | + if (($text = $style->getLastPageText()) !== '') |
|
1293 | 1293 | { |
1294 | 1294 | $controls->add("\n"); |
1295 | 1295 | $label = $this->createPagerButton($pager, $buttonType, false, $text, '', ''); |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | { |
1301 | 1301 | $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, self::CMD_PAGE_NEXT); |
1302 | 1302 | $controls->add($button); |
1303 | - if(($text = $style->getLastPageText()) !== '') |
|
1303 | + if (($text = $style->getLastPageText()) !== '') |
|
1304 | 1304 | { |
1305 | 1305 | $controls->add("\n"); |
1306 | 1306 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_LAST); |
@@ -1321,24 +1321,24 @@ discard block |
||
1321 | 1321 | $pageCount = $this->getPageCount(); |
1322 | 1322 | $pageIndex = $this->getCurrentPageIndex() + 1; |
1323 | 1323 | $maxButtonCount = $style->getPageButtonCount(); |
1324 | - $buttonCount = $maxButtonCount > $pageCount?$pageCount:$maxButtonCount; |
|
1324 | + $buttonCount = $maxButtonCount > $pageCount ? $pageCount : $maxButtonCount; |
|
1325 | 1325 | $startPageIndex = 1; |
1326 | 1326 | $endPageIndex = $buttonCount; |
1327 | - if($pageIndex > $endPageIndex) |
|
1327 | + if ($pageIndex > $endPageIndex) |
|
1328 | 1328 | { |
1329 | - $startPageIndex = ((int)(($pageIndex - 1) / $maxButtonCount)) * $maxButtonCount + 1; |
|
1330 | - if(($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) |
|
1329 | + $startPageIndex = ((int) (($pageIndex - 1) / $maxButtonCount)) * $maxButtonCount + 1; |
|
1330 | + if (($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) |
|
1331 | 1331 | $endPageIndex = $pageCount; |
1332 | - if($endPageIndex - $startPageIndex + 1 < $maxButtonCount) |
|
1332 | + if ($endPageIndex - $startPageIndex + 1 < $maxButtonCount) |
|
1333 | 1333 | { |
1334 | - if(($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) |
|
1334 | + if (($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) |
|
1335 | 1335 | $startPageIndex = 1; |
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - if($startPageIndex > 1) |
|
1339 | + if ($startPageIndex > 1) |
|
1340 | 1340 | { |
1341 | - if(($text = $style->getFirstPageText()) !== '') |
|
1341 | + if (($text = $style->getFirstPageText()) !== '') |
|
1342 | 1342 | { |
1343 | 1343 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_FIRST); |
1344 | 1344 | $controls->add($button); |
@@ -1350,9 +1350,9 @@ discard block |
||
1350 | 1350 | $controls->add("\n"); |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - for($i = $startPageIndex;$i <= $endPageIndex;++$i) |
|
1353 | + for ($i = $startPageIndex; $i <= $endPageIndex; ++$i) |
|
1354 | 1354 | { |
1355 | - if($i === $pageIndex) |
|
1355 | + if ($i === $pageIndex) |
|
1356 | 1356 | { |
1357 | 1357 | $label = $this->createPagerButton($pager, $buttonType, false, "$i", '', ''); |
1358 | 1358 | $controls->add($label); |
@@ -1362,17 +1362,17 @@ discard block |
||
1362 | 1362 | $button = $this->createPagerButton($pager, $buttonType, true, "$i", self::CMD_PAGE, "$i"); |
1363 | 1363 | $controls->add($button); |
1364 | 1364 | } |
1365 | - if($i < $endPageIndex) |
|
1365 | + if ($i < $endPageIndex) |
|
1366 | 1366 | $controls->add("\n"); |
1367 | 1367 | } |
1368 | 1368 | |
1369 | - if($pageCount > $endPageIndex) |
|
1369 | + if ($pageCount > $endPageIndex) |
|
1370 | 1370 | { |
1371 | 1371 | $controls->add("\n"); |
1372 | 1372 | $nextPageIndex = $endPageIndex + 1; |
1373 | 1373 | $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, "$nextPageIndex"); |
1374 | 1374 | $controls->add($button); |
1375 | - if(($text = $style->getLastPageText()) !== '') |
|
1375 | + if (($text = $style->getLastPageText()) !== '') |
|
1376 | 1376 | { |
1377 | 1377 | $controls->add("\n"); |
1378 | 1378 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_LAST); |
@@ -1388,16 +1388,16 @@ discard block |
||
1388 | 1388 | */ |
1389 | 1389 | protected function createAutoColumns($dataSource) |
1390 | 1390 | { |
1391 | - if(!$dataSource) |
|
1391 | + if (!$dataSource) |
|
1392 | 1392 | return null; |
1393 | 1393 | $autoColumns = $this->getAutoColumns(); |
1394 | 1394 | $autoColumns->clear(); |
1395 | - foreach($dataSource as $row) |
|
1395 | + foreach ($dataSource as $row) |
|
1396 | 1396 | { |
1397 | - foreach($row as $key => $value) |
|
1397 | + foreach ($row as $key => $value) |
|
1398 | 1398 | { |
1399 | 1399 | $column = new $this->AutoGenerateColumnName; |
1400 | - if(is_string($key)) |
|
1400 | + if (is_string($key)) |
|
1401 | 1401 | { |
1402 | 1402 | $column->setHeaderText($key); |
1403 | 1403 | $column->setDataField($key); |
@@ -1433,9 +1433,9 @@ discard block |
||
1433 | 1433 | $itemStyle = $this->getViewState('ItemStyle', null); |
1434 | 1434 | |
1435 | 1435 | $alternatingItemStyle = $this->getViewState('AlternatingItemStyle', null); |
1436 | - if($itemStyle !== null) |
|
1436 | + if ($itemStyle !== null) |
|
1437 | 1437 | { |
1438 | - if($alternatingItemStyle === null) |
|
1438 | + if ($alternatingItemStyle === null) |
|
1439 | 1439 | $alternatingItemStyle = $itemStyle; |
1440 | 1440 | else |
1441 | 1441 | $alternatingItemStyle->mergeWith($itemStyle); |
@@ -1444,9 +1444,9 @@ discard block |
||
1444 | 1444 | $selectedItemStyle = $this->getViewState('SelectedItemStyle', null); |
1445 | 1445 | |
1446 | 1446 | $editItemStyle = $this->getViewState('EditItemStyle', null); |
1447 | - if($selectedItemStyle !== null) |
|
1447 | + if ($selectedItemStyle !== null) |
|
1448 | 1448 | { |
1449 | - if($editItemStyle === null) |
|
1449 | + if ($editItemStyle === null) |
|
1450 | 1450 | $editItemStyle = $selectedItemStyle; |
1451 | 1451 | else |
1452 | 1452 | $editItemStyle->mergeWith($selectedItemStyle); |
@@ -1457,77 +1457,77 @@ discard block |
||
1457 | 1457 | $pagerStyle = $this->getViewState('PagerStyle', null); |
1458 | 1458 | $separatorStyle = $this->getViewState('SeparatorStyle', null); |
1459 | 1459 | |
1460 | - foreach($this->getControls() as $index => $item) |
|
1460 | + foreach ($this->getControls() as $index => $item) |
|
1461 | 1461 | { |
1462 | - if(!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) |
|
1462 | + if (!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) |
|
1463 | 1463 | continue; |
1464 | 1464 | $itemType = $item->getItemType(); |
1465 | - switch($itemType) |
|
1465 | + switch ($itemType) |
|
1466 | 1466 | { |
1467 | 1467 | case TListItemType::Header: |
1468 | - if($headerStyle) |
|
1468 | + if ($headerStyle) |
|
1469 | 1469 | $item->getStyle()->mergeWith($headerStyle); |
1470 | - if(!$this->getShowHeader()) |
|
1470 | + if (!$this->getShowHeader()) |
|
1471 | 1471 | $item->setVisible(false); |
1472 | 1472 | break; |
1473 | 1473 | case TListItemType::Footer: |
1474 | - if($footerStyle) |
|
1474 | + if ($footerStyle) |
|
1475 | 1475 | $item->getStyle()->mergeWith($footerStyle); |
1476 | - if(!$this->getShowFooter()) |
|
1476 | + if (!$this->getShowFooter()) |
|
1477 | 1477 | $item->setVisible(false); |
1478 | 1478 | break; |
1479 | 1479 | case TListItemType::Separator: |
1480 | - if($separatorStyle) |
|
1480 | + if ($separatorStyle) |
|
1481 | 1481 | $item->getStyle()->mergeWith($separatorStyle); |
1482 | 1482 | break; |
1483 | 1483 | case TListItemType::Item: |
1484 | - if($itemStyle) |
|
1484 | + if ($itemStyle) |
|
1485 | 1485 | $item->getStyle()->mergeWith($itemStyle); |
1486 | 1486 | break; |
1487 | 1487 | case TListItemType::AlternatingItem: |
1488 | - if($alternatingItemStyle) |
|
1488 | + if ($alternatingItemStyle) |
|
1489 | 1489 | $item->getStyle()->mergeWith($alternatingItemStyle); |
1490 | 1490 | break; |
1491 | 1491 | case TListItemType::SelectedItem: |
1492 | - if($selectedItemStyle) |
|
1492 | + if ($selectedItemStyle) |
|
1493 | 1493 | $item->getStyle()->mergeWith($selectedItemStyle); |
1494 | - if($index % 2 == 1) |
|
1494 | + if ($index % 2 == 1) |
|
1495 | 1495 | { |
1496 | - if($itemStyle) |
|
1496 | + if ($itemStyle) |
|
1497 | 1497 | $item->getStyle()->mergeWith($itemStyle); |
1498 | 1498 | } |
1499 | 1499 | else |
1500 | 1500 | { |
1501 | - if($alternatingItemStyle) |
|
1501 | + if ($alternatingItemStyle) |
|
1502 | 1502 | $item->getStyle()->mergeWith($alternatingItemStyle); |
1503 | 1503 | } |
1504 | 1504 | break; |
1505 | 1505 | case TListItemType::EditItem: |
1506 | - if($editItemStyle) |
|
1506 | + if ($editItemStyle) |
|
1507 | 1507 | $item->getStyle()->mergeWith($editItemStyle); |
1508 | - if($index % 2 == 1) |
|
1508 | + if ($index % 2 == 1) |
|
1509 | 1509 | { |
1510 | - if($itemStyle) |
|
1510 | + if ($itemStyle) |
|
1511 | 1511 | $item->getStyle()->mergeWith($itemStyle); |
1512 | 1512 | } |
1513 | 1513 | else |
1514 | 1514 | { |
1515 | - if($alternatingItemStyle) |
|
1515 | + if ($alternatingItemStyle) |
|
1516 | 1516 | $item->getStyle()->mergeWith($alternatingItemStyle); |
1517 | 1517 | } |
1518 | 1518 | break; |
1519 | 1519 | case TListItemType::Pager: |
1520 | - if($pagerStyle) |
|
1520 | + if ($pagerStyle) |
|
1521 | 1521 | { |
1522 | 1522 | $item->getStyle()->mergeWith($pagerStyle); |
1523 | - if($index === 0) |
|
1523 | + if ($index === 0) |
|
1524 | 1524 | { |
1525 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) |
|
1525 | + if ($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) |
|
1526 | 1526 | $item->setVisible(false); |
1527 | 1527 | } |
1528 | 1528 | else |
1529 | 1529 | { |
1530 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) |
|
1530 | + if ($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) |
|
1531 | 1531 | $item->setVisible(false); |
1532 | 1532 | } |
1533 | 1533 | } |
@@ -1535,25 +1535,25 @@ discard block |
||
1535 | 1535 | default: |
1536 | 1536 | break; |
1537 | 1537 | } |
1538 | - if($this->_columns && $itemType !== TListItemType::Pager) |
|
1538 | + if ($this->_columns && $itemType !== TListItemType::Pager) |
|
1539 | 1539 | { |
1540 | 1540 | $n = $this->_columns->getCount(); |
1541 | 1541 | $cells = $item->getCells(); |
1542 | - for($i = 0;$i < $n;++$i) |
|
1542 | + for ($i = 0; $i < $n; ++$i) |
|
1543 | 1543 | { |
1544 | 1544 | $cell = $cells->itemAt($i); |
1545 | 1545 | $column = $this->_columns->itemAt($i); |
1546 | - if(!$column->getVisible()) |
|
1546 | + if (!$column->getVisible()) |
|
1547 | 1547 | $cell->setVisible(false); |
1548 | 1548 | else |
1549 | 1549 | { |
1550 | - if($itemType === TListItemType::Header) |
|
1550 | + if ($itemType === TListItemType::Header) |
|
1551 | 1551 | $style = $column->getHeaderStyle(false); |
1552 | - elseif($itemType === TListItemType::Footer) |
|
1552 | + elseif ($itemType === TListItemType::Footer) |
|
1553 | 1553 | $style = $column->getFooterStyle(false); |
1554 | 1554 | else |
1555 | 1555 | $style = $column->getItemStyle(false); |
1556 | - if($style !== null) |
|
1556 | + if ($style !== null) |
|
1557 | 1557 | $cell->getStyle()->mergeWith($style); |
1558 | 1558 | } |
1559 | 1559 | } |
@@ -1568,9 +1568,9 @@ discard block |
||
1568 | 1568 | public function renderBeginTag($writer) |
1569 | 1569 | { |
1570 | 1570 | parent::renderBeginTag($writer); |
1571 | - if(($caption = $this->getCaption()) !== '') |
|
1571 | + if (($caption = $this->getCaption()) !== '') |
|
1572 | 1572 | { |
1573 | - if(($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) |
|
1573 | + if (($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) |
|
1574 | 1574 | $writer->addAttribute('align', strtolower($align)); |
1575 | 1575 | $writer->renderBeginTag('caption'); |
1576 | 1576 | $writer->write($caption); |
@@ -1584,30 +1584,30 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | public function render($writer) |
1586 | 1586 | { |
1587 | - if($this->getHasControls()) |
|
1587 | + if ($this->getHasControls()) |
|
1588 | 1588 | { |
1589 | 1589 | $this->groupCells(); |
1590 | - if($this->_useEmptyTemplate) |
|
1590 | + if ($this->_useEmptyTemplate) |
|
1591 | 1591 | { |
1592 | 1592 | $control = new TWebControl; |
1593 | 1593 | $control->setID($this->getClientID()); |
1594 | 1594 | $control->copyBaseAttributes($this); |
1595 | - if($this->getHasStyle()) |
|
1595 | + if ($this->getHasStyle()) |
|
1596 | 1596 | $control->getStyle()->copyFrom($this->getStyle()); |
1597 | 1597 | $control->renderBeginTag($writer); |
1598 | 1598 | $this->renderContents($writer); |
1599 | 1599 | $control->renderEndTag($writer); |
1600 | 1600 | } |
1601 | - elseif($this->getViewState('ItemCount', 0) > 0) |
|
1601 | + elseif ($this->getViewState('ItemCount', 0) > 0) |
|
1602 | 1602 | { |
1603 | 1603 | $this->applyItemStyles(); |
1604 | - if($this->_topPager) |
|
1604 | + if ($this->_topPager) |
|
1605 | 1605 | { |
1606 | 1606 | $this->_topPager->renderControl($writer); |
1607 | 1607 | $writer->writeLine(); |
1608 | 1608 | } |
1609 | 1609 | $this->renderTable($writer); |
1610 | - if($this->_bottomPager) |
|
1610 | + if ($this->_bottomPager) |
|
1611 | 1611 | { |
1612 | 1612 | $writer->writeLine(); |
1613 | 1613 | $this->_bottomPager->renderControl($writer); |
@@ -1623,27 +1623,27 @@ discard block |
||
1623 | 1623 | protected function renderTable($writer) |
1624 | 1624 | { |
1625 | 1625 | $this->renderBeginTag($writer); |
1626 | - if($this->_header && $this->_header->getVisible()) |
|
1626 | + if ($this->_header && $this->_header->getVisible()) |
|
1627 | 1627 | { |
1628 | 1628 | $writer->writeLine(); |
1629 | - if($style = $this->getViewState('TableHeadStyle', null)) |
|
1629 | + if ($style = $this->getViewState('TableHeadStyle', null)) |
|
1630 | 1630 | $style->addAttributesToRender($writer); |
1631 | 1631 | $writer->renderBeginTag('thead'); |
1632 | 1632 | $this->_header->render($writer); |
1633 | 1633 | $writer->renderEndTag(); |
1634 | 1634 | } |
1635 | 1635 | $writer->writeLine(); |
1636 | - if($style = $this->getViewState('TableBodyStyle', null)) |
|
1636 | + if ($style = $this->getViewState('TableBodyStyle', null)) |
|
1637 | 1637 | $style->addAttributesToRender($writer); |
1638 | 1638 | $writer->renderBeginTag('tbody'); |
1639 | - foreach($this->getItems() as $item) |
|
1639 | + foreach ($this->getItems() as $item) |
|
1640 | 1640 | $item->renderControl($writer); |
1641 | 1641 | $writer->renderEndTag(); |
1642 | 1642 | |
1643 | - if($this->_footer && $this->_footer->getVisible()) |
|
1643 | + if ($this->_footer && $this->_footer->getVisible()) |
|
1644 | 1644 | { |
1645 | 1645 | $writer->writeLine(); |
1646 | - if($style = $this->getViewState('TableFootStyle', null)) |
|
1646 | + if ($style = $this->getViewState('TableFootStyle', null)) |
|
1647 | 1647 | $style->addAttributesToRender($writer); |
1648 | 1648 | $writer->renderBeginTag('tfoot'); |
1649 | 1649 | $this->_footer->render($writer); |
@@ -224,10 +224,12 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function addParsedObject($object) |
226 | 226 | { |
227 | - if($object instanceof TDataGridColumn) |
|
228 | - $this->getColumns()->add($object); |
|
229 | - else |
|
230 | - parent::addParsedObject($object); // this is needed by EmptyTemplate |
|
227 | + if($object instanceof TDataGridColumn) { |
|
228 | + $this->getColumns()->add($object); |
|
229 | + } else { |
|
230 | + parent::addParsedObject($object); |
|
231 | + } |
|
232 | + // this is needed by EmptyTemplate |
|
231 | 233 | } |
232 | 234 | |
233 | 235 | /** |
@@ -235,8 +237,9 @@ discard block |
||
235 | 237 | */ |
236 | 238 | public function getColumns() |
237 | 239 | { |
238 | - if(!$this->_columns) |
|
239 | - $this->_columns = new TDataGridColumnCollection($this); |
|
240 | + if(!$this->_columns) { |
|
241 | + $this->_columns = new TDataGridColumnCollection($this); |
|
242 | + } |
|
240 | 243 | return $this->_columns; |
241 | 244 | } |
242 | 245 | |
@@ -245,8 +248,9 @@ discard block |
||
245 | 248 | */ |
246 | 249 | public function getAutoColumns() |
247 | 250 | { |
248 | - if(!$this->_autoColumns) |
|
249 | - $this->_autoColumns = new TDataGridColumnCollection($this); |
|
251 | + if(!$this->_autoColumns) { |
|
252 | + $this->_autoColumns = new TDataGridColumnCollection($this); |
|
253 | + } |
|
250 | 254 | return $this->_autoColumns; |
251 | 255 | } |
252 | 256 | |
@@ -255,8 +259,9 @@ discard block |
||
255 | 259 | */ |
256 | 260 | public function getItems() |
257 | 261 | { |
258 | - if(!$this->_items) |
|
259 | - $this->_items = new TDataGridItemCollection; |
|
262 | + if(!$this->_items) { |
|
263 | + $this->_items = new TDataGridItemCollection; |
|
264 | + } |
|
260 | 265 | return $this->_items; |
261 | 266 | } |
262 | 267 | |
@@ -498,10 +503,11 @@ discard block |
||
498 | 503 | { |
499 | 504 | $index = $this->getSelectedItemIndex(); |
500 | 505 | $items = $this->getItems(); |
501 | - if($index >= 0 && $index < $items->getCount()) |
|
502 | - return $items->itemAt($index); |
|
503 | - else |
|
504 | - return null; |
|
506 | + if($index >= 0 && $index < $items->getCount()) { |
|
507 | + return $items->itemAt($index); |
|
508 | + } else { |
|
509 | + return null; |
|
510 | + } |
|
505 | 511 | } |
506 | 512 | |
507 | 513 | /** |
@@ -522,8 +528,9 @@ discard block |
||
522 | 528 | */ |
523 | 529 | public function setSelectedItemIndex($value) |
524 | 530 | { |
525 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
526 | - $value = -1; |
|
531 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
532 | + $value = -1; |
|
533 | + } |
|
527 | 534 | if(($current = $this->getSelectedItemIndex()) !== $value) |
528 | 535 | { |
529 | 536 | $this->setViewState('SelectedItemIndex', $value, -1); |
@@ -532,14 +539,16 @@ discard block |
||
532 | 539 | if($current >= 0 && $current < $itemCount) |
533 | 540 | { |
534 | 541 | $item = $items->itemAt($current); |
535 | - if($item->getItemType() !== TListItemType::EditItem) |
|
536 | - $item->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
542 | + if($item->getItemType() !== TListItemType::EditItem) { |
|
543 | + $item->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
544 | + } |
|
537 | 545 | } |
538 | 546 | if($value >= 0 && $value < $itemCount) |
539 | 547 | { |
540 | 548 | $item = $items->itemAt($value); |
541 | - if($item->getItemType() !== TListItemType::EditItem) |
|
542 | - $item->setItemType(TListItemType::SelectedItem); |
|
549 | + if($item->getItemType() !== TListItemType::EditItem) { |
|
550 | + $item->setItemType(TListItemType::SelectedItem); |
|
551 | + } |
|
543 | 552 | } |
544 | 553 | } |
545 | 554 | } |
@@ -551,10 +560,11 @@ discard block |
||
551 | 560 | { |
552 | 561 | $index = $this->getEditItemIndex(); |
553 | 562 | $items = $this->getItems(); |
554 | - if($index >= 0 && $index < $items->getCount()) |
|
555 | - return $items->itemAt($index); |
|
556 | - else |
|
557 | - return null; |
|
563 | + if($index >= 0 && $index < $items->getCount()) { |
|
564 | + return $items->itemAt($index); |
|
565 | + } else { |
|
566 | + return null; |
|
567 | + } |
|
558 | 568 | } |
559 | 569 | |
560 | 570 | /** |
@@ -574,17 +584,20 @@ discard block |
||
574 | 584 | */ |
575 | 585 | public function setEditItemIndex($value) |
576 | 586 | { |
577 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
578 | - $value = -1; |
|
587 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
588 | + $value = -1; |
|
589 | + } |
|
579 | 590 | if(($current = $this->getEditItemIndex()) !== $value) |
580 | 591 | { |
581 | 592 | $this->setViewState('EditItemIndex', $value, -1); |
582 | 593 | $items = $this->getItems(); |
583 | 594 | $itemCount = $items->getCount(); |
584 | - if($current >= 0 && $current < $itemCount) |
|
585 | - $items->itemAt($current)->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
586 | - if($value >= 0 && $value < $itemCount) |
|
587 | - $items->itemAt($value)->setItemType(TListItemType::EditItem); |
|
595 | + if($current >= 0 && $current < $itemCount) { |
|
596 | + $items->itemAt($current)->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
597 | + } |
|
598 | + if($value >= 0 && $value < $itemCount) { |
|
599 | + $items->itemAt($value)->setItemType(TListItemType::EditItem); |
|
600 | + } |
|
588 | 601 | } |
589 | 602 | } |
590 | 603 | |
@@ -666,10 +679,11 @@ discard block |
||
666 | 679 | */ |
667 | 680 | public function setEmptyTemplate($value) |
668 | 681 | { |
669 | - if($value instanceof ITemplate || $value === null) |
|
670 | - $this->_emptyTemplate = $value; |
|
671 | - else |
|
672 | - throw new TInvalidDataTypeException('datagrid_template_required', 'EmptyTemplate'); |
|
682 | + if($value instanceof ITemplate || $value === null) { |
|
683 | + $this->_emptyTemplate = $value; |
|
684 | + } else { |
|
685 | + throw new TInvalidDataTypeException('datagrid_template_required', 'EmptyTemplate'); |
|
686 | + } |
|
673 | 687 | } |
674 | 688 | |
675 | 689 | /** |
@@ -696,45 +710,40 @@ discard block |
||
696 | 710 | $this->setSelectedItemIndex($param->getItem()->getItemIndex()); |
697 | 711 | $this->onSelectedIndexChanged($param); |
698 | 712 | return true; |
699 | - } |
|
700 | - elseif(strcasecmp($command, self::CMD_EDIT) === 0) |
|
713 | + } elseif(strcasecmp($command, self::CMD_EDIT) === 0) |
|
701 | 714 | { |
702 | 715 | $this->onEditCommand($param); |
703 | 716 | return true; |
704 | - } |
|
705 | - elseif(strcasecmp($command, self::CMD_DELETE) === 0) |
|
717 | + } elseif(strcasecmp($command, self::CMD_DELETE) === 0) |
|
706 | 718 | { |
707 | 719 | $this->onDeleteCommand($param); |
708 | 720 | return true; |
709 | - } |
|
710 | - elseif(strcasecmp($command, self::CMD_UPDATE) === 0) |
|
721 | + } elseif(strcasecmp($command, self::CMD_UPDATE) === 0) |
|
711 | 722 | { |
712 | 723 | $this->onUpdateCommand($param); |
713 | 724 | return true; |
714 | - } |
|
715 | - elseif(strcasecmp($command, self::CMD_CANCEL) === 0) |
|
725 | + } elseif(strcasecmp($command, self::CMD_CANCEL) === 0) |
|
716 | 726 | { |
717 | 727 | $this->onCancelCommand($param); |
718 | 728 | return true; |
719 | - } |
|
720 | - elseif(strcasecmp($command, self::CMD_SORT) === 0) |
|
729 | + } elseif(strcasecmp($command, self::CMD_SORT) === 0) |
|
721 | 730 | { |
722 | 731 | $this->onSortCommand(new TDataGridSortCommandEventParameter($sender, $param)); |
723 | 732 | return true; |
724 | - } |
|
725 | - elseif(strcasecmp($command, self::CMD_PAGE) === 0) |
|
733 | + } elseif(strcasecmp($command, self::CMD_PAGE) === 0) |
|
726 | 734 | { |
727 | 735 | $p = $param->getCommandParameter(); |
728 | - if(strcasecmp($p, self::CMD_PAGE_NEXT) === 0) |
|
729 | - $pageIndex = $this->getCurrentPageIndex() + 1; |
|
730 | - elseif(strcasecmp($p, self::CMD_PAGE_PREV) === 0) |
|
731 | - $pageIndex = $this->getCurrentPageIndex() - 1; |
|
732 | - elseif(strcasecmp($p, self::CMD_PAGE_FIRST) === 0) |
|
733 | - $pageIndex = 0; |
|
734 | - elseif(strcasecmp($p, self::CMD_PAGE_LAST) === 0) |
|
735 | - $pageIndex = $this->getPageCount() - 1; |
|
736 | - else |
|
737 | - $pageIndex = TPropertyValue::ensureInteger($p) - 1; |
|
736 | + if(strcasecmp($p, self::CMD_PAGE_NEXT) === 0) { |
|
737 | + $pageIndex = $this->getCurrentPageIndex() + 1; |
|
738 | + } elseif(strcasecmp($p, self::CMD_PAGE_PREV) === 0) { |
|
739 | + $pageIndex = $this->getCurrentPageIndex() - 1; |
|
740 | + } elseif(strcasecmp($p, self::CMD_PAGE_FIRST) === 0) { |
|
741 | + $pageIndex = 0; |
|
742 | + } elseif(strcasecmp($p, self::CMD_PAGE_LAST) === 0) { |
|
743 | + $pageIndex = $this->getPageCount() - 1; |
|
744 | + } else { |
|
745 | + $pageIndex = TPropertyValue::ensureInteger($p) - 1; |
|
746 | + } |
|
738 | 747 | $this->onPageIndexChanged(new TDataGridPageChangedEventParameter($sender, $pageIndex)); |
739 | 748 | return true; |
740 | 749 | } |
@@ -857,30 +866,34 @@ discard block |
||
857 | 866 | public function saveState() |
858 | 867 | { |
859 | 868 | parent::saveState(); |
860 | - if(!$this->getEnableViewState(true)) |
|
861 | - return; |
|
862 | - if($this->_items) |
|
863 | - $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
|
864 | - else |
|
865 | - $this->clearViewState('ItemCount'); |
|
869 | + if(!$this->getEnableViewState(true)) { |
|
870 | + return; |
|
871 | + } |
|
872 | + if($this->_items) { |
|
873 | + $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
|
874 | + } else { |
|
875 | + $this->clearViewState('ItemCount'); |
|
876 | + } |
|
866 | 877 | if($this->_autoColumns) |
867 | 878 | { |
868 | 879 | $state = []; |
869 | - foreach($this->_autoColumns as $column) |
|
870 | - $state[] = $column->saveState(); |
|
880 | + foreach($this->_autoColumns as $column) { |
|
881 | + $state[] = $column->saveState(); |
|
882 | + } |
|
871 | 883 | $this->setViewState('AutoColumns', $state, []); |
884 | + } else { |
|
885 | + $this->clearViewState('AutoColumns'); |
|
872 | 886 | } |
873 | - else |
|
874 | - $this->clearViewState('AutoColumns'); |
|
875 | 887 | if($this->_columns) |
876 | 888 | { |
877 | 889 | $state = []; |
878 | - foreach($this->_columns as $column) |
|
879 | - $state[] = $column->saveState(); |
|
890 | + foreach($this->_columns as $column) { |
|
891 | + $state[] = $column->saveState(); |
|
892 | + } |
|
880 | 893 | $this->setViewState('Columns', $state, []); |
894 | + } else { |
|
895 | + $this->clearViewState('Columns'); |
|
881 | 896 | } |
882 | - else |
|
883 | - $this->clearViewState('Columns'); |
|
884 | 897 | } |
885 | 898 | |
886 | 899 | /** |
@@ -890,8 +903,9 @@ discard block |
||
890 | 903 | public function loadState() |
891 | 904 | { |
892 | 905 | parent::loadState(); |
893 | - if(!$this->getEnableViewState(true)) |
|
894 | - return; |
|
906 | + if(!$this->getEnableViewState(true)) { |
|
907 | + return; |
|
908 | + } |
|
895 | 909 | if(!$this->getIsDataBound()) |
896 | 910 | { |
897 | 911 | $state = $this->getViewState('AutoColumns', []); |
@@ -904,9 +918,9 @@ discard block |
||
904 | 918 | $column->loadState($st); |
905 | 919 | $this->_autoColumns->add($column); |
906 | 920 | } |
921 | + } else { |
|
922 | + $this->_autoColumns = null; |
|
907 | 923 | } |
908 | - else |
|
909 | - $this->_autoColumns = null; |
|
910 | 924 | $state = $this->getViewState('Columns', []); |
911 | 925 | if($this->_columns && $this->_columns->getCount() === count($state)) |
912 | 926 | { |
@@ -955,34 +969,38 @@ discard block |
||
955 | 969 | |
956 | 970 | if($columns->getCount()) |
957 | 971 | { |
958 | - foreach($columns as $column) |
|
959 | - $column->initialize(); |
|
972 | + foreach($columns as $column) { |
|
973 | + $column->initialize(); |
|
974 | + } |
|
960 | 975 | $selectedIndex = $this->getSelectedItemIndex(); |
961 | 976 | $editIndex = $this->getEditItemIndex(); |
962 | 977 | for($index = 0;$index < $itemCount;++$index) |
963 | 978 | { |
964 | 979 | if($index === 0) |
965 | 980 | { |
966 | - if($allowPaging) |
|
967 | - $this->_topPager = $this->createPager(); |
|
981 | + if($allowPaging) { |
|
982 | + $this->_topPager = $this->createPager(); |
|
983 | + } |
|
968 | 984 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, false, null, $columns); |
969 | 985 | } |
970 | - if($index === $editIndex) |
|
971 | - $itemType = TListItemType::EditItem; |
|
972 | - elseif($index === $selectedIndex) |
|
973 | - $itemType = TListItemType::SelectedItem; |
|
974 | - elseif($index % 2) |
|
975 | - $itemType = TListItemType::AlternatingItem; |
|
976 | - else |
|
977 | - $itemType = TListItemType::Item; |
|
986 | + if($index === $editIndex) { |
|
987 | + $itemType = TListItemType::EditItem; |
|
988 | + } elseif($index === $selectedIndex) { |
|
989 | + $itemType = TListItemType::SelectedItem; |
|
990 | + } elseif($index % 2) { |
|
991 | + $itemType = TListItemType::AlternatingItem; |
|
992 | + } else { |
|
993 | + $itemType = TListItemType::Item; |
|
994 | + } |
|
978 | 995 | $items->add($this->createItemInternal($index, $dsIndex, $itemType, false, null, $columns)); |
979 | 996 | $dsIndex++; |
980 | 997 | } |
981 | 998 | if($index > 0) |
982 | 999 | { |
983 | 1000 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, false, null, $columns); |
984 | - if($allowPaging) |
|
985 | - $this->_bottomPager = $this->createPager(); |
|
1001 | + if($allowPaging) { |
|
1002 | + $this->_bottomPager = $this->createPager(); |
|
1003 | + } |
|
986 | 1004 | } |
987 | 1005 | } |
988 | 1006 | if(!$dsIndex && $this->_emptyTemplate !== null) |
@@ -1011,9 +1029,9 @@ discard block |
||
1011 | 1029 | $columns = new TList($this->getColumns()); |
1012 | 1030 | $autoColumns = $this->createAutoColumns($data); |
1013 | 1031 | $columns->mergeWith($autoColumns); |
1032 | + } else { |
|
1033 | + $columns = $this->getColumns(); |
|
1014 | 1034 | } |
1015 | - else |
|
1016 | - $columns = $this->getColumns(); |
|
1017 | 1035 | $this->_allColumns = $columns; |
1018 | 1036 | |
1019 | 1037 | $items = $this->getItems(); |
@@ -1024,31 +1042,35 @@ discard block |
||
1024 | 1042 | $this->setViewState('DataSourceIndex', $dsIndex, 0); |
1025 | 1043 | if($columns->getCount()) |
1026 | 1044 | { |
1027 | - foreach($columns as $column) |
|
1028 | - $column->initialize(); |
|
1045 | + foreach($columns as $column) { |
|
1046 | + $column->initialize(); |
|
1047 | + } |
|
1029 | 1048 | |
1030 | 1049 | $selectedIndex = $this->getSelectedItemIndex(); |
1031 | 1050 | $editIndex = $this->getEditItemIndex(); |
1032 | 1051 | foreach($data as $key => $row) |
1033 | 1052 | { |
1034 | - if($keyField !== '') |
|
1035 | - $keys->add($this->getDataFieldValue($row, $keyField)); |
|
1036 | - else |
|
1037 | - $keys->add($key); |
|
1053 | + if($keyField !== '') { |
|
1054 | + $keys->add($this->getDataFieldValue($row, $keyField)); |
|
1055 | + } else { |
|
1056 | + $keys->add($key); |
|
1057 | + } |
|
1038 | 1058 | if($index === 0) |
1039 | 1059 | { |
1040 | - if($allowPaging) |
|
1041 | - $this->_topPager = $this->createPager(); |
|
1060 | + if($allowPaging) { |
|
1061 | + $this->_topPager = $this->createPager(); |
|
1062 | + } |
|
1042 | 1063 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, true, null, $columns); |
1043 | 1064 | } |
1044 | - if($index === $editIndex) |
|
1045 | - $itemType = TListItemType::EditItem; |
|
1046 | - elseif($index === $selectedIndex) |
|
1047 | - $itemType = TListItemType::SelectedItem; |
|
1048 | - elseif($index % 2) |
|
1049 | - $itemType = TListItemType::AlternatingItem; |
|
1050 | - else |
|
1051 | - $itemType = TListItemType::Item; |
|
1065 | + if($index === $editIndex) { |
|
1066 | + $itemType = TListItemType::EditItem; |
|
1067 | + } elseif($index === $selectedIndex) { |
|
1068 | + $itemType = TListItemType::SelectedItem; |
|
1069 | + } elseif($index % 2) { |
|
1070 | + $itemType = TListItemType::AlternatingItem; |
|
1071 | + } else { |
|
1072 | + $itemType = TListItemType::Item; |
|
1073 | + } |
|
1052 | 1074 | $items->add($this->createItemInternal($index, $dsIndex, $itemType, true, $row, $columns)); |
1053 | 1075 | $index++; |
1054 | 1076 | $dsIndex++; |
@@ -1056,8 +1078,9 @@ discard block |
||
1056 | 1078 | if($index > 0) |
1057 | 1079 | { |
1058 | 1080 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, true, null, $columns); |
1059 | - if($allowPaging) |
|
1060 | - $this->_bottomPager = $this->createPager(); |
|
1081 | + if($allowPaging) { |
|
1082 | + $this->_bottomPager = $this->createPager(); |
|
1083 | + } |
|
1061 | 1084 | } |
1062 | 1085 | } |
1063 | 1086 | $this->setViewState('ItemCount', $index, 0); |
@@ -1075,21 +1098,24 @@ discard block |
||
1075 | 1098 | */ |
1076 | 1099 | private function groupCells() |
1077 | 1100 | { |
1078 | - if(($columns = $this->_allColumns) === null) |
|
1079 | - return; |
|
1101 | + if(($columns = $this->_allColumns) === null) { |
|
1102 | + return; |
|
1103 | + } |
|
1080 | 1104 | $items = $this->getItems(); |
1081 | 1105 | foreach($columns as $id => $column) |
1082 | 1106 | { |
1083 | - if(!$column->getEnableCellGrouping()) |
|
1084 | - continue; |
|
1107 | + if(!$column->getEnableCellGrouping()) { |
|
1108 | + continue; |
|
1109 | + } |
|
1085 | 1110 | $prevCell = null; |
1086 | 1111 | $prevCellText = null; |
1087 | 1112 | foreach($items as $item) |
1088 | 1113 | { |
1089 | 1114 | $itemType = $item->getItemType(); |
1090 | 1115 | $cell = $item->getCells()->itemAt($id); |
1091 | - if(!$cell->getVisible()) |
|
1092 | - continue; |
|
1116 | + if(!$cell->getVisible()) { |
|
1117 | + continue; |
|
1118 | + } |
|
1093 | 1119 | if($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) |
1094 | 1120 | { |
1095 | 1121 | if(($cellText = $this->getCellText($cell)) === '') |
@@ -1102,11 +1128,11 @@ discard block |
||
1102 | 1128 | { |
1103 | 1129 | $prevCell = $cell; |
1104 | 1130 | $prevCellText = $cellText; |
1105 | - } |
|
1106 | - else |
|
1131 | + } else |
|
1107 | 1132 | { |
1108 | - if(($rowSpan = $prevCell->getRowSpan()) === 0) |
|
1109 | - $rowSpan = 1; |
|
1133 | + if(($rowSpan = $prevCell->getRowSpan()) === 0) { |
|
1134 | + $rowSpan = 1; |
|
1135 | + } |
|
1110 | 1136 | $prevCell->setRowSpan($rowSpan + 1); |
1111 | 1137 | $cell->setVisible(false); |
1112 | 1138 | } |
@@ -1122,8 +1148,9 @@ discard block |
||
1122 | 1148 | $controls = $cell->getControls(); |
1123 | 1149 | foreach($controls as $control) |
1124 | 1150 | { |
1125 | - if($control instanceof \Prado\IDataRenderer) |
|
1126 | - return $control->getData(); |
|
1151 | + if($control instanceof \Prado\IDataRenderer) { |
|
1152 | + return $control->getData(); |
|
1153 | + } |
|
1127 | 1154 | } |
1128 | 1155 | } |
1129 | 1156 | return $data; |
@@ -1152,8 +1179,7 @@ discard block |
||
1152 | 1179 | $this->getControls()->add($item); |
1153 | 1180 | $item->dataBind(); |
1154 | 1181 | $this->onItemDataBound($param); |
1155 | - } |
|
1156 | - else |
|
1182 | + } else |
|
1157 | 1183 | { |
1158 | 1184 | $this->onItemCreated($param); |
1159 | 1185 | $this->getControls()->add($item); |
@@ -1173,12 +1199,14 @@ discard block |
||
1173 | 1199 | $index = 0; |
1174 | 1200 | foreach($columns as $column) |
1175 | 1201 | { |
1176 | - if($itemType === TListItemType::Header) |
|
1177 | - $cell = new TTableHeaderCell; |
|
1178 | - else |
|
1179 | - $cell = new TTableCell; |
|
1180 | - if(($id = $column->getID()) !== '') |
|
1181 | - $item->registerObject($id, $cell); |
|
1202 | + if($itemType === TListItemType::Header) { |
|
1203 | + $cell = new TTableHeaderCell; |
|
1204 | + } else { |
|
1205 | + $cell = new TTableCell; |
|
1206 | + } |
|
1207 | + if(($id = $column->getID()) !== '') { |
|
1208 | + $item->registerObject($id, $cell); |
|
1209 | + } |
|
1182 | 1210 | $cells->add($cell); |
1183 | 1211 | $column->initializeCell($cell, $index, $itemType); |
1184 | 1212 | $index++; |
@@ -1228,20 +1256,20 @@ discard block |
||
1228 | 1256 | { |
1229 | 1257 | if($buttonType === TDataGridPagerButtonType::LinkButton) |
1230 | 1258 | { |
1231 | - if($enabled) |
|
1232 | - $button = new TLinkButton; |
|
1233 | - else |
|
1259 | + if($enabled) { |
|
1260 | + $button = new TLinkButton; |
|
1261 | + } else |
|
1234 | 1262 | { |
1235 | 1263 | $button = new TLabel; |
1236 | 1264 | $button->setText($text); |
1237 | 1265 | return $button; |
1238 | 1266 | } |
1239 | - } |
|
1240 | - else |
|
1267 | + } else |
|
1241 | 1268 | { |
1242 | 1269 | $button = new TButton; |
1243 | - if(!$enabled) |
|
1244 | - $button->setEnabled(false); |
|
1270 | + if(!$enabled) { |
|
1271 | + $button->setEnabled(false); |
|
1272 | + } |
|
1245 | 1273 | } |
1246 | 1274 | $button->setText($text); |
1247 | 1275 | $button->setCommandName($commandName); |
@@ -1271,8 +1299,7 @@ discard block |
||
1271 | 1299 | |
1272 | 1300 | $label = $this->createPagerButton($pager, $buttonType, false, $style->getPrevPageText(), '', ''); |
1273 | 1301 | $controls->add($label); |
1274 | - } |
|
1275 | - else |
|
1302 | + } else |
|
1276 | 1303 | { |
1277 | 1304 | if(($text = $style->getFirstPageText()) !== '') |
1278 | 1305 | { |
@@ -1295,8 +1322,7 @@ discard block |
||
1295 | 1322 | $label = $this->createPagerButton($pager, $buttonType, false, $text, '', ''); |
1296 | 1323 | $controls->add($label); |
1297 | 1324 | } |
1298 | - } |
|
1299 | - else |
|
1325 | + } else |
|
1300 | 1326 | { |
1301 | 1327 | $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, self::CMD_PAGE_NEXT); |
1302 | 1328 | $controls->add($button); |
@@ -1327,12 +1353,14 @@ discard block |
||
1327 | 1353 | if($pageIndex > $endPageIndex) |
1328 | 1354 | { |
1329 | 1355 | $startPageIndex = ((int)(($pageIndex - 1) / $maxButtonCount)) * $maxButtonCount + 1; |
1330 | - if(($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) |
|
1331 | - $endPageIndex = $pageCount; |
|
1356 | + if(($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) { |
|
1357 | + $endPageIndex = $pageCount; |
|
1358 | + } |
|
1332 | 1359 | if($endPageIndex - $startPageIndex + 1 < $maxButtonCount) |
1333 | 1360 | { |
1334 | - if(($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) |
|
1335 | - $startPageIndex = 1; |
|
1361 | + if(($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) { |
|
1362 | + $startPageIndex = 1; |
|
1363 | + } |
|
1336 | 1364 | } |
1337 | 1365 | } |
1338 | 1366 | |
@@ -1356,14 +1384,14 @@ discard block |
||
1356 | 1384 | { |
1357 | 1385 | $label = $this->createPagerButton($pager, $buttonType, false, "$i", '', ''); |
1358 | 1386 | $controls->add($label); |
1359 | - } |
|
1360 | - else |
|
1387 | + } else |
|
1361 | 1388 | { |
1362 | 1389 | $button = $this->createPagerButton($pager, $buttonType, true, "$i", self::CMD_PAGE, "$i"); |
1363 | 1390 | $controls->add($button); |
1364 | 1391 | } |
1365 | - if($i < $endPageIndex) |
|
1366 | - $controls->add("\n"); |
|
1392 | + if($i < $endPageIndex) { |
|
1393 | + $controls->add("\n"); |
|
1394 | + } |
|
1367 | 1395 | } |
1368 | 1396 | |
1369 | 1397 | if($pageCount > $endPageIndex) |
@@ -1388,8 +1416,9 @@ discard block |
||
1388 | 1416 | */ |
1389 | 1417 | protected function createAutoColumns($dataSource) |
1390 | 1418 | { |
1391 | - if(!$dataSource) |
|
1392 | - return null; |
|
1419 | + if(!$dataSource) { |
|
1420 | + return null; |
|
1421 | + } |
|
1393 | 1422 | $autoColumns = $this->getAutoColumns(); |
1394 | 1423 | $autoColumns->clear(); |
1395 | 1424 | foreach($dataSource as $row) |
@@ -1403,8 +1432,7 @@ discard block |
||
1403 | 1432 | $column->setDataField($key); |
1404 | 1433 | $column->setSortExpression($key); |
1405 | 1434 | $autoColumns->add($column); |
1406 | - } |
|
1407 | - else |
|
1435 | + } else |
|
1408 | 1436 | { |
1409 | 1437 | $column->setHeaderText(TListItemType::Item); |
1410 | 1438 | $column->setDataField($key); |
@@ -1435,10 +1463,11 @@ discard block |
||
1435 | 1463 | $alternatingItemStyle = $this->getViewState('AlternatingItemStyle', null); |
1436 | 1464 | if($itemStyle !== null) |
1437 | 1465 | { |
1438 | - if($alternatingItemStyle === null) |
|
1439 | - $alternatingItemStyle = $itemStyle; |
|
1440 | - else |
|
1441 | - $alternatingItemStyle->mergeWith($itemStyle); |
|
1466 | + if($alternatingItemStyle === null) { |
|
1467 | + $alternatingItemStyle = $itemStyle; |
|
1468 | + } else { |
|
1469 | + $alternatingItemStyle->mergeWith($itemStyle); |
|
1470 | + } |
|
1442 | 1471 | } |
1443 | 1472 | |
1444 | 1473 | $selectedItemStyle = $this->getViewState('SelectedItemStyle', null); |
@@ -1446,10 +1475,11 @@ discard block |
||
1446 | 1475 | $editItemStyle = $this->getViewState('EditItemStyle', null); |
1447 | 1476 | if($selectedItemStyle !== null) |
1448 | 1477 | { |
1449 | - if($editItemStyle === null) |
|
1450 | - $editItemStyle = $selectedItemStyle; |
|
1451 | - else |
|
1452 | - $editItemStyle->mergeWith($selectedItemStyle); |
|
1478 | + if($editItemStyle === null) { |
|
1479 | + $editItemStyle = $selectedItemStyle; |
|
1480 | + } else { |
|
1481 | + $editItemStyle->mergeWith($selectedItemStyle); |
|
1482 | + } |
|
1453 | 1483 | } |
1454 | 1484 | |
1455 | 1485 | $headerStyle = $this->getViewState('HeaderStyle', null); |
@@ -1459,61 +1489,73 @@ discard block |
||
1459 | 1489 | |
1460 | 1490 | foreach($this->getControls() as $index => $item) |
1461 | 1491 | { |
1462 | - if(!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) |
|
1463 | - continue; |
|
1492 | + if(!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) { |
|
1493 | + continue; |
|
1494 | + } |
|
1464 | 1495 | $itemType = $item->getItemType(); |
1465 | 1496 | switch($itemType) |
1466 | 1497 | { |
1467 | 1498 | case TListItemType::Header: |
1468 | - if($headerStyle) |
|
1469 | - $item->getStyle()->mergeWith($headerStyle); |
|
1470 | - if(!$this->getShowHeader()) |
|
1471 | - $item->setVisible(false); |
|
1499 | + if($headerStyle) { |
|
1500 | + $item->getStyle()->mergeWith($headerStyle); |
|
1501 | + } |
|
1502 | + if(!$this->getShowHeader()) { |
|
1503 | + $item->setVisible(false); |
|
1504 | + } |
|
1472 | 1505 | break; |
1473 | 1506 | case TListItemType::Footer: |
1474 | - if($footerStyle) |
|
1475 | - $item->getStyle()->mergeWith($footerStyle); |
|
1476 | - if(!$this->getShowFooter()) |
|
1477 | - $item->setVisible(false); |
|
1507 | + if($footerStyle) { |
|
1508 | + $item->getStyle()->mergeWith($footerStyle); |
|
1509 | + } |
|
1510 | + if(!$this->getShowFooter()) { |
|
1511 | + $item->setVisible(false); |
|
1512 | + } |
|
1478 | 1513 | break; |
1479 | 1514 | case TListItemType::Separator: |
1480 | - if($separatorStyle) |
|
1481 | - $item->getStyle()->mergeWith($separatorStyle); |
|
1515 | + if($separatorStyle) { |
|
1516 | + $item->getStyle()->mergeWith($separatorStyle); |
|
1517 | + } |
|
1482 | 1518 | break; |
1483 | 1519 | case TListItemType::Item: |
1484 | - if($itemStyle) |
|
1485 | - $item->getStyle()->mergeWith($itemStyle); |
|
1520 | + if($itemStyle) { |
|
1521 | + $item->getStyle()->mergeWith($itemStyle); |
|
1522 | + } |
|
1486 | 1523 | break; |
1487 | 1524 | case TListItemType::AlternatingItem: |
1488 | - if($alternatingItemStyle) |
|
1489 | - $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1525 | + if($alternatingItemStyle) { |
|
1526 | + $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1527 | + } |
|
1490 | 1528 | break; |
1491 | 1529 | case TListItemType::SelectedItem: |
1492 | - if($selectedItemStyle) |
|
1493 | - $item->getStyle()->mergeWith($selectedItemStyle); |
|
1530 | + if($selectedItemStyle) { |
|
1531 | + $item->getStyle()->mergeWith($selectedItemStyle); |
|
1532 | + } |
|
1494 | 1533 | if($index % 2 == 1) |
1495 | 1534 | { |
1496 | - if($itemStyle) |
|
1497 | - $item->getStyle()->mergeWith($itemStyle); |
|
1498 | - } |
|
1499 | - else |
|
1535 | + if($itemStyle) { |
|
1536 | + $item->getStyle()->mergeWith($itemStyle); |
|
1537 | + } |
|
1538 | + } else |
|
1500 | 1539 | { |
1501 | - if($alternatingItemStyle) |
|
1502 | - $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1540 | + if($alternatingItemStyle) { |
|
1541 | + $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1542 | + } |
|
1503 | 1543 | } |
1504 | 1544 | break; |
1505 | 1545 | case TListItemType::EditItem: |
1506 | - if($editItemStyle) |
|
1507 | - $item->getStyle()->mergeWith($editItemStyle); |
|
1546 | + if($editItemStyle) { |
|
1547 | + $item->getStyle()->mergeWith($editItemStyle); |
|
1548 | + } |
|
1508 | 1549 | if($index % 2 == 1) |
1509 | 1550 | { |
1510 | - if($itemStyle) |
|
1511 | - $item->getStyle()->mergeWith($itemStyle); |
|
1512 | - } |
|
1513 | - else |
|
1551 | + if($itemStyle) { |
|
1552 | + $item->getStyle()->mergeWith($itemStyle); |
|
1553 | + } |
|
1554 | + } else |
|
1514 | 1555 | { |
1515 | - if($alternatingItemStyle) |
|
1516 | - $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1556 | + if($alternatingItemStyle) { |
|
1557 | + $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1558 | + } |
|
1517 | 1559 | } |
1518 | 1560 | break; |
1519 | 1561 | case TListItemType::Pager: |
@@ -1522,13 +1564,14 @@ discard block |
||
1522 | 1564 | $item->getStyle()->mergeWith($pagerStyle); |
1523 | 1565 | if($index === 0) |
1524 | 1566 | { |
1525 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) |
|
1526 | - $item->setVisible(false); |
|
1527 | - } |
|
1528 | - else |
|
1567 | + if($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) { |
|
1568 | + $item->setVisible(false); |
|
1569 | + } |
|
1570 | + } else |
|
1529 | 1571 | { |
1530 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) |
|
1531 | - $item->setVisible(false); |
|
1572 | + if($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) { |
|
1573 | + $item->setVisible(false); |
|
1574 | + } |
|
1532 | 1575 | } |
1533 | 1576 | } |
1534 | 1577 | break; |
@@ -1543,18 +1586,20 @@ discard block |
||
1543 | 1586 | { |
1544 | 1587 | $cell = $cells->itemAt($i); |
1545 | 1588 | $column = $this->_columns->itemAt($i); |
1546 | - if(!$column->getVisible()) |
|
1547 | - $cell->setVisible(false); |
|
1548 | - else |
|
1589 | + if(!$column->getVisible()) { |
|
1590 | + $cell->setVisible(false); |
|
1591 | + } else |
|
1549 | 1592 | { |
1550 | - if($itemType === TListItemType::Header) |
|
1551 | - $style = $column->getHeaderStyle(false); |
|
1552 | - elseif($itemType === TListItemType::Footer) |
|
1553 | - $style = $column->getFooterStyle(false); |
|
1554 | - else |
|
1555 | - $style = $column->getItemStyle(false); |
|
1556 | - if($style !== null) |
|
1557 | - $cell->getStyle()->mergeWith($style); |
|
1593 | + if($itemType === TListItemType::Header) { |
|
1594 | + $style = $column->getHeaderStyle(false); |
|
1595 | + } elseif($itemType === TListItemType::Footer) { |
|
1596 | + $style = $column->getFooterStyle(false); |
|
1597 | + } else { |
|
1598 | + $style = $column->getItemStyle(false); |
|
1599 | + } |
|
1600 | + if($style !== null) { |
|
1601 | + $cell->getStyle()->mergeWith($style); |
|
1602 | + } |
|
1558 | 1603 | } |
1559 | 1604 | } |
1560 | 1605 | } |
@@ -1570,8 +1615,9 @@ discard block |
||
1570 | 1615 | parent::renderBeginTag($writer); |
1571 | 1616 | if(($caption = $this->getCaption()) !== '') |
1572 | 1617 | { |
1573 | - if(($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) |
|
1574 | - $writer->addAttribute('align', strtolower($align)); |
|
1618 | + if(($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) { |
|
1619 | + $writer->addAttribute('align', strtolower($align)); |
|
1620 | + } |
|
1575 | 1621 | $writer->renderBeginTag('caption'); |
1576 | 1622 | $writer->write($caption); |
1577 | 1623 | $writer->renderEndTag(); |
@@ -1592,13 +1638,13 @@ discard block |
||
1592 | 1638 | $control = new TWebControl; |
1593 | 1639 | $control->setID($this->getClientID()); |
1594 | 1640 | $control->copyBaseAttributes($this); |
1595 | - if($this->getHasStyle()) |
|
1596 | - $control->getStyle()->copyFrom($this->getStyle()); |
|
1641 | + if($this->getHasStyle()) { |
|
1642 | + $control->getStyle()->copyFrom($this->getStyle()); |
|
1643 | + } |
|
1597 | 1644 | $control->renderBeginTag($writer); |
1598 | 1645 | $this->renderContents($writer); |
1599 | 1646 | $control->renderEndTag($writer); |
1600 | - } |
|
1601 | - elseif($this->getViewState('ItemCount', 0) > 0) |
|
1647 | + } elseif($this->getViewState('ItemCount', 0) > 0) |
|
1602 | 1648 | { |
1603 | 1649 | $this->applyItemStyles(); |
1604 | 1650 | if($this->_topPager) |
@@ -1626,25 +1672,29 @@ discard block |
||
1626 | 1672 | if($this->_header && $this->_header->getVisible()) |
1627 | 1673 | { |
1628 | 1674 | $writer->writeLine(); |
1629 | - if($style = $this->getViewState('TableHeadStyle', null)) |
|
1630 | - $style->addAttributesToRender($writer); |
|
1675 | + if($style = $this->getViewState('TableHeadStyle', null)) { |
|
1676 | + $style->addAttributesToRender($writer); |
|
1677 | + } |
|
1631 | 1678 | $writer->renderBeginTag('thead'); |
1632 | 1679 | $this->_header->render($writer); |
1633 | 1680 | $writer->renderEndTag(); |
1634 | 1681 | } |
1635 | 1682 | $writer->writeLine(); |
1636 | - if($style = $this->getViewState('TableBodyStyle', null)) |
|
1637 | - $style->addAttributesToRender($writer); |
|
1683 | + if($style = $this->getViewState('TableBodyStyle', null)) { |
|
1684 | + $style->addAttributesToRender($writer); |
|
1685 | + } |
|
1638 | 1686 | $writer->renderBeginTag('tbody'); |
1639 | - foreach($this->getItems() as $item) |
|
1640 | - $item->renderControl($writer); |
|
1687 | + foreach($this->getItems() as $item) { |
|
1688 | + $item->renderControl($writer); |
|
1689 | + } |
|
1641 | 1690 | $writer->renderEndTag(); |
1642 | 1691 | |
1643 | 1692 | if($this->_footer && $this->_footer->getVisible()) |
1644 | 1693 | { |
1645 | 1694 | $writer->writeLine(); |
1646 | - if($style = $this->getViewState('TableFootStyle', null)) |
|
1647 | - $style->addAttributesToRender($writer); |
|
1695 | + if($style = $this->getViewState('TableFootStyle', null)) { |
|
1696 | + $style->addAttributesToRender($writer); |
|
1697 | + } |
|
1648 | 1698 | $writer->renderBeginTag('tfoot'); |
1649 | 1699 | $this->_footer->render($writer); |
1650 | 1700 | $writer->renderEndTag(); |
@@ -151,21 +151,21 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function evaluateIsValid() |
153 | 153 | { |
154 | - if(($value = $this->getValidationValue($this->getValidationTarget())) === '') |
|
154 | + if (($value = $this->getValidationValue($this->getValidationTarget())) === '') |
|
155 | 155 | return true; |
156 | 156 | |
157 | - if(($controlToCompare = $this->getControlToCompare()) !== '') |
|
157 | + if (($controlToCompare = $this->getControlToCompare()) !== '') |
|
158 | 158 | { |
159 | - if(($control2 = $this->findControl($controlToCompare)) === null) |
|
159 | + if (($control2 = $this->findControl($controlToCompare)) === null) |
|
160 | 160 | throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
161 | - if(($value2 = $this->getValidationValue($control2)) === '') |
|
161 | + if (($value2 = $this->getValidationValue($control2)) === '') |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | else |
165 | 165 | $value2 = $this->getValueToCompare(); |
166 | 166 | |
167 | 167 | $values = $this->getComparisonValues($value, $value2); |
168 | - switch($this->getOperator()) |
|
168 | + switch ($this->getOperator()) |
|
169 | 169 | { |
170 | 170 | case TValidationCompareOperator::Equal: |
171 | 171 | return $values[0] == $values[1]; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function getComparisonValues($value1, $value2) |
194 | 194 | { |
195 | - switch($this->getDataType()) |
|
195 | + switch ($this->getDataType()) |
|
196 | 196 | { |
197 | 197 | case TValidationDataType::Integer: |
198 | 198 | return [intval($value1), intval($value2)]; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | return [floatval($value1), floatval($value2)]; |
201 | 201 | case TValidationDataType::Date: |
202 | 202 | $dateFormat = $this->getDateFormat(); |
203 | - if($dateFormat !== '') |
|
203 | + if ($dateFormat !== '') |
|
204 | 204 | { |
205 | 205 | $formatter = new TSimpleDateFormatter($dateFormat); |
206 | 206 | return [$formatter->parse($value1), $formatter->parse($value2)]; |
@@ -218,17 +218,17 @@ discard block |
||
218 | 218 | protected function getClientScriptOptions() |
219 | 219 | { |
220 | 220 | $options = parent::getClientScriptOptions(); |
221 | - if(($name = $this->getControlToCompare()) !== '') |
|
221 | + if (($name = $this->getControlToCompare()) !== '') |
|
222 | 222 | { |
223 | - if(($control = $this->findControl($name)) !== null) |
|
223 | + if (($control = $this->findControl($name)) !== null) |
|
224 | 224 | $options['ControlToCompare'] = $control->getClientID(); |
225 | 225 | } |
226 | - if(($value = $this->getValueToCompare()) !== '') |
|
226 | + if (($value = $this->getValueToCompare()) !== '') |
|
227 | 227 | $options['ValueToCompare'] = $value; |
228 | - if(($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) |
|
228 | + if (($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) |
|
229 | 229 | $options['Operator'] = $operator; |
230 | 230 | $options['DataType'] = $this->getDataType(); |
231 | - if(($dateFormat = $this->getDateFormat()) !== '') |
|
231 | + if (($dateFormat = $this->getDateFormat()) !== '') |
|
232 | 232 | $options['DateFormat'] = $dateFormat; |
233 | 233 | return $options; |
234 | 234 | } |
@@ -151,18 +151,21 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function evaluateIsValid() |
153 | 153 | { |
154 | - if(($value = $this->getValidationValue($this->getValidationTarget())) === '') |
|
155 | - return true; |
|
154 | + if(($value = $this->getValidationValue($this->getValidationTarget())) === '') { |
|
155 | + return true; |
|
156 | + } |
|
156 | 157 | |
157 | 158 | if(($controlToCompare = $this->getControlToCompare()) !== '') |
158 | 159 | { |
159 | - if(($control2 = $this->findControl($controlToCompare)) === null) |
|
160 | - throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
|
161 | - if(($value2 = $this->getValidationValue($control2)) === '') |
|
162 | - return false; |
|
160 | + if(($control2 = $this->findControl($controlToCompare)) === null) { |
|
161 | + throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
|
162 | + } |
|
163 | + if(($value2 = $this->getValidationValue($control2)) === '') { |
|
164 | + return false; |
|
165 | + } |
|
166 | + } else { |
|
167 | + $value2 = $this->getValueToCompare(); |
|
163 | 168 | } |
164 | - else |
|
165 | - $value2 = $this->getValueToCompare(); |
|
166 | 169 | |
167 | 170 | $values = $this->getComparisonValues($value, $value2); |
168 | 171 | switch($this->getOperator()) |
@@ -204,9 +207,9 @@ discard block |
||
204 | 207 | { |
205 | 208 | $formatter = new TSimpleDateFormatter($dateFormat); |
206 | 209 | return [$formatter->parse($value1), $formatter->parse($value2)]; |
210 | + } else { |
|
211 | + return [strtotime($value1), strtotime($value2)]; |
|
207 | 212 | } |
208 | - else |
|
209 | - return [strtotime($value1), strtotime($value2)]; |
|
210 | 213 | } |
211 | 214 | return [$value1, $value2]; |
212 | 215 | } |
@@ -220,16 +223,20 @@ discard block |
||
220 | 223 | $options = parent::getClientScriptOptions(); |
221 | 224 | if(($name = $this->getControlToCompare()) !== '') |
222 | 225 | { |
223 | - if(($control = $this->findControl($name)) !== null) |
|
224 | - $options['ControlToCompare'] = $control->getClientID(); |
|
226 | + if(($control = $this->findControl($name)) !== null) { |
|
227 | + $options['ControlToCompare'] = $control->getClientID(); |
|
228 | + } |
|
229 | + } |
|
230 | + if(($value = $this->getValueToCompare()) !== '') { |
|
231 | + $options['ValueToCompare'] = $value; |
|
232 | + } |
|
233 | + if(($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) { |
|
234 | + $options['Operator'] = $operator; |
|
225 | 235 | } |
226 | - if(($value = $this->getValueToCompare()) !== '') |
|
227 | - $options['ValueToCompare'] = $value; |
|
228 | - if(($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) |
|
229 | - $options['Operator'] = $operator; |
|
230 | 236 | $options['DataType'] = $this->getDataType(); |
231 | - if(($dateFormat = $this->getDateFormat()) !== '') |
|
232 | - $options['DateFormat'] = $dateFormat; |
|
237 | + if(($dateFormat = $this->getDateFormat()) !== '') { |
|
238 | + $options['DateFormat'] = $dateFormat; |
|
239 | + } |
|
233 | 240 | return $options; |
234 | 241 | } |
235 | 242 | } |
236 | 243 | \ No newline at end of file |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getHorizontalAlign() |
61 | 61 | { |
62 | - if($this->getHasStyle()) |
|
62 | + if ($this->getHasStyle()) |
|
63 | 63 | return $this->getStyle()->getHorizontalAlign(); |
64 | 64 | else |
65 | 65 | return 'NotSet'; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getVerticalAlign() |
82 | 82 | { |
83 | - if($this->getHasStyle()) |
|
83 | + if ($this->getHasStyle()) |
|
84 | 84 | return $this->getStyle()->getVerticalAlign(); |
85 | 85 | else |
86 | 86 | return 'NotSet'; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getWrap() |
137 | 137 | { |
138 | - if($this->getHasStyle()) |
|
138 | + if ($this->getHasStyle()) |
|
139 | 139 | return $this->getStyle()->getWrap(); |
140 | 140 | else |
141 | 141 | return true; |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | protected function addAttributesToRender($writer) |
202 | 202 | { |
203 | 203 | parent::addAttributesToRender($writer); |
204 | - if(($colspan = $this->getColumnSpan()) > 0) |
|
204 | + if (($colspan = $this->getColumnSpan()) > 0) |
|
205 | 205 | $writer->addAttribute('colspan', "$colspan"); |
206 | - if(($rowspan = $this->getRowSpan()) > 0) |
|
206 | + if (($rowspan = $this->getRowSpan()) > 0) |
|
207 | 207 | $writer->addAttribute('rowspan', "$rowspan"); |
208 | 208 | } |
209 | 209 | |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function renderContents($writer) |
215 | 215 | { |
216 | - if(($text = $this->getText()) !== '') |
|
216 | + if (($text = $this->getText()) !== '') |
|
217 | 217 | $writer->write($text); |
218 | - elseif($this->getHasControls()) |
|
218 | + elseif ($this->getHasControls()) |
|
219 | 219 | parent::renderContents($writer); |
220 | 220 | else |
221 | 221 | $writer->write(' '); |
@@ -59,10 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getHorizontalAlign() |
61 | 61 | { |
62 | - if($this->getHasStyle()) |
|
63 | - return $this->getStyle()->getHorizontalAlign(); |
|
64 | - else |
|
65 | - return 'NotSet'; |
|
62 | + if($this->getHasStyle()) { |
|
63 | + return $this->getStyle()->getHorizontalAlign(); |
|
64 | + } else { |
|
65 | + return 'NotSet'; |
|
66 | + } |
|
66 | 67 | } |
67 | 68 | |
68 | 69 | /** |
@@ -80,10 +81,11 @@ discard block |
||
80 | 81 | */ |
81 | 82 | public function getVerticalAlign() |
82 | 83 | { |
83 | - if($this->getHasStyle()) |
|
84 | - return $this->getStyle()->getVerticalAlign(); |
|
85 | - else |
|
86 | - return 'NotSet'; |
|
84 | + if($this->getHasStyle()) { |
|
85 | + return $this->getStyle()->getVerticalAlign(); |
|
86 | + } else { |
|
87 | + return 'NotSet'; |
|
88 | + } |
|
87 | 89 | } |
88 | 90 | |
89 | 91 | /** |
@@ -135,10 +137,11 @@ discard block |
||
135 | 137 | */ |
136 | 138 | public function getWrap() |
137 | 139 | { |
138 | - if($this->getHasStyle()) |
|
139 | - return $this->getStyle()->getWrap(); |
|
140 | - else |
|
141 | - return true; |
|
140 | + if($this->getHasStyle()) { |
|
141 | + return $this->getStyle()->getWrap(); |
|
142 | + } else { |
|
143 | + return true; |
|
144 | + } |
|
142 | 145 | } |
143 | 146 | |
144 | 147 | /** |
@@ -201,10 +204,12 @@ discard block |
||
201 | 204 | protected function addAttributesToRender($writer) |
202 | 205 | { |
203 | 206 | parent::addAttributesToRender($writer); |
204 | - if(($colspan = $this->getColumnSpan()) > 0) |
|
205 | - $writer->addAttribute('colspan', "$colspan"); |
|
206 | - if(($rowspan = $this->getRowSpan()) > 0) |
|
207 | - $writer->addAttribute('rowspan', "$rowspan"); |
|
207 | + if(($colspan = $this->getColumnSpan()) > 0) { |
|
208 | + $writer->addAttribute('colspan', "$colspan"); |
|
209 | + } |
|
210 | + if(($rowspan = $this->getRowSpan()) > 0) { |
|
211 | + $writer->addAttribute('rowspan', "$rowspan"); |
|
212 | + } |
|
208 | 213 | } |
209 | 214 | |
210 | 215 | /** |
@@ -213,12 +218,13 @@ discard block |
||
213 | 218 | */ |
214 | 219 | public function renderContents($writer) |
215 | 220 | { |
216 | - if(($text = $this->getText()) !== '') |
|
217 | - $writer->write($text); |
|
218 | - elseif($this->getHasControls()) |
|
219 | - parent::renderContents($writer); |
|
220 | - else |
|
221 | - $writer->write(' '); |
|
221 | + if(($text = $this->getText()) !== '') { |
|
222 | + $writer->write($text); |
|
223 | + } elseif($this->getHasControls()) { |
|
224 | + parent::renderContents($writer); |
|
225 | + } else { |
|
226 | + $writer->write(' '); |
|
227 | + } |
|
222 | 228 | } |
223 | 229 | } |
224 | 230 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | */ |
35 | 35 | public function write($str) |
36 | 36 | { |
37 | - if($this->firstLine) |
|
37 | + if ($this->firstLine) |
|
38 | 38 | { |
39 | 39 | $this->firstLine = false; |
40 | 40 | $this->_writer->write(THttpUtility::htmlEncode(ltrim($str))); |
@@ -107,33 +107,33 @@ discard block |
||
107 | 107 | |
108 | 108 | private function determineCacheability() |
109 | 109 | { |
110 | - if(!$this->_cacheChecked) |
|
110 | + if (!$this->_cacheChecked) |
|
111 | 111 | { |
112 | 112 | $this->_cacheChecked = true; |
113 | - if($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
113 | + if ($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack())) |
|
114 | 114 | { |
115 | - if($this->_cacheModuleID !== '') |
|
115 | + if ($this->_cacheModuleID !== '') |
|
116 | 116 | { |
117 | 117 | $this->_cache = $this->getApplication()->getModule($this->_cacheModuleID); |
118 | - if(!($this->_cache instanceof ICache)) |
|
118 | + if (!($this->_cache instanceof ICache)) |
|
119 | 119 | throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
120 | 120 | } |
121 | 121 | else |
122 | 122 | $this->_cache = $this->getApplication()->getCache(); |
123 | - if($this->_cache !== null) |
|
123 | + if ($this->_cache !== null) |
|
124 | 124 | { |
125 | 125 | $this->_cacheAvailable = true; |
126 | 126 | $data = $this->_cache->get($this->getCacheKey()); |
127 | - if(is_array($data)) |
|
127 | + if (is_array($data)) |
|
128 | 128 | { |
129 | 129 | $param = new TOutputCacheCheckDependencyEventParameter; |
130 | - $param->setCacheTime(isset($data[3])?$data[3]:0); |
|
130 | + $param->setCacheTime(isset($data[3]) ? $data[3] : 0); |
|
131 | 131 | $this->onCheckDependency($param); |
132 | 132 | $this->_dataCached = $param->getIsValid(); |
133 | 133 | } |
134 | 134 | else |
135 | 135 | $this->_dataCached = false; |
136 | - if($this->_dataCached) |
|
136 | + if ($this->_dataCached) |
|
137 | 137 | list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
138 | 138 | } |
139 | 139 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function initRecursive($namingContainer = null) |
151 | 151 | { |
152 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
152 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
153 | 153 | { |
154 | 154 | $stack = $this->getPage()->getCachingStack(); |
155 | 155 | $stack->push($this); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function loadRecursive() |
172 | 172 | { |
173 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
173 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
174 | 174 | { |
175 | 175 | $stack = $this->getPage()->getCachingStack(); |
176 | 176 | $stack->push($this); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | else |
181 | 181 | { |
182 | - if($this->_dataCached) |
|
182 | + if ($this->_dataCached) |
|
183 | 183 | $this->performActions(); |
184 | 184 | parent::loadRecursive(); |
185 | 185 | } |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | { |
190 | 190 | $page = $this->getPage(); |
191 | 191 | $cs = $page->getClientScript(); |
192 | - foreach($this->_actions as $action) |
|
192 | + foreach ($this->_actions as $action) |
|
193 | 193 | { |
194 | - if($action[0] === 'Page.ClientScript') |
|
195 | - call_user_func_array([$cs,$action[1]], $action[2]); |
|
196 | - elseif($action[0] === 'Page') |
|
197 | - call_user_func_array([$page,$action[1]], $action[2]); |
|
194 | + if ($action[0] === 'Page.ClientScript') |
|
195 | + call_user_func_array([$cs, $action[1]], $action[2]); |
|
196 | + elseif ($action[0] === 'Page') |
|
197 | + call_user_func_array([$page, $action[1]], $action[2]); |
|
198 | 198 | else |
199 | - call_user_func_array([$this->getSubProperty($action[0]),$action[1]], $action[2]); |
|
199 | + call_user_func_array([$this->getSubProperty($action[0]), $action[1]], $action[2]); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function preRenderRecursive() |
211 | 211 | { |
212 | - if($this->_cacheAvailable && !$this->_dataCached) |
|
212 | + if ($this->_cacheAvailable && !$this->_dataCached) |
|
213 | 213 | { |
214 | 214 | $stack = $this->getPage()->getCachingStack(); |
215 | 215 | $stack->push($this); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | protected function &saveStateRecursive($needViewState = true) |
246 | 246 | { |
247 | - if($this->_dataCached) |
|
247 | + if ($this->_dataCached) |
|
248 | 248 | return $this->_state; |
249 | 249 | else |
250 | 250 | { |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function registerAction($context, $funcName, $funcParams) |
268 | 268 | { |
269 | - $this->_actions[] = [$context,$funcName,$funcParams]; |
|
269 | + $this->_actions[] = [$context, $funcName, $funcParams]; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | public function getCacheKey() |
273 | 273 | { |
274 | - if($this->_cacheKey === null) |
|
274 | + if ($this->_cacheKey === null) |
|
275 | 275 | $this->_cacheKey = $this->calculateCacheKey(); |
276 | 276 | return $this->_cacheKey; |
277 | 277 | } |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | protected function calculateCacheKey() |
290 | 290 | { |
291 | 291 | $key = $this->getBaseCacheKey(); |
292 | - if($this->_varyBySession) |
|
292 | + if ($this->_varyBySession) |
|
293 | 293 | $key .= $this->getSession()->getSessionID(); |
294 | - if($this->_varyByParam !== '') |
|
294 | + if ($this->_varyByParam !== '') |
|
295 | 295 | { |
296 | 296 | $params = []; |
297 | 297 | $request = $this->getRequest(); |
298 | - foreach(explode(',', $this->_varyByParam) as $name) |
|
298 | + foreach (explode(',', $this->_varyByParam) as $name) |
|
299 | 299 | { |
300 | 300 | $name = trim($name); |
301 | 301 | $params[$name] = $request->itemAt($name); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | protected function getBaseCacheKey() |
315 | 315 | { |
316 | - return self::CACHE_ID_PREFIX . $this->_keyPrefix . $this->getPage()->getPagePath() . $this->getUniqueID(); |
|
316 | + return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getPage()->getPagePath().$this->getUniqueID(); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function setDuration($value) |
389 | 389 | { |
390 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
390 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
391 | 391 | throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
392 | 392 | $this->_duration = $value; |
393 | 393 | } |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | */ |
482 | 482 | public function render($writer) |
483 | 483 | { |
484 | - if($this->_dataCached) |
|
484 | + if ($this->_dataCached) |
|
485 | 485 | $writer->write($this->_contents); |
486 | - elseif($this->_cacheAvailable) |
|
486 | + elseif ($this->_cacheAvailable) |
|
487 | 487 | { |
488 | 488 | $textwriter = new TTextWriter(); |
489 | - $multiwriter = new TOutputCacheTextWriterMulti([$writer->getWriter(),$textwriter]); |
|
489 | + $multiwriter = new TOutputCacheTextWriterMulti([$writer->getWriter(), $textwriter]); |
|
490 | 490 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter); |
491 | 491 | |
492 | 492 | $stack = $this->getPage()->getCachingStack(); |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $stack->pop(); |
496 | 496 | |
497 | 497 | $content = $textwriter->flush(); |
498 | - $data = [$content,$this->_state,$this->_actions,time()]; |
|
498 | + $data = [$content, $this->_state, $this->_actions, time()]; |
|
499 | 499 | $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); |
500 | 500 | } |
501 | 501 | else |
@@ -115,11 +115,12 @@ discard block |
||
115 | 115 | if($this->_cacheModuleID !== '') |
116 | 116 | { |
117 | 117 | $this->_cache = $this->getApplication()->getModule($this->_cacheModuleID); |
118 | - if(!($this->_cache instanceof ICache)) |
|
119 | - throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
|
118 | + if(!($this->_cache instanceof ICache)) { |
|
119 | + throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID); |
|
120 | + } |
|
121 | + } else { |
|
122 | + $this->_cache = $this->getApplication()->getCache(); |
|
120 | 123 | } |
121 | - else |
|
122 | - $this->_cache = $this->getApplication()->getCache(); |
|
123 | 124 | if($this->_cache !== null) |
124 | 125 | { |
125 | 126 | $this->_cacheAvailable = true; |
@@ -130,11 +131,12 @@ discard block |
||
130 | 131 | $param->setCacheTime(isset($data[3])?$data[3]:0); |
131 | 132 | $this->onCheckDependency($param); |
132 | 133 | $this->_dataCached = $param->getIsValid(); |
134 | + } else { |
|
135 | + $this->_dataCached = false; |
|
136 | + } |
|
137 | + if($this->_dataCached) { |
|
138 | + list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
|
133 | 139 | } |
134 | - else |
|
135 | - $this->_dataCached = false; |
|
136 | - if($this->_dataCached) |
|
137 | - list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data; |
|
138 | 140 | } |
139 | 141 | } |
140 | 142 | } |
@@ -155,9 +157,9 @@ discard block |
||
155 | 157 | $stack->push($this); |
156 | 158 | parent::initRecursive($namingContainer); |
157 | 159 | $stack->pop(); |
160 | + } else { |
|
161 | + parent::initRecursive($namingContainer); |
|
158 | 162 | } |
159 | - else |
|
160 | - parent::initRecursive($namingContainer); |
|
161 | 163 | } |
162 | 164 | |
163 | 165 | /** |
@@ -176,11 +178,11 @@ discard block |
||
176 | 178 | $stack->push($this); |
177 | 179 | parent::loadRecursive(); |
178 | 180 | $stack->pop(); |
179 | - } |
|
180 | - else |
|
181 | + } else |
|
181 | 182 | { |
182 | - if($this->_dataCached) |
|
183 | - $this->performActions(); |
|
183 | + if($this->_dataCached) { |
|
184 | + $this->performActions(); |
|
185 | + } |
|
184 | 186 | parent::loadRecursive(); |
185 | 187 | } |
186 | 188 | } |
@@ -191,12 +193,13 @@ discard block |
||
191 | 193 | $cs = $page->getClientScript(); |
192 | 194 | foreach($this->_actions as $action) |
193 | 195 | { |
194 | - if($action[0] === 'Page.ClientScript') |
|
195 | - call_user_func_array([$cs,$action[1]], $action[2]); |
|
196 | - elseif($action[0] === 'Page') |
|
197 | - call_user_func_array([$page,$action[1]], $action[2]); |
|
198 | - else |
|
199 | - call_user_func_array([$this->getSubProperty($action[0]),$action[1]], $action[2]); |
|
196 | + if($action[0] === 'Page.ClientScript') { |
|
197 | + call_user_func_array([$cs,$action[1]], $action[2]); |
|
198 | + } elseif($action[0] === 'Page') { |
|
199 | + call_user_func_array([$page,$action[1]], $action[2]); |
|
200 | + } else { |
|
201 | + call_user_func_array([$this->getSubProperty($action[0]),$action[1]], $action[2]); |
|
202 | + } |
|
200 | 203 | } |
201 | 204 | } |
202 | 205 | |
@@ -215,9 +218,9 @@ discard block |
||
215 | 218 | $stack->push($this); |
216 | 219 | parent::preRenderRecursive(); |
217 | 220 | $stack->pop(); |
221 | + } else { |
|
222 | + parent::preRenderRecursive(); |
|
218 | 223 | } |
219 | - else |
|
220 | - parent::preRenderRecursive(); |
|
221 | 224 | } |
222 | 225 | |
223 | 226 | /** |
@@ -244,9 +247,9 @@ discard block |
||
244 | 247 | */ |
245 | 248 | protected function &saveStateRecursive($needViewState = true) |
246 | 249 | { |
247 | - if($this->_dataCached) |
|
248 | - return $this->_state; |
|
249 | - else |
|
250 | + if($this->_dataCached) { |
|
251 | + return $this->_state; |
|
252 | + } else |
|
250 | 253 | { |
251 | 254 | $st = parent::saveStateRecursive($needViewState); |
252 | 255 | // serialization is needed to avoid undefined classes when loading state |
@@ -271,8 +274,9 @@ discard block |
||
271 | 274 | |
272 | 275 | public function getCacheKey() |
273 | 276 | { |
274 | - if($this->_cacheKey === null) |
|
275 | - $this->_cacheKey = $this->calculateCacheKey(); |
|
277 | + if($this->_cacheKey === null) { |
|
278 | + $this->_cacheKey = $this->calculateCacheKey(); |
|
279 | + } |
|
276 | 280 | return $this->_cacheKey; |
277 | 281 | } |
278 | 282 | |
@@ -289,8 +293,9 @@ discard block |
||
289 | 293 | protected function calculateCacheKey() |
290 | 294 | { |
291 | 295 | $key = $this->getBaseCacheKey(); |
292 | - if($this->_varyBySession) |
|
293 | - $key .= $this->getSession()->getSessionID(); |
|
296 | + if($this->_varyBySession) { |
|
297 | + $key .= $this->getSession()->getSessionID(); |
|
298 | + } |
|
294 | 299 | if($this->_varyByParam !== '') |
295 | 300 | { |
296 | 301 | $params = []; |
@@ -387,8 +392,9 @@ discard block |
||
387 | 392 | */ |
388 | 393 | public function setDuration($value) |
389 | 394 | { |
390 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
391 | - throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
|
395 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
396 | + throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this)); |
|
397 | + } |
|
392 | 398 | $this->_duration = $value; |
393 | 399 | } |
394 | 400 | |
@@ -481,9 +487,9 @@ discard block |
||
481 | 487 | */ |
482 | 488 | public function render($writer) |
483 | 489 | { |
484 | - if($this->_dataCached) |
|
485 | - $writer->write($this->_contents); |
|
486 | - elseif($this->_cacheAvailable) |
|
490 | + if($this->_dataCached) { |
|
491 | + $writer->write($this->_contents); |
|
492 | + } elseif($this->_cacheAvailable) |
|
487 | 493 | { |
488 | 494 | $textwriter = new TTextWriter(); |
489 | 495 | $multiwriter = new TOutputCacheTextWriterMulti([$writer->getWriter(),$textwriter]); |
@@ -497,8 +503,8 @@ discard block |
||
497 | 503 | $content = $textwriter->flush(); |
498 | 504 | $data = [$content,$this->_state,$this->_actions,time()]; |
499 | 505 | $this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency()); |
506 | + } else { |
|
507 | + parent::render($writer); |
|
500 | 508 | } |
501 | - else |
|
502 | - parent::render($writer); |
|
503 | 509 | } |
504 | 510 | } |
505 | 511 | \ No newline at end of file |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function getTemplateByClassName($className) |
64 | 64 | { |
65 | 65 | $class = new \ReflectionClass($className); |
66 | - $tplFile = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $class->getShortName() . self::TEMPLATE_FILE_EXT; |
|
66 | + $tplFile = dirname($class->getFileName()).DIRECTORY_SEPARATOR.$class->getShortName().self::TEMPLATE_FILE_EXT; |
|
67 | 67 | return $this->getTemplateByFileName($tplFile); |
68 | 68 | } |
69 | 69 | |
@@ -73,38 +73,38 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getTemplateByFileName($fileName) |
75 | 75 | { |
76 | - if(($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
|
76 | + if (($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
|
77 | 77 | { |
78 | 78 | Prado::trace("Loading template $fileName", '\Prado\Web\UI\TTemplateManager'); |
79 | - if(($cache = $this->getApplication()->getCache()) === null) |
|
79 | + if (($cache = $this->getApplication()->getCache()) === null) |
|
80 | 80 | return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
81 | 81 | else |
82 | 82 | { |
83 | - $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); |
|
84 | - if(is_array($array)) |
|
83 | + $array = $cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
|
84 | + if (is_array($array)) |
|
85 | 85 | { |
86 | 86 | list($template, $timestamps) = $array; |
87 | - if($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
87 | + if ($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
88 | 88 | return $template; |
89 | 89 | $cacheValid = true; |
90 | - foreach($timestamps as $tplFile => $timestamp) |
|
90 | + foreach ($timestamps as $tplFile => $timestamp) |
|
91 | 91 | { |
92 | - if(!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
92 | + if (!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
93 | 93 | { |
94 | 94 | $cacheValid = false; |
95 | 95 | break; |
96 | 96 | } |
97 | 97 | } |
98 | - if($cacheValid) |
|
98 | + if ($cacheValid) |
|
99 | 99 | return $template; |
100 | 100 | } |
101 | 101 | $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
102 | 102 | $includedFiles = $template->getIncludedFiles(); |
103 | 103 | $timestamps = []; |
104 | 104 | $timestamps[$fileName] = filemtime($fileName); |
105 | - foreach($includedFiles as $includedFile) |
|
105 | + foreach ($includedFiles as $includedFile) |
|
106 | 106 | $timestamps[$includedFile] = filemtime($includedFile); |
107 | - $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template,$timestamps]); |
|
107 | + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName, [$template, $timestamps]); |
|
108 | 108 | return $template; |
109 | 109 | } |
110 | 110 | } |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected function getLocalizedTemplate($filename) |
121 | 121 | { |
122 | - if(($app = $this->getApplication()->getGlobalization(false)) === null) |
|
123 | - return is_file($filename)?$filename:null; |
|
124 | - foreach($app->getLocalizedResource($filename) as $file) |
|
122 | + if (($app = $this->getApplication()->getGlobalization(false)) === null) |
|
123 | + return is_file($filename) ? $filename : null; |
|
124 | + foreach ($app->getLocalizedResource($filename) as $file) |
|
125 | 125 | { |
126 | - if(($file = realpath($file)) !== false && is_file($file)) |
|
126 | + if (($file = realpath($file)) !== false && is_file($file)) |
|
127 | 127 | return $file; |
128 | 128 | } |
129 | 129 | return null; |
@@ -76,16 +76,17 @@ discard block |
||
76 | 76 | if(($fileName = $this->getLocalizedTemplate($fileName)) !== null) |
77 | 77 | { |
78 | 78 | Prado::trace("Loading template $fileName", '\Prado\Web\UI\TTemplateManager'); |
79 | - if(($cache = $this->getApplication()->getCache()) === null) |
|
80 | - return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
81 | - else |
|
79 | + if(($cache = $this->getApplication()->getCache()) === null) { |
|
80 | + return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
81 | + } else |
|
82 | 82 | { |
83 | 83 | $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); |
84 | 84 | if(is_array($array)) |
85 | 85 | { |
86 | 86 | list($template, $timestamps) = $array; |
87 | - if($this->getApplication()->getMode() === TApplicationMode::Performance) |
|
88 | - return $template; |
|
87 | + if($this->getApplication()->getMode() === TApplicationMode::Performance) { |
|
88 | + return $template; |
|
89 | + } |
|
89 | 90 | $cacheValid = true; |
90 | 91 | foreach($timestamps as $tplFile => $timestamp) |
91 | 92 | { |
@@ -95,21 +96,23 @@ discard block |
||
95 | 96 | break; |
96 | 97 | } |
97 | 98 | } |
98 | - if($cacheValid) |
|
99 | - return $template; |
|
99 | + if($cacheValid) { |
|
100 | + return $template; |
|
101 | + } |
|
100 | 102 | } |
101 | 103 | $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
102 | 104 | $includedFiles = $template->getIncludedFiles(); |
103 | 105 | $timestamps = []; |
104 | 106 | $timestamps[$fileName] = filemtime($fileName); |
105 | - foreach($includedFiles as $includedFile) |
|
106 | - $timestamps[$includedFile] = filemtime($includedFile); |
|
107 | + foreach($includedFiles as $includedFile) { |
|
108 | + $timestamps[$includedFile] = filemtime($includedFile); |
|
109 | + } |
|
107 | 110 | $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, [$template,$timestamps]); |
108 | 111 | return $template; |
109 | 112 | } |
113 | + } else { |
|
114 | + return null; |
|
110 | 115 | } |
111 | - else |
|
112 | - return null; |
|
113 | 116 | } |
114 | 117 | |
115 | 118 | /** |
@@ -119,12 +122,14 @@ discard block |
||
119 | 122 | */ |
120 | 123 | protected function getLocalizedTemplate($filename) |
121 | 124 | { |
122 | - if(($app = $this->getApplication()->getGlobalization(false)) === null) |
|
123 | - return is_file($filename)?$filename:null; |
|
125 | + if(($app = $this->getApplication()->getGlobalization(false)) === null) { |
|
126 | + return is_file($filename)?$filename:null; |
|
127 | + } |
|
124 | 128 | foreach($app->getLocalizedResource($filename) as $file) |
125 | 129 | { |
126 | - if(($file = realpath($file)) !== false && is_file($file)) |
|
127 | - return $file; |
|
130 | + if(($file = realpath($file)) !== false && is_file($file)) { |
|
131 | + return $file; |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | return null; |
130 | 135 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | */ |
65 | 65 | public function load() |
66 | 66 | { |
67 | - if(($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
67 | + if (($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
68 | 68 | return $data; |
69 | 69 | else |
70 | 70 | throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
@@ -64,10 +64,11 @@ |
||
64 | 64 | */ |
65 | 65 | public function load() |
66 | 66 | { |
67 | - if(($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) |
|
68 | - return $data; |
|
69 | - else |
|
70 | - throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
|
67 | + if(($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) { |
|
68 | + return $data; |
|
69 | + } else { |
|
70 | + throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); |
|
71 | + } |
|
71 | 72 | } |
72 | 73 | } |
73 | 74 |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | |
199 | 199 | $this->determinePostBackMode(); |
200 | 200 | |
201 | - if($this->getIsPostBack()) |
|
201 | + if ($this->getIsPostBack()) |
|
202 | 202 | { |
203 | - if($this->getIsCallback()) |
|
203 | + if ($this->getIsCallback()) |
|
204 | 204 | $this->processCallbackRequest($writer); |
205 | 205 | else |
206 | 206 | $this->processPostBackRequest($writer); |
@@ -292,13 +292,13 @@ discard block |
||
292 | 292 | |
293 | 293 | protected static function decodeUTF8($data, $enc) |
294 | 294 | { |
295 | - if(is_array($data)) |
|
295 | + if (is_array($data)) |
|
296 | 296 | { |
297 | - foreach($data as $k => $v) |
|
297 | + foreach ($data as $k => $v) |
|
298 | 298 | $data[$k] = self::decodeUTF8($v, $enc); |
299 | 299 | return $data; |
300 | - } elseif(is_string($data)) { |
|
301 | - return iconv('UTF-8', $enc . '//IGNORE', $data); |
|
300 | + } elseif (is_string($data)) { |
|
301 | + return iconv('UTF-8', $enc.'//IGNORE', $data); |
|
302 | 302 | } else { |
303 | 303 | return $data; |
304 | 304 | } |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | $this->setAdapter(new TActivePageAdapter($this)); |
314 | 314 | |
315 | 315 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
316 | - if(strlen($callbackEventParameter) > 0) |
|
317 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
316 | + if (strlen($callbackEventParameter) > 0) |
|
317 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string) $callbackEventParameter); |
|
318 | 318 | |
319 | 319 | // Decode Callback postData from UTF-8 to current Charset |
320 | 320 | if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function getCallbackClient() |
386 | 386 | { |
387 | - if($this->getAdapter() !== null) |
|
387 | + if ($this->getAdapter() !== null) |
|
388 | 388 | return $this->getAdapter()->getCallbackClientHandler(); |
389 | 389 | else |
390 | 390 | return new TCallbackClientScript(); |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function setForm(TForm $form) |
452 | 452 | { |
453 | - if($this->_form === null) |
|
453 | + if ($this->_form === null) |
|
454 | 454 | $this->_form = $form; |
455 | 455 | else |
456 | 456 | throw new TInvalidOperationException('page_form_duplicated'); |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | */ |
465 | 465 | public function getValidators($validationGroup = null) |
466 | 466 | { |
467 | - if(!$this->_validators) |
|
467 | + if (!$this->_validators) |
|
468 | 468 | $this->_validators = new TList; |
469 | - if(empty($validationGroup) === true) |
|
469 | + if (empty($validationGroup) === true) |
|
470 | 470 | return $this->_validators; |
471 | 471 | else |
472 | 472 | { |
473 | 473 | $list = new TList; |
474 | - foreach($this->_validators as $validator) |
|
475 | - if($validator->getValidationGroup() === $validationGroup) |
|
474 | + foreach ($this->_validators as $validator) |
|
475 | + if ($validator->getValidationGroup() === $validationGroup) |
|
476 | 476 | $list->add($validator); |
477 | 477 | return $list; |
478 | 478 | } |
@@ -488,18 +488,18 @@ discard block |
||
488 | 488 | { |
489 | 489 | Prado::trace("Page validate()", 'Prado\Web\UI\TPage'); |
490 | 490 | $this->_validated = true; |
491 | - if($this->_validators && $this->_validators->getCount()) |
|
491 | + if ($this->_validators && $this->_validators->getCount()) |
|
492 | 492 | { |
493 | - if($validationGroup === null) |
|
493 | + if ($validationGroup === null) |
|
494 | 494 | { |
495 | - foreach($this->_validators as $validator) |
|
495 | + foreach ($this->_validators as $validator) |
|
496 | 496 | $validator->validate(); |
497 | 497 | } |
498 | 498 | else |
499 | 499 | { |
500 | - foreach($this->_validators as $validator) |
|
500 | + foreach ($this->_validators as $validator) |
|
501 | 501 | { |
502 | - if($validator->getValidationGroup() === $validationGroup) |
|
502 | + if ($validator->getValidationGroup() === $validationGroup) |
|
503 | 503 | $validator->validate(); |
504 | 504 | } |
505 | 505 | } |
@@ -514,12 +514,12 @@ discard block |
||
514 | 514 | */ |
515 | 515 | public function getIsValid() |
516 | 516 | { |
517 | - if($this->_validated) |
|
517 | + if ($this->_validated) |
|
518 | 518 | { |
519 | - if($this->_validators && $this->_validators->getCount()) |
|
519 | + if ($this->_validators && $this->_validators->getCount()) |
|
520 | 520 | { |
521 | - foreach($this->_validators as $validator) |
|
522 | - if(!$validator->getIsValid()) |
|
521 | + foreach ($this->_validators as $validator) |
|
522 | + if (!$validator->getIsValid()) |
|
523 | 523 | return false; |
524 | 524 | } |
525 | 525 | return true; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | */ |
534 | 534 | public function getTheme() |
535 | 535 | { |
536 | - if(is_string($this->_theme)) |
|
536 | + if (is_string($this->_theme)) |
|
537 | 537 | $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
538 | 538 | return $this->_theme; |
539 | 539 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function setTheme($value) |
546 | 546 | { |
547 | - $this->_theme = empty($value)?null:$value; |
|
547 | + $this->_theme = empty($value) ?null:$value; |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function getStyleSheetTheme() |
555 | 555 | { |
556 | - if(is_string($this->_styleSheet)) |
|
556 | + if (is_string($this->_styleSheet)) |
|
557 | 557 | $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
558 | 558 | return $this->_styleSheet; |
559 | 559 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function setStyleSheetTheme($value) |
566 | 566 | { |
567 | - $this->_styleSheet = empty($value)?null:$value; |
|
567 | + $this->_styleSheet = empty($value) ?null:$value; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function applyControlSkin($control) |
576 | 576 | { |
577 | - if(($theme = $this->getTheme()) !== null) |
|
577 | + if (($theme = $this->getTheme()) !== null) |
|
578 | 578 | $theme->applySkin($control); |
579 | 579 | } |
580 | 580 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function applyControlStyleSheet($control) |
587 | 587 | { |
588 | - if(($theme = $this->getStyleSheetTheme()) !== null) |
|
588 | + if (($theme = $this->getStyleSheetTheme()) !== null) |
|
589 | 589 | $theme->applySkin($control); |
590 | 590 | } |
591 | 591 | |
@@ -594,10 +594,10 @@ discard block |
||
594 | 594 | */ |
595 | 595 | public function getClientScript() |
596 | 596 | { |
597 | - if(!$this->_clientScript) { |
|
597 | + if (!$this->_clientScript) { |
|
598 | 598 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
599 | 599 | |
600 | - if($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) |
|
600 | + if ($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) |
|
601 | 601 | throw new THttpException(404, 'page_csmanagerclass_invalid', $className); |
602 | 602 | |
603 | 603 | $this->_clientScript = new $className($this); |
@@ -671,23 +671,23 @@ discard block |
||
671 | 671 | $this->raiseEvent('OnPreRenderComplete', $this, $param); |
672 | 672 | $cs = $this->getClientScript(); |
673 | 673 | $theme = $this->getTheme(); |
674 | - if($theme instanceof ITheme) |
|
674 | + if ($theme instanceof ITheme) |
|
675 | 675 | { |
676 | - foreach($theme->getStyleSheetFiles() as $url) |
|
676 | + foreach ($theme->getStyleSheetFiles() as $url) |
|
677 | 677 | $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
678 | - foreach($theme->getJavaScriptFiles() as $url) |
|
678 | + foreach ($theme->getJavaScriptFiles() as $url) |
|
679 | 679 | $cs->registerHeadScriptFile($url, $url); |
680 | 680 | } |
681 | 681 | $styleSheet = $this->getStyleSheetTheme(); |
682 | - if($styleSheet instanceof ITheme) |
|
682 | + if ($styleSheet instanceof ITheme) |
|
683 | 683 | { |
684 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
684 | + foreach ($styleSheet->getStyleSheetFiles() as $url) |
|
685 | 685 | $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
686 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
686 | + foreach ($styleSheet->getJavaScriptFiles() as $url) |
|
687 | 687 | $cs->registerHeadScriptFile($url, $url); |
688 | 688 | } |
689 | 689 | |
690 | - if($cs->getRequiresHead() && $this->getHead() === null) |
|
690 | + if ($cs->getRequiresHead() && $this->getHead() === null) |
|
691 | 691 | throw new TConfigurationException('page_head_required'); |
692 | 692 | } |
693 | 693 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | private function getCssMediaType($url) |
703 | 703 | { |
704 | 704 | $segs = explode('.', basename($url)); |
705 | - if(isset($segs[2])) |
|
705 | + if (isset($segs[2])) |
|
706 | 706 | return $segs[count($segs) - 2]; |
707 | 707 | else |
708 | 708 | return ''; |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | private function determinePostBackMode() |
728 | 728 | { |
729 | 729 | $postData = $this->getRequest(); |
730 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
730 | + if ($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
731 | 731 | $this->_postData = $postData; |
732 | 732 | } |
733 | 733 | |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | */ |
808 | 808 | public function registerRequiresPostData($control) |
809 | 809 | { |
810 | - $id = is_string($control)?$control:$control->getUniqueID(); |
|
810 | + $id = is_string($control) ? $control : $control->getUniqueID(); |
|
811 | 811 | $this->_controlsRegisteredForPostData[$id] = true; |
812 | 812 | $params = func_get_args(); |
813 | - foreach($this->getCachingStack() as $item) |
|
813 | + foreach ($this->getCachingStack() as $item) |
|
814 | 814 | $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
815 | 815 | } |
816 | 816 | |
@@ -819,10 +819,10 @@ discard block |
||
819 | 819 | */ |
820 | 820 | public function getPostBackEventTarget() |
821 | 821 | { |
822 | - if($this->_postBackEventTarget === null && $this->_postData !== null) |
|
822 | + if ($this->_postBackEventTarget === null && $this->_postData !== null) |
|
823 | 823 | { |
824 | 824 | $eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
825 | - if(!empty($eventTarget)) |
|
825 | + if (!empty($eventTarget)) |
|
826 | 826 | $this->_postBackEventTarget = $this->findControl($eventTarget); |
827 | 827 | } |
828 | 828 | return $this->_postBackEventTarget; |
@@ -842,9 +842,9 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public function getPostBackEventParameter() |
844 | 844 | { |
845 | - if($this->_postBackEventParameter === null && $this->_postData !== null) |
|
845 | + if ($this->_postBackEventParameter === null && $this->_postData !== null) |
|
846 | 846 | { |
847 | - if(($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
847 | + if (($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
848 | 848 | $this->_postBackEventParameter = ''; |
849 | 849 | } |
850 | 850 | return $this->_postBackEventParameter; |
@@ -866,37 +866,37 @@ discard block |
||
866 | 866 | protected function processPostData($postData, $beforeLoad) |
867 | 867 | { |
868 | 868 | $this->_isLoadingPostData = true; |
869 | - if($beforeLoad) |
|
869 | + if ($beforeLoad) |
|
870 | 870 | $this->_restPostData = new TMap; |
871 | - foreach($postData as $key => $value) |
|
871 | + foreach ($postData as $key => $value) |
|
872 | 872 | { |
873 | - if($this->isSystemPostField($key)) |
|
873 | + if ($this->isSystemPostField($key)) |
|
874 | 874 | continue; |
875 | - elseif($control = $this->findControl($key)) |
|
875 | + elseif ($control = $this->findControl($key)) |
|
876 | 876 | { |
877 | - if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
877 | + if ($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
878 | 878 | { |
879 | - if($control->loadPostData($key, $postData)) |
|
879 | + if ($control->loadPostData($key, $postData)) |
|
880 | 880 | $this->_controlsPostDataChanged[] = $control; |
881 | 881 | } |
882 | - elseif($control instanceof IPostBackEventHandler && |
|
882 | + elseif ($control instanceof IPostBackEventHandler && |
|
883 | 883 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
884 | 884 | { |
885 | - $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
|
885 | + $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
|
886 | 886 | } |
887 | 887 | unset($this->_controlsRequiringPostData[$key]); |
888 | 888 | } |
889 | - elseif($beforeLoad) |
|
889 | + elseif ($beforeLoad) |
|
890 | 890 | $this->_restPostData->add($key, $value); |
891 | 891 | } |
892 | 892 | |
893 | - foreach($this->_controlsRequiringPostData as $key => $value) |
|
893 | + foreach ($this->_controlsRequiringPostData as $key => $value) |
|
894 | 894 | { |
895 | - if($control = $this->findControl($key)) |
|
895 | + if ($control = $this->findControl($key)) |
|
896 | 896 | { |
897 | - if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
897 | + if ($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
|
898 | 898 | { |
899 | - if($control->loadPostData($key, $this->_postData)) |
|
899 | + if ($control->loadPostData($key, $this->_postData)) |
|
900 | 900 | $this->_controlsPostDataChanged[] = $control; |
901 | 901 | } |
902 | 902 | else |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | */ |
921 | 921 | protected function raiseChangedEvents() |
922 | 922 | { |
923 | - foreach($this->_controlsPostDataChanged as $control) |
|
923 | + foreach ($this->_controlsPostDataChanged as $control) |
|
924 | 924 | $control->raisePostDataChangedEvent(); |
925 | 925 | } |
926 | 926 | |
@@ -929,9 +929,9 @@ discard block |
||
929 | 929 | */ |
930 | 930 | protected function raisePostBackEvent() |
931 | 931 | { |
932 | - if(($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
932 | + if (($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
933 | 933 | $this->validate(); |
934 | - elseif($postBackHandler instanceof IPostBackEventHandler) |
|
934 | + elseif ($postBackHandler instanceof IPostBackEventHandler) |
|
935 | 935 | $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
936 | 936 | } |
937 | 937 | |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | */ |
951 | 951 | public function ensureRenderInForm($control) |
952 | 952 | { |
953 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
953 | + if (!$this->getIsCallback() && !$this->_inFormRender) |
|
954 | 954 | throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
955 | 955 | } |
956 | 956 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | */ |
960 | 960 | public function beginFormRender($writer) |
961 | 961 | { |
962 | - if($this->_formRendered) |
|
962 | + if ($this->_formRendered) |
|
963 | 963 | throw new TConfigurationException('page_form_duplicated'); |
964 | 964 | $this->_formRendered = true; |
965 | 965 | $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
@@ -971,15 +971,15 @@ discard block |
||
971 | 971 | */ |
972 | 972 | public function endFormRender($writer) |
973 | 973 | { |
974 | - if($this->_focus) |
|
974 | + if ($this->_focus) |
|
975 | 975 | { |
976 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
976 | + if (($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
977 | 977 | $focus = $this->_focus->getClientID(); |
978 | 978 | else |
979 | 979 | $focus = $this->_focus; |
980 | 980 | $this->getClientScript()->registerFocusControl($focus); |
981 | 981 | } |
982 | - elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
982 | + elseif ($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
983 | 983 | $this->getClientScript()->registerFocusControl($lastFocus); |
984 | 984 | $this->_inFormRender = false; |
985 | 985 | } |
@@ -1023,10 +1023,10 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function setHead(THead $value) |
1025 | 1025 | { |
1026 | - if($this->_head) |
|
1026 | + if ($this->_head) |
|
1027 | 1027 | throw new TInvalidOperationException('page_head_duplicated'); |
1028 | 1028 | $this->_head = $value; |
1029 | - if($this->_title !== null) |
|
1029 | + if ($this->_title !== null) |
|
1030 | 1030 | { |
1031 | 1031 | $this->_head->setTitle($this->_title); |
1032 | 1032 | $this->_title = null; |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | */ |
1039 | 1039 | public function getTitle() |
1040 | 1040 | { |
1041 | - if($this->_head) |
|
1041 | + if ($this->_head) |
|
1042 | 1042 | return $this->_head->getTitle(); |
1043 | 1043 | else |
1044 | 1044 | return $this->_title === null ? '' : $this->_title; |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | */ |
1053 | 1053 | public function setTitle($value) |
1054 | 1054 | { |
1055 | - if($this->_head) |
|
1055 | + if ($this->_head) |
|
1056 | 1056 | $this->_head->setTitle($value); |
1057 | 1057 | else |
1058 | 1058 | $this->_title = $value; |
@@ -1107,10 +1107,10 @@ discard block |
||
1107 | 1107 | */ |
1108 | 1108 | public function getStatePersister() |
1109 | 1109 | { |
1110 | - if($this->_statePersister === null) |
|
1110 | + if ($this->_statePersister === null) |
|
1111 | 1111 | { |
1112 | 1112 | $this->_statePersister = Prado::createComponent($this->_statePersisterClass); |
1113 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
1113 | + if (!($this->_statePersister instanceof IPageStatePersister)) |
|
1114 | 1114 | throw new TInvalidDataTypeException('page_statepersister_invalid'); |
1115 | 1115 | $this->_statePersister->setPage($this); |
1116 | 1116 | } |
@@ -1194,9 +1194,9 @@ discard block |
||
1194 | 1194 | */ |
1195 | 1195 | public function registerCachingAction($context, $funcName, $funcParams) |
1196 | 1196 | { |
1197 | - if($this->_cachingStack) |
|
1197 | + if ($this->_cachingStack) |
|
1198 | 1198 | { |
1199 | - foreach($this->_cachingStack as $cache) |
|
1199 | + foreach ($this->_cachingStack as $cache) |
|
1200 | 1200 | $cache->registerAction($context, $funcName, $funcParams); |
1201 | 1201 | } |
1202 | 1202 | } |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | */ |
1207 | 1207 | public function getCachingStack() |
1208 | 1208 | { |
1209 | - if(!$this->_cachingStack) |
|
1209 | + if (!$this->_cachingStack) |
|
1210 | 1210 | $this->_cachingStack = new TStack; |
1211 | 1211 | return $this->_cachingStack; |
1212 | 1212 | } |
@@ -200,13 +200,14 @@ discard block |
||
200 | 200 | |
201 | 201 | if($this->getIsPostBack()) |
202 | 202 | { |
203 | - if($this->getIsCallback()) |
|
204 | - $this->processCallbackRequest($writer); |
|
205 | - else |
|
206 | - $this->processPostBackRequest($writer); |
|
203 | + if($this->getIsCallback()) { |
|
204 | + $this->processCallbackRequest($writer); |
|
205 | + } else { |
|
206 | + $this->processPostBackRequest($writer); |
|
207 | + } |
|
208 | + } else { |
|
209 | + $this->processNormalRequest($writer); |
|
207 | 210 | } |
208 | - else |
|
209 | - $this->processNormalRequest($writer); |
|
210 | 211 | |
211 | 212 | $this->_writer = null; |
212 | 213 | } |
@@ -294,8 +295,9 @@ discard block |
||
294 | 295 | { |
295 | 296 | if(is_array($data)) |
296 | 297 | { |
297 | - foreach($data as $k => $v) |
|
298 | - $data[$k] = self::decodeUTF8($v, $enc); |
|
298 | + foreach($data as $k => $v) { |
|
299 | + $data[$k] = self::decodeUTF8($v, $enc); |
|
300 | + } |
|
299 | 301 | return $data; |
300 | 302 | } elseif(is_string($data)) { |
301 | 303 | return iconv('UTF-8', $enc . '//IGNORE', $data); |
@@ -313,14 +315,16 @@ discard block |
||
313 | 315 | $this->setAdapter(new TActivePageAdapter($this)); |
314 | 316 | |
315 | 317 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
316 | - if(strlen($callbackEventParameter) > 0) |
|
317 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
318 | + if(strlen($callbackEventParameter) > 0) { |
|
319 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
320 | + } |
|
318 | 321 | |
319 | 322 | // Decode Callback postData from UTF-8 to current Charset |
320 | 323 | if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
321 | - strtoupper($enc = $g->getCharset()) != 'UTF-8') |
|
322 | - foreach ($this->_postData as $k => $v) |
|
324 | + strtoupper($enc = $g->getCharset()) != 'UTF-8') { |
|
325 | + foreach ($this->_postData as $k => $v) |
|
323 | 326 | $this->_postData[$k] = self::decodeUTF8($v, $enc); |
327 | + } |
|
324 | 328 | |
325 | 329 | Prado::trace("Page onPreInit()", 'Prado\Web\UI\TPage'); |
326 | 330 | $this->onPreInit(null); |
@@ -384,10 +388,11 @@ discard block |
||
384 | 388 | */ |
385 | 389 | public function getCallbackClient() |
386 | 390 | { |
387 | - if($this->getAdapter() !== null) |
|
388 | - return $this->getAdapter()->getCallbackClientHandler(); |
|
389 | - else |
|
390 | - return new TCallbackClientScript(); |
|
391 | + if($this->getAdapter() !== null) { |
|
392 | + return $this->getAdapter()->getCallbackClientHandler(); |
|
393 | + } else { |
|
394 | + return new TCallbackClientScript(); |
|
395 | + } |
|
391 | 396 | } |
392 | 397 | |
393 | 398 | /** |
@@ -450,10 +455,11 @@ discard block |
||
450 | 455 | */ |
451 | 456 | public function setForm(TForm $form) |
452 | 457 | { |
453 | - if($this->_form === null) |
|
454 | - $this->_form = $form; |
|
455 | - else |
|
456 | - throw new TInvalidOperationException('page_form_duplicated'); |
|
458 | + if($this->_form === null) { |
|
459 | + $this->_form = $form; |
|
460 | + } else { |
|
461 | + throw new TInvalidOperationException('page_form_duplicated'); |
|
462 | + } |
|
457 | 463 | } |
458 | 464 | |
459 | 465 | /** |
@@ -464,16 +470,18 @@ discard block |
||
464 | 470 | */ |
465 | 471 | public function getValidators($validationGroup = null) |
466 | 472 | { |
467 | - if(!$this->_validators) |
|
468 | - $this->_validators = new TList; |
|
469 | - if(empty($validationGroup) === true) |
|
470 | - return $this->_validators; |
|
471 | - else |
|
473 | + if(!$this->_validators) { |
|
474 | + $this->_validators = new TList; |
|
475 | + } |
|
476 | + if(empty($validationGroup) === true) { |
|
477 | + return $this->_validators; |
|
478 | + } else |
|
472 | 479 | { |
473 | 480 | $list = new TList; |
474 | - foreach($this->_validators as $validator) |
|
475 | - if($validator->getValidationGroup() === $validationGroup) |
|
481 | + foreach($this->_validators as $validator) { |
|
482 | + if($validator->getValidationGroup() === $validationGroup) |
|
476 | 483 | $list->add($validator); |
484 | + } |
|
477 | 485 | return $list; |
478 | 486 | } |
479 | 487 | } |
@@ -492,15 +500,16 @@ discard block |
||
492 | 500 | { |
493 | 501 | if($validationGroup === null) |
494 | 502 | { |
495 | - foreach($this->_validators as $validator) |
|
496 | - $validator->validate(); |
|
497 | - } |
|
498 | - else |
|
503 | + foreach($this->_validators as $validator) { |
|
504 | + $validator->validate(); |
|
505 | + } |
|
506 | + } else |
|
499 | 507 | { |
500 | 508 | foreach($this->_validators as $validator) |
501 | 509 | { |
502 | - if($validator->getValidationGroup() === $validationGroup) |
|
503 | - $validator->validate(); |
|
510 | + if($validator->getValidationGroup() === $validationGroup) { |
|
511 | + $validator->validate(); |
|
512 | + } |
|
504 | 513 | } |
505 | 514 | } |
506 | 515 | } |
@@ -518,14 +527,15 @@ discard block |
||
518 | 527 | { |
519 | 528 | if($this->_validators && $this->_validators->getCount()) |
520 | 529 | { |
521 | - foreach($this->_validators as $validator) |
|
522 | - if(!$validator->getIsValid()) |
|
530 | + foreach($this->_validators as $validator) { |
|
531 | + if(!$validator->getIsValid()) |
|
523 | 532 | return false; |
533 | + } |
|
524 | 534 | } |
525 | 535 | return true; |
536 | + } else { |
|
537 | + throw new TInvalidOperationException('page_isvalid_unknown'); |
|
526 | 538 | } |
527 | - else |
|
528 | - throw new TInvalidOperationException('page_isvalid_unknown'); |
|
529 | 539 | } |
530 | 540 | |
531 | 541 | /** |
@@ -533,8 +543,9 @@ discard block |
||
533 | 543 | */ |
534 | 544 | public function getTheme() |
535 | 545 | { |
536 | - if(is_string($this->_theme)) |
|
537 | - $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
|
546 | + if(is_string($this->_theme)) { |
|
547 | + $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
|
548 | + } |
|
538 | 549 | return $this->_theme; |
539 | 550 | } |
540 | 551 | |
@@ -553,8 +564,9 @@ discard block |
||
553 | 564 | */ |
554 | 565 | public function getStyleSheetTheme() |
555 | 566 | { |
556 | - if(is_string($this->_styleSheet)) |
|
557 | - $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
567 | + if(is_string($this->_styleSheet)) { |
|
568 | + $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
569 | + } |
|
558 | 570 | return $this->_styleSheet; |
559 | 571 | } |
560 | 572 | |
@@ -574,8 +586,9 @@ discard block |
||
574 | 586 | */ |
575 | 587 | public function applyControlSkin($control) |
576 | 588 | { |
577 | - if(($theme = $this->getTheme()) !== null) |
|
578 | - $theme->applySkin($control); |
|
589 | + if(($theme = $this->getTheme()) !== null) { |
|
590 | + $theme->applySkin($control); |
|
591 | + } |
|
579 | 592 | } |
580 | 593 | |
581 | 594 | /** |
@@ -585,8 +598,9 @@ discard block |
||
585 | 598 | */ |
586 | 599 | public function applyControlStyleSheet($control) |
587 | 600 | { |
588 | - if(($theme = $this->getStyleSheetTheme()) !== null) |
|
589 | - $theme->applySkin($control); |
|
601 | + if(($theme = $this->getStyleSheetTheme()) !== null) { |
|
602 | + $theme->applySkin($control); |
|
603 | + } |
|
590 | 604 | } |
591 | 605 | |
592 | 606 | /** |
@@ -597,8 +611,9 @@ discard block |
||
597 | 611 | if(!$this->_clientScript) { |
598 | 612 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
599 | 613 | |
600 | - if($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) |
|
601 | - throw new THttpException(404, 'page_csmanagerclass_invalid', $className); |
|
614 | + if($className !== '\Prado\Web\UI\TClientScriptManager' && !is_subclass_of($className, '\Prado\Web\UI\TClientScriptManager')) { |
|
615 | + throw new THttpException(404, 'page_csmanagerclass_invalid', $className); |
|
616 | + } |
|
602 | 617 | |
603 | 618 | $this->_clientScript = new $className($this); |
604 | 619 | } |
@@ -673,22 +688,27 @@ discard block |
||
673 | 688 | $theme = $this->getTheme(); |
674 | 689 | if($theme instanceof ITheme) |
675 | 690 | { |
676 | - foreach($theme->getStyleSheetFiles() as $url) |
|
677 | - $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
678 | - foreach($theme->getJavaScriptFiles() as $url) |
|
679 | - $cs->registerHeadScriptFile($url, $url); |
|
691 | + foreach($theme->getStyleSheetFiles() as $url) { |
|
692 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
693 | + } |
|
694 | + foreach($theme->getJavaScriptFiles() as $url) { |
|
695 | + $cs->registerHeadScriptFile($url, $url); |
|
696 | + } |
|
680 | 697 | } |
681 | 698 | $styleSheet = $this->getStyleSheetTheme(); |
682 | 699 | if($styleSheet instanceof ITheme) |
683 | 700 | { |
684 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
685 | - $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
686 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
687 | - $cs->registerHeadScriptFile($url, $url); |
|
701 | + foreach($styleSheet->getStyleSheetFiles() as $url) { |
|
702 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
703 | + } |
|
704 | + foreach($styleSheet->getJavaScriptFiles() as $url) { |
|
705 | + $cs->registerHeadScriptFile($url, $url); |
|
706 | + } |
|
688 | 707 | } |
689 | 708 | |
690 | - if($cs->getRequiresHead() && $this->getHead() === null) |
|
691 | - throw new TConfigurationException('page_head_required'); |
|
709 | + if($cs->getRequiresHead() && $this->getHead() === null) { |
|
710 | + throw new TConfigurationException('page_head_required'); |
|
711 | + } |
|
692 | 712 | } |
693 | 713 | |
694 | 714 | /** |
@@ -702,10 +722,11 @@ discard block |
||
702 | 722 | private function getCssMediaType($url) |
703 | 723 | { |
704 | 724 | $segs = explode('.', basename($url)); |
705 | - if(isset($segs[2])) |
|
706 | - return $segs[count($segs) - 2]; |
|
707 | - else |
|
708 | - return ''; |
|
725 | + if(isset($segs[2])) { |
|
726 | + return $segs[count($segs) - 2]; |
|
727 | + } else { |
|
728 | + return ''; |
|
729 | + } |
|
709 | 730 | } |
710 | 731 | |
711 | 732 | /** |
@@ -727,8 +748,9 @@ discard block |
||
727 | 748 | private function determinePostBackMode() |
728 | 749 | { |
729 | 750 | $postData = $this->getRequest(); |
730 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
731 | - $this->_postData = $postData; |
|
751 | + if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) { |
|
752 | + $this->_postData = $postData; |
|
753 | + } |
|
732 | 754 | } |
733 | 755 | |
734 | 756 | /** |
@@ -810,8 +832,9 @@ discard block |
||
810 | 832 | $id = is_string($control)?$control:$control->getUniqueID(); |
811 | 833 | $this->_controlsRegisteredForPostData[$id] = true; |
812 | 834 | $params = func_get_args(); |
813 | - foreach($this->getCachingStack() as $item) |
|
814 | - $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
|
835 | + foreach($this->getCachingStack() as $item) { |
|
836 | + $item->registerAction('Page', 'registerRequiresPostData', [$id]); |
|
837 | + } |
|
815 | 838 | } |
816 | 839 | |
817 | 840 | /** |
@@ -822,8 +845,9 @@ discard block |
||
822 | 845 | if($this->_postBackEventTarget === null && $this->_postData !== null) |
823 | 846 | { |
824 | 847 | $eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
825 | - if(!empty($eventTarget)) |
|
826 | - $this->_postBackEventTarget = $this->findControl($eventTarget); |
|
848 | + if(!empty($eventTarget)) { |
|
849 | + $this->_postBackEventTarget = $this->findControl($eventTarget); |
|
850 | + } |
|
827 | 851 | } |
828 | 852 | return $this->_postBackEventTarget; |
829 | 853 | } |
@@ -844,8 +868,9 @@ discard block |
||
844 | 868 | { |
845 | 869 | if($this->_postBackEventParameter === null && $this->_postData !== null) |
846 | 870 | { |
847 | - if(($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
848 | - $this->_postBackEventParameter = ''; |
|
871 | + if(($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) { |
|
872 | + $this->_postBackEventParameter = ''; |
|
873 | + } |
|
849 | 874 | } |
850 | 875 | return $this->_postBackEventParameter; |
851 | 876 | } |
@@ -866,28 +891,29 @@ discard block |
||
866 | 891 | protected function processPostData($postData, $beforeLoad) |
867 | 892 | { |
868 | 893 | $this->_isLoadingPostData = true; |
869 | - if($beforeLoad) |
|
870 | - $this->_restPostData = new TMap; |
|
894 | + if($beforeLoad) { |
|
895 | + $this->_restPostData = new TMap; |
|
896 | + } |
|
871 | 897 | foreach($postData as $key => $value) |
872 | 898 | { |
873 | - if($this->isSystemPostField($key)) |
|
874 | - continue; |
|
875 | - elseif($control = $this->findControl($key)) |
|
899 | + if($this->isSystemPostField($key)) { |
|
900 | + continue; |
|
901 | + } elseif($control = $this->findControl($key)) |
|
876 | 902 | { |
877 | 903 | if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
878 | 904 | { |
879 | - if($control->loadPostData($key, $postData)) |
|
880 | - $this->_controlsPostDataChanged[] = $control; |
|
881 | - } |
|
882 | - elseif($control instanceof IPostBackEventHandler && |
|
905 | + if($control->loadPostData($key, $postData)) { |
|
906 | + $this->_controlsPostDataChanged[] = $control; |
|
907 | + } |
|
908 | + } elseif($control instanceof IPostBackEventHandler && |
|
883 | 909 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
884 | 910 | { |
885 | 911 | $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
886 | 912 | } |
887 | 913 | unset($this->_controlsRequiringPostData[$key]); |
914 | + } elseif($beforeLoad) { |
|
915 | + $this->_restPostData->add($key, $value); |
|
888 | 916 | } |
889 | - elseif($beforeLoad) |
|
890 | - $this->_restPostData->add($key, $value); |
|
891 | 917 | } |
892 | 918 | |
893 | 919 | foreach($this->_controlsRequiringPostData as $key => $value) |
@@ -896,11 +922,12 @@ discard block |
||
896 | 922 | { |
897 | 923 | if($control instanceof \Prado\Web\UI\IPostBackDataHandler) |
898 | 924 | { |
899 | - if($control->loadPostData($key, $this->_postData)) |
|
900 | - $this->_controlsPostDataChanged[] = $control; |
|
925 | + if($control->loadPostData($key, $this->_postData)) { |
|
926 | + $this->_controlsPostDataChanged[] = $control; |
|
927 | + } |
|
928 | + } else { |
|
929 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
901 | 930 | } |
902 | - else |
|
903 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
904 | 931 | unset($this->_controlsRequiringPostData[$key]); |
905 | 932 | } |
906 | 933 | } |
@@ -920,8 +947,9 @@ discard block |
||
920 | 947 | */ |
921 | 948 | protected function raiseChangedEvents() |
922 | 949 | { |
923 | - foreach($this->_controlsPostDataChanged as $control) |
|
924 | - $control->raisePostDataChangedEvent(); |
|
950 | + foreach($this->_controlsPostDataChanged as $control) { |
|
951 | + $control->raisePostDataChangedEvent(); |
|
952 | + } |
|
925 | 953 | } |
926 | 954 | |
927 | 955 | /** |
@@ -929,10 +957,11 @@ discard block |
||
929 | 957 | */ |
930 | 958 | protected function raisePostBackEvent() |
931 | 959 | { |
932 | - if(($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
933 | - $this->validate(); |
|
934 | - elseif($postBackHandler instanceof IPostBackEventHandler) |
|
935 | - $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
|
960 | + if(($postBackHandler = $this->getPostBackEventTarget()) === null) { |
|
961 | + $this->validate(); |
|
962 | + } elseif($postBackHandler instanceof IPostBackEventHandler) { |
|
963 | + $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
|
964 | + } |
|
936 | 965 | } |
937 | 966 | |
938 | 967 | /** |
@@ -950,8 +979,9 @@ discard block |
||
950 | 979 | */ |
951 | 980 | public function ensureRenderInForm($control) |
952 | 981 | { |
953 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
954 | - throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
982 | + if(!$this->getIsCallback() && !$this->_inFormRender) { |
|
983 | + throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
984 | + } |
|
955 | 985 | } |
956 | 986 | |
957 | 987 | /** |
@@ -959,8 +989,9 @@ discard block |
||
959 | 989 | */ |
960 | 990 | public function beginFormRender($writer) |
961 | 991 | { |
962 | - if($this->_formRendered) |
|
963 | - throw new TConfigurationException('page_form_duplicated'); |
|
992 | + if($this->_formRendered) { |
|
993 | + throw new TConfigurationException('page_form_duplicated'); |
|
994 | + } |
|
964 | 995 | $this->_formRendered = true; |
965 | 996 | $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
966 | 997 | $this->_inFormRender = true; |
@@ -973,14 +1004,15 @@ discard block |
||
973 | 1004 | { |
974 | 1005 | if($this->_focus) |
975 | 1006 | { |
976 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
977 | - $focus = $this->_focus->getClientID(); |
|
978 | - else |
|
979 | - $focus = $this->_focus; |
|
1007 | + if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) { |
|
1008 | + $focus = $this->_focus->getClientID(); |
|
1009 | + } else { |
|
1010 | + $focus = $this->_focus; |
|
1011 | + } |
|
980 | 1012 | $this->getClientScript()->registerFocusControl($focus); |
1013 | + } elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) { |
|
1014 | + $this->getClientScript()->registerFocusControl($lastFocus); |
|
981 | 1015 | } |
982 | - elseif($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
983 | - $this->getClientScript()->registerFocusControl($lastFocus); |
|
984 | 1016 | $this->_inFormRender = false; |
985 | 1017 | } |
986 | 1018 | |
@@ -1023,8 +1055,9 @@ discard block |
||
1023 | 1055 | */ |
1024 | 1056 | public function setHead(THead $value) |
1025 | 1057 | { |
1026 | - if($this->_head) |
|
1027 | - throw new TInvalidOperationException('page_head_duplicated'); |
|
1058 | + if($this->_head) { |
|
1059 | + throw new TInvalidOperationException('page_head_duplicated'); |
|
1060 | + } |
|
1028 | 1061 | $this->_head = $value; |
1029 | 1062 | if($this->_title !== null) |
1030 | 1063 | { |
@@ -1038,10 +1071,11 @@ discard block |
||
1038 | 1071 | */ |
1039 | 1072 | public function getTitle() |
1040 | 1073 | { |
1041 | - if($this->_head) |
|
1042 | - return $this->_head->getTitle(); |
|
1043 | - else |
|
1044 | - return $this->_title === null ? '' : $this->_title; |
|
1074 | + if($this->_head) { |
|
1075 | + return $this->_head->getTitle(); |
|
1076 | + } else { |
|
1077 | + return $this->_title === null ? '' : $this->_title; |
|
1078 | + } |
|
1045 | 1079 | } |
1046 | 1080 | |
1047 | 1081 | /** |
@@ -1052,10 +1086,11 @@ discard block |
||
1052 | 1086 | */ |
1053 | 1087 | public function setTitle($value) |
1054 | 1088 | { |
1055 | - if($this->_head) |
|
1056 | - $this->_head->setTitle($value); |
|
1057 | - else |
|
1058 | - $this->_title = $value; |
|
1089 | + if($this->_head) { |
|
1090 | + $this->_head->setTitle($value); |
|
1091 | + } else { |
|
1092 | + $this->_title = $value; |
|
1093 | + } |
|
1059 | 1094 | } |
1060 | 1095 | |
1061 | 1096 | /** |
@@ -1110,8 +1145,9 @@ discard block |
||
1110 | 1145 | if($this->_statePersister === null) |
1111 | 1146 | { |
1112 | 1147 | $this->_statePersister = Prado::createComponent($this->_statePersisterClass); |
1113 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
1114 | - throw new TInvalidDataTypeException('page_statepersister_invalid'); |
|
1148 | + if(!($this->_statePersister instanceof IPageStatePersister)) { |
|
1149 | + throw new TInvalidDataTypeException('page_statepersister_invalid'); |
|
1150 | + } |
|
1115 | 1151 | $this->_statePersister->setPage($this); |
1116 | 1152 | } |
1117 | 1153 | return $this->_statePersister; |
@@ -1196,8 +1232,9 @@ discard block |
||
1196 | 1232 | { |
1197 | 1233 | if($this->_cachingStack) |
1198 | 1234 | { |
1199 | - foreach($this->_cachingStack as $cache) |
|
1200 | - $cache->registerAction($context, $funcName, $funcParams); |
|
1235 | + foreach($this->_cachingStack as $cache) { |
|
1236 | + $cache->registerAction($context, $funcName, $funcParams); |
|
1237 | + } |
|
1201 | 1238 | } |
1202 | 1239 | } |
1203 | 1240 | |
@@ -1206,8 +1243,9 @@ discard block |
||
1206 | 1243 | */ |
1207 | 1244 | public function getCachingStack() |
1208 | 1245 | { |
1209 | - if(!$this->_cachingStack) |
|
1210 | - $this->_cachingStack = new TStack; |
|
1246 | + if(!$this->_cachingStack) { |
|
1247 | + $this->_cachingStack = new TStack; |
|
1248 | + } |
|
1211 | 1249 | return $this->_cachingStack; |
1212 | 1250 | } |
1213 | 1251 | |
@@ -1216,7 +1254,8 @@ discard block |
||
1216 | 1254 | */ |
1217 | 1255 | public function flushWriter() |
1218 | 1256 | { |
1219 | - if ($this->_writer) |
|
1220 | - $this->Response->write($this->_writer->flush()); |
|
1257 | + if ($this->_writer) { |
|
1258 | + $this->Response->write($this->_writer->flush()); |
|
1259 | + } |
|
1221 | 1260 | } |
1222 | 1261 | } |
1223 | 1262 | \ No newline at end of file |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $this->_initialized = true; |
83 | 83 | $service = $this->getService(); |
84 | - if($service instanceof TPageService) |
|
84 | + if ($service instanceof TPageService) |
|
85 | 85 | $service->setThemeManager($this); |
86 | 86 | else |
87 | 87 | throw new TConfigurationException('thememanager_service_unavailable'); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getTheme($name) |
95 | 95 | { |
96 | - $themePath = $this->getBasePath() . DIRECTORY_SEPARATOR . $name; |
|
97 | - $themeUrl = rtrim($this->getBaseUrl(), '/') . '/' . $name; |
|
96 | + $themePath = $this->getBasePath().DIRECTORY_SEPARATOR.$name; |
|
97 | + $themeUrl = rtrim($this->getBaseUrl(), '/').'/'.$name; |
|
98 | 98 | return Prado::createComponent($this->getThemeClass(), $themePath, $themeUrl); |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string|null $class Theme class name in namespace format |
103 | 103 | */ |
104 | 104 | public function setThemeClass($class) { |
105 | - $this->_themeClass = $class === null ? self::DEFAULT_THEMECLASS : (string)$class; |
|
105 | + $this->_themeClass = $class === null ? self::DEFAULT_THEMECLASS : (string) $class; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $themes = []; |
121 | 121 | $basePath = $this->getBasePath(); |
122 | 122 | $folder = @opendir($basePath); |
123 | - while($file = @readdir($folder)) |
|
123 | + while ($file = @readdir($folder)) |
|
124 | 124 | { |
125 | - if($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) |
|
125 | + if ($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file)) |
|
126 | 126 | $themes[] = $file; |
127 | 127 | } |
128 | 128 | closedir($folder); |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getBasePath() |
137 | 137 | { |
138 | - if($this->_basePath === null) |
|
138 | + if ($this->_basePath === null) |
|
139 | 139 | { |
140 | - $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
|
141 | - if(($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
140 | + $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH; |
|
141 | + if (($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
142 | 142 | throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
143 | 143 | $this->_basePath = $basePath; |
144 | 144 | } |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function setBasePath($value) |
153 | 153 | { |
154 | - if($this->_initialized) |
|
154 | + if ($this->_initialized) |
|
155 | 155 | throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
156 | 156 | else |
157 | 157 | { |
158 | 158 | $this->_basePath = Prado::getPathOfNamespace($value); |
159 | - if($this->_basePath === null || !is_dir($this->_basePath)) |
|
159 | + if ($this->_basePath === null || !is_dir($this->_basePath)) |
|
160 | 160 | throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
161 | 161 | } |
162 | 162 | } |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getBaseUrl() |
169 | 169 | { |
170 | - if($this->_baseUrl === null) |
|
170 | + if ($this->_baseUrl === null) |
|
171 | 171 | { |
172 | 172 | $appPath = dirname($this->getRequest()->getApplicationFilePath()); |
173 | 173 | $basePath = $this->getBasePath(); |
174 | - if(strpos($basePath, $appPath) === false) |
|
174 | + if (strpos($basePath, $appPath) === false) |
|
175 | 175 | throw new TConfigurationException('thememanager_baseurl_required'); |
176 | 176 | $appUrl = rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
177 | - $this->_baseUrl = $appUrl . strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
177 | + $this->_baseUrl = $appUrl.strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
|
178 | 178 | } |
179 | 179 | return $this->_baseUrl; |
180 | 180 | } |
@@ -81,10 +81,11 @@ discard block |
||
81 | 81 | { |
82 | 82 | $this->_initialized = true; |
83 | 83 | $service = $this->getService(); |
84 | - if($service instanceof TPageService) |
|
85 | - $service->setThemeManager($this); |
|
86 | - else |
|
87 | - throw new TConfigurationException('thememanager_service_unavailable'); |
|
84 | + if($service instanceof TPageService) { |
|
85 | + $service->setThemeManager($this); |
|
86 | + } else { |
|
87 | + throw new TConfigurationException('thememanager_service_unavailable'); |
|
88 | + } |
|
88 | 89 | } |
89 | 90 | |
90 | 91 | /** |
@@ -122,8 +123,9 @@ discard block |
||
122 | 123 | $folder = @opendir($basePath); |
123 | 124 | while($file = @readdir($folder)) |
124 | 125 | { |
125 | - if($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) |
|
126 | - $themes[] = $file; |
|
126 | + if($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file)) { |
|
127 | + $themes[] = $file; |
|
128 | + } |
|
127 | 129 | } |
128 | 130 | closedir($folder); |
129 | 131 | return $themes; |
@@ -138,8 +140,9 @@ discard block |
||
138 | 140 | if($this->_basePath === null) |
139 | 141 | { |
140 | 142 | $this->_basePath = dirname($this->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH; |
141 | - if(($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) |
|
142 | - throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
143 | + if(($basePath = realpath($this->_basePath)) === false || !is_dir($basePath)) { |
|
144 | + throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath); |
|
145 | + } |
|
143 | 146 | $this->_basePath = $basePath; |
144 | 147 | } |
145 | 148 | return $this->_basePath; |
@@ -151,13 +154,14 @@ discard block |
||
151 | 154 | */ |
152 | 155 | public function setBasePath($value) |
153 | 156 | { |
154 | - if($this->_initialized) |
|
155 | - throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
|
156 | - else |
|
157 | + if($this->_initialized) { |
|
158 | + throw new TInvalidOperationException('thememanager_basepath_unchangeable'); |
|
159 | + } else |
|
157 | 160 | { |
158 | 161 | $this->_basePath = Prado::getPathOfNamespace($value); |
159 | - if($this->_basePath === null || !is_dir($this->_basePath)) |
|
160 | - throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
162 | + if($this->_basePath === null || !is_dir($this->_basePath)) { |
|
163 | + throw new TInvalidDataValueException('thememanager_basepath_invalid', $value); |
|
164 | + } |
|
161 | 165 | } |
162 | 166 | } |
163 | 167 | |
@@ -171,8 +175,9 @@ discard block |
||
171 | 175 | { |
172 | 176 | $appPath = dirname($this->getRequest()->getApplicationFilePath()); |
173 | 177 | $basePath = $this->getBasePath(); |
174 | - if(strpos($basePath, $appPath) === false) |
|
175 | - throw new TConfigurationException('thememanager_baseurl_required'); |
|
178 | + if(strpos($basePath, $appPath) === false) { |
|
179 | + throw new TConfigurationException('thememanager_baseurl_required'); |
|
180 | + } |
|
176 | 181 | $appUrl = rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\'); |
177 | 182 | $this->_baseUrl = $appUrl . strtr(substr($basePath, strlen($appPath)), '\\', '/'); |
178 | 183 | } |