function SearchPlusForm($name = "SearchForm", $fieldName = "Search", $fieldLabel = '')
 {
     $action = $this->getRequest()->param("Action");
     $page = SearchPlusPage::get()->first();
     if ($page) {
         //!in_array($action, array("login", "logout")) &&
         if (!$fieldLabel) {
             if (isset($_REQUEST[$fieldName])) {
                 $searchText = $_REQUEST[$fieldName];
                 //we set $_REQUEST["Search"] below because it is also used by things like Text::ContextSummary
                 $_REQUEST["Search"] = $_REQUEST[$fieldName];
             } elseif (isset($_REQUEST["Search"])) {
                 $searchText = $_REQUEST["Search"];
             } else {
                 $searchText = 'Search';
             }
         } else {
             $searchText = '';
         }
         $field = new TextField($fieldName, $fieldLabel, $searchText);
         $fields = new FieldList($field);
         $actions = new FieldList(new FormAction('results', 'Search'));
         $form = new SearchForm($this, $name, $fields, $actions);
         $form->setFormAction($page->Link() . "results/");
         $form->setPageLength(Config::inst()->get("SearchPlusPage", "result_length"));
         $form->unsetValidator();
         return $form;
     } elseif (!$page) {
         user_error("You need to create a SearchPlusPage to have a search box", E_USER_NOTICE);
     }
 }
Esempio n. 2
0
 public function SpeakerSearchForm()
 {
     $searchField = new TextField('mq', 'Search Speaker', $this->getSearchQuery());
     $searchField->setAttribute("placeholder", "first name, last name or irc nickname");
     $fields = new FieldList($searchField);
     $form = new SearchForm($this, 'SpeakerSearchForm', $fields);
     $form->setFormAction($this->Link('results'));
     return $form;
 }
 /**
  * Site search form.
  *
  * Similar to ContentControllerSearchExtension::SearchForm() but
  * redirecting to a suitable page to avoid invalid URLs such as
  * 'adg/AdgEntity.html/SearchForm'
  *
  * The default redirection is to '/home/SearchForm' but can be
  * changed with GtkdocControllerSearcExtension::setSearchAction().
  */
 public function SearchForm()
 {
     if ($this->owner->request && $this->owner->request->getVar('Search')) {
         $searchText = $this->owner->request->getVar('Search');
     } else {
         $searchText = _t('SearchForm.SEARCH', 'Search');
     }
     $fields = new FieldList(new TextField('Search', false, $searchText));
     $actions = new FieldList(new FormAction('results', _t('SearchForm.GO', 'Go')));
     $form = new SearchForm($this->owner, 'SearchForm', $fields, $actions);
     $form->classesToSearch(FulltextSearchable::get_searchable_classes());
     // The following line is the reason of this overriding: we must
     // redirect to a suitable page to avoid invalid URLs such as
     // 'adg/AdgEntity.html/SearchForm'
     $form->setFormAction(self::$search_action);
     return $form;
 }