currentID = $currentID; } public function getHTMLFragments($gridField) { $modelClass = $gridField->getModelClass(); $parentID = 0; if($this->currentID) { $modelObj = DataObject::get_by_id($modelClass, $this->currentID); if($modelObj->hasMethod('getParent')) { $parent = $modelObj->getParent(); } elseif($modelObj->ParentID) { $parent = $modelObj->Parent(); } if($parent) $parentID = $parent->ID; // Attributes $attrs = array_merge($this->attributes, array( 'href' => sprintf($this->linkSpec, $parentID), 'class' => 'cms-panel-link list-parent-link' )); $attrsStr = ''; foreach($attrs as $k => $v) $attrsStr .= " $k=\"" . Convert::raw2att($v) . "\""; $forTemplate = new ArrayData(array( 'UpLink' => sprintf('%s', $attrsStr, _t('GridField.LEVELUP', 'Level up')) )); return array( 'before' => $forTemplate->renderWith('GridFieldLevelup'), ); } } public function setAttributes($attrs) { $this->attributes = $attrs; return $this; } public function getAttributes() { return $this->attributes; } public function setLinkSpec($link) { $this->linkSpec = $link; return $this; } public function getLinkSpec() { return $this->linkSpec; } }