forked from pollen8/fabrik
/
group.php
1635 lines (1423 loc) · 39 KB
/
group.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Fabrik Group Model
*
* @package Joomla
* @subpackage Fabrik
* @copyright Copyright (C) 2005-2020 Media A-Team, Inc. - All rights reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
jimport('joomla.application.component.model');
/**
* Fabrik Group Model
*
* @package Fabrik
* @since 3.0
*/
class FabrikFEModelGroup extends FabModel
{
/**
* Element plugins
*
* @var array
*/
public $elements = null;
/**
* Published element plugins
*
* @var array
*/
public $publishedElements = null;
/**
* How many times the group's data is repeated
*
* @var int
*/
public $repeatTotal = null;
/**
* Parameters
*
* @var Registry
*/
protected $params = null;
/**
* Id of group to load
*
* @var int
*/
protected $id = null;
/**
* Group table
*
* @var JTable
*/
protected $group = null;
/**
* Form model
*
* @var FabrikFEModelForm
*/
protected $form = null;
/**
* List model
*
* @var FabrikFEModelList
*/
protected $table = null;
/**
* Join model
*
* @var FabrikFEModelJoin
*/
protected $joinModel = null;
/**
* Published element plugins shown in the list
*
* @var array
*/
protected $publishedListElements = null;
/**
* Form ids that the group is in (maximum of one value)
*
* @var array
*/
protected $formsIamIn = null;
/**
* Can the group be viewed (set to false if no elements are visible in the group
*
* @var bool
*/
protected $canView = null;
/**
* Can the group be edited (if false, will override element ACL's and make all elements read only)
*
* @var bool
*/
protected $canEdit = null;
protected $groupProperties = null;
/*
* cache for properties object
*
* @var object
*/
/**
* Save this so we can set endRow on previous element if it was hidden and this element isn't.
* @var null
*/
private $setColumnCssLastElement = null;
/**
* Can the user edit the group
*
* @return bool
*/
public function canEdit()
{
/**
* First cut at this code, need to add actual ACL setting for edit
*
* Mostly needed so people can run plugins on this hook, to set groups to read only
*/
if (!is_null($this->canEdit))
{
return $this->canEdit;
}
$params = $this->getParams();
$this->canEdit = true;
// If group show is type 5, then always read only.
if (in_array($params->get('repeat_group_show_first', '1'), array('2', '5')))
{
$this->canEdit = false;
return $this->canEdit;
}
$formModel = $this->getFormModel();
$pluginCanEdit = FabrikWorker::getPluginManager()->runPlugins('onCanEditGroup', $formModel, 'form', $this);
if (empty($pluginCanEdit))
{
$pluginCanEdit = true;
}
else
{
$pluginCanEdit = !in_array(false, $pluginCanEdit);
}
$this->canEdit = $pluginCanEdit;
return $this->canEdit;
}
/**
* Get group params
*
* @return object params
*/
public function &getParams()
{
if (!$this->params)
{
$this->params = new Registry($this->getGroup()->params);
}
return $this->params;
}
/**
* Get group table
*
* @return FabrikTableGroup
*/
public function &getGroup()
{
if (is_null($this->group))
{
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_fabrik/tables');
$this->group = FabTable::getInstance('Group', 'FabrikTable');
$this->group->load($this->getId());
}
return $this->group;
}
/**
* Set the group row
*
* @param FabrikTableGroup $group Fabrik table
*
* @since 3.0.5
*
* @return void
*/
public function setGroup($group)
{
$this->group = $group;
}
/**
* Get group id
*
* @return int
*/
public function getId()
{
return $this->get('id');
}
/**
* Method to set the group id
*
* @param int $id group ID number
*
* @return void
*/
public function setId($id)
{
// Set new group ID
$this->id = $id;
}
/**
* Get the groups form model
*
* @return FabrikFEModelForm form model
*/
public function getFormModel()
{
if (!isset($this->form))
{
$formIds = $this->getFormsIamIn();
$formId = empty($formIds) ? 0 : $formIds[0];
$this->form = JModelLegacy::getInstance('Form', 'FabrikFEModel');
$this->form->setId($formId);
$this->form->getForm();
$this->form->getlistModel();
}
return $this->form;
}
/**
* Get an array of forms that the group is in
* NOTE: now a group can only belong to one form
*
* @return array form ids
*/
public function getFormsIamIn()
{
if (!isset($this->formsIamIn))
{
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select('form_id')->from('#__{package}_formgroup')->where('group_id = ' . (int) $this->getId());
$db->setQuery($query);
$this->formsIamIn = $db->loadColumn();
}
return $this->formsIamIn;
}
/**
* Can the user view the group
*
* @param string $mode View mode list|form
*
* @return bool
*/
public function canView($mode = 'form')
{
// No ACL option for list view.
if ($mode === 'list')
{
return true;
}
if (!is_null($this->canView))
{
return $this->canView;
}
$params = $this->getParams();
$elementModels = $this->getPublishedElements();
$this->canView = false;
foreach ($elementModels as $elementModel)
{
// $$$ hugh - added canUse() check, corner case, see:
// http://fabrikar.com/forums/showthread.php?p=111746#post111746
if (!$elementModel->canView() && !$elementModel->canUse())
{
continue;
}
$this->canView = true;
break;
}
// Get the group access level
$groups = $this->user->getAuthorisedViewLevels();
$groupAccess = $params->get('access', '');
if ($groupAccess !== '')
{
$this->canView = in_array($groupAccess, $groups);
// If the user can't access the group return that and ignore repeat_group_show_first option
if (!$this->canView)
{
return $this->canView;
}
}
/*
* Sigh - seems that the repeat group 'repeat_group_show_first' property has been bastardized to be a setting
* that is applicable to a group even when not in a repeat group, and has basically become a standard group setting.
* My bad for labelling it poorly to start with.
* So, now if this is set to 'no' the group is not shown but canView was returning true - doh! Caused issues in
* multi page forms where we were trying to set/check errors in groups which were not attached to the form.
*/
$formModel = $this->getFormModel();
$showGroup = $params->get('repeat_group_show_first', '1');
if ($showGroup == 0)
{
$this->canView = false;
}
// If editable but only show group in details view:
if (!($formModel->isEditable() && $showGroup == 2))
{
$this->canView = true;
}
// If form not editable and show group in form view:
if (!$formModel->isEditable() && $showGroup == 3)
{
$this->canView = false;
}
return $this->canView;
}
/**
* Get an array of published elements
*
* @since 120/10/2011 - can override with elementid request data (used in inline edit to limit which elements are shown)
*
* @return PlgFabrik_Element[] published element objects
*/
public function getPublishedElements()
{
if (!isset($this->publishedElements))
{
$this->publishedElements = array();
}
$ids = (array) $this->app->input->get('elementid', array(), 'array');
$sig = implode('.', $ids);
if ($sig === '')
{
$sig = 'default';
}
if (!array_key_exists($sig, $this->publishedElements))
{
$this->publishedElements[$sig] = array();
$elements = (array) $this->getMyElements();
foreach ($elements as $elementModel)
{
$element = $elementModel->getELement();
if ($element->published == 1)
{
if (empty($ids) || in_array($element->id, $ids))
{
$this->publishedElements[$sig][] = $elementModel;
}
}
}
}
return $this->publishedElements[$sig];
}
/**
* Returns array of elements in the group
*
* NOTE: pretty sure that ->elements will already be loaded
* within $formModel->getGroupsHiarachy()
*
* @return PlgFabrik_Element[] Element objects (bound to element plugin)
*/
public function getMyElements()
{
// Elements should generally have already been loaded via the plugin manager getFormPlugins() method
if (!isset($this->elements))
{
$this->getGroup();
$this->elements = array();
$pluginManager = FabrikWorker::getPluginManager();
$formModel = $this->getFormModel();
$allGroups = $pluginManager->getFormPlugins($formModel);
if (empty($this->elements))
{
// Horrible hack for when saving group
/*
* $$$ rob Using @ for now as in inline edit in podion you get multiple notices when
* saving the status element
*/
/* Bauer note: this error prevents adding new elements
* in a new list (where Id is not yet known) in php 7
*/
// $this->elements = @$allGroups[$this->getId()]->elements;
$thisId = $this->getId();
if (!empty($thisId))
{
$this->elements = $allGroups[$thisId]->elements;
}
}
}
return $this->elements;
}
/**
* Set the context in which the element occurs
*
* @param object $formModel Form model
* @param object $listModel List model
*
* @return void
*/
public function setContext($formModel, $listModel)
{
$this->form = $formModel;
$this->table = $listModel;
}
/**
* Randomise the element list (note the array is the pre-rendered elements)
*
* @param array &$elements form views processed/formatted list of elements that the form template uses
*
* @return void
*/
public function randomiseElements(&$elements)
{
if ($this->getParams()->get('random', false) == true)
{
$keys = array_keys($elements);
shuffle($keys);
foreach ($keys as $key)
{
$new[$key] = $elements[$key];
}
$elements = $new;
}
}
/**
* Set the element column css allows for group column settings to be applied
*
* @param object &$element Pre-render element properties
* @param int $rowIx Current key when looping over elements.
*
* @since Fabrik 3.0.5.2
*
* @return int the next column count
*/
public function setColumnCss(&$element, $rowIx)
{
$params = $this->getParams();
$colCount = (int) $params->get('group_columns');
if ($colCount === 0)
{
$colCount = 1;
}
$element->offset = $params->get('group_offset', 0);
// Bootstrap grid formatting
if ($colCount === 1) // Single column
{
$element->startRow = true;
$element->endRow = 1;
$element->span = FabrikHelperHTML::getGridSpan('12');
$element->column = ' style="clear:both;width:100%;"';
$rowIx = -1;
return $rowIx;
}
// Multi-column
$widths = $params->get('group_column_widths', '');
$w = floor((100 - ($colCount * 6)) / $colCount) . '%';
if ($widths !== '')
{
$widths = explode(',', $widths);
$w = FArrayHelper::getValue($widths, ($rowIx) % $colCount, $w);
}
$element->column = ' style="float:left;width:' . $w . ';';
$element->startRow = 0;
$element->endRow = 0;
/**
* Hidden fields at start of row will be grouped on a separate row to avoid
* issues with css selector :first-child.
* $rowIx == -1 indicates a new row to distinguish it from
* $rowIx = 0 which indicates hidden fields already processed at start of row.
**/
if ($rowIx === 0 && !$element->hidden)
{
// Previous element must have been hidden - so set end of row on that and new row on this
$this->setColumnCssLastElement->endRow = 1;
$rowIx = -1;
}
if ($rowIx < 0)
{
$rowIx = 0;
$element->startRow = 1;
$element->column .= "clear:both;";
}
$element->column .= '" ';
$spans = $this->columnSpans();
$spanKey = $rowIx % $colCount;
$default = floor(12 / $colCount);
$element->span = $element->hidden ? '' : FArrayHelper::getValue($spans, $spanKey, FabrikHelperHTML::getGridSpan((int)floor(12 / $colCount)));
if (!$element->hidden)
{
$rowIx++;
}
if ($rowIx !== 0 && ($rowIx % $colCount === 0))
{
$element->endRow = 1;
// Reset rowIx to indicate a new row.
$rowIx = -1;
}
// Save this so we can set endRow on previous element if it was hidden and this element isn't.
$this->setColumnCssLastElement = $element;
return $rowIx;
}
/**
* Work out the bootstrap column spans for the group
* Assigned to each element in setColumnCss()
* Looks at the property group_column_widths which accepts either % or 1-12 as values
*
* @since 3.0b
*
* @return array|void
*/
public function columnSpans()
{
$params = $this->getParams();
$widths = $params->get('group_column_widths', '');
if (trim($widths) === '')
{
return '';
}
$widths = explode(',', $widths);
if (FabrikWorker::j3())
{
foreach ($widths as &$w)
{
if ($w == '')
{
$w = 6;
}
if (strstr($w, '%'))
{
$w = (int) str_replace('%', '', $w);
$w = (int) floor(($w / 100) * 12);
}
$w = ' ' . FabrikHelperHTML::getGridSpan($w);
}
}
return $widths;
}
/**
* Alias to getFormModel()
*
* @deprecated
*
* @return object form model
*/
public function getForm()
{
return $this->getFormModel();
}
/**
* Get a list of all elements which are set to show in list or
* are set to include in list query
*
* @since 3.0.6
*
* @return array list of element models
*/
public function getListQueryElements()
{
if (!isset($this->listQueryElements))
{
$this->listQueryElements = array();
}
$input = $this->app->input;
$groupParams = $this->getParams();
// $$$ rob fabrik_show_in_list set in admin module params (will also be set in menu items and content plugins later on)
// its an array of element ids that should be show. Overrides default element 'show_in_list' setting.
$showInList = $input->get('fabrik_show_in_list', array(), 'array');
$sig = empty($showInList) ? 0 : implode('.', $showInList);
if (!array_key_exists($sig, $this->listQueryElements))
{
$this->listQueryElements[$sig] = array();
$elements = $this->getMyElements();
/**
* $$$ Paul - it is possible that the user has set Include in List Query
* to No for table primary key or join foreign key. If List is then set
* to Merge and Reduce, this causes a problem because the pk/fk
* placeholder is not set. We therefore include the table PK and join FK
* regardless of Include in List Query settings if any elements in the
* group have Include in List Query = Yes.
* In order to avoid iterating over the elements twice, we save the
* PK / FK elementModel and include it as soon as it is needed.
* If the access level does not allow for these to be used, then we should
* display some sort of warning - though this is not included in this fix.
**/
$join = $this->getJoinModel();
if (is_null($join->getJoin()->params))
{
$joinId = '';
$joinFk = '';
}
else
{
$joinId = $join->getForeignID();
$joinFk = $join->getForeignKey();
}
$elementIncluded = false;
$tablePkIncluded = $joinFkIncluded = false;
$tablePkElement = $joinFkElement = null;
foreach ($elements as $elementModel)
{
$element = $elementModel->getElement();
$params = $elementModel->getParams();
/**
* $$$ hugh - experimenting adding non-viewable data to encrypted vars on forms,
* also we need them in addDefaultDataFromRO()
* if ($element->published == 1 && $elementModel->canView())
*/
if ($element->published == 1)
{
$full_name = $elementModel->getFullName(true, false);
/**
* As this function seems to be used to build both the list view and the form view, we should NOT
* include elements in the list query if the user can not view them, as their data is sent to the json object
* and thus visible in the page source.
* Jaanus: also when we exclude elements globally with group settings ($groupParams->get('list_view_and_query', 1) == 0)
*/
if ($input->get('view') == 'list' && ((!$this->getListModel()->isUserDoElement($full_name) && !$elementModel->canView('list')) || $groupParams->get('list_view_and_query', 1) == 0))
{
continue;
}
$showThisInList = $element->primary_key || $params->get('include_in_list_query', 1) == 1
|| (empty($showInList) && $element->show_in_list_summary) || in_array($element->id, $showInList);
if ($showThisInList)
{
if ($element->primary_key || $full_name == $joinId)
{
$tablePkIncluded = true;
}
elseif (!$tablePkIncluded && !is_null($tablePkElement))
{
// Add primary key before other element
$this->listQueryElements[$sig][] = $tablePkElement;
$tablePkIncluded = true;
}
if ($full_name == $joinFk)
{
$joinFkIncluded = true;
}
elseif (!$joinFkIncluded && !is_null($joinFkElement))
{
// Add foreign key before other element
$this->listQueryElements[$sig][] = $joinFkElement;
$joinFkIncluded = true;
}
$this->listQueryElements[$sig][] = $elementModel;
$elementIncluded = true;
}
elseif ($element->primary_key || $full_name == $joinId)
{
if ($elementIncluded)
{
// Add primary key after other element
$this->listQueryElements[$sig][] = $elementModel;
$tablePkIncluded = true;
}
else
{
// Save primary key for future use
$tablePkElement = $elementModel;
}
}
elseif ($elementModel->getFullName(true, false) == $joinFk)
{
if ($elementIncluded)
{
// Add foreign key after other element
$this->listQueryElements[$sig][] = $elementModel;
$joinFkIncluded = true;
}
else
{
// Save foreign key for future use
$joinFkElement = $elementModel;
}
}
}
}
}
return $this->listQueryElements[$sig];
}
/**
* Get the group's associated join model
*
* @return FabrikFEModelJoin join model
*/
public function getJoinModel()
{
$group = $this->getGroup();
if (is_null($this->joinModel))
{
$this->joinModel = JModelLegacy::getInstance('Join', 'FabrikFEModel');
$this->joinModel->setId($group->join_id);
$js = $this->getListModel()->getJoins();
// $$$ rob set join models data from preloaded table joins - reduced load time
for ($x = 0; $x < count($js); $x++)
{
if ($js[$x]->id == $group->join_id && $js[$x]->element_id == 0)
{
$this->joinModel->setData($js[$x]);
break;
}
}
$this->joinModel->getJoin();
}
return $this->joinModel;
}
/**
* Get the groups list model
*
* @return FabrikFEModelList list model
*/
public function getlistModel()
{
return $this->getFormModel()->getlistModel();
}
/**
* Get published elements to show in list
*
* @return PlgFabrik_Element[]
*/
public function getPublishedListElements()
{
if (!isset($this->publishedListElements))
{
$this->publishedListElements = array();
}
$input = $this->app->input;
$params = $this->getParams();
// $$$ rob fabrik_show_in_list set in admin module params (will also be set in menu items and content plugins later on)
// its an array of element ids that should be show. Overrides default element 'show_in_list' setting.
$showInList = (array) $input->get('fabrik_show_in_list', array(), 'array');
$sig = empty($showInList) ? 0 : implode('.', $showInList);
if (!array_key_exists($sig, $this->publishedListElements))
{
$this->publishedListElements[$sig] = array();
$elements = $this->getMyElements();
foreach ($elements as $elementModel)
{
$element = $elementModel->getElement();
if ($params->get('list_view_and_query', 1) == 1 && $element->published == 1 && $elementModel->canView('list'))
{
if (empty($showInList))
{
if ($element->show_in_list_summary)
{
$this->publishedListElements[$sig][] = $elementModel;
}
}
else
{
if (in_array($element->id, $showInList))
{
$this->publishedListElements[$sig][] = $elementModel;
}
}
}
}
}
return $this->publishedListElements[$sig];
}
/**
* Is the group a repeat group
*
* @return bool
*/
public function canCopyElementValues()
{
$params = $this->getParams();
return $params->get('repeat_copy_element_values', '0') === '1';
}
/**
* Get the group's join_id
*
* @return mixed join_id, or false if not a join
*/
public function getJoinId()
{
if (!$this->isJoin())
{
return false;
}
return $this->getGroup()->join_id;
}
/**
* Is the group a join?
*
* @return bool
*/
public function isJoin()
{
return $this->getGroup()->is_join;
}
/**
* Make a group object to be used in the form view. Object contains
* group display properties
*
* @param object &$formModel form model
*
* @return object group display properties
*/
public function getGroupProperties(&$formModel)
{
if (!isset($this->groupProperties))
{
$w = new FabrikWorker;
$input = $this->app->input;
$group = new stdClass;
$groupTable = $this->getGroup();
$params = $this->getParams();
$view = $input->get('view');
if (!isset($this->editable))
{
$this->editable = $formModel->isEditable();
}
if ($this->editable)
{
// If all of the groups elements are not editable then set the group to uneditable
$elements = $this->getPublishedElements();
$editable = false;
foreach ($elements as $element)
{
if ($element->canUse())
{
$editable = true;
}
}
if (!$editable)
{
$this->editable = false;
}
}
$group->editable = $this->editable;
$group->canRepeat = $params->get('repeat_group_button', '0');
$showGroup = $params->def('repeat_group_show_first', '1');
$pages = $formModel->getPages();
$startPage = isset($formModel->sessionModel->last_page) ? $formModel->sessionModel->last_page : 0;
if ($showGroup == -1 || $showGroup == 0 || ($view == 'form' && $showGroup == -2) || ($view == 'details' && $showGroup == -3))
{
$groupTable->css .= ";display:none;";
}
$group->css = trim(str_replace(array("<br />", "<br>"), "", $groupTable->css));
$group->id = $groupTable->id;
$label = $input->getString('group' . $group->id . '_label', $groupTable->label);
if (JString::stristr($label, "{Add/Edit}"))
{
$replace = $formModel->isNewRecord() ? FText::_('COM_FABRIK_ADD') : FText::_('COM_FABRIK_EDIT');
$label = str_replace("{Add/Edit}", $replace, $label);
}
$groupTable->label = $label;
$group->title = $w->parseMessageForPlaceHolder($groupTable->label, $formModel->data, false);
$group->title = FText::_($group->title);
$group->name = $groupTable->name;
$group->displaystate = ($group->canRepeat == 1 && $formModel->isEditable()) ? 1 : 0;
$group->maxRepeat = (int) $params->get('repeat_max');
$group->minRepeat = $params->get('repeat_min', '') === '' ? 1 : (int) $params->get('repeat_min', '');
$group->numRepeatElement = $params->get('repeat_num_element', '');
$group->noDataMsg = $params->get('repeat_no_data_message', '');
$group->showMaxRepeats = $params->get('show_repeat_max', '0') == '1';
$group->minMaxErrMsg = $params->get('repeat_error_message', '');
$group->minMaxErrMsg = FText::_($group->minMaxErrMsg);
$group->canAddRepeat = $this->canAddRepeat();
$group->canDeleteRepeat = $this->canDeleteRepeat();
$intro = FabrikString::translate($params->get('intro'));
$group->intro = $formModel->parseIntroOutroPlaceHolders($intro, $group->editable, $formModel->isNewRecord());
$outro = FText::_($params->get('outro'));
$group->outro = $formModel->parseIntroOutroPlaceHolders($outro, $group->editable, $formModel->isNewRecord());
$group->columns = $params->get('group_columns', 1);
$group->splitPage = $this->isSplitPage();
$group->showLegend = $this->showLegend($group);
$group->labels = $params->get('labels_above', -1);
$group->dlabels = $params->get('labels_above_details', -1);
$group->classArray = array();
$group->class = '';
$group->canOrder = $params->get('repeat_sortable', '') === '1';
if ($this->canRepeat())
{
$group->tmpl = $params->get('repeat_template', 'repeatgroup');
}
else
{
$group->tmpl = 'group';
}