1 <?php
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 class ComplexTableField extends TableListField {
32
33 34 35 36 37
38 protected $addTitle;
39
40 protected $detailFormFields;
41
42 protected $viewAction, $sourceJoin, $sourceItems;
43
44 45 46
47 protected $controller;
48
49 50 51
52 public $parentClass;
53
54 55 56 57
58 protected $parentIdName;
59
60 61 62
63 protected $permissions = array(
64 "add",
65 "edit",
66 "show",
67 "delete",
68
69 );
70
71 72 73 74 75
76 protected $template = "ComplexTableField";
77
78 79 80 81 82
83 public = "ComplexTableField_popup";
84
85 86 87 88 89
90 public $itemClass = 'ComplexTableField_Item';
91
92 93 94 95 96
97 public = 'ComplexTableField_Popup';
98
99 100 101
102 protected = true;
103
104 105 106 107
108 protected = null;
109
110 111 112 113 114
115 public = null;
116
117 118 119
120 protected $detailFormValidator = null;
121
122 123 124 125 126 127
128 protected $relationAutoSetting = true;
129
130 131 132
133 protected = 560;
134 protected = 390;
135
136 public $defaultAction = 'show';
137
138 public $actions = array(
139 'show' => array(
140 'label' => 'Show',
141 'icon' => 'cms/images/show.png',
142 'icon_disabled' => 'cms/images/show_disabled.png',
143 'class' => 'popuplink showlink',
144 ),
145 'edit' => array(
146 'label' => 'Edit',
147 'icon' => 'cms/images/edit.gif',
148 'icon_disabled' => 'cms/images/edit_disabled.gif',
149 'class' => 'popuplink editlink',
150 ),
151 'delete' => array(
152 'label' => 'Delete',
153 'icon' => 'cms/images/delete.gif',
154 'icon_disabled' => 'cms/images/delete_disabled.gif',
155 'class' => 'popuplink deletelink',
156 ),
157 );
158
159 static $url_handlers = array(
160 'item/$ID' => 'handleItem',
161 '$Action!' => '$Action',
162 );
163
164 function handleItem($request) {
165 return new ComplexTableField_ItemRequest($this, $request->param('ID'));
166 }
167
168 function getViewer() {
169 return new SSViewer($this->template);
170 }
171
172 function ($width, $height) {
173 $width = (int)$width;
174 $height = (int)$height;
175
176 if($width < 0 || $height < 0) {
177 user_error("setPopupSize expects non-negative arguments.", E_USER_WARNING);
178 return;
179 }
180
181 $this->popupWidth = $width;
182 $this->popupHeight = $height;
183 }
184
185 function () {
186 return $this->popupWidth;
187 }
188
189 function () {
190 return $this->popupHeight;
191 }
192
193 194 195 196 197 198 199 200 201 202 203 204
205 function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {
206 $this->detailFormFields = $detailFormFields;
207 $this->controller = $controller;
208 $this->pageSize = 10;
209
210 parent::__construct($name, $sourceClass, $fieldList, $sourceFilter, $sourceSort, $sourceJoin);
211 }
212
213 214 215 216 217
218 function sourceFilter() {
219 $sourceFilter = parent::sourceFilter();
220
221 if($this->relationAutoSetting
222 && $this->getParentClass()
223 && ($filterKey = $this->getParentIdName($this->getParentClass(), $this->sourceClass()))
224 && ($filterValue = $this->sourceID()) ) {
225
226 $newFilter = "\"$filterKey\" = '" . Convert::raw2sql($filterValue) . "'";
227
228 if($sourceFilter && is_array($sourceFilter)) {
229
230 $sourceFilter = implode(") AND (", $sourceFilter);
231 }
232
233 $sourceFilter = $sourceFilter ? "($sourceFilter) AND ($newFilter)" : $newFilter;
234 }
235 return $sourceFilter;
236 }
237
238 function isComposite() {
239 return false;
240 }
241
242 243 244
245 function FieldHolder() {
246 Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js");
247 Requirements::javascript(THIRDPARTY_DIR . "/greybox/greybox.js");
248 Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
249 Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableListField.js');
250 Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
251 Requirements::css(THIRDPARTY_DIR . "/greybox/greybox.css");
252 Requirements::css(SAPPHIRE_DIR . "/css/TableListField.css");
253 Requirements::css(SAPPHIRE_DIR . "/css/ComplexTableField.css");
254
255
256 if($this->popupCaption) {
257 $id = $this->id();
258 if(Director::is_ajax()) {
259 $js = <<<JS
260 $('$id').GB_Caption = '$this->popupCaption';
261 JS;
262 FormResponse::add($js);
263 } else {
264 $js = <<<JS
265 Event.observe(window, 'load', function() { \$('$id').GB_Caption = '$this->popupCaption'; });
266 JS;
267 Requirements::customScript($js);
268 }
269 }
270
271
272
273 $this->sourceItems();
274
275 return $this->renderWith($this->template);
276 }
277
278 function sourceClass() {
279 return $this->sourceClass;
280 }
281
282 283 284
285 function Items() {
286 $this->sourceItems = $this->sourceItems();
287
288 if(!$this->sourceItems) {
289 return null;
290 }
291
292 $pageStart = (isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) ? $_REQUEST['ctf'][$this->Name()]['start'] : 0;
293 $this->sourceItems->setPageLimits($pageStart, $this->pageSize, $this->totalCount);
294
295 $output = new DataObjectSet();
296 foreach($this->sourceItems as $pageIndex=>$item) {
297 $output->push(new $this->itemClass($item, $this));
298 }
299 return $output;
300 }
301
302 303 304 305 306 307
308 function ($caption) {
309 $this->popupCaption = Convert::raw2js($caption);
310 }
311
312 313 314
315 function setDetailFormValidator( Validator $validator ) {
316 $this->detailFormValidator = $validator;
317 }
318
319 function setAddTitle($addTitle) {
320 if(is_string($addTitle))
321 $this->addTitle = $addTitle;
322 }
323
324 function Title() {
325 return $this->addTitle ? $this->addTitle : parent::Title();
326 }
327
328 329 330 331 332 333
334 function ItemCount() {
335 return count($this->fieldList);
336 }
337
338 339 340 341 342
343 function IsAddMode() {
344 return ($this->methodName == "add" || $this->request->param('Action') == 'AddForm');
345 }
346
347 function sourceID() {
348 $idField = $this->form->dataFieldByName('ID');
349
350
351
352
353
354
355
356
357 return ($idField) ? $idField->Value() : (isset($_REQUEST['ctf']['ID']) ? $_REQUEST['ctf']['ID'] : null);
358 }
359
360
361
362 function AddLink() {
363 return Controller::join_links($this->Link(), 'add');
364 }
365
366 367 368
369 function createFieldSet() {
370 $fieldset = new FieldSet();
371 foreach($this->fieldTypes as $key => $fieldType){
372 $fieldset->push(new $fieldType($key));
373 }
374 return $fieldset;
375 }
376
377 function setController($controller) {
378 $this->controller = $controller;
379 }
380
381 382 383 384 385 386
387 function getParentClass() {
388 if($this->parentClass === false) {
389
390 return false;
391 } elseif(!empty($this->parentClass)) {
392 return $this->parentClass;
393 } elseif($this->form && $this->form->getRecord()) {
394 return $this->form->getRecord()->ClassName;
395 }
396 }
397
398 399 400
401 function getParentRecord() {
402 if($this->form && $record = $this->form->getRecord()) {
403 return $record;
404 } else {
405 $parentID = (int)$this->sourceID();
406 $parentClass = $this->getParentClass();
407
408 if($parentClass) {
409 if($parentID) return DataObject::get_by_id($parentClass, $parentID);
410 else return singleton($parentClass);
411 }
412 }
413 }
414
415 416 417 418 419 420 421
422 function setParentClass($className) {
423 $this->parentClass = $className;
424 }
425
426 427 428
429 function getParentIdName($parentClass, $childClass) {
430 return $this->getParentIdNameRelation($childClass, $parentClass, 'has_one');
431 }
432
433 434 435 436 437 438
439 function setParentIdName($str) {
440 $this->parentIdName = $str;
441 }
442
443 444 445 446 447
448 function getParentIdNameRelation($parentClass, $childClass, $relation) {
449 if($this->parentIdName) return $this->parentIdName;
450
451 $relations = array_flip(singleton($parentClass)->$relation());
452
453 $classes = array_reverse(ClassInfo::ancestry($childClass));
454 foreach($classes as $class) {
455 if(isset($relations[$class])) return $relations[$class] . 'ID';
456 }
457 return false;
458 }
459
460 function ($template) {
461 $this->templatePopup = $template;
462 }
463
464
465
466 467 468 469 470 471 472 473 474 475
476 function getCustomFieldsFor($childData) {
477 if($this->detailFormFields instanceof FieldSet) {
478 return $this->detailFormFields;
479 }
480
481 $fieldsMethod = $this->detailFormFields;
482
483 if(!is_string($fieldsMethod)) {
484 $this->detailFormFields = 'getCMSFields';
485 $fieldsMethod = 'getCMSFields';
486 }
487
488 if(!$childData->hasMethod($fieldsMethod)) {
489 $fieldsMethod = 'getCMSFields';
490 }
491
492 return $childData->$fieldsMethod();
493 }
494
495 function getFieldsFor($childData) {
496 $hasManyRelationName = null;
497 $manyManyRelationName = null;
498
499
500 if($parentClass = $this->getParentRecord()) {
501 $manyManyRelations = $parentClass->many_many();
502 $manyManyRelationName = null;
503 $manyManyComponentSet = null;
504
505 $hasManyRelations = $parentClass->has_many();
506 $hasManyRelationName = null;
507 $hasManyComponentSet = null;
508
509 if($manyManyRelations) foreach($manyManyRelations as $relation => $class) {
510 if($class == $this->sourceClass()) {
511 $manyManyRelationName = $relation;
512 }
513 }
514
515 if($hasManyRelations) foreach($hasManyRelations as $relation => $class) {
516 if($class == $this->sourceClass()) {
517 $hasManyRelationName = $relation;
518 }
519 }
520 }
521
522
523 if(!$childData->ID && $this->getParentClass()) {
524
525 $parentIDName = $this->getParentIdName($this->getParentClass(), $this->sourceClass());
526 $childData->$parentIDName = $this->sourceID();
527 }
528
529 $detailFields = $this->getCustomFieldsFor($childData);
530
531 if($this->getParentClass() && $hasManyRelationName && $childData->ID) {
532 $hasManyComponentSet = $parentClass->getComponents($hasManyRelationName);
533 }
534
535
536 $detailFields->removeByName('ID');
537
538
539 if($childData->ID) {
540 $detailFields->push(new HiddenField('ctf[childID]', '', $childData->ID));
541 }
542
543
544 $detailFields->push(new HiddenField('ctf[ClassName]', '', $this->sourceClass()));
545
546 if($this->getParentClass()) {
547 $detailFields->push(new HiddenField('ctf[parentClass]', '', $this->getParentClass()));
548
549 if($manyManyRelationName && $this->relationAutoSetting) {
550 $detailFields->push(new HiddenField('ctf[manyManyRelation]', '', $manyManyRelationName));
551 }
552
553 if($hasManyRelationName && $this->relationAutoSetting) {
554 $detailFields->push(new HiddenField('ctf[hasManyRelation]', '', $hasManyRelationName));
555 }
556
557 if($manyManyRelationName || $hasManyRelationName) {
558 $detailFields->push(new HiddenField('ctf[sourceID]', '', $this->sourceID()));
559 }
560
561 $parentIdName = $this->getParentIdName($this->getParentClass(), $this->sourceClass());
562
563 if($parentIdName) {
564 if($this->relationAutoSetting) {
565
566 $detailFields->removeByName($parentIdName);
567 $detailFields->push(new HiddenField($parentIdName, '', $this->sourceID()));
568 }
569 }
570 }
571
572 return $detailFields;
573 }
574
575 function getValidatorFor($childData) {
576
577 if(!isset($this->detailFormValidator) && $childData->hasMethod('getValidator')) {
578 $this->detailFormValidator = $childData->getValidator();
579 }
580 return $this->detailFormValidator;
581 }
582
583
584
585 function add() {
586 if(!$this->can('add')) return;
587
588 return $this->customise(array(
589 'DetailForm' => $this->AddForm(),
590 ))->renderWith($this->templatePopup);
591 }
592
593 function AddForm($childID = null) {
594 $className = $this->sourceClass();
595 $childData = new $className();
596
597 $fields = $this->getFieldsFor($childData);
598 $validator = $this->getValidatorFor($childData);
599
600 $form = new $this->popupClass(
601 $this,
602 'AddForm',
603 $fields,
604 $validator,
605 false,
606 $childData
607 );
608
609 $form->loadDataFrom($childData);
610
611 return $form;
612 }
613
614 615 616 617 618 619 620 621 622
623 function setRelationAutoSetting($value) {
624 $this->relationAutoSetting = $value;
625 }
626
627 628 629 630 631 632 633 634 635 636
637 function saveComplexTableField($data, $form, $params) {
638 $className = $this->sourceClass();
639 $childData = new $className();
640 $form->saveInto($childData);
641
642 try {
643 $childData->write();
644 } catch(ValidationException $e) {
645 $form->sessionMessage($e->getResult()->message(), 'bad');
646 return Director::redirectBack();
647 }
648
649
650 if(isset($data['ctf']['manyManyRelation'])) {
651 $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
652 $relationName = $data['ctf']['manyManyRelation'];
653 $componentSet = $parentRecord->getManyManyComponents($relationName);
654 $componentSet->add($childData);
655 }
656
657 if(isset($data['ctf']['hasManyRelation'])) {
658 $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
659 $relationName = $data['ctf']['hasManyRelation'];
660
661 $componentSet = $parentRecord->getComponents($relationName);
662 $componentSet->add($childData);
663 }
664
665 $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
666
667 $closeLink = sprintf(
668 '<small><a href="%s" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>',
669 $referrer,
670 _t('ComplexTableField.CLOSEPOPUP', 'Close Popup')
671 );
672
673 $editLink = Controller::join_links($this->Link(), 'item/' . $childData->ID . '/edit');
674
675 $message = sprintf(
676 _t('ComplexTableField.SUCCESSADD', 'Added %s %s %s'),
677 $childData->i18n_singular_name(),
678 '<a href="' . $editLink . '">' . $childData->Title . '</a>',
679 $closeLink
680 );
681
682 $form->sessionMessage($message, 'good');
683
684 Director::redirectBack();
685 }
686 }
687
688 689 690 691 692
693 class ComplexTableField_ItemRequest extends TableListField_ItemRequest {
694 protected $ctf;
695 protected $itemID;
696 protected $methodName;
697
698 static $url_handlers = array(
699 '$Action!' => '$Action',
700 '' => 'index',
701 );
702
703 function Link($action = null) {
704 return Controller::join_links($this->ctf->Link(), '/item/', $this->itemID, $action);
705 }
706
707 function index() {
708 return $this->show();
709 }
710
711 712 713 714 715
716 function show() {
717 if($this->ctf->Can('show') !== true) {
718 return false;
719 }
720
721 $this->methodName = "show";
722 return $this->renderWith($this->ctf->templatePopup);
723 }
724
725 726 727
728 729 730 731 732 733 734 735
736
737 738 739 740 741
742 function edit() {
743 if($this->ctf->Can('edit') !== true) {
744 return false;
745 }
746
747 $this->methodName = "edit";
748
749 return $this->renderWith($this->ctf->templatePopup);
750 }
751
752 function delete() {
753 if($this->ctf->Can('delete') !== true) {
754 return false;
755 }
756
757 $this->dataObj()->delete();
758 }
759
760
761
762 763 764
765 function dataObj() {
766
767 if(is_numeric($this->itemID)) {
768
769 return DataObject::get_by_id(ClassInfo::baseDataClass(Object::getCustomClass($this->ctf->sourceClass())), $this->itemID);
770 }
771
772 }
773
774 775 776 777 778 779 780 781 782 783 784
785 function DetailForm($childID = null) {
786 $childData = $this->dataObj();
787
788 $fields = $this->ctf->getFieldsFor($childData);
789 $validator = $this->ctf->getValidatorFor($childData);
790 $readonly = ($this->methodName == "show");
791
792 $form = new $this->ctf->popupClass(
793 $this,
794 "DetailForm",
795 $fields,
796 $validator,
797 $readonly,
798 $childData
799 );
800
801 $form->loadDataFrom($childData);
802 if ($readonly) $form->makeReadonly();
803
804 return $form;
805 }
806
807 808 809 810 811 812 813 814 815 816
817 function saveComplexTableField($data, $form, $request) {
818 $dataObject = $this->dataObj();
819
820 try {
821 $form->saveInto($dataObject);
822 $dataObject->write();
823 } catch(ValidationException $e) {
824 $form->sessionMessage($e->getResult()->message(), 'bad');
825 return Director::redirectBack();
826 }
827
828
829 if(isset($data['ctf']['manyManyRelation'])) {
830 $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
831 $relationName = $data['ctf']['manyManyRelation'];
832 $componentSet = $parentRecord->getManyManyComponents($relationName);
833 $componentSet->add($dataObject);
834 }
835
836 $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
837
838 $closeLink = sprintf(
839 '<small><a href="%s" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>',
840 $referrer,
841 _t('ComplexTableField.CLOSEPOPUP', 'Close Popup')
842 );
843 $message = sprintf(
844 _t('ComplexTableField.SUCCESSEDIT', 'Saved %s %s %s'),
845 $dataObject->i18n_singular_name(),
846 '<a href="' . $this->Link() . '">"' . htmlspecialchars($dataObject->Title, ENT_QUOTES) . '"</a>',
847 $closeLink
848 );
849
850 $form->sessionMessage($message, 'good');
851
852 Director::redirectBack();
853 }
854
855 function () {
856 return $_REQUEST['ctf']['start']+1;
857 }
858
859 function () {
860 $this->ctf->LinkToItem();
861
862 if(!isset($_REQUEST['ctf']['start']) || !is_numeric($_REQUEST['ctf']['start']) || $_REQUEST['ctf']['start'] == 0) {
863 return null;
864 }
865
866 $start = 0;
867 return Controller::join_links($this->Link(), "$this->methodName?ctf[start]={$start}");
868 }
869
870 function () {
871 if(!isset($_REQUEST['ctf']['start']) || !is_numeric($_REQUEST['ctf']['start']) || $_REQUEST['ctf']['start'] == $this->totalCount-1) {
872 return null;
873 }
874
875 $start = $this->totalCount - 1;
876 return Controller::join_links($this->Link(), "$this->methodName?ctf[start]={$start}");
877 }
878
879 function () {
880 if(!isset($_REQUEST['ctf']['start']) || !is_numeric($_REQUEST['ctf']['start']) || $_REQUEST['ctf']['start'] == $this->totalCount-1) {
881 return null;
882 }
883
884 $start = $_REQUEST['ctf']['start'] + 1;
885 return Controller::join_links($this->Link(), "$this->methodName?ctf[start]={$start}");
886 }
887
888 function () {
889 if(!isset($_REQUEST['ctf']['start']) || !is_numeric($_REQUEST['ctf']['start']) || $_REQUEST['ctf']['start'] == 0) {
890 return null;
891 }
892
893 $start = $_REQUEST['ctf']['start'] - 1;
894 return Controller::join_links($this->Link(), "$this->methodName?ctf[start]={$start}");
895 }
896
897 898 899 900 901
902
903 function () {
904 $this->pageSize = 9;
905 $currentItem = $this->PopupCurrentItem();
906 $result = new DataObjectSet();
907 if($currentItem < 6) {
908 $offset = 1;
909 } elseif($this->totalCount - $currentItem <= 4) {
910 $offset = $currentItem - (10 - ($this->totalCount - $currentItem));
911 $offset = $offset <= 0 ? 1 : $offset;
912 } else {
913 $offset = $currentItem - 5;
914 }
915 for($i = $offset;$i <= $offset + $this->pageSize && $i <= $this->totalCount;$i++) {
916 $start = $i - 1;
917 $links['link'] = Controller::join_links($this->Link() . "$this->methodName?ctf[start]={$start}");
918 $links['number'] = $i;
919 $links['active'] = $i == $currentItem ? false : true;
920 $result->push(new ArrayData($links));
921 }
922 return $result;
923 }
924
925 function () {
926 return false;
927 }
928
929
930 931 932 933 934
935
936 937 938
939 function () {
940 global $_ALL_CLASSES;
941
942 $items = array();
943 $parents = isset($_ALL_CLASSES['parents'][$this->class]) ? $_ALL_CLASSES['parents'][$this->class] : null;
944
945 if($parents) {
946 foreach($parents as $parent) {
947 if(!in_array($parent, $_ALL_CLASSES['parents']['TableListField'])) {
948 $items[] = $parent . '_Popup';
949 }
950 }
951 }
952
953 $items[] = $this->class . '_Popup';
954
955 return implode(' ', $items);
956 }
957
958
959 960 961
962 function getParentIdName($parentClass, $childClass) {
963 return $this->getParentIdNameRelation($childClass, $parentClass, 'has_one');
964 }
965
966 967 968 969 970 971
972 function setParentIdName($str) {
973 $this->parentIdName = $str;
974 }
975
976 977 978
979 function getParentIdNameRelation($parentClass, $childClass, $relation) {
980 if($this->parentIdName) return $this->parentIdName;
981
982 $relations = singleton($parentClass)->$relation();
983 $classes = ClassInfo::ancestry($childClass);
984 if($relations) {
985 foreach($relations as $k => $v) {
986 if(array_key_exists($v, $classes)) return $k . 'ID';
987 }
988 }
989 return false;
990 }
991
992 function ($template) {
993 $this->templatePopup = $template;
994 }
995
996
997 }
998
999 1000 1001 1002 1003
1004 class ComplexTableField_Item extends TableListField_Item {
1005 function Link($action = null) {
1006 return Controller::join_links($this->parent->Link(), '/item/', $this->item->ID, $action);
1007 }
1008
1009 function EditLink() {
1010 return Controller::join_links($this->Link(), "edit");
1011 }
1012
1013 function ShowLink() {
1014 return Controller::join_links($this->Link(), "show");
1015 }
1016
1017 function DeleteLink() {
1018 return Controller::join_links($this->Link(), "delete");
1019 }
1020
1021 1022 1023 1024
1025 function IsDefaultAction($action) {
1026 return ($action == $this->parent->defaultAction);
1027 }
1028 }
1029
1030
1031 1032 1033 1034 1035 1036 1037 1038
1039 class extends Form {
1040 protected $sourceClass;
1041
1042 protected $dataObject;
1043
1044 function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
1045 $this->dataObject = $dataObject;
1046
1047 Requirements::clear();
1048 Requirements::unblock_all();
1049
1050 $actions = new FieldSet();
1051 if(!$readonly) {
1052 $actions->push(
1053 $saveAction = new FormAction(
1054 "saveComplexTableField",
1055 _t('CMSMain.SAVE')
1056 )
1057 );
1058 $saveAction->addExtraClass('save');
1059 }
1060
1061 parent::__construct($controller, $name, $fields, $actions, $validator);
1062 }
1063
1064 function forTemplate() {
1065 $ret = parent::forTemplate();
1066
1067 1068 1069 1070
1071 Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
1072 Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
1073 Requirements::css(CMS_DIR . '/css/typography.css');
1074 Requirements::css(CMS_DIR . '/css/cms_right.css');
1075 Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
1076 Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
1077 Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
1078 Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
1079 Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
1080 Requirements::javascript(SAPPHIRE_DIR . "/javascript/layout_helpers.js");
1081 Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
1082 Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
1083
1084
1085 $parent = $this->getParentController();
1086 if($parent instanceof ComplexTableField) {
1087 $callback = $parent->requirementsForPopupCallback;
1088 } else {
1089 $callback = $parent->getParentController()->requirementsForPopupCallback;
1090 }
1091 if($callback) call_user_func($callback, $this);
1092
1093
1094
1095 if($this->dataObject && $this->dataObject->hasMethod('getRequirementsForPopup')) {
1096 $this->dataObject->getRequirementsForPopup();
1097 }
1098
1099 return $ret;
1100 }
1101
1102 1103 1104
1105 function getParentController() {
1106 return $this->controller;
1107 }
1108 }
1109
1110 ?>
1111
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-