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)); }
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)]); } } }
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()))]); } }
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)); } }
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); }
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)); }
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); } } }
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)); } }
/** * Поиск результатов по параметрам * @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)); } }
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); }