本文整理汇总了PHP中SearchForm类的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm类的具体用法?PHP SearchForm怎么用?PHP SearchForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SearchForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm
/**
* @ticket 44858
*/
public function testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm()
{
//test to check that if value of a dropdown field is already set in REQUEST object (from any form such as mass update form instead of search form)
//i.e. search is made on empty string, but REQUEST object gets value of that dropdown field from some other form on the same page
//then on clicking serach button, value of that field should not be used as filter in where clause
$this->markTestIncomplete('This test should actually check that the $whereArray is indeed populated');
return;
//array to simulate REQUEST object
$requestArray['module'] = 'Accounts';
$requestArray['action'] = 'index';
$requestArray['searchFormTab'] = 'basic_search';
$requestArray['account_type'] = 'Analyst';
//value of a dropdown field set in REQUEST object
$requestArray['query'] = 'true';
$requestArray['button'] = 'Search';
$requestArray['globalLinksOpen'] = 'true';
$requestArray['current_user_only_basic'] = 0;
$account = SugarTestAccountUtilities::createAccount();
$searchForm = new SearchForm($account, 'Accounts');
require 'modules/Accounts/vardefs.php';
require 'modules/Accounts/metadata/SearchFields.php';
require 'modules/Accounts/metadata/searchdefs.php';
$searchForm->searchFields = $searchFields[$searchForm->module];
$searchForm->searchdefs = $searchdefs[$searchForm->module];
$searchForm->populateFromArray($requestArray, 'basic_search', false);
$whereArray = $searchForm->generateSearchWhere(true, $account->module_dir);
//echo var_export($whereArray, true);
$this->assertEquals(0, count($whereArray));
}
示例2: SearchPlusForm
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);
}
}
示例3: testPublishedPagesMatchedByTitleInDefaultLanguage
function testPublishedPagesMatchedByTitleInDefaultLanguage()
{
$sf = new SearchForm($this->mockController, 'SearchForm');
$publishedPage = $this->objFromFixture('SiteTree', 'publishedPage');
$publishedPage->publish('Stage', 'Live');
$translatedPublishedPage = $publishedPage->createTranslation('de_DE');
$translatedPublishedPage->Title = 'translatedPublishedPage';
$translatedPublishedPage->Content = 'German content';
$translatedPublishedPage->write();
$translatedPublishedPage->publish('Stage', 'Live');
$this->waitUntilIndexingFinished();
// Translatable::set_current_locale() can't be used because the context
// from the holder is not present here - we set the language explicitly
// through a pseudo GET variable in getResults()
$lang = 'en_US';
$results = $sf->getResults(null, array('Search' => 'content', 'locale' => $lang));
$this->assertContains($publishedPage->ID, $results->column('ID'), 'Published pages are found by searchform in default language');
$this->assertNotContains($translatedPublishedPage->ID, $results->column('ID'), 'Published pages in another language are not found when searching in default language');
$lang = 'de_DE';
$results = $sf->getResults(null, array('Search' => 'content', 'locale' => $lang));
$this->assertNotContains($publishedPage->ID, $results->column('ID'), 'Published pages in default language are not found when searching in another language');
$actual = $results->column('ID');
array_walk($actual, 'intval');
$this->assertContains((int) $translatedPublishedPage->ID, $actual, 'Published pages in another language are found when searching in this language');
}
示例4: actionIndex
public function actionIndex()
{
$this->pageTitle = Yii::t('title', 'Server droplist');
$form = new SearchForm();
$form->scenario = 'droplist';
$model = null;
if (isset($_POST['SearchForm'])) {
$form->attributes = $_POST['SearchForm'];
if ($form->validate()) {
if (!empty($form->mobId) and !empty($form->item_id)) {
$where = 'mobId = ' . $form->mobId . ' AND itemid = ' . $form->item_id;
} elseif (!empty($form->mobId)) {
$where = 'mobId = ' . $form->mobId;
} elseif (!empty($form->item_id)) {
$where = 'item_id = ' . $form->item_id;
} else {
$where = null;
}
$criteria = new CDbCriteria();
$criteria->select = 'mobId, item_id, min, max, chance';
$criteria->condition = $where;
$criteria->order = 'chance DESC, max DESC';
$criteria->limit = 100;
$model = Droplist::model()->findAll($criteria);
}
}
$this->render('/droplist', array('form' => $form, 'model' => $model));
}
示例5: createAction
/**
* Creates a new company
*/
public function createAction()
{
if ($this->request->isPost()) {
$form = new SearchForm();
$company = new MeiuiSearch();
$data = $this->request->getPost();
if (!$form->isValid($data, $company)) {
foreach ($form->getMessages() as $message) {
$this->flash->error($message);
}
return $this->forward('search/create');
}
if ($company->save() == false) {
foreach ($company->getMessages() as $message) {
$this->flash->error($message);
}
return $this->forward('search/create');
}
$form->clear();
$this->flash->success("search was created successfully");
return $this->forward("search/list");
} else {
$this->view->form = new SearchForm(null, array('edit' => true));
}
}
示例6: testDisabledShowInSearchFlagNotIncluded
function testDisabledShowInSearchFlagNotIncluded()
{
$sf = new SearchForm($this->mockController, 'SearchForm');
$page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage');
$results = $sf->getResults(null, array('Search' => 'dontShowInSearchPage'));
$this->assertNotContains($page->ID, $results->column('ID'), 'Page with "Show in Search" disabled doesnt show');
}
示例7: SpeakerSearchForm
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;
}
示例8: actionSearch
public function actionSearch()
{
if (Yii::app()->getRequest()->getQuery('SearchForm')) {
$form = new SearchForm();
$form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
if ($form->validate()) {
$category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
$this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->search($form->q, $form->category)]);
}
}
}
示例9: actionResult
public function actionResult()
{
$model = new SearchForm();
$form = new CForm('application.views.search.form', $model);
if ($form->submitted('search') && $form->validate()) {
$result = $model->searchResult();
//$this->redirect(array('search/index'));
$this->render('index', array('form' => $form, 'result' => $result));
} else {
$this->render('index', array('form' => $form));
}
}
示例10: actionSearch
public function actionSearch()
{
if (!Yii::app()->getRequest()->getQuery('SearchForm')) {
throw new CHttpException(404);
}
$form = new SearchForm();
$form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
if ($form->validate()) {
$category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
$this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
}
}
示例11: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
$oLogItemNaoCadastrado = LogItemNaoCadastrado::model()->naoCadastrado()->exibir()->findAll();
$oOrdemServico = new OrdemServico('search');
$oOrdemServico->unsetAttributes();
$oSearchForm = new SearchForm();
$oOrdemServico->status = LogOrdemServico::ABERTA;
if (isset($_GET['OrdemServico'])) {
$oOrdemServico->attributes = $_GET['OrdemServico'];
$oSearchForm->request = $_GET['OrdemServico'];
}
$this->render('index', array('oLogItemNaoCadastrado' => $oLogItemNaoCadastrado, 'oOrdemServico' => $oOrdemServico, 'exibeFormularioBusca' => $oSearchForm->checaRequisicaoVazia()));
}
示例12: run
public function run()
{
$search = new SearchForm();
$controller = $this->getController();
$controller->layout = 'form';
if (isset($_GET['SearchForm'])) {
$search->attributes = $_GET['SearchForm'];
if ($search->validate()) {
if ($search->searchq == '') {
$query = '%';
} else {
$query = $search->searchq;
}
$kategorie = $search->kategorie;
$wortart = $search->wortart;
$klasse = '';
// Suchoptionen filtern:
$filteredResults = wortschatz::model()->filterSearchOptions($kategorie, $wortart, $klasse);
// alle genauen Treffer:
$exactSearchResults = wortschatz::model()->exactSearch($filteredResults, $query);
$pages_exact = $exactSearchResults['pages'];
$countAll_exact = $exactSearchResults['countAll'];
$count_exact = $exactSearchResults['count'];
$sort_exact = $exactSearchResults['sort'];
$models_exact = $exactSearchResults['models'];
$linkedExactResults = wortschatz::model()->addLinks($models_exact);
$models_exact_linked = $linkedExactResults['models'];
// alle LIKE-Treffer:
$standardSearchResults = wortschatz::model()->standardSearch($filteredResults, $query);
$pages_standard = $standardSearchResults['pages'];
$countAll_standard = $standardSearchResults['countAll'];
$count_standard = $standardSearchResults['count'];
$sort_standard = $standardSearchResults['sort'];
$models_standard = $standardSearchResults['models'];
// LIKE-Treffer ohne genaue Treffer:
$cleanedResults = wortschatz::model()->removeExactResults($models_standard, $models_exact);
$linkedResults = wortschatz::model()->addLinks($cleanedResults['models']);
$models_linked = $linkedResults['models'];
if ($count_exact != 0 or $count_standard != 0) {
$controller->render('search', array('search' => $search, 'query' => $query, 'models' => $models_linked, 'pages' => $pages_standard, 'countAll' => $countAll_standard, 'count' => $count_standard, 'sort' => $sort_standard, 'models_exact' => $models_exact_linked, 'pages_exact' => $pages_exact, 'countAll_exact' => $countAll_exact, 'count_exact' => $count_exact, 'sort_exact' => $sort_exact));
} else {
$controller->render('search', array('search' => $search, 'errortext' => 'Keine Daten gefunden'));
}
} else {
$controller->render('search', array('search' => $search));
}
} else {
$controller->render('search', array('search' => $search));
}
}
示例13: createComponentSearchForm
protected function createComponentSearchForm()
{
if ($this->searchRequest->groups) {
$groups = array_fill_keys($this->searchRequest->groups, true);
} else {
$groups = array();
foreach ($this->context->groups->getList() as $group) {
$groups[$group->id] = true;
}
}
$form = new SearchForm($this->context->groups);
$form->setDefaults(array('s' => $this->getParameter('s'), 'from' => $this->searchRequest ? $this->searchRequest->from : null, 'groups' => $groups));
$form->onSuccess[] = callback($form, 'submitted');
return $form;
}
示例14: actionSaveSort
public function actionSaveSort()
{
$objTypeId = Yii::app()->request->getParam('id', NULL);
$sort = Yii::app()->request->getParam('sort');
if (count($sort) >= param('searchMaxField', 15)) {
HAjax::jsonError(tt('Search max field ') . param('searchMaxField', 3));
}
if ($objTypeId !== NULL && $sort && is_array($sort)) {
$elements = SearchForm::getSearchFields();
$sql = "DELETE FROM {{search_form}} WHERE obj_type_id=:id AND status!=:status";
Yii::app()->db->createCommand($sql)->execute(array(':id' => $objTypeId, ':status' => SearchFormModel::STATUS_NOT_REMOVE));
$i = 3;
foreach ($sort as $field) {
if (!isset($elements[$field])) {
continue;
}
$search = new SearchFormModel();
$search->attributes = array('obj_type_id' => $objTypeId, 'field' => $field, 'status' => $elements[$field]['status'], 'sorter' => $i, 'formdesigner_id' => isset($elements[$field]['formdesigner_id']) ? $elements[$field]['formdesigner_id'] : 0);
$search->save();
$i++;
}
// delete assets js cache
ConfigurationModel::clearGenerateJSAssets();
HAjax::jsonOk();
}
HAjax::jsonError();
}
示例15: init
public function init()
{
parent::init();
if (!issetModule('messages')) {
throw404();
}
$this->cityActive = SearchForm::cityInit();
}