当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchForm::validate方法代码示例

本文整理汇总了PHP中SearchForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::validate方法的具体用法?PHP SearchForm::validate怎么用?PHP SearchForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchForm的用法示例。


在下文中一共展示了SearchForm::validate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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));
 }
开发者ID:noiary,项目名称:Aion-Core-v4.7.5,代码行数:28,代码来源:DroplistController.php

示例2: 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)]);
         }
     }
 }
开发者ID:RexGalicie,项目名称:yupe,代码行数:11,代码来源:CatalogController.php

示例3: 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()))]);
     }
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:12,代码来源:CatalogController.php

示例4: 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));
     }
 }
开发者ID:BackupTheBerlios,项目名称:swahili-dict,代码行数:50,代码来源:SearchAction_new.php

示例5: actionSearch

    public function actionSearch()
    {
        $model = new SearchForm();
        $dataProvider = null;
        if (isset($_REQUEST['SearchForm'])) {
            $model->attributes = $_REQUEST['SearchForm'];
            if ($model->validate()) {
                $friendList = AuxiliaryFriendsOperator::getFriendIdList();
                $sqlCount = 'SELECT count(*)
					 FROM ' . Upload::model()->tableName() . ' u
					 LEFT JOIN  ' . Users::model()->tableName() . ' s ON s.Id = u.userId 
					 WHERE (u.userId in (' . $friendList . ') 
					 			OR 
						 		u.userId = ' . Yii::app()->user->id . '
						 		OR
						 		u.publicData = 1 )
					 	   AND	
					 	   (s.realname like "%' . $model->keyword . '%"
						   		OR
						   		u.description like "%' . $model->keyword . '%")';
                $count = Yii::app()->db->createCommand($sqlCount)->queryScalar();
                $sql = 'SELECT u.Id as id, u.description, s.realname, s.Id as userId
					 FROM ' . Upload::model()->tableName() . ' u
					 LEFT JOIN  ' . Users::model()->tableName() . ' s ON s.Id = u.userId 
					 WHERE (u.userId in (' . $friendList . ') 
					 			OR 
						 		u.userId = ' . Yii::app()->user->id . ' 
						 		OR
						 		u.publicData = 1)
					 	   AND
					 	   (s.realname like "%' . $model->keyword . '%"
					 			OR
					 	   		u.description like "%' . $model->keyword . '%")';
                $dataProvider = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'sort' => array('attributes' => array('id', 'realname')), 'pagination' => array('pageSize' => Yii::app()->params->imageCountInOnePage, 'params' => array(CHtml::encode('SearchForm[keyword]') => $model->attributes['keyword']))));
            }
        }
        Yii::app()->clientScript->scriptMap['jquery.js'] = false;
        //TODO: added below line because gridview.js is loaded before.
        Yii::app()->clientScript->scriptMap['jquery.yiigridview.js'] = false;
        $this->renderPartial('searchImageResults', array('model' => $model, 'dataProvider' => $dataProvider), false, true);
    }
开发者ID:Avinash1000,项目名称:traceper,代码行数:41,代码来源:ImageController.php

示例6: actionSearch

 public function actionSearch($ihq = null, $iht = null, $status = null)
 {
     $queryLength = mb_strlen($ihq, 'UTF-8');
     // search by hash
     $is_hash = false;
     if (40 == $queryLength && preg_match('#^[0-9a-f]{40}$#i', $ihq)) {
         $is_hash = true;
         if ($torrent = Yii::app()->torrentsService->getTorrentByHash($ihq)) {
             Yii::app()->request->redirect($torrent->getUrl());
         }
     }
     $this->checkSearchRequest();
     if (!empty($iht)) {
         if (preg_match('#^\\d$#sui', $iht) && LCategory::getCategoryTag($iht)) {
             $iht = LCategory::getCategoryTag($iht);
         }
     }
     if (!empty($ihq)) {
         $this->pageTitle = ucfirst($ihq) . ' Torrents Search Results | ' . Yii::app()->name . ' Torrent Search Engine';
     } elseif (!empty($iht)) {
         $this->pageTitle = mb_convert_case($iht, MB_CASE_TITLE, 'utf-8') . ' Torrents | ' . Yii::app()->name . ' Torrent Search Engine';
     }
     Yii::app()->getRequest()->getQuery('age');
     if (Yii::app()->getRequest()->getQuery('ihs', null) === '1') {
         $_GET['popular'] = '1';
     }
     $searchModel = new SearchForm('simple');
     $searchModel->words = $ihq;
     $searchModel->tags = $iht;
     $searchModel->age = Yii::app()->getRequest()->getQuery('age', 0);
     $searchModel->popular = empty($_GET['popular']) ? 0 : 1;
     $searchModel->status = empty($status) ? 0 : 1;
     $searchModel->validate();
     $torrents = new CArrayDataProvider(array());
     $totalCount = 0;
     if (!$searchModel->getErrors()) {
         $torrentModel = LTorrent::model();
         $torrents = $torrentModel->getSphinxDataProvider($searchModel);
         $totalCount = $torrents->getTotalItemCount();
         if (empty($totalCount)) {
             $words = explode(' ', $searchModel->words);
             if (count($words) > 1) {
                 $searchModel->words = $words;
                 $torrents = $torrentModel->getSphinxDataProvider($searchModel);
                 $totalCount = $torrents->getTotalItemCount();
             }
         }
     }
     if (isset($_REQUEST['lucky'])) {
         $t = $torrents->getData();
         if (count($t)) {
             $idx = rand(0, count($t) - 1);
             Yii::app()->request->redirect($t[$idx]->getUrl());
         }
     }
     $this->render('list', array('torrents' => $torrents, 'search' => $searchModel->words, 'categoryTag' => $iht, 'categoriesTags' => LCategory::$categoriesTags, 'totalFound' => $totalCount));
 }
