This repository has been archived by the owner on Aug 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
class.atknode.inc
4910 lines (4362 loc) · 167 KB
/
class.atknode.inc
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
/**
* This file is part of the ATK distribution on GitHub.
* Detailed copyright and licensing information can be found
* in the doc/COPYRIGHT and doc/LICENSE files which should be
* included in the distribution.
*
* @package atk
*
* @copyright (c)2000-2007 Ivo Jansch
* @copyright (c)2000-2008 Ibuildings.nl BV
* @license http://www.achievo.org/atk/licensing ATK Open Source License
*
* @version $Revision: 7077 $
*/
/**
* some includes
*/
atkimport("atk.attributes.atkattribute");
atkimport("atk.atkcontroller");
atkimport("atk.modules.atkmodule");
/**
* Define some flags for nodes. Use the constructor of the atkNode
* class to set the flags. (concatenate multiple flags with '|')
*/
/**
* No new records may be added
*/
define("NF_NO_ADD", 1);
/**
* Records may not be edited
*/
define("NF_NO_EDIT", 2);
/**
* Records may not be deleted
*/
define("NF_NO_DELETE", 4);
/**
* Immediately after you add a new record,
* you get the editpage for that record
*/
define("NF_EDITAFTERADD", 8);
/**
* Records may not be searched
*/
define("NF_NO_SEARCH", 16);
/**
* Ignore addFilter filters
*/
define("NF_NO_FILTER", 32);
/**
* Doesn't show an add form on the admin page
* but a link to the form
*/
define("NF_ADD_LINK", 64);
/**
* Records may not be viewed
*/
define("NF_NO_VIEW", 128);
/**
* Records / trees may be copied
*/
define("NF_COPY", 256);
/**
* If this flag is set and only one record is
* present on a selectpage, atk automagically
* selects it and moves on to the target
*/
define("NF_AUTOSELECT", 512);
/**
* If set, atk stores the old values of
* a record as ["atkorgrec"] in the $rec that
* gets passed to the postUpdate
*/
define("NF_TRACK_CHANGES", 1024);
/**
* Quick way to disable accessright checking
* for an entire node. (Everybody may access this node)
*/
define("NF_NO_SECURITY", 2048);
/**
* Extended search feature is turned off
*/
define("NF_NO_EXTENDED_SEARCH", 4096);
/**
* Multi-selection of records is turned on
*/
define("NF_MULTI_RECORD_ACTIONS", 8192);
/**
* Multi-priority-selection of records is turned on
*/
define("NF_MRPA", 16384);
/**
* Add locking support to node, if one user is editing a record,
* no one else may edit it.
*/
define("NF_LOCK", 32768);
/**
* Multi-language support
*/
define("NF_ML", 65536);
/**
* Quick way to ensable the csv import feature
*/
define("NF_IMPORT", 131072);
/**
* Add CSV export ability to the node.
*/
define("NF_EXPORT", 262144);
/**
* Disable csv import feature
* @deprecated since ATK 5.2
*/
define("NF_NO_IMPORT", 0);
/**
* Enable extended sorting (multicolumn sort)
*/
define("NF_EXT_SORT", 524288);
/**
* Makes a node cache it's recordlist
*/
define("NF_CACHE_RECORDLIST", 1048576);
/**
* After adding a new record add another one instantaniously.
*/
define("NF_ADDAFTERADD", 2097152);
/**
* No sorting possible.
*/
define("NF_NO_SORT", 4194304);
/**
* Use the dialog popup box when adding a new record for this node.
*/
define("NF_ADD_DIALOG", 8388608);
/**
* Use the dialog add-or-copy popup box when adding a new record for this node.
*/
define("NF_ADDORCOPY_DIALOG", 16777216);
/**
* Specific node flag 1
*/
define("NF_SPECIFIC_1", 33554432);
/**
* Specific node flag 2
*/
define("NF_SPECIFIC_2", 67108864);
/**
* Specific node flag 3
*/
define("NF_SPECIFIC_3", 134217728);
/**
* Specific node flag 4
*/
define("NF_SPECIFIC_4", 268435456);
/**
* Specific node flag 5
*/
define("NF_SPECIFIC_5", 536870912);
/**
* Records may be copied and open for editing
*/
define("NF_EDITAFTERCOPY", 1073741824);
/**
* Alias for NF_MULTI_RECORD_ACTIONS flag (shortcut)
*/
define("NF_MRA", NF_MULTI_RECORD_ACTIONS);
/**
* Alias for NF_ML flag (typed out)
*/
define("NF_MULTILANGUAGE", NF_ML);
/**
* Aggregate flag to quickly create readonly nodes
*/
define("NF_READONLY", NF_NO_ADD | NF_NO_DELETE | NF_NO_EDIT);
/**
* action status flags
* Note that these have binary numbers, even though an action could never have
* two statusses at the same time.
* This is done however, so the flags can be used as a mask in the setFeedback
* function.
*/
/**
* The action is cancelled
*
* action status flag
*/
define("ACTION_CANCELLED", 1);
/**
* The action failed to accomplish it's goal
*
* action status flag
*/
define("ACTION_FAILED", 2);
/**
* The action is a success
*
* action status flag
*/
define("ACTION_SUCCESS", 4);
/**
* Trigger flags
*/
define("TRIGGER_NONE", 0);
define("TRIGGER_AUTO", 1);
define("TRIGGER_PRE", 2);
define("TRIGGER_POST", 4);
define("TRIGGER_ALL", TRIGGER_PRE | TRIGGER_POST);
/**
* Multi-record-actions selection modes. These
* modes are mutually exclusive.
*/
/**
* Multiple selections possible.
*/
define("MRA_MULTI_SELECT", 1);
/**
* Only one selection possible.
*/
define("MRA_SINGLE_SELECT", 2);
/**
* No selection possible (e.g. action is always for all (visible) records!).
*/
define("MRA_NO_SELECT", 3);
/**
* The atkNode class represents a piece of information that is part of an
* application. This class provides standard functionality for adding,
* editing and deleting nodes.
* This class must be seen as an abstract base class: For every piece of
* information in an application, a class must be derived from this class
* with specific implementations for that type of node.
*
* @author Ivo Jansch <[email protected]>
* @package atk
*/
class atkNode
{
/**
* reference to the class which is used to validate atknodes
* the validator is overridable by changing this variabele
*
* @access private
* @var String
*/
var $m_validate_class = "atk.atknodevalidator";
/**
* Unique field sets of a certain node.
*
* Indicates which field combinations should be unique.
* It doesn't contain the unique fields which have been set by flag
* AF_UNIQUE.
*
* @access private
* @var array
*/
var $m_uniqueFieldSets = array();
/**
* Nodes must be initialised using the init() function before they can be
* used. This member indicated whether the node has been initialised.
* @access private
* @var boolean
*/
var $m_initialised = false;
/**
* Check to prevent double execution of setAttribSizes on pages with more
* than one form.
* @access private
* @var boolean
*/
var $m_attribsizesset = false;
/**
* The list of attributes of a node. These should be of the class
* atkAttribute or one of its derivatives.
* @access private
* @var array
*/
var $m_attribList = array();
/**
* Index list containing the attributes in the order in which they will
* appear on screen.
* @access private
* @var array
*/
var $m_attribIndexList = array();
/**
* Reference to the page on which the node is rendering its output.
* @access private
* @var atkPage
*/
var $m_page = NULL;
/**
* List of available tabs. Associative array structured like this:
* array($action=>$arrayOfTabnames)
* @access private
* @var array
*/
var $m_tabList = array();
/**
* List of available sections. Associative array structured like this:
* array($action=>$arrayOfSectionnames)
* @access private
* @var array
*/
var $m_sectionList = array();
/**
* Keep track of tabs per attribute.
* @access private
* @var array
*/
var $m_attributeTabs = array();
/**
* Keep track if a tab contains attribs (checkEmptyTabs function)
* @access private
* @var array
*/
var $m_filledTabs = array();
/**
* The nodetype.
* @access protected
* @var String
*/
var $m_type;
/**
* The module of the node.
* @access protected
* @var String
*/
var $m_module;
/**
* The database that the node is using for storing and loading its data.
* @access protected
* @var mixed
*/
var $m_db = NULL;
/**
* The table to use for data storage.
* @access protected
* @var String
*/
var $m_table;
/**
* The name of the sequence used for autoincrement fields.
* @access protected
* @var String
*/
var $m_seq;
/**
* Name of the attribute that contains the language of a record.
* Used with ATK's data internationalization feature.
* @access private
* @var String
*/
var $m_lngfield;
/**
* List of names of the attributes that form this node's primary key.
* @access protected
* @var array
*/
var $m_primaryKey = array();
/**
* The postvars (or getvars) that are passed to a page will be passed
* to the class using the dispatch function. We store them in a member
* variable for easy access.
* @access protected
* @var array
*/
var $m_postvars = array();
/**
* The action that the node is currently performing.
* @access protected
* @var String
*/
var $m_action;
/**
* Contains the definition of what needs to rendered partially.
* If set to NULL not in partial rendering mode.
*/
var $m_partial = NULL;
/**
* The active action handler.
* @access protected
* @var atkActionHandler
*/
var $m_handler = NULL;
/**
* Default order by statement.
* @access protected
* @var String
*/
var $m_default_order = "";
/**
* var used for tracking relation within this node.
* @todo Remove this member, it's using memory while it's used only in
* the case of multilanguage node, and even then only on one
* occasion.
* @access private
* @var array
*/
var $m_relations = array();
/**
* Bitwise mask of node flags (NF_* flags).
* @var int
*/
var $m_flags;
/*
* Name of the field that is used for creating an alphabetical index in
* admin/select pages.
* @access private
* @var String
*/
var $m_index = "";
/**
* Default tab being displayed in add/edit mode.
* @access private
* @var String
*/
var $m_default_tab = "default";
/**
* Default sections that are expanded.
* @access private
* @var String
*/
var $m_default_expanded_sections = array();
/**
* Record filters, in attributename/required value pairs.
* @access private
* @var array
*/
var $m_filters = array();
/**
* Record filters, as a list of sql statements.
* @access private
* @var array
*/
var $m_fuzzyFilters = array();
/**
* For speed, we keep track of a list of attributes that we don't have to
* load in recordlists.
* @access protected
* @var array
*/
var $m_listExcludes = array();
/**
* For speed, we keep track of a list of attributes that we don't have to
* load when in view pages.
* @todo This can probably be moved to the view handler.
* @access protected
* @var array
*/
var $m_viewExcludes = array();
/**
* For speed, we keep track of a list of attributes that have the cascade
* delete flag set.
* @todo This should be moved to the delete handler, or should not be
* cached at all. (caching this on each load is slower than just
* retrieving the list when it's needed)
* @access private
* @var array
*/
var $m_cascadingAttribs = array();
/**
* Actions are mapped to security units.
*
* For example, both actions "save" and "add" require access "add". If an
* item is not in this list, it's treated 'as-is'. Derived nodes may add
* more mappings to tell the systems that some custom actions require the
* same privilege as others.
* Structure: array($action=>$requiredPrivilege)
* @access protected
* @var array
*/
var $m_securityMap = array("save" => "add",
"update" => "edit",
"multiupdate" => "edit",
"copy" => "add",
"import" => "add",
"editcopy" => "add",
"search" => "admin",
"smartsearch" => "admin");
/**
* The right to execute certain actions can be implied by the fact that you
* have some other right. For example, if you have the right to access a
* feature (admin right), you may also view that record, and don't need
* explicit rights to view it. So the 'view' right is said to be 'implied'
* by the 'admin' right.
* This is a subtle difference with m_securityMap.
* @access protected
* @var array
*/
var $m_securityImplied = array("view" => "admin");
/**
* Name of the node that is used for privilege checking.
*
* If a class is named 'project', then by default, if the system needs to
* know whether a user may edit a record, the securitymanager searches
* for 'edit' access on 'project'. However, if an alias is set here, the
* securitymanger searches for 'edit' on that alias.
* @access private
* @var String
*/
var $m_securityAlias = "";
/*
* Nodes can specify actions that require no access level
* Note: for the moment, the "select" action is always allowed.
* @todo This may not be correct. We have to find a way to bind the
* select action to the action that follows after the select.
* @access private
* @var array
*/
var $m_unsecuredActions = array("select", "multiselect", "feedback");
/*
*
* Boolean that is set to true when the stacktrace is displayed, so it
* is displayed only once.
* @deprecated This member is as deprecated as the statusbar() method.
* @access private
* @var boolean
*/
var $m_statusbarDone = false;
/**
* Auto search-actions; action that will be performed if only one record
* is found.
* @access private
* @var array
*/
var $m_search_action;
/**
* Priority actions
* @access private
* @todo This, and the priority_min/max members, should be moved
* to the recordlist
* @var array
*/
var $m_priority_actions = array();
/**
* Minimum for the mra priority select
* @access private
* @var int
*/
var $m_priority_min = 1;
/**
* Maximum for the mra priority select
* @access private
* @var int
*/
var $m_priority_max = 0;
/**
* The lock instance
* @access protected
* @var atkLock
*/
var $m_lock = NULL;
/**
* List of actions that should give success/failure feedback
* @access private
* @var array
*/
var $m_feedback = array();
/**
* Default language used by Multilanguage Nodes.
* @access protected
* @var String
*/
var $m_defaultlanguage = "";
/**
* Number to use with numbering
* @access protected
* @var mixed
*/
var $m_numbering = null;
/**
* Descriptor template.
* @access protected
* @var String
*/
var $m_descTemplate = NULL;
/**
* Descriptor handler.
* @access protected
* @var Object
*/
var $m_descHandler = NULL;
/**
* List of action listeners
* @access protected
* @var Array
*/
var $m_actionListeners = array();
/**
* List of trigger listeners
* @access protected
* @var Array
*/
var $m_triggerListeners = array();
/**
* List of callback functions to manipulate the record actions
*
* @var array
*/
protected $m_recordActionsCallbacks = array();
/**
* List of callback functions to add css class to row.
* See details in atkDGList::getRecordlistData() method
*
* @var array
*/
protected $m_rowClassCallback = array();
/**
* Tracker variable to see if we are currently in 'modifier mode' (running inside
* the scope of a modname_nodename_modifier() method). The variable contains the
* name of the modifying module.
* @access private
* @var String
*/
var $m_modifier = "";
/**
* Extended search action. The action which is called if the user
* wants to perform an extended search.
*
* @access private
* @var String
*/
var $m_extended_search_action = NULL;
/**
* List of editable list attributes.
* @access private
* @var Array
*/
var $m_editableListAttributes = array();
/**
* Multi-record actions, selection mode.
* @access private
* @var int
*/
var $m_mraSelectionMode = MRA_MULTI_SELECT;
/**
* The default edit fieldprefix to use for atk
* @access private
* @var String
*/
var $m_edit_fieldprefix = '';
/**
* Lock mode.
*
* @var int
*/
private $m_lockMode = 'exclusive'; // atkLock::EXCLUSIVE (would mean atkLock needs to be available!)
/**
* Default column name (null means across all columns)
*
* @var string
*/
private $m_defaultColumn = null;
/**
* Current maximum attribute order value.
*
* @var int
*/
private $m_attribOrder = 0;
/**
* Constructor.
*
* This initialises the node. Derived classes should always call their
* parent constructor ($this->atkNode($name, $flags), to initialize the
* base class.
* <br>
* <b>Example:</b>
* <code>$this->atkNode('test',NF_NO_EDIT);</code>
* @param String $type The nodetype (by default equal to the classname)
* @param int $flags Bitmask of node flags (NF_*).
*/
function atkNode($type = "", $flags = 0)
{
if ($type == "")
$type = strtolower(get_class($this));
atkdebug("Creating a new atkNode for $type");
$this->m_type = $type;
$this->m_flags = $flags;
$this->m_module = atkModule::getModuleScope();
$this->setEditFieldPrefix(atkconfig('edit_fieldprefix', ''));
}
/**
* Resolve section. If a section is only prefixed by
* a dot this means we need to add the default tab
* before the dot.
*
* @param string $section section name
* @return resolved section name
*/
function resolveSection($section)
{
list($part1, $part2) = (strpos($section, ".") !== false) ? explode('.', $section)
: array($section, "");
if ($part2 != NULL && strlen($part2) > 0 && strlen($part1) == 0)
return $this->m_default_tab . "." . $part2;
else if (strlen($part2) == 0 && strlen($part1) == 0)
return $this->m_default_tab;
else
return $section;
}
/**
* Resolve sections.
*
* @param array $sections section list
* @return array resolved section list
*
* @see resolveSection
*/
function resolveSections($sections)
{
$result = array();
foreach ($sections as $section) {
$result[] = $this->resolveSection($section);
}
return $result;
}
/**
* Returns the default column name.
*
* @return string default column name
*/
public function getDefaultColumn()
{
return $this->m_defaultColumn;
}
/**
* Set default column name.
*
* @param string name default column name
*/
public function setDefaultColumn($name)
{
$this->m_defaultColumn = $name;
}
/**
* Resolve column for sections.
*
* If one of the sections contains something after a double
* colon (:) than that's used as column name, else the default
* column name will be used.
*
* @param array $sections sections
*
* @return string column name
*/
protected function resolveColumn(&$sections)
{
$column = $this->getDefaultColumn();
if (!is_array($sections)) {
return $column;
}
foreach ($sections as &$section) {
if (strpos($section, ":") !== false) {
list($section, $column) = explode(':', $section);
}
}
return $column;
}
/**
* Resolve sections, tabs and the order based on the given
* argument to the attribute add method.
*
* @param mixed $sections
* @param mixed $tabs
* @param mixed $order
*/
function resolveSectionsTabsOrder(&$sections, &$tabs, &$column, &$order)
{
// Because sections/tabs will probably be used more than the order override option
// the API for this method now favours the $sections argument. For backwards
// compatibility we still support the old API ($attribute,$order=0).
if ($sections !== NULL && is_int($sections)) {
$order = $sections;
$sections = array($this->m_default_tab);
}
// If no section/tab is specified or tabs are disabled, we use the current default tab
// (specified with the setDefaultTab method, or "default" otherwise)
elseif ($sections === NULL || (is_string($sections) && strlen($sections) == 0) || !atkconfig("tabs")) {
$sections = array($this->m_default_tab);
}
// Sections should be an array.
else if ($sections != "*" && !is_array($sections)) {
$sections = array($sections);
}
$column = $this->resolveColumn($sections);
if (is_array($sections)) {
$sections = $this->resolveSections($sections);
}
// Filter tabs from section names.
$tabs = $this->getTabsFromSections($sections);
}
/**
* Add an atkAttribute (or one of its derivatives) to the node.
* @param atkAttribute $attribute The attribute you want to add
* @param mixed $sections The sections/tab(s) on which the attribute should be
* displayed. Can be a tabname (String) or a list of
* tabs (array) or "*" if the attribute should be
* displayed on all tabs.
* @param int $order The order at which the attribute should be displayed.
* If ommitted, this defaults to 100 for the first
* attribute, and 100 more for each next attribute that
* is added.
* @return atkAttribute the attribute just added
*/
public function add($attribute, $sections = NULL, $order = 0)
{
$tabs = null;
$column = null;
$attribute->m_owner = $this->m_type;
// If we're running inside modifier scope, we have to tell the attribute
// what module he originated from.
if ($this->m_modifier != "")
$attribute->m_module = $this->m_modifier;
if (!atkReadOptimizer()) {
$this->resolveSectionsTabsOrder($sections, $tabs, $column, $order);
// check for parent fieldname (treeview)
if ($attribute->hasFlag(AF_PARENT)) {
$this->m_parent = $attribute->fieldName();
}
// check for cascading delete flag
if ($attribute->hasFlag(AF_CASCADE_DELETE)) {
$this->m_cascadingAttribs[] = $attribute->fieldName();
}
if ($attribute->hasFlag(AF_HIDE_LIST) && !$attribute->hasFlag(AF_PRIMARY)) {
if (!in_array($attribute->fieldName(), $this->m_listExcludes)) {
$this->m_listExcludes[] = $attribute->fieldName();
}
}
if ($attribute->hasFlag(AF_HIDE_VIEW) && !$attribute->hasFlag(AF_PRIMARY)) {
if (!in_array($attribute->fieldName(), $this->m_viewExcludes)) {
$this->m_viewExcludes[] = $attribute->fieldName();
}
}
} else {
// when the read optimizer is enabled there is no active tab
// we circument this by putting all attributes on all tabs
if ($sections !== NULL && is_int($sections))
$order = $sections;
$tabs = "*";
$sections = "*";
$column = $this->getDefaultColumn();
}
// NOTE: THIS SHOULD WORK. BUT, since add() is called from inside the $this
// constructor, m_ownerInstance ends up being a copy of $this, rather than
// a reference. Don't ask me why, it has something to do with the way PHP
// handles the constructor.
// To work around this, we reassign the this pointer to the attributes as
// soon as possible AFTER the constructor. (the dispatcher function)
$attribute->setOwnerInstance($this);
if ($attribute->hasFlag(AF_PRIMARY)) {
if (!in_array($attribute->fieldName(), $this->m_primaryKey)) {
$this->m_primaryKey[] = $attribute->fieldName();
}
}
if ($attribute->hasFlag(AF_MULTILANGUAGE)) {
$this->m_lngfield = $attribute->fieldName();
}
$attribute->init();
$exist = false;
if (isset($this->m_attribList[$attribute->fieldName()]) && is_object($this->m_attribList[$attribute->fieldName()])) {
$exist = true;
// if order is set, overwrite it with new order, last order will count
if ($order != 0) {
$this->m_attribIndexList[$this->m_attribList[$attribute->fieldName()]->m_index]["order"] = $order;
}
$attribute->m_index = $this->m_attribList[$attribute->fieldName()]->m_index;