/**
  * @return \FieldList
  */
 public function getGeoFields()
 {
     $fields = new FieldList();
     $fields->push(new HeaderField('AddressHeader', _t('GeoMemberExtension.ADDRESSHEADER', 'Address')));
     $fields->push($this->getAddressFields(), 'Address');
     $fields->push(new HeaderField('GeoHeader', _t('GeoMemberExtension.GEOHEADER', 'Geo data')));
     $latitude = new TextField('Latitude', _t('GeoMemberExtension.LATITUDE', 'Latitude'), $this->owner->Latitude ? $this->owner->Latitude : null);
     $latitude->setAttribute('placeholder', _t('GeoMemberExtension.LATITUDE', 'Latitude'));
     $latitude->setTitle('');
     $longitude = new TextField('Longitude', _t('GeoMemberExtension.LONGITUDE', 'Longitude'), $this->owner->Longitude ? $this->owner->Longitude : null);
     $longitude->setAttribute('placeholder', _t('GeoMemberExtension.LONGITUDE', 'Longitude'));
     $longitude->setTitle('');
     $coords = new FieldGroup($latitude, $longitude);
     $coords->setFieldHolderTemplate('AddressFieldHolder');
     $coords->setTitle(_t('GeoMemberExtension.COORDS', 'Coordinates'));
     $fields->push($coords);
     $fields->push(new CheckboxField('GeolocateOnLocation', _t('GeoMemberExtension.GEOLOCATEONLOCATION', 'Only show location instead of full address')));
     $tz = timezone_identifiers_list();
     $timezone = $this->owner->Timezone;
     if (!$timezone) {
         $timezone = date_default_timezone_get();
     }
     $fields->push($tzdd = new DropdownField('Timezone', _t('GeoMemberExtension.TIMEZONE', 'Timezone'), array_combine($tz, $tz), $timezone));
     $tzdd->setEmptyString('');
     return $fields;
 }
 /**
  * Returns a Form for page searching for use in templates.
  *
  * Can be modified from a decorator by a 'updateSearchForm' method
  *
  * @return Form
  */
 public function SearchForm()
 {
     // Create the fields
     $content = new TextField('q[Title]', _t('CMSSearch.FILTERTITLEHEADING', 'Module Name'));
     $dateHeader = new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4);
     $dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From'));
     $dateFrom->setConfig('showcalendar', true);
     $dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To'));
     $dateTo->setConfig('showcalendar', true);
     $pageClasses = new DropdownField('q[Module]', _t('ContentModule.MODULETYPEOPT', 'Module Type', 'Dropdown for limiting search to a module type'), $this->getModuleTypes());
     $pageClasses->setEmptyString(_t('ContentModule.MODULETYPEANYOPT', 'Any'));
     // Group the Datefields
     $dateGroup = new FieldGroup($dateHeader, $dateFrom, $dateTo);
     $dateGroup->setFieldHolderTemplate('FieldGroup_DefaultFieldHolder')->addExtraClass('stacked');
     // Create the Field list
     $fields = new FieldList($content, $dateGroup, $pageClasses);
     // Create the Search and Reset action
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left.ss.APPLY FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.RESET', 'Reset')));
     // Use <button> to allow full jQuery UI styling on the all of the Actions
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     // Create the form
     $form = Form::create($this, 'SearchForm', $fields, $actions)->addExtraClass('cms-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator();
     // Load the form with previously sent search data
     $form->loadDataFrom($this->request->getVars());
     // Allow decorators to modify the form
     $this->extend('updateSearchForm', $form);
     return $form;
 }
Beispiel #3
0
 function SearchForm()
 {
     // get all page types in a dropdown-compatible format
     $pageTypeClasses = SiteTree::page_type_classes();
     $pageTypes = array();
     foreach ($pageTypeClasses as $pageTypeClass) {
         $pageTypes[$pageTypeClass] = _t($pageTypeClass . '.SINGULARNAME', $pageTypeClass);
     }
     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 FieldList(new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup(new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4), $dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From')), $dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To'))), new DropdownField('q[FilterClass]', _t('CMSMain.PAGES', 'Pages'), $filterMap), $classDropdown = new DropdownField('q[ClassName]', _t('CMSMain.PAGETYPEOPT', 'Page Type', 'Dropdown for limiting search to a page type'), $pageTypes));
     $dateGroup->setFieldHolderTemplate('FieldGroup_DefaultFieldHolder')->addExtraClass('stacked');
     $dateFrom->setConfig('showcalendar', true);
     $dateTo->setConfig('showcalendar', true);
     $classDropdown->setEmptyString(_t('CMSMain.PAGETYPEANYOPT', 'Any'));
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left.ss.APPLY FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.RESET', 'Reset')));
     // Use <button> to allow full jQuery UI styling
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     $form = Form::create($this, 'SearchForm', $fields, $actions)->addExtraClass('cms-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator();
     $form->loadDataFrom($this->request->getVars());
     $this->extend('updateSearchForm', $form);
     return $form;
 }