/**
  * Get HTML for the field to display
  *
  * @param array $properties Properties array
  * @return string
  */
 public function Field($properties = array())
 {
     $module_dir = basename(dirname(dirname(__DIR__)));
     Requirements::javascript($module_dir . '/javascript/MovieTitleField.js');
     Requirements::add_i18n_javascript($module_dir . '/javascript/lang');
     $list = new ArrayList($this->composite_fields);
     return $list->renderWith('MovieTitleField');
 }
 public function getHTMLFragments($grid)
 {
     $cols = new ArrayList();
     foreach ($grid->getColumns() as $name) {
         $meta = $grid->getColumnMetadata($name);
         $cols->push(new ArrayData(array('Name' => $name, 'Title' => $meta['title'])));
     }
     return array('header' => $cols->renderWith('GridFieldTitleHeader'));
 }
 /**
  * @param GridField $grid
  * @return array
  */
 public function getHTMLFragments($grid)
 {
     $cols = new ArrayList();
     foreach ($grid->getColumns() as $name) {
         $meta = $grid->getColumnMetadata($name);
         $cols->push(new ArrayData(array('Name' => $name, 'Title' => $meta['title'])));
     }
     $days = new ArrayList();
     for ($i = 0; $i < 5; $i++) {
         $date = new Date();
         $date->setValue(date('d-m-Y', strtotime('+' . $i . ' days', strtotime($this->startDate))));
         $isHoliday = in_array($date->Format('Y-m-d'), $this->holidays);
         $days->push(new ArrayData(array('Day' => $date->Format('l'), 'IsHoliday' => $isHoliday)));
     }
     return array('header' => $cols->renderWith('RosterGridFieldTitleHeader', array('StartDate' => $this->startDate, 'Days' => $days)));
 }
 function processTemplateHTML($templateName, $templateVariables = null)
 {
     if (!$templateVariables) {
         $templateVariables = new ArrayList();
     }
     $mappingService = Config::inst()->get('Mappable', 'mapping_service');
     $result = $templateVariables->renderWith($templateName . $mappingService . 'HTML');
     return $result;
 }
 private function getRowTemplate(GridField $grid, GridFieldEditableColumns $editable)
 {
     $columns = new ArrayList();
     $handled = array_keys($editable->getDisplayFields($grid));
     if ($grid->getList()) {
         $record = Object::create($grid->getModelClass());
     } else {
         $record = null;
     }
     $fields = $editable->getFields($grid, $record);
     foreach ($grid->getColumns() as $column) {
         if (in_array($column, $handled)) {
             $field = $fields->dataFieldByName($column);
             $field->setName(sprintf('%s[%s][{%%=o.num%%}][%s]', $grid->getName(), __CLASS__, $field->getName()));
             $content = $field->Field();
         } else {
             $content = null;
         }
         $attrs = '';
         foreach ($grid->getColumnAttributes($record, $column) as $attr => $val) {
             $attrs .= sprintf(' %s="%s"', $attr, Convert::raw2att($val));
         }
         $columns->push(new ArrayData(array('Content' => $content, 'Attributes' => $attrs, 'IsActions' => $column == 'Actions')));
     }
     return $columns->renderWith('GridFieldAddNewInlineRow');
 }