request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'test_index' ); } else { return $this->render ( 'test_index' ); } } } public function actionMockup_record() { { return $this->render ( 'mockup_record' ); } } public function actionMockup_recordstriped() { { return $this->render ( 'mockup_recordstriped' ); } } public function actionMockup_recordmapa() { { return $this->render ( 'mockup_recordmapa' ); } } public function actionMockup_recordmapb() { { return $this->render ( 'mockup_recordmapb' ); } } public function actionMockup_recordtabstop() { { return $this->render ( 'mockup_recordtabstop' ); } } public function actionIndex() { if(Yii::$app->user->isGuest) { $model = new SearchFormGuest (); } else { $model = new SearchForm (); } //$model->attributes = Yii::$app->request->get(); $request = Yii::$app->request->get(); //$get = $request->get(); // equivalent to: $get = $_GET; $filters = [ ]; /*if(Yii::$app->user->isGuest) { if (isset ( $_REQUEST ['SearchFormGuest'] )) { $searchform = $_REQUEST ['SearchFormGuest']; } else $searchform = [ ]; } else { if (isset ( $_REQUEST ['SearchForm'] )) { $searchform = $_REQUEST ['SearchForm']; } else $searchform = [ ]; } foreach ( $model->knownLParams as $kp ) { if (isset ( $searchform [$kp] ) && strlen ( $searchform [$kp] ) > 0) { if (strcasecmp ( $searchform [$kp], "---" ) > 0) $filters [$kp] = $searchform [$kp]; } if (isset ( $_REQUEST [$kp] ) && strlen ( $_REQUEST [$kp] ) > 0) { if (strcasecmp ( $_REQUEST [$kp], "---" ) > 0) $filters [$kp] = $_REQUEST [$kp]; } } foreach ( $model->knownParams as $kp ) { if (isset ( $searchform [$kp] ) && strlen ( $searchform [$kp] ) > 0) { $filters [$kp] = $searchform [$kp]; } if (isset ( $_REQUEST [$kp] ) && strlen ( $_REQUEST [$kp] ) > 0) { $filters [$kp] = $_REQUEST[$kp]; } } */ if (empty ( $q )) $q [] = "*:*".Yii::$app->params['thematicSOLRfilter']; $fqs = []; //turning get parameters into arrays $querystring = explode('&', $_SERVER['QUERY_STRING']); $params = array(); if($_SERVER['QUERY_STRING'] != "") { foreach( $querystring as $param ) { // prevent notice on explode() if $param has no '=' if (strpos($param, '=') === false) $param += '='; list($key, $value) = explode('=', $param, 2); $params[urldecode($key)][] = urldecode($value); } } //enable multi facet search and turning get parameters into arrays foreach ($params as $fieldName => $index){ $facetQueryTerm = array("key"=>$fieldName, "query"=>$fieldName.':("'.implode('" OR "',$index).'")', "tag" => $fieldName); array_push($fqs, $facetQueryTerm); } $page = 0; $rawfqs = [ ]; $escapedfqs= []; $config = SOLRQueryManager::getConfigSearch (); $query = SOLRQueryManager::createSearchQuery ( $config ); $facetnames = [ 'country', 'sampletype', 'preparationType' ]; $facetlabels = [ 'country' => 'Country', 'sampletype' => 'Sample Type', 'preparationType' => 'Preparation Type', ]; $fieldtypes = [ 'country' => 'listandsearch', 'sampletype' => 'list', 'preparationType' => 'list' ]; try { $raw_response = SOLRQueryManager::browseQuery ( $query, implode ( " AND ", $q ), $fqs, $page, $facetnames ); $docs = $raw_response->getDocuments (); $numFoundTotal = $raw_response->getNumFound (); } catch ( \Solarium\Exception\HttpException $e ) { Yii::$app->mailer->compose ()->setFrom (Yii::$app->params ['noreplyMail'] )->setTo ( Yii::$app->params ['feedbackMail'] )->setSubject ( 'Error occured' )->setTextBody ( $e . "\n q:" . implode ( " AND ", $q ) . "\nfqs:" . implode ( " ", $fqs ) . "\n facets" . implode ( " ", $facetnames ) . "\n URL built: " . Yii::$app->request->url . "\n and the user is " . Yii::$app->request->userIP )->send (); return $this->render ( '/site/error', [ "name" => "Oooops", "message" => "The SOLR instance seems to be gone.", "error" => $e ] ); } $rawfacets = $raw_response->getFacetSet (); $facets = [ ]; //var_dump($raw_response); foreach ( $facetnames as $facetName ) { $tmp = [ ]; foreach ( $rawfacets->getFacet ( $facetName ) as $doc => $count ) if (isset($rawfqs) && ! empty ( ($rawfqs) )) $tmp [] = array('facetCount' => $count, 'facetResult' => $doc); else $tmp [] = array('facetCount' => $count, 'facetResult' => $doc); arsort($tmp); //descending sorting //TODO: Sortierung nach facetCount, im Moment Reihenfolge im Array umgedreht, da er standardmäßig nach dem ersten sortiert $facets [$facetName] = array_slice($tmp, 0, 10); // die ersten 10 } if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'index', ['facets' => $facets, 'facetlabels' => $facetlabels, 'docs'=> $docs, ] ); } else { return $this->render ( 'index', ['filters' => $filters, // 'model' => $model, 'numFoundTotal' => $numFoundTotal, 'facets' => $facets, 'facetlabels' => $facetlabels, 'fieldtypes' => $fieldtypes, 'docs'=> $docs, ] ); } } public function actionMockup_results_canis() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_canis' ); } else { return $this->render ( 'mockup_results_canis' ); } } } public function actionMockup_results_crepis() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_crepis' ); } else { return $this->render ( 'mockup_results_crepis' ); } } } public function actionMockup_results_pinnularia() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_pinnularia' ); } else { return $this->render ( 'mockup_results_pinnularia' ); } } } public function actionMockup_results_toxicodendron() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_toxicodendron' ); } else { return $this->render ( 'mockup_results_toxicodendron' ); } } } public function actionMockup_results_avena() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_avena' ); } else { return $this->render ( 'mockup_results_avena' ); } } } public function actionMockup_results_esample() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_esample' ); } else { return $this->render ( 'mockup_results_esample' ); } } } public function actionMockup_results_gigantobilharzia() { { if (Yii::$app->request->isPjax) { throw new \ErrorException (); return $this->renderPartial ( 'mockup_results_gigantobilharzia' ); } else { return $this->render ( 'mockup_results_gigantobilharzia' ); } } } }