/** * Creates a rendered Programme Crawler Field using the .ss template * @param type $properties an array of values to decorate the field * @return type a rendered template */ function Field($properties = array()) { $obj = $properties ? $this->customise($properties) : $this; $obj->Options = ArrayList::create(); $dobj = DataObject::create(array('MyTitle' => 'No Color', 'Value' => '', 'CSSRGB' => '255 255 255', 'CSSHex' => '#ffffff', 'CSSCMYK' => '0 0 0 0')); $obj->Options->push($dobj); //go through source, if object it is a custom color, if not, get data from ColourSchemes foreach ($this->getSource() as $value) { $mobj = DataObject::create(); if ($value instanceof Object) { $mobj->MyTitle = $value->OPColor; $mobj->Value = $value->CSSColor; $mobj->CSSRGB = $value->CSSRGB; $mobj->CSSHex = $value->CSSHex; $mobj->CSSCMYK = $value->CSSCMYK; } else { $cs = ColourSchemes::get()->filter('OPColor', $value)->first(); if (!empty($cs)) { $mobj->MyTitle = $cs->OPColor; $mobj->Value = $cs->CSSColor; $mobj->CSSRGB = $cs->CSSRGB; $mobj->CSSHex = $cs->CSSHex; $mobj->CSSCMYK = $cs->CSSCMYK; } } $obj->Options->push($mobj); } // directly point to the template file $tmp = $obj->renderWith(BASE_PATH . '/' . OPCOLORWORKINGFOLDER . "/templates/OpColorField.ss"); return $tmp; }
/** * Creates a rendered Programme Crawler Field using the .ss template * @param type $properties an array of values to decorate the field * @return type a rendered template */ function Field($properties = array()) { $obj = $properties ? $this->customise($properties) : $this; $obj->Options = ArrayList::create(); $dobj = DataObject::create(); $dobj->MyTitle = 'No Color'; $dobj->Value = ''; $dobj->CSSRGB = '255 255 255'; $dobj->CSSHex = '#ffffff'; $dobj->CSSCMYK = '0 0 0 0'; $obj->Options->push($dobj); $source = ColourSchemes::get()->sort('ID'); if ($source) { foreach ($source as $value) { $mobj = DataObject::create(); $mobj->MyTitle = $value->OPColor; $mobj->Value = $value->CSSColor; $mobj->CSSRGB = $value->CSSRGB; $mobj->CSSHex = $value->CSSHex; $mobj->CSSCMYK = $value->CSSCMYK; $obj->Options->push($mobj); } } // directly point to the template file $tmp = $obj->renderWith(BASE_PATH . '/' . OPCOLORWORKINGFOLDER . "/templates/OpColorField.ss"); return $tmp; }
public function updateEditForm(&$form) { $form->Fields()->fieldByName('Root')->push($tabMain = new Tab('Colour Schemes', GridField::create('ColourSchemes', null, ColourSchemes::get()->sort('ID'), GridFieldConfig_RecordEditor::create())->setForm($form))); }