开发者ID:maduhu,项目名称:openbay,代码行数:57,代码来源:MainController.php

示例7: 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;
         $countries['list'] = [];
         $countries['checked'] = [];
         $price['minValue'] = [];
         $price['maxValue'] = [];
         //$countries['list'] = $this->productRepository->getCountriesFilter($form->q);
         if (Yii::app()->request->getQuery('strana')) {
             foreach (Yii::app()->request->getQuery('strana') as $item) {
                 $countries['checked'] += [$item => $item];
             }
         }
         $price = $this->productRepository->getPricesFilter($form->q);
         if (Yii::app()->request->getQuery('minPrice')) {
             $price['minValue'] = Yii::app()->request->getQuery('minPrice');
         }
         if (Yii::app()->request->getQuery('maxPrice')) {
             $price['maxValue'] = Yii::app()->request->getQuery('maxPrice');
         }
         $this->render('search', ['category' => $category, 'searchForm' => $form, 'price' => $price, 'countries' => $countries, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
     } else {
         if ($form->category) {
             $category = StoreCategory::model()->findByPk($form->category);
             $this->redirect('/store/' . $category->type);
         }
     }
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:34,代码来源:CatalogController.php

示例8: run

 public function run()
 {
     $search = new SearchForm();
     $controller = $this->getController();
     $controller->layout = 'form';
     $controller->pageDescriptionMetaTag = false;
     //use the default Meta-Tag
     if (isset($_GET['SearchForm'])) {
         $search->attributes = $_GET['SearchForm'];
         if ($search->validate()) {
             if ($search->searchq == '') {
                 $query = '%';
             } else {
                 $query = $search->searchq;
             }
             // Ergebnis 1: alle Treffer die genau dem Suchbegriff entsprechen:
             $exactSearchResults = wortschatz::model()->exactSearch($query);
             $pages_exact = $exactSearchResults['pages'];
             $countAll_exact = $exactSearchResults['countAll'];
             $count_exact = $exactSearchResults['count'];
             $sort_exact = $exactSearchResults['sort'];
             $models_exact = $exactSearchResults['models'];
             // Ergebnis 2: alle Treffer die den Suchbegriff als Wort enthalten (enthalten auch die genauen Treffer):
             $wordSearchResults = wortschatz::model()->wordSearch($query);
             $pages_word = $wordSearchResults['pages'];
             $countAll_word = $wordSearchResults['countAll'];
             $count_word = $wordSearchResults['count'];
             $sort_word = $wordSearchResults['sort'];
             $models_word = $wordSearchResults['models'];
             // Ergebnis 3: Wort-Treffer ohne genaue Treffer (Ergebnis 2 minus Ergebnis 1):
             $cleanedResults = wortschatz::model()->removeExactResults($models_word, $models_exact);
             $models_cleaned = $cleanedResults['models'];
             // Ergebnis 4: alle LIKE-Treffer (Wortteilsuche):
             $standardSearchResults = wortschatz::model()->standardSearch($query);
             $pages_standard = $standardSearchResults['pages'];
             $countAll_standard = $standardSearchResults['countAll'];
             $count_standard = $standardSearchResults['count'];
             $sort_standard = $standardSearchResults['sort'];
             $models_standard = $standardSearchResults['models'];
             // Ergebnis 5: LIKE-Treffer ohne Worttreffer und exakte Treffer (Ergebnis 4 minus Ergebnis 2):
             if ($models_word == NULL) {
                 $models_word = $models_exact;
             }
             $cleanedLikeResults = wortschatz::model()->removeExactResults($models_standard, $models_word);
             $models_likeCleaned = $cleanedLikeResults['models'];
             if ($count_exact != 0 or $count_word != 0) {
                 $controller->render('search', array('search' => $search, 'query' => $query, 'models' => $models_cleaned, 'pages' => $pages_standard, 'countAll' => $countAll_standard, 'count' => $count_standard, 'sort' => $sort_standard, 'models_exact' => $models_exact, 'pages_exact' => $pages_exact, 'countAll_exact' => $countAll_exact, 'count_exact' => $count_exact, 'sort_exact' => $sort_exact, 'models_like' => $models_likeCleaned));
             } else {
                 if ($count_exact == 0 and $count_word == 0 and $count_standard != 0) {
                     $controller->render('search', array('errortext' => 'Der exakte Suchbegriff wurde nicht gefunden. Unscharfe Ergebnisse:<br /><br />', 'search' => $search, 'query' => $query, 'models' => $models_standard, 'pages' => $pages_standard, 'countAll' => $countAll_standard, 'count' => $count_standard, 'sort' => $sort_standard, 'models_exact' => $models_exact, 'pages_exact' => $pages_exact, 'countAll_exact' => $countAll_exact, 'count_exact' => $count_exact, 'sort_exact' => $sort_exact, 'models_like' => $models_likeCleaned));
                 } 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));
     }
 }
开发者ID:BackupTheBerlios,项目名称:swahili-dict,代码行数:61,代码来源:SearchAction.php

示例9: actionSearch

 /**
  * Поиск результатов по параметрам
  * @return mixed
  */
 public function actionSearch()
 {
     if ($this->_needRegister()) {
         $this->render('needregister');
         return;
     }
     if ((isset($_GET['clean']) || isset($_GET['newsearch'])) && Yii::app()->user->getState('searchdata')) {
         //  очистить результаты поиска и в раздел "мне нравятся"
         Yii::app()->user->setState('searchdata', null, null);
         if (isset($_GET['clean'])) {
             $this->redirect(array('anketa/mylike'));
         } else {
             //newsearch
             $this->redirect(array('anketa/search'));
         }
     }
     if (isset(Yii::app()->user->searchdata) && !Yii::app()->user->getState('mainsearch')) {
         // определить критерии поиска
         // echo Yii::app()->user->name;
         if (Yii::app()->user->isGuest) {
             $model = new Anketa();
             //(array('gender'=>''));
         } else {
             $model = Anketa::model()->findbypk(Yii::app()->user->id);
         }
         $criteria = $model->getsearchcriteria(Yii::app()->user->searchdata);
         $count = Anketa::model()->count($criteria);
         $criteria->limit = 2;
         $models = Anketa::model()->findAll($criteria);
         $this->render('2big', array('models' => $models, 'count' => $count));
     } else {
         $model = new SearchForm();
         Yii::app()->user->setState('mainsearch', 0);
         if (Yii::app()->user->hasState('saveddata')) {
             $model->attributes = Yii::app()->user->getState('saveddata');
         }
         if (isset($_POST['SearchForm'])) {
             $model->attributes = $_POST['SearchForm'];
             if ($model->validate()) {
                 if (isset($_POST['savedata'])) {
                     Yii::app()->user->setState('saveddata', $model->attributes);
                 }
                 Yii::app()->user->setState('searchdata', $model->attributes);
                 Yii::app()->user->setState('guestlikes', array());
                 $this->refresh();
             } else {
                 print_r($model->getErrors());
             }
         }
         $this->render('search', array('model' => $model));
     }
 }
开发者ID:nellka,项目名称:mebel,代码行数:56,代码来源:Anketa2Controller.php

示例10: actionSearch

    public function actionSearch()
    {
        $model = new SearchForm();
        $dataProvider = null;
        if (isset($_REQUEST['SearchForm'])) {
            $model->attributes = $_REQUEST['SearchForm'];
            if ($model->validate()) {
                $sqlCount = 'SELECT count(*)
					 FROM ' . Users::model()->tableName() . ' u 
					 WHERE realname like "%' . $model->keyword . '%"';
                $count = Yii::app()->db->createCommand($sqlCount)->queryScalar();
                /*
                 * if status is 0 it means friend request made but not yet confirmed
                 * if status is 1 it means friend request is confirmed.
                 * if status is -1 it means there is no relation of any kind between users.
                 */
                $sql = 'SELECT u.Id as id, u.realname as Name, f.Id as friendShipId,
								 IF(f.status = 0 OR f.status = 1, f.status, -1) as status,
								 IF(f.friend1 = ' . Yii::app()->user->id . ', true, false ) as requester
						FROM ' . Users::model()->tableName() . ' u 
						LEFT JOIN ' . Friends::model()->tableName() . ' f 
							ON  (f.friend1 = ' . Yii::app()->user->id . ' 
								 AND f.friend2 =  u.Id)
								 OR 
								 (f.friend1 = u.Id 
								 AND f.friend2 = ' . Yii::app()->user->id . ' ) 
						WHERE u.realname like "%' . $model->keyword . '%"';
                $dataProvider = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'sort' => array('attributes' => array('id', 'Name')), 'params' => array(CHtml::encode('SearchForm[keyword]') => $model->attributes['keyword']), 'pagination' => array('pageSize' => Yii::app()->params->itemCountInOnePage, 'params' => array(CHtml::encode('SearchForm[keyword]') => $model->attributes['keyword']))));
            }
        }
        Yii::app()->clientScript->scriptMap['jquery.js'] = false;
        Yii::app()->clientScript->scriptMap['jquery.yiigridview.js'] = false;
        $this->renderPartial('searchResults', array('model' => $model, 'dataProvider' => $dataProvider), false, true);
    }
开发者ID:Avinash1000,项目名称:traceper,代码行数:34,代码来源:UsersController.php


注:本文中的SearchForm::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。