Beispiel #1
0
 function SearchForm()
 {
     // get all page types in a dropdown-compatible format
     $pageTypes = SiteTree::page_type_classes();
     array_unshift($pageTypes, 'All');
     $pageTypes = array_combine($pageTypes, $pageTypes);
     asort($pageTypes);
     // get all filter instances
     $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
     $filterMap = array();
     // remove base class
     array_shift($filters);
     // add filters to map
     foreach ($filters as $filter) {
         $filterMap[$filter] = call_user_func(array($filter, 'title'));
     }
     // ensure that 'all pages' filter is on top position
     uasort($filterMap, create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;'));
     $fields = new FieldSet(new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup($dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FilterDateFrom', 'from')), $dateTo = new DateField('LastEditedTo', _t('CMSSearch.FilterDateFrom', 'to'))), new DropdownField('FilterClass', _t('CMSMain.SearchTreeFormPagesDropdown', 'Pages'), $filterMap), new DropdownField('ClassName', _t('CMSMain.PAGETYPEOPT', 'Page Type', PR_MEDIUM, 'Dropdown for limiting search to a page type'), $pageTypes, null, null, _t('CMSMain.PAGETYPEANYOPT', 'Any')));
     $dateGroup->subfieldParam = 'FieldHolder';
     $dateFrom->setConfig('showcalendar', true);
     $dateTo->setConfig('showcalendar', true);
     $actions = new FieldSet($resetAction = new ResetFormAction('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')), $searchAction = new FormAction('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search')));
     $resetAction->addExtraClass('ss-ui-action-minor');
     $form = new Form($this, 'SearchForm', $fields, $actions);
     $form->setFormMethod('GET');
     $form->disableSecurityToken();
     $form->unsetValidator();
     return $form;
 }
 /**
  * Get a search form for a single {@link DataObject} subclass.
  * 
  * @return Form
  */
 public function SearchForm()
 {
     $context = singleton($this->modelClass)->getDefaultSearchContext();
     $fields = $context->getSearchFields();
     $columnSelectionField = $this->ColumnSelectionField();
     $fields->push($columnSelectionField);
     $validator = new RequiredFields();
     $validator->setJavascriptValidationHandler('none');
     $form = new Form($this, "SearchForm", $fields, new FieldSet(new FormAction('search', _t('MemberTableField.SEARCH', 'Search')), $clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH', 'Clear Search'))), $validator);
     //$form->setFormAction(Controller::join_links($this->Link(), "search"));
     $form->setFormMethod('get');
     $form->setHTMLID("Form_SearchForm_" . $this->modelClass);
     $form->disableSecurityToken();
     $clearAction->useButtonTag = true;
     $clearAction->addExtraClass('minorAction');
     return $form;
 }
 public function SearchForm()
 {
     if ($this->modelClass != 'All') {
         $context = singleton($this->modelClass)->getDefaultSearchContext();
         $fields = $context->getSearchFields();
     } else {
         $fields = new FieldSet();
     }
     $fields->push(new DropdownField('State', 'State', array('unapproved' => 'Awaiting Moderation', 'approved' => 'Approved', 'spam' => 'Marked as Spam'), 'unapproved'));
     $fields->push(new HiddenField('Page', 'Page', 0));
     $form = new Form($this, "SearchForm", $fields, new FieldSet(new FormAction('search', _t('MemberTableField.SEARCH', 'Search')), $clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH', 'Clear Search'))));
     $form->setFormMethod('get');
     $form->setHTMLID("Form_SearchForm_" . $this->modelClass);
     $clearAction->useButtonTag = true;
     $clearAction->addExtraClass('minorAction');
     return $form;
 }