Source of file SiteMediaDataObjectManager.php
Size: 2,871 Bytes - Last Modified: 2021-12-24T06:34:20+00:00
/var/www/docs.ssmods.com/process/src/code/SiteMediaDataObjectManager.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | <?php class SiteMediaDataObjectManager extends ManyManyDataObjectManager { /* // taken directly from DataObjectManager class. Modified to always return to edit field function saveComplexTableField($data, $form, $params) { $className = $this->sourceClass(); $childData = new $className(); $form->saveInto($childData); try { $childData->write(); } catch(ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad'); return Director::redirectBack(); } if($childData->many_many()) { $form->saveInto($childData); $childData->write(); } $form->sessionMessage(sprintf(_t('DataObjectManager.ADDEDNEW','Added new %s successfully'),$this->SingleTitle()), 'good'); // **PATCH** if($form->getFileFields() || $form->getNestedDOMs()) { if(true) { $form->clearMessage(); Director::redirect(Controller::join_links($this->BaseLink(),'item', $childData->ID, 'edit')); } else { Director::redirectBack(); } } */ function saveComplexTableField($data, $form, $params) { $className = $this->sourceClass(); $childData = new $className(); $form->saveInto($childData); try { $childData->write(); } catch(ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad'); return Director::redirectBack(); } // Save the many many relationship if it's available if(isset($data['ctf']['manyManyRelation'])) { $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']); $relationName = $data['ctf']['manyManyRelation']; $componentSet = $parentRecord ? $parentRecord->getManyManyComponents($relationName) : null; if($componentSet) $componentSet->add($childData); } if(isset($data['ctf']['hasManyRelation'])) { $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']); $relationName = $data['ctf']['hasManyRelation']; $componentSet = $parentRecord ? $parentRecord->getComponents($relationName) : null; if($componentSet) $componentSet->add($childData); } $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $closeLink = sprintf( '<small><a href="%s" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>', $referrer, _t('ComplexTableField.CLOSEPOPUP', 'Close Popup') ); $editLink = Controller::join_links($this->Link(), 'item/' . $childData->ID . '/edit'); $message = sprintf( _t('ComplexTableField.SUCCESSADD', 'Added %s %s %s'), $childData->singular_name(), '<a href="' . $editLink . '">' . $childData->Title . '</a>', $closeLink ); $form->sessionMessage($message, 'good'); // **PATCH //Director::redirectBack(); Director::redirect($editLink); } } |