-
Notifications
You must be signed in to change notification settings - Fork 167
/
BaseEditorController.php
1321 lines (1157 loc) · 59.9 KB
/
BaseEditorController.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
/** ---------------------------------------------------------------------
* app/lib/ca/BaseEditorController.php :
* ----------------------------------------------------------------------
* CollectiveAccess
* Open-source collections management software
* ----------------------------------------------------------------------
*
* Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
* Copyright 2009-2012 Whirl-i-Gig
*
* For more information visit http://www.CollectiveAccess.org
*
* This program is free software; you may redistribute it and/or modify it under
* the terms of the provided license as published by Whirl-i-Gig
*
* CollectiveAccess is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* This source code is free and modifiable under the terms of
* GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
* the "license.txt" file for details, or visit the CollectiveAccess web site at
* http://www.CollectiveAccess.org
*
* @package CollectiveAccess
* @subpackage UI
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License version 3
*
* ----------------------------------------------------------------------
*/
/**
*
*/
require_once(__CA_MODELS_DIR__."/ca_editor_uis.php");
require_once(__CA_MODELS_DIR__."/ca_attribute_values.php");
require_once(__CA_MODELS_DIR__."/ca_metadata_elements.php");
require_once(__CA_MODELS_DIR__."/ca_bundle_mappings.php");
require_once(__CA_MODELS_DIR__."/ca_bundle_displays.php");
require_once(__CA_MODELS_DIR__."/ca_attributes.php");
require_once(__CA_MODELS_DIR__."/ca_attribute_values.php");
require_once(__CA_LIB_DIR__."/core/Datamodel.php");
require_once(__CA_LIB_DIR__."/ca/ApplicationPluginManager.php");
require_once(__CA_LIB_DIR__."/ca/ResultContext.php");
require_once(__CA_LIB_DIR__."/ca/ImportExport/DataExporter.php");
require_once(__CA_LIB_DIR__."/core/Logging/Eventlog.php");
class BaseEditorController extends ActionController {
# -------------------------------------------------------
protected $opo_datamodel;
protected $opo_app_plugin_manager;
protected $opo_result_context;
# -------------------------------------------------------
#
# -------------------------------------------------------
public function __construct(&$po_request, &$po_response, $pa_view_paths=null) {
parent::__construct($po_request, $po_response, $pa_view_paths);
$this->opo_datamodel = Datamodel::load();
$this->opo_app_plugin_manager = new ApplicationPluginManager();
$this->opo_result_context = new ResultContext($po_request, $this->ops_table_name, ResultContext::getLastFind($po_request, $this->ops_table_name));
}
# -------------------------------------------------------
/**
* Generates a form for editing new or existing records. The form is rendered into the current view, inherited from ActionController
*
* @param array $pa_values An optional array of values to preset in the format, overriding any existing values in the model of the record being editing.
* @param array $pa_options Array of options passed through to _initView
*
*/
public function Edit($pa_values=null, $pa_options=null) {
list($vn_subject_id, $t_subject, $t_ui, $vn_parent_id, $vn_above_id) = $this->_initView($pa_options);
$vs_mode = $this->request->getParameter('mode', pString);
//
// Is record deleted?
//
if ($t_subject->hasField('deleted') && $t_subject->get('deleted')) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2550?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => $vn_subject_id ? __CA_BUNDLE_ACCESS_READONLY__ : __CA_BUNDLE_ACCESS_EDIT__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
//
// Are we duplicating?
//
if (($vs_mode == 'dupe') && $this->request->user->canDoAction('can_duplicate_'.$t_subject->tableName())) {
if (!($vs_type_name = $t_subject->getTypeName())) {
$vs_type_name = $t_subject->getProperty('NAME_SINGULAR');
}
// Trigger "before duplicate" hook
$this->opo_app_plugin_manager->hookBeforeDuplicateItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject));
if ($t_dupe = $t_subject->duplicate(array(
'user_id' => $this->request->getUserID(),
'duplicate_nonpreferred_labels' => $this->request->user->getPreference($t_subject->tableName().'_duplicate_nonpreferred_labels'),
'duplicate_attributes' => $this->request->user->getPreference($t_subject->tableName().'_duplicate_attributes'),
'duplicate_relationships' => $this->request->user->getPreference($t_subject->tableName().'_duplicate_relationships'),
'duplicate_media' => $this->request->user->getPreference($t_subject->tableName().'_duplicate_media'),
'duplicate_subitems' => $this->request->user->getPreference($t_subject->tableName().'_duplicate_subitems')
))) {
$this->notification->addNotification(_t('Duplicated %1 "%2" (%3)', $vs_type_name, $t_subject->getLabelForDisplay(), $t_subject->get($t_subject->getProperty('ID_NUMBERING_ID_FIELD'))), __NOTIFICATION_TYPE_INFO__);
// Trigger duplicate hook
$this->opo_app_plugin_manager->hookDuplicateItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject, 'duplicate' => $t_dupe));
// redirect to edit newly created dupe.
$this->response->setRedirect(caNavUrl($this->request, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(), array($t_subject->primaryKey() => $t_dupe->getPrimaryKey())));
return;
} else {
$this->notification->addNotification(_t('Could not duplicate %1: %2', $vs_type_name, join('; ', $t_subject->getErrors())), __NOTIFICATION_TYPE_ERROR__);
}
}
if($vn_above_id) {
// Convert "above" id (the id of the record we're going to make the newly created record parent of
// to parent_id, by getting the parent of the "above" record, so the inspector can display the name of the parent
if (($t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name)) && $t_instance->load($vn_above_id)) {
$vn_parent_id = $t_instance->get($vs_parent_id_fld = $t_instance->getProperty('HIERARCHY_PARENT_ID_FLD'));
$this->request->setParameter($vs_parent_id_fld, $vn_parent_id);
$this->view->setVar('parent_id', $vn_parent_id);
}
}
if ((!$t_subject->getPrimaryKey()) && ($vn_subject_id)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2500?r='.urlencode($this->request->getFullUrlPath()));
return;
}
if(is_array($pa_values)) {
foreach($pa_values as $vs_key => $vs_val) {
$t_subject->set($vs_key, $vs_val);
}
}
// set "context" id from those editors that need to restrict idno lookups to within the context of another field value (eg. idno's for ca_list_items are only unique within a given list_id)
if ($vs_idno_context_field = $t_subject->getProperty('ID_NUMBERING_CONTEXT_FIELD')) {
if ($vn_subject_id > 0) {
$this->view->setVar('_context_id', $t_subject->get($vs_idno_context_field));
} else {
if ($vn_parent_id > 0) {
$t_parent = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name);
if ($t_parent->load($vn_parent_id)) {
$this->view->setVar('_context_id', $t_parent->get($vs_idno_context_field));
}
}
}
}
// get default screen
if (!($vn_type_id = $t_subject->getTypeID())) {
$vn_type_id = $this->request->getParameter($t_subject->getTypeFieldName(), pInteger);
}
$va_nav = $t_ui->getScreensAsNavConfigFragment($this->request, $vn_type_id, $this->request->getModulePath(), $this->request->getController(), $this->request->getAction(),
array(),
array()
);
if (!$this->request->getActionExtra() || !isset($va_nav['fragment'][str_replace("Screen", "screen_", $this->request->getActionExtra())])) {
$this->request->setActionExtra($va_nav['defaultScreen']);
}
$this->view->setVar('t_ui', $t_ui);
if (!$t_ui->getPrimaryKey()) {
$this->notification->addNotification(_t('There is no configuration available for this editor. Check your system configuration and ensure there is at least one valid configuration for this type of editor.'), __NOTIFICATION_TYPE_ERROR__);
}
if ($vn_subject_id) { $this->request->session->setVar($this->ops_table_name.'_browse_last_id', $vn_subject_id); } // set last edited
# trigger "EditItem" hook
$this->opo_app_plugin_manager->hookEditItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject));
$this->render('screen_html.php');
}
# -------------------------------------------------------
/**
* Saves the content of a form editing new or existing records. It returns the same form + status messages rendered into the current view, inherited from ActionController
*
* @param array $pa_options Array of options passed through to _initView and saveBundlesForScreen()
*/
public function Save($pa_options=null) {
list($vn_subject_id, $t_subject, $t_ui, $vn_parent_id, $vn_above_id) = $this->_initView($pa_options);
if (!is_array($pa_options)) { $pa_options = array(); }
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_EDIT__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) < __CA_ACL_EDIT_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
if($vn_above_id) {
// Convert "above" id (the id of the record we're going to make the newly created record parent of
if (($t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name)) && $t_instance->load($vn_above_id)) {
$vn_parent_id = $t_instance->get($vs_parent_id_fld = $t_instance->getProperty('HIERARCHY_PARENT_ID_FLD'));
$this->request->setParameter($vs_parent_id_fld, $vn_parent_id);
$this->view->setVar('parent_id', $vn_parent_id);
}
}
$vs_auth_table_name = $this->ops_table_name;
if (in_array($this->ops_table_name, array('ca_representation_annotations'))) { $vs_auth_table_name = 'ca_objects'; }
if(!sizeof($_POST)) {
$this->notification->addNotification(_t("Cannot save using empty request. Are you using a bookmark?"), __NOTIFICATION_TYPE_ERROR__);
$this->render('screen_html.php');
return;
}
// set "context" id from those editors that need to restrict idno lookups to within the context of another field value (eg. idno's for ca_list_items are only unique within a given list_id)
$vn_context_id = null;
if ($vs_idno_context_field = $t_subject->getProperty('ID_NUMBERING_CONTEXT_FIELD')) {
if ($vn_subject_id > 0) {
$this->view->setVar('_context_id', $vn_context_id = $t_subject->get($vs_idno_context_field));
} else {
if ($vn_parent_id > 0) {
$t_parent = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name);
if ($t_parent->load($vn_parent_id)) {
$this->view->setVar('_context_id', $vn_context_id = $t_parent->get($vs_idno_context_field));
}
}
}
if ($vn_context_id) { $t_subject->set($vs_idno_context_field, $vn_context_id); }
}
if (!($vs_type_name = $t_subject->getTypeName())) {
$vs_type_name = $t_subject->getProperty('NAME_SINGULAR');
}
if ($vn_subject_id && !$t_subject->getPrimaryKey()) {
$this->notification->addNotification(_t("%1 does not exist", $vs_type_name), __NOTIFICATION_TYPE_ERROR__);
return;
}
# trigger "BeforeSaveItem" hook
$this->opo_app_plugin_manager->hookBeforeSaveItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject, 'is_insert' => $vb_is_insert));
$vb_is_insert = !$t_subject->getPrimaryKey();
$vb_save_rc = $t_subject->saveBundlesForScreen($this->request->getActionExtra(), $this->request, array_merge($pa_options, array('ui_instance' => $t_ui)));
$this->view->setVar('t_ui', $t_ui);
if(!$vn_subject_id) {
$vn_subject_id = $t_subject->getPrimaryKey();
if (!$vb_save_rc) {
$vs_message = _t("Could not save %1", $vs_type_name);
} else {
$vs_message = _t("Added %1", $vs_type_name);
$this->request->setParameter($t_subject->primaryKey(), $vn_subject_id, 'GET');
$this->view->setVar($t_subject->primaryKey(), $vn_subject_id);
$this->view->setVar('subject_id', $vn_subject_id);
$this->request->session->setVar($this->ops_table_name.'_browse_last_id', $vn_subject_id); // set last edited
// If "above_id" is set then, we want to load the record pointed to by it and set its' parent to be the newly created record
// The newly created record's parent is already set to be the current parent of the "above_id"; the net effect of all of this
// is to insert the newly created record between the "above_id" record and its' current parent.
if ($vn_above_id && ($t_instance = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name, true)) && $t_instance->load($vn_above_id)) {
$t_instance->setMode(ACCESS_WRITE);
$t_instance->set('parent_id', $vn_subject_id);
$t_instance->update();
if ($t_instance->numErrors()) {
$this->notification->addNotification($t_instance->getErrorDescription(), __NOTIFICATION_TYPE_ERROR__);
}
}
}
} else {
$vs_message = _t("Saved changes to %1", $vs_type_name);
}
$va_errors = $this->request->getActionErrors(); // all errors from all sources
$va_general_errors = $this->request->getActionErrors('general'); // just "general" errors - ones that are not attached to a specific part of the form
if (is_array($va_general_errors) && sizeof($va_general_errors) > 0) {
foreach($va_general_errors as $o_e) {
$this->notification->addNotification($o_e->getErrorDescription(), __NOTIFICATION_TYPE_ERROR__);
}
}
if(sizeof($va_errors) - sizeof($va_general_errors) > 0) {
$va_error_list = array();
$vb_no_save_error = false;
foreach($va_errors as $o_e) {
$va_error_list[$o_e->getErrorDescription()] = "<li>".$o_e->getErrorDescription()."</li>\n";
switch($o_e->getErrorNumber()) {
case 1100: // duplicate/invalid idno
if (!$vn_subject_id) { // can't save new record if idno is not valid (when updating everything but idno is saved if it is invalid)
$vb_no_save_error = true;
}
break;
}
}
if ($vb_no_save_error) {
$this->notification->addNotification(_t("There are errors preventing <strong>ALL</strong> information from being saved. Correct the problems and click \"save\" again.\n<ul>").join("\n", $va_error_list)."</ul>", __NOTIFICATION_TYPE_ERROR__);
} else {
$this->notification->addNotification($vs_message, __NOTIFICATION_TYPE_INFO__);
$this->notification->addNotification(_t("There are errors preventing information in specific fields from being saved as noted below.\n<ul>").join("\n", $va_error_list)."</ul>", __NOTIFICATION_TYPE_ERROR__);
}
} else {
$this->notification->addNotification($vs_message, __NOTIFICATION_TYPE_INFO__);
$this->opo_result_context->invalidateCache();
$this->opo_result_context->saveContext();
}
# trigger "SaveItem" hook
$this->opo_app_plugin_manager->hookSaveItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject, 'is_insert' => $vb_is_insert));
$this->render('screen_html.php');
}
# -------------------------------------------------------
/**
* Performs two-step delete of an existing record. The first step is a confirmation dialog, followed by actual deletion upon user confirmation
*
* @param array $pa_options Array of options passed through to _initView
*/
public function Delete($pa_options=null) {
list($vn_subject_id, $t_subject, $t_ui) = $this->_initView($pa_options);
if (!$vn_subject_id) { return; }
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_EDIT__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
if (!$vs_type_name = $t_subject->getTypeName()) {
$vs_type_name = $t_subject->getProperty('NAME_SINGULAR');
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) < __CA_ACL_EDIT_DELETE_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
// get parent_id, if it exists, prior to deleting so we can
// set the browse_last_id parameter to something sensible
$vn_parent_id = null;
if ($vs_parent_fld = $t_subject->getProperty('HIERARCHY_PARENT_ID_FLD')) {
$vn_parent_id = $t_subject->get($vs_parent_fld);
}
if ($vn_subject_id && !$t_subject->getPrimaryKey()) {
$this->notification->addNotification(_t("%1 does not exist", $vs_type_name), __NOTIFICATION_TYPE_ERROR__);
return;
}
// Don't allow deletion of roots in simple mono-hierarchies... that's bad.
if (!$vn_parent_id && (in_array($t_subject->getProperty('HIERARCHY_TYPE'), array(__CA_HIER_TYPE_SIMPLE_MONO__, __CA_HIER_TYPE_MULTI_MONO__)))) {
$this->notification->addNotification(_t("Cannot delete root of hierarchy"), __NOTIFICATION_TYPE_ERROR__);
return;
}
if ($vb_confirm = ($this->request->getParameter('confirm', pInteger) == 1) ? true : false) {
$vb_we_set_transation = false;
if (!$t_subject->inTransaction()) {
$t_subject->setTransaction($o_t = new Transaction());
$vb_we_set_transation = true;
}
// Do we need to move relationships?
if (($vn_remap_id = $this->request->getParameter('remapToID', pInteger)) && ($this->request->getParameter('referenceHandling', pString) == 'remap')) {
$va_tables = array(
'ca_objects', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_list_items', 'ca_loans', 'ca_movements', 'ca_tours', 'ca_tour_stops'
);
$vn_c = 0;
foreach($va_tables as $vs_table) {
$vn_c += $t_subject->moveRelationships($vs_table, $vn_remap_id);
}
if ($vn_c > 0) {
$t_target = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name);
$t_target->load($vn_remap_id);
$this->notification->addNotification(($vn_c == 1) ? _t("Transferred %1 relationship to <em>%2</em> (%3)", $vn_c, $t_target->getLabelForDisplay(), $t_target->get($t_target->getProperty('ID_NUMBERING_ID_FIELD'))) : _t("Transferred %1 relationships to <em>%2</em> (%3)", $vn_c, $t_target->getLabelForDisplay(), $t_target->get($t_target->getProperty('ID_NUMBERING_ID_FIELD'))), __NOTIFICATION_TYPE_INFO__);
}
}
$t_subject->setMode(ACCESS_WRITE);
if ($this->_beforeDelete($t_subject)) {
$t_subject->delete(true);
}
$vb_after_res = $this->_afterDelete($t_subject);
if ($vb_we_set_transation) {
if (!$vb_after_res) {
$o_t->rollbackTransaction();
} else {
$o_t->commitTransaction();
}
}
}
$this->view->setVar('confirmed', $vb_confirm);
if ($t_subject->numErrors()) {
foreach($t_subject->errors() as $o_e) {
$this->notification->addNotification($o_e->getErrorDescription(), __NOTIFICATION_TYPE_ERROR__);
}
} else {
if ($vb_confirm) {
$this->notification->addNotification(_t("%1 was deleted", $vs_type_name), __NOTIFICATION_TYPE_INFO__);
// update result list since it has changed
$this->opo_result_context->removeIDFromResults($vn_subject_id);
$this->opo_result_context->invalidateCache();
$this->opo_result_context->saveContext();
// clear subject_id - it's no longer valid
$t_subject->clear();
$this->view->setVar($t_subject->primaryKey(), null);
$this->request->setParameter($t_subject->primaryKey(), null, 'PATH');
// set last browse id for hierarchy browser
$this->request->session->setVar($this->ops_table_name.'_browse_last_id', $vn_parent_id);
// Clear out row_id so sidenav is disabled
$this->request->setParameter($t_subject->primaryKey(), null, 'POST');
# trigger "DeleteItem" hook
$this->opo_app_plugin_manager->hookDeleteItem(array('id' => $vn_subject_id, 'table_num' => $t_subject->tableNum(), 'table_name' => $t_subject->tableName(), 'instance' => $t_subject));
}
}
$this->view->setVar('subject_name', $t_subject->getLabelForDisplay(false));
$this->render('delete_html.php');
}
# -------------------------------------------------------
/**
* Generates display summary of record data based upon a bundle display for screen (HTML)
*
* @param array $pa_options Array of options passed through to _initView
*/
public function Summary($pa_options=null) {
JavascriptLoadManager::register('tableList');
list($vn_subject_id, $t_subject) = $this->_initView($pa_options);
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
$t_display = new ca_bundle_displays();
$va_displays = $t_display->getBundleDisplays(array('table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__));
if ((!($vn_display_id = $this->request->getParameter('display_id', pInteger))) || !isset($va_displays[$vn_display_id])) {
if ((!($vn_display_id = $this->request->user->getVar($t_subject->tableName().'_summary_display_id'))) || !isset($va_displays[$vn_display_id])) {
$va_tmp = array_keys($va_displays);
$vn_display_id = $va_tmp[0];
}
}
$this->view->setVar('bundle_displays', $va_displays);
$this->view->setVar('t_display', $t_display);
// Check validity and access of specified display
if ($t_display->load($vn_display_id) && ($t_display->haveAccessToDisplay($this->request->getUserID(), __CA_BUNDLE_DISPLAY_READ_ACCESS__))) {
$this->view->setVar('display_id', $vn_display_id);
$va_placements = $t_display->getPlacements(array('returnAllAvailableIfEmpty' => true, 'table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'no_tooltips' => true, 'format' => 'simple', 'settingsOnly' => true));
$va_display_list = array();
foreach($va_placements as $vn_placement_id => $va_display_item) {
$va_settings = caUnserializeForDatabase($va_display_item['settings']);
// get column header text
$vs_header = $va_display_item['display'];
if (isset($va_settings['label']) && is_array($va_settings['label'])) {
if ($vs_tmp = array_shift(caExtractValuesByUserLocale(array($va_settings['label'])))) { $vs_header = $vs_tmp; }
}
$va_display_list[$vn_placement_id] = array(
'placement_id' => $vn_placement_id,
'bundle_name' => $va_display_item['bundle_name'],
'display' => $vs_header,
'settings' => $va_settings
);
}
$this->view->setVar('placements', $va_display_list);
$this->request->user->setVar($t_subject->tableName().'_summary_display_id', $vn_display_id);
} else {
$this->view->setVar('display_id', null);
$this->view->setVar('placements', array());
}
$this->render('summary_html.php');
}
# -------------------------------------------------------
/**
* Generates display summary of record data based upon a bundle display for print (PDF)
*
* @param array $pa_options Array of options passed through to _initView
*/
public function PrintSummary($pa_options=null) {
require_once(__CA_LIB_DIR__."/core/Print/html2pdf/html2pdf.class.php");
JavascriptLoadManager::register('tableList');
list($vn_subject_id, $t_subject) = $this->_initView($pa_options);
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
$t_display = new ca_bundle_displays();
$va_displays = $t_display->getBundleDisplays(array('table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__));
if ((!($vn_display_id = $this->request->getParameter('display_id', pInteger))) || (!isset($va_displays[$vn_display_id]))) {
if ((!($vn_display_id = $this->request->user->getVar($t_subject->tableName().'_summary_display_id'))) || !isset($va_displays[$vn_display_id])) {
$va_tmp = array_keys($va_displays);
$vn_display_id = $va_tmp[0];
}
}
$this->view->setVar('t_display', $t_display);
$this->view->setVar('bundle_displays', $va_displays);
// Check validity and access of specified display
if ($t_display->load($vn_display_id) && ($t_display->haveAccessToDisplay($this->request->getUserID(), __CA_BUNDLE_DISPLAY_READ_ACCESS__))) {
$this->view->setVar('display_id', $vn_display_id);
$va_placements = $t_display->getPlacements(array('returnAllAvailableIfEmpty' => true, 'table' => $t_subject->tableNum(), 'user_id' => $this->request->getUserID(), 'access' => __CA_BUNDLE_DISPLAY_READ_ACCESS__, 'no_tooltips' => true, 'format' => 'simple', 'settingsOnly' => true));
$va_display_list = array();
foreach($va_placements as $vn_placement_id => $va_display_item) {
$va_settings = caUnserializeForDatabase($va_display_item['settings']);
// get column header text
$vs_header = $va_display_item['display'];
if (isset($va_settings['label']) && is_array($va_settings['label'])) {
if ($vs_tmp = array_shift(caExtractValuesByUserLocale(array($va_settings['label'])))) { $vs_header = $vs_tmp; }
}
$va_display_list[$vn_placement_id] = array(
'placement_id' => $vn_placement_id,
'bundle_name' => $va_display_item['bundle_name'],
'display' => $vs_header,
'settings' => $va_settings
);
}
$this->view->setVar('placements', $va_display_list);
$this->request->user->setVar($t_subject->tableName().'_summary_display_id', $vn_display_id);
$vs_format = $this->request->config->get("summary_print_format");
} else {
$this->view->setVar('display_id', null);
$this->view->setVar('placements', array());
}
try {
$vs_content = $this->render('print_summary_html.php');
$vo_html2pdf = new HTML2PDF('P',$vs_format,'en');
$vo_html2pdf->setDefaultFont("dejavusans");
$vo_html2pdf->WriteHTML($vs_content);
$vo_html2pdf->Output('summary.pdf');
$vb_printed_properly = true;
} catch (Exception $e) {
$vb_printed_properly = false;
$o_event_log = new Eventlog();
$o_event_log->log(array('CODE' => 'DEBG', 'MESSAGE' => $vs_msg = _t("Could not generate PDF: %1", preg_replace('![^A-Za-z0-9 \-\?\/\.]+!', ' ', $e->getMessage())), 'SOURCE' => 'BaseEditorController->PrintSummary()'));
$this->postError(3100, $vs_msg,"BaseEditorController->PrintSummary()");
}
}
# -------------------------------------------------------
/**
* Returns change log display for currently edited record in current view inherited from ActionController
*
* @param array $pa_options Array of options passed through to _initView
*/
public function Log($pa_options=null) {
JavascriptLoadManager::register('tableList');
list($vn_subject_id, $t_subject) = $this->_initView($pa_options);
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
$this->render('log_html.php');
}
# -------------------------------------------------------
/**
*
*
* @param array $pa_options Array of options passed through to _initView
*/
public function Access($pa_options=null) {
JavascriptLoadManager::register('tableList');
list($vn_subject_id, $t_subject) = $this->_initView($pa_options);
//
// Is record of correct type?
//
$va_restrict_to_types = null;
if ($t_subject->getAppConfig()->get('perform_type_access_checking')) {
$va_restrict_to_types = caGetTypeRestrictionsForUser($this->ops_table_name, array('access' => __CA_BUNDLE_ACCESS_READONLY__));
}
if (is_array($va_restrict_to_types) && !in_array($t_subject->get('type_id'), $va_restrict_to_types)) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2560?r='.urlencode($this->request->getFullUrlPath()));
return;
}
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
if ((!$this->request->user->canDoAction('can_change_acl_'.$t_subject->tableName()))) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2570?r='.urlencode($this->request->getFullUrlPath()));
return;
}
$this->render('access_html.php');
}
# -------------------------------------------------------
/**
*
*
* @param array $pa_options Array of options passed through to _initView
*/
public function SetAccess($pa_options=null) {
list($vn_subject_id, $t_subject) = $this->_initView($pa_options);
if ((!$t_subject->isSaveable($this->request)) || (!$this->request->user->canDoAction('can_change_acl_'.$t_subject->tableName()))) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2570?r='.urlencode($this->request->getFullUrlPath()));
return;
}
$vs_form_prefix = $this->request->getParameter('_formName', pString);
// Save user ACL's
$va_users_to_set = array();
foreach($_REQUEST as $vs_key => $vs_val) {
if (preg_match("!^{$vs_form_prefix}_user_id(.*)$!", $vs_key, $va_matches)) {
$vn_user_id = (int)$this->request->getParameter($vs_form_prefix.'_user_id'.$va_matches[1], pInteger);
$vn_access = $this->request->getParameter($vs_form_prefix.'_user_access_'.$va_matches[1], pInteger);
if ($vn_access >= 0) {
$va_users_to_set[$vn_user_id] = $vn_access;
}
}
}
$t_subject->setACLUsers($va_users_to_set);
// Save group ACL's
$va_groups_to_set = array();
foreach($_REQUEST as $vs_key => $vs_val) {
if (preg_match("!^{$vs_form_prefix}_group_id(.*)$!", $vs_key, $va_matches)) {
$vn_group_id = (int)$this->request->getParameter($vs_form_prefix.'_group_id'.$va_matches[1], pInteger);
$vn_access = $this->request->getParameter($vs_form_prefix.'_group_access_'.$va_matches[1], pInteger);
if ($vn_access >= 0) {
$va_groups_to_set[$vn_group_id] = $vn_access;
}
}
}
$t_subject->setACLUserGroups($va_groups_to_set);
// Save "world" ACL
$t_subject->setACLWorldAccess($x=$this->request->getParameter("{$vs_form_prefix}_access_world", pInteger));
$this->Access();
}
# -------------------------------------------------------
/**
* Initializes editor view with core set of values, loads model with record to be edited and selects user interface to use.
*
* @param $pa_options Array of options. Supported options are:
* ui = The ui_id or editor_code value for the user interface to use. If omitted the default user interface is used.
*/
protected function _initView($pa_options=null) {
// load required javascript
JavascriptLoadManager::register('bundleableEditor');
JavascriptLoadManager::register('imageScroller');
$t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_table_name);
$vn_subject_id = $this->request->getParameter($t_subject->primaryKey(), pInteger);
if (!$vn_subject_id || !$t_subject->load($vn_subject_id)) {
// empty (ie. new) rows don't have a type_id set, which means we'll have no idea which attributes to display
// so we get the type_id off of the request
if (!$vn_type_id = $this->request->getParameter($t_subject->getTypeFieldName(), pInteger)) {
$vn_type_id = null;
}
// then set the empty row's type_id
$t_subject->set($t_subject->getTypeFieldName(), $vn_type_id);
// then reload the definitions (which includes bundle specs)
$t_subject->reloadLabelDefinitions();
}
$t_ui = new ca_editor_uis();
if (isset($pa_options['ui']) && $pa_options['ui']) {
if (is_numeric($pa_options['ui'])) {
$t_ui->load((int)$pa_options['ui']);
}
if (!$t_ui->getPrimaryKey()) {
$t_ui->load(array('editor_code' => $pa_options['ui']));
}
}
if (!$t_ui->getPrimaryKey()) {
$t_ui = ca_editor_uis::loadDefaultUI($this->ops_table_name, $this->request, $t_subject->getTypeID());
}
$this->view->setVar($t_subject->primaryKey(), $vn_subject_id);
$this->view->setVar('subject_id', $vn_subject_id);
$this->view->setVar('t_subject', $t_subject);
MetaTagManager::setWindowTitle(_t("Editing %1 : %2", ($vs_type = $t_subject->getTypeName()) ? $vs_type : $t_subject->getProperty('NAME_SINGULAR'), ($vn_subject_id) ? $t_subject->getLabelForDisplay(true) : _t('new %1', $t_subject->getTypeName())));
if ($vs_parent_id_fld = $t_subject->getProperty('HIERARCHY_PARENT_ID_FLD')) {
$this->view->setVar('parent_id', $vn_parent_id = $this->request->getParameter($vs_parent_id_fld, pInteger));
// The "above_id" is set when the new record we're creating is to be inserted *above* an existing record (eg. made
// the parent of another record). It will be set to the record we're inserting above. We ignore it if set when editing
// an existing record since it is only relevant for newly created records.
if (!$vn_subject_id) {
$this->view->setVar('above_id', $vn_above_id = $this->request->getParameter('above_id', pInteger));
}
return array($vn_subject_id, $t_subject, $t_ui, $vn_parent_id, $vn_above_id);
}
return array($vn_subject_id, $t_subject, $t_ui);
}
# -------------------------------------------------------
# File attribute bundle download
# -------------------------------------------------------
/**
* Initiates user download of file stored in a file attribute, returning file in response to request.
* Adds download output to response directly. No view is used.
*
* @param array $pa_options Array of options passed through to _initView
*/
public function DownloadFile() {
list($vn_subject_id, $t_subject) = $this->_initView();
if (!($pn_value_id = $this->request->getParameter('value_id', pInteger))) { return; }
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
$o_view = new View($this->request, $this->request->getViewsDirectoryPath().'/bundles/');
// TODO: check that file is part of item user has access rights for
$t_attr_val = new ca_attribute_values($pn_value_id);
if (!$t_attr_val->getPrimaryKey()) { return; }
$t_attr_val->useBlobAsFileField(true);
// get value
$t_element = new ca_metadata_elements($t_attr_val->get('element_id'));
// check that value is a file attribute
if ($t_element->get('datatype') != 15) { // 15=file
return;
}
$o_view->setVar('file_path', $t_attr_val->getFilePath('value_blob'));
$o_view->setVar('file_name', ($vs_name = trim($t_attr_val->get('value_longtext2'))) ? $vs_name : _t("downloaded_file"));
// send download
$this->response->addContent($o_view->render('ca_attributes_download_file.php'));
}
# -------------------------------------------------------
# Media attribute bundle download
# -------------------------------------------------------
/**
* Initiates user download of media stored in a media attribute, returning file in response to request.
* Adds download output to response directly. No view is used.
*
* @param array $pa_options Array of options passed through to _initView
*/
public function DownloadMedia($pa_options=null) {
list($vn_subject_id, $t_subject) = $this->_initView($pa_options);
if (!($pn_value_id = $this->request->getParameter('value_id', pInteger))) { return; }
$ps_version = $this->request->getParameter('version', pString);
//
// Does user have access to row?
//
if ($t_subject->getAppConfig()->get('perform_item_level_access_checking')) {
if ($t_subject->checkACLAccessForUser($this->request->user) == __CA_ACL_NO_ACCESS__) {
$this->response->setRedirect($this->request->config->get('error_display_url').'/n/2580?r='.urlencode($this->request->getFullUrlPath()));
return;
}
}
// TODO: check that file is part of item user has access rights for
$t_attr_val = new ca_attribute_values($pn_value_id);
if (!$t_attr_val->getPrimaryKey()) { return; }
$t_attr_val->useBlobAsMediaField(true);
if (!in_array($ps_version, $t_attr_val->getMediaVersions('value_blob'))) { $ps_version = 'original'; }
$o_view = new View($this->request, $this->request->getViewsDirectoryPath().'/bundles/');
// get value
$t_element = new ca_metadata_elements($t_attr_val->get('element_id'));
// check that value is a media attribute
if ($t_element->get('datatype') != 16) { // 16=media
return;
}
$o_view->setVar('file_path', $t_attr_val->getMediaPath('value_blob', $ps_version));
$o_view->setVar('file_name', ($vs_name = trim($t_attr_val->get('value_longtext2'))) ? $vs_name : _t("downloaded_file"));
// send download
$this->response->addContent($o_view->render('ca_attributes_download_media.php'));
}
# -------------------------------------------------------
#
# -------------------------------------------------------
/**
* Returns content for overlay containing details for media attribute
*
* Expects the following request parameters:
* value_id = the id of the attribute value (ca_attribute_values) record to display
*
* Optional request parameters:
* version = The version of the representation to display. If omitted the display version configured in media_display.conf is used
*
*/
public function GetMediaInfo() {
$pn_value_id = $this->request->getParameter('value_id', pInteger);
$this->response->addContent($this->getMediaAttributeViewerHTMLBundle($this->request, array('display' => 'media_overlay', 'value_id' => $pn_value_id, 'containerID' => 'caMediaPanelContentArea')));
}
# ------------------------------------------------------
/**
*
*/
public function getMediaAttributeViewerHTMLBundle($po_request, $pa_options=null) {
$va_access_values = (isset($pa_options['access']) && is_array($pa_options['access'])) ? $pa_options['access'] : array();
$vs_display_type = (isset($pa_options['display']) && $pa_options['display']) ? $pa_options['display'] : 'media_overlay';
$vs_container_dom_id = (isset($pa_options['containerID']) && $pa_options['containerID']) ? $pa_options['containerID'] : null;
$pn_value_id = (isset($pa_options['value_id']) && $pa_options['value_id']) ? $pa_options['value_id'] : null;
$t_attr_val = new ca_attribute_values();
$t_attr_val->load($pn_value_id);
$t_attr_val->useBlobAsMediaField(true);
$o_view = new View($po_request, $po_request->getViewsDirectoryPath().'/bundles/');
$o_view->setVar('containerID', $vs_container_dom_id);
$va_rep_display_info = caGetMediaDisplayInfo('media_overlay', $t_attr_val->getMediaInfo('value_blob', 'INPUT', 'MIMETYPE'));
$va_rep_display_info['poster_frame_url'] = $t_attr_val->getMediaUrl('value_blob', $va_rep_display_info['poster_frame_version']);
$o_view->setVar('display_options', $va_rep_display_info);
$o_view->setVar('representation_id', $pn_representation_id);
$o_view->setVar('t_attribute_value', $t_attr_val);
$o_view->setVar('versions', $va_versions = $t_attr_val->getMediaVersions('value_blob'));
$t_media = new Media();
$o_view->setVar('version_type', $t_media->getMimetypeTypename($t_attr_val->getMediaInfo('value_blob', 'original', 'MIMETYPE')));
$ps_version = $po_request->getParameter('version', pString);
if (!in_array($ps_version, $va_versions)) {
if (!($ps_version = $va_rep_display_info['display_version'])) { $ps_version = null; }
}
$o_view->setVar('version', $ps_version);
$o_view->setVar('version_info', $t_attr_val->getMediaInfo('value_blob', $ps_version));
return $o_view->render('media_attribute_viewer_html.php');
}
# -------------------------------------------------------
# Dynamic navigation generation
# -------------------------------------------------------
/**
* Generates side-navigation for current UI based upon screen structure in database. Called by AppNavigation class.
*
* @param array $pa_params Array of parameters used to generate navigation
* @param array $pa_options Array of options passed through to _initView
* @return array Navigation specification ready for inclusion in a menu spec
*/
public function _genDynamicNav($pa_params, $pa_options=null) {
list($vn_subject_id, $t_subject, $t_ui) = $this->_initView($pa_options);
if (!$this->request->isLoggedIn()) { return array(); }
if (!$vn_type_id = $t_subject->getTypeID()) {
$vn_type_id = $this->request->getParameter($t_subject->getTypeFieldName(), pInteger);
}
$va_nav = $t_ui->getScreensAsNavConfigFragment($this->request, $vn_type_id, $pa_params['default']['module'], $pa_params['default']['controller'], $pa_params['default']['action'],
isset($pa_params['parameters']) ? $pa_params['parameters'] : null,
isset($pa_params['requires']) ? $pa_params['requires'] : null,
($vn_subject_id > 0) ? false : true,
array('hideIfNoAccess' => isset($pa_params['hideIfNoAccess']) ? $pa_params['hideIfNoAccess'] : false)
);
if (!$this->request->getActionExtra()) {