public function getTitle() { if ($this->AlbumName) { return $this->AlbumName; } return parent::getTitle(); }
function setValue($data) { if ($this->buyable) { $value = $this->buyable->FullName ? $this->buyable->FullName : $this->buyable->getTitle(); //to TEST!!! $this->fieldSelectedBuyable->setValue($value); } }
/** * Do we do anything with data??? */ function setValue($data) { if ($this->buyable) { $value = $this->buyable->FullName ? $this->buyable->FullName : $this->buyable->getTitle(); //to TEST!!! $this->fieldSelectedBuyable->setValue("Once you have selected a new value, it will appear here..."); } }
public function getTitle() { if ($this->EmailAddress) { return $this->EmailAddress; } if ($this->EmailSubject) { return $this->EmailSubject; } return parent::getTitle(); }
public function getTitle() { if ($this->Caption) { return $this->dbObject('Caption')->FirstSentence(); } if ($image = $this->Image()) { return $image->Title; } return parent::getTitle(); }
/** * Updates the Upload/Attach response from the UploadField * with the new DataObject records for the JS template * * @param DataObject $record Newly create DataObject record * @param array $uploadResponse Upload or Attach response from UploadField * @return array Updated $uploadResponse with $record data */ protected function newRecordJSTemplateData(DataObject &$record, &$uploadResponse) { // fetch uploadedFile record and sort out previewURL // update $uploadResponse datas in case changes happened onAfterWrite() $uploadedFile = DataObject::get_by_id($this->component->getFileRelationClassName($this->gridField), $uploadResponse['id']); if ($uploadedFile) { $uploadResponse['name'] = $uploadedFile->Name; $uploadResponse['url'] = $uploadedFile->getURL(); if ($uploadedFile instanceof Image) { $uploadResponse['thumbnail_url'] = $uploadedFile->CroppedImage(30, 30)->getURL(); } else { $uploadResponse['thumbnail_url'] = $uploadedFile->Icon(); } // check if our new record has a Title, if not create one automatically $title = $record->getTitle(); if (!$title || $title === $record->ID) { if ($record->hasDatabaseField('Title')) { $record->Title = $uploadedFile->Title; $record->write(); } else { if ($record->hasDatabaseField('Name')) { $record->Name = $uploadedFile->Title; $record->write(); } } } } // Collect all data for JS template $return = array_merge($uploadResponse, array('record' => array('id' => $record->ID))); return $return; }
/** * Model 'related' sidebar * * @param SidebarController $sidebar * @param DataObject $model * @param array $whitelist only show actions with these names in the related sidebar */ protected function sidebarRelatedItems(SidebarController $sidebar, DataObject $model, $whitelist = NULL) { $sidebarlist = array(); // need to get the module name from the controller name $action_name = array('new' => 'new'); foreach ($model->getLinkRules() as $name => $hasmany) { if (method_exists($this, $name)) { $controller_name = $this->name; $action_name['link'] = $name; $field = $hasmany['field']; } elseif (method_exists($this, 'view' . $name)) { $controller_name = $this->name; $action_name['link'] = 'view' . $name; $field = $hasmany['field']; } elseif (method_exists($this, 'view_' . $name)) { $controller_name = $this->name; $action_name['link'] = 'view_' . $name; $field = $hasmany['field']; } else { $controller_name = $hasmany['do'] . 's'; $action_name['link'] = 'view_' . strtolower(str_replace(' ', '_', $model->getTitle())); $field = $hasmany['fkfield']; } $link = array(); foreach ($hasmany['actions'] as $action) { if (!is_null($whitelist) && !in_array($name, $whitelist)) { continue; } if ($action == 'new') { $controller_name = $hasmany['do'] . 's'; $field = $hasmany['fkfield']; } $modules = isset($hasmany['modules'][$action]) ? $hasmany['modules'][$action] : $this->_modules; if (isset($hasmany['newtab'][$action])) { $link[$action] = array('modules' => $modules, 'controller' => $controller_name, 'action' => strtolower($action_name[$action]), $field => $model->{$model->idField}, 'newtab' => TRUE); } else { $link[$action] = array('modules' => $modules, 'controller' => $controller_name, 'action' => strtolower($action_name[$action]), $field => $model->{$model->idField}); } } if (!empty($link)) { $sidebarlist[$name] = array_merge(array('tag' => isset($hasmany['label']) ? $hasmany['label'] : 'Show ' . $name), $link); } } $sidebar->addList('related_items', $sidebarlist); }