public function getSearchContext()
 {
     if ($this->IsEditingNews()) {
         $context = new NewsSearchContext($this->modelClass, $this);
         foreach ($context->getFields() as $field) {
             $field->setName(sprintf('q[%s]', $field->getName()));
         }
         foreach ($context->getFilters() as $filter) {
             $filter->setFullName(sprintf('q[%s]', $filter->getFullName()));
         }
         $this->extend('updateSearchContext', $context);
         return $context;
     }
     return parent::getSearchContext();
 }
 public function __construct($modelClass, $newsAdmin = null, $fields = null, $filters = null)
 {
     $fields = new FieldList(TextField::create('Title'), TextField::create('URLSegment'), DropdownField::create('ParentID', 'Parent page')->setSource(NewsIndex::get()->map('ID', 'Title')->toArray())->setEmptyString('Select'), HeaderField::create('DatesHeader', 'Dates')->setHeadingLevel(3), DateField::create('StartDate')->setTitle(null)->setAttribute('placeholder', 'Start Date'), DateField::create('EndDate')->setTitle(null)->setAttribute('placeholder', 'End Date'), CheckboxSetField::create('Types')->setSource(NewsSearchContext::GetNewsTypes($newsAdmin))->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Types']) ? $_REQUEST['q']['Types'] : null), TextField::create('Tags'), TextField::create('Summary'), TextField::create('Content'), TextField::create('Author'), CheckboxSetField::create('Categories')->setSource(NewsCategory::get()->map('ID', 'Title')->toArray())->setValue(isset($_REQUEST['q']) && isset($_REQUEST['q']['Categories']) ? $_REQUEST['q']['Categories'] : null));
     $filters = array('Title' => new PartialMatchFilter('Title'), 'URLSegment' => new PartialMatchFilter('URLSegment'), 'ParentID' => new ExactMatchFilter('ParentID'), 'Tags' => new PartialMatchFilter('Tags'), 'Summary' => new PartialMatchFilter('Summary'), 'Content' => new PartialMatchFilter('Content'), 'Author' => new PartialMatchFilter('Author'), 'StartDate' => new GreaterThanOrEqualFilter('DateTime'), 'EndDate' => new LessThanOrEqualFilter('DateTime'));
     if ($newsAdmin) {
         $this->newsAdmin = $newsAdmin;
     }
     parent::__construct($modelClass, $fields, $filters);
 }