dropDownAttributes )) {
$this->dropDownAttributes = array ();
foreach ( $model->getParameters () as $name => $list ) {
if (isset ( $list ['type'] ) && $list ['type'] == 'select') {
array_push ( $this->dropDownAttributes, $name );
}
}
}
if (! isset ( $this->selectionLists )) {
$this->selectionLists = FormSelectionQueryManager::getAllLists ( $this->dropDownAttributes, $model->getSelectionListNonChosen () );
}
}
// ------------------- controller actions ----------------
/**
* this does all the thing for searching the index:
*/
public function actionIndex() {
// Yii::info ( "actionIndexSearch" );
$model = new SearchForm ();
$model->attributes = Yii::$app->request->post ();
$modelwebsite = new WebsitesearchForm ();
// we get all the lists for the drop-down lists in the form -- why??
try{
$this->collectDropDownAttributesLists ( $model );
} catch (\Solarium\Exception\HttpException $e) {
Yii::$app->mailer->compose()
->setFrom('errorggbn@bgbm.org')
->setTo('p.kelbert@bgbm.org')
->setSubject('Error occured')
->setTextBody($e)
->send();
return $this->render('/site/error', ["name"=>"Oooops",
"message"=>"The SOLR instance seems to be gone.","exception"=>$e]);
}
// Rukeia 23-02-2013: we store all form parameter values in $filters
$filters = array ();
if (isset ( $_REQUEST ['SearchForm'] )) {
$searchform = $_REQUEST ['SearchForm'];
} else
$searchform = [ ];
if (isset ( $searchform ['fullScientificName'] ) && strlen ( $searchform ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $searchform ['fullScientificName'];
}
if (isset ( $_REQUEST ['fullScientificName'] ) && strlen ( $_REQUEST ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $_REQUEST ['fullScientificName'];
}
if (isset ( $searchform ['familyName'] ) && strlen ( $searchform ['familyName'] ) > 0) {
$filters ['familyName'] = $searchform ['familyName'];
}
if (isset ( $_REQUEST ['familyName'] ) && strlen ( $_REQUEST ['familyName'] ) > 0) {
$filters ['familyName'] = $_REQUEST ['familyName'];
}
if (isset ( $searchform ['kingdom'] ) && strlen ( $searchform ['kingdom'] ) > 0) {
$filters ['kingdom'] = $searchform ['kingdom'];
}
if (isset ( $_REQUEST ['kingdom'] ) && strlen ( $_REQUEST ['kingdom'] ) > 0) {
$filters ['kingdom'] = $_REQUEST ['kingdom'];
}
if (isset ( $searchform ['country'] ) && strlen ( $searchform ['country'] ) > 0) {
if (strcasecmp ( $searchform ['country'], "---" ) > 0)
$filters ['country'] = $searchform ['country'];
}
if (isset ( $_REQUEST ['country'] ) && strlen ( $_REQUEST ['country'] ) > 0) {
if (strcasecmp ( $_REQUEST ['country'], "---" ) > 0)
$filters ['country'] = $_REQUEST ['country'];
}
if (isset ( $searchform ['countrycode'] ) && strlen ( $searchform ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $searchform ['countrycode'];
}
if (isset ( $_REQUEST ['countrycode'] ) && strlen ( $_REQUEST ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $_REQUEST ['countrycode'];
}
if (isset ( $searchform ['id'] ) && strlen ( $searchform ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $searchform ['id'];
}
if (isset ( $_REQUEST ['id'] ) && strlen ( $_REQUEST ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $_REQUEST ['id'];
}
if (isset ( $searchform ['unitID'] ) && strlen ( $searchform ['unitID'] ) > 0) {
$filters ['unitID'] = $searchform ['unitID'];
}
if (isset ( $_REQUEST ['unitID'] ) && strlen ( $_REQUEST ['unitID'] ) > 0) {
$filters ['unitID'] = $_REQUEST ['unitID'];
}
if (isset ( $_REQUEST ['geneticlocus'] ) && strlen ( $_REQUEST ['geneticlocus'] ) > 0) {
if (strcasecmp ( $_REQUEST ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $_REQUEST ['geneticlocus'];
}
if (isset ( $searchform ['geneticlocus'] ) && strlen ( $searchform ['geneticlocus'] ) > 0) {
if (strcasecmp ( $searchform ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $searchform ['geneticlocus'];
}
if (isset ( $_REQUEST ['continent'] ) && strlen ( $_REQUEST ['continent'] ) > 0) {
if (strcasecmp ( $_REQUEST ['continent'], "---" ) > 0)
$filters ['continent'] = $_REQUEST ['continent'];
}
if (isset ( $searchform ['continent'] ) && strlen ( $searchform ['continent'] ) > 0) {
if (strcasecmp ( $searchform ['continent'], "---" ) > 0)
$filters ['continent'] = $searchform ['continent'];
}
if (isset ( $_REQUEST ['sea'] ) && strlen ( $_REQUEST ['sea'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sea'], "---" ) > 0)
$filters ['sea'] = $_REQUEST ['sea'];
}
if (isset ( $searchform ['sea'] ) && strlen ( $searchform ['sea'] ) > 0) {
if (strcasecmp ( $searchform ['sea'], "---" ) > 0)
$filters ['sea'] = $searchform ['sea'];
}
if (isset ( $_REQUEST ['ocean'] ) && strlen ( $_REQUEST ['ocean'] ) > 0) {
if (strcasecmp ( $_REQUEST ['ocean'], "---" ) > 0)
$filters ['ocean'] = $_REQUEST ['ocean'];
}
if (isset ( $searchform ['ocean'] ) && strlen ( $searchform ['ocean'] ) > 0) {
if (strcasecmp ( $searchform ['ocean'], "---" ) > 0)
$filters ['ocean'] = $searchform ['ocean'];
}
if (isset ( $_REQUEST ['locality'] ) && strlen ( $_REQUEST ['locality'] ) > 0) {
$filters ['locality'] = $_REQUEST ['locality'];
}
if (isset ( $searchform ['locality'] ) && strlen ( $searchform ['locality'] ) > 0) {
$filters ['locality'] = $searchform ['locality'];
}
if (isset ( $_REQUEST ['collectors'] ) && strlen ( $_REQUEST ['collectors'] ) > 0) {
$filters ['collectors'] = $_REQUEST ['collectors'];
}
if (isset ( $searchform ['collectors'] ) && strlen ( $searchform ['collectors'] ) > 0) {
$filters ['collectors'] = $searchform ['collectors'];
}
if (isset ( $searchform ['collectornumber'] ) && strlen ( $searchform ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $searchform ['collectornumber'];
}
if (isset ( $_REQUEST ['collectornumber'] ) && strlen ( $_REQUEST ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $_REQUEST ['collectornumber'];
}
if (isset ( $_REQUEST ['institution'] ) && strlen ( $_REQUEST ['institution'] ) > 0) {
$filters ['institution'] = $_REQUEST ['institution'];
}
if (isset ( $searchform ['institution'] ) && strlen ( $searchform ['institution'] ) > 0) {
$filters ['institution'] = $searchform ['institution'];
}
if (isset ( $_REQUEST ['voucherCol'] ) && strlen ( $_REQUEST ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $_REQUEST ['voucherCol'];
}
if (isset ( $searchform ['voucherCol'] ) && strlen ( $searchform ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $searchform ['voucherCol'];
}
if (isset ( $searchform ['sampletype'] ) && strlen ( $searchform ['sampletype'] ) > 0) {
if (strcasecmp ( $searchform ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $searchform ['sampletype'];
}
if (isset ( $_REQUEST ['sampletype'] ) && strlen ( $_REQUEST ['sampletype'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $_REQUEST ['sampletype'];
}
if (isset ( $_REQUEST ['collectionYearFrom'] ) && strlen ( $_REQUEST ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $_REQUEST ['collectionYearFrom'];
}
if (isset ( $searchform ['collectionYearFrom'] ) && strlen ( $searchform ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $searchform ['collectionYearFrom'];
}
if (isset ( $_REQUEST ['collectionYearTo'] ) && strlen ( $_REQUEST ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $_REQUEST ['collectionYearTo'];
}
if (isset ( $searchform ['collectionYearTo'] ) && strlen ( $searchform ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $searchform ['collectionYearTo'];
}
if (isset ( $_REQUEST ['latitudeTo'] ) && strlen ( $_REQUEST ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $_REQUEST ['latitudeTo'];
}
if (isset ( $searchform ['latitudeTo'] ) && strlen ( $searchform ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $searchform ['latitudeTo'];
}
if (isset ( $_REQUEST ['latitudeFrom'] ) && strlen ( $_REQUEST ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $_REQUEST ['latitudeFrom'];
}
if (isset ( $searchform ['latitudeFrom'] ) && strlen ( $searchform ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $searchform ['latitudeFrom'];
}
if (isset ( $_REQUEST ['longitudeTo'] ) && strlen ( $_REQUEST ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $_REQUEST ['longitudeTo'];
}
if (isset ( $searchform ['longitudeTo'] ) && strlen ( $searchform ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $searchform ['longitudeTo'];
}
if (isset ( $_REQUEST ['longitudeFrom'] ) && strlen ( $_REQUEST ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $_REQUEST ['longitudeFrom'];
}
if (isset ( $searchform ['longitudeFrom'] ) && strlen ( $searchform ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $searchform ['longitudeFrom'];
}
if (isset ( $_REQUEST ['cites'] ) && strlen ( $_REQUEST ['cites'] ) > 0) {
$filters ['cites'] = $_REQUEST ['cites'];
}
if (isset ( $searchform ['cites'] ) && strlen ( $searchform ['cites'] ) > 0) {
$filters ['cites'] = $searchform ['cites'];
}
$submitWebsearch = Yii::$app->getUrlManager ()->createUrl ( [
'websitesearch/search'
] );
// Yii::info ( "Filters: " . implode ( $filters, "\n" ) );
if ($filters) {
if ($model->validate ()) {
$this->redirect ( Url::to ( array_merge ( [
'search/result'
], $filters ) ) );
} else {
$errors = $model->errors;
return $this->render ( 'show/listView', [
'model' => $model,
'selectionLists' => $this->selectionLists,
"filters" => $filters,
"errors" => $errors,
'submitWebsearch' => $submitWebsearch
] );
}
}
try{
return $this->render ( 'search', array (
'model' => $model,
'selectionLists' => $this->selectionLists,
'modelwebsite' => $modelwebsite,
'submitWebsearch' => $submitWebsearch
) );
} catch (\yii\base\ErrorException $e) {
// if(strpos($e, "SOLR")!=0)
Yii::$app->mailer->compose()
->setFrom('errorggbn@bgbm.org')
->setTo('p.kelbert@bgbm.org')
->setSubject('Error occured')
->setTextBody($e)
->send();
return $this->render('/site/error', ["name"=>"Oooops",
"message"=>"Something went wrong.","exception"=>$e]);
}
}
public function actionResult() {
// Yii::info ( "actionResult" );
$filters = [ ];
$model = new SearchForm ();
$model->attributes = Yii::$app->request->post ();
// foreach ( $model->attributes as $att )
// Yii::info ( "ATTR" + $att );
if (isset ( $_REQUEST ['SearchForm'] )) {
$searchform = $_REQUEST ['SearchForm'];
} else
$searchform = [ ];
if (isset ( $searchform ['fullScientificName'] ) && strlen ( $searchform ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $searchform ['fullScientificName'];
}
if (isset ( $_REQUEST ['fullScientificName'] ) && strlen ( $_REQUEST ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $_REQUEST ['fullScientificName'];
}
if (isset ( $searchform ['familyName'] ) && strlen ( $searchform ['familyName'] ) > 0) {
$filters ['familyName'] = $searchform ['familyName'];
}
if (isset ( $_REQUEST ['familyName'] ) && strlen ( $_REQUEST ['familyName'] ) > 0) {
$filters ['familyName'] = $_REQUEST ['familyName'];
}
if (isset ( $searchform ['genus'] ) && strlen ( $searchform ['genus'] ) > 0) {
$filters ['genus'] = $searchform ['genus'];
}
if (isset ( $_REQUEST ['genus'] ) && strlen ( $_REQUEST ['genus'] ) > 0) {
$filters ['genus'] = $_REQUEST ['genus'];
}
if (isset ( $searchform ['orderName'] ) && strlen ( $searchform ['orderName'] ) > 0) {
$filters ['orderName'] = $searchform ['orderName'];
}
if (isset ( $_REQUEST ['orderName'] ) && strlen ( $_REQUEST ['orderName'] ) > 0) {
$filters ['orderName'] = $_REQUEST ['orderName'];
}
if (isset ( $searchform ['className'] ) && strlen ( $searchform ['className'] ) > 0) {
$filters ['className'] = $searchform ['className'];
}
if (isset ( $_REQUEST ['className'] ) && strlen ( $_REQUEST ['className'] ) > 0) {
$filters ['className'] = $_REQUEST ['className'];
}
if (isset ( $searchform ['phylumName'] ) && strlen ( $searchform ['phylumName'] ) > 0) {
$filters ['phylumName'] = $searchform ['phylumName'];
}
if (isset ( $_REQUEST ['phylumName'] ) && strlen ( $_REQUEST ['phylumName'] ) > 0) {
$filters ['phylumName'] = $_REQUEST ['phylumName'];
}
if (isset ( $searchform ['kingdom'] ) && strlen ( $searchform ['kingdom'] ) > 0) {
$filters ['kingdom'] = $searchform ['kingdom'];
}
if (isset ( $_REQUEST ['kingdom'] ) && strlen ( $_REQUEST ['kingdom'] ) > 0) {
$filters ['kingdom'] = $_REQUEST ['kingdom'];
}
if (isset ( $searchform ['country'] ) && strlen ( $searchform ['country'] ) > 0) {
if (strcasecmp ( $searchform ['country'], "---" ) > 0)
$filters ['country'] = $searchform ['country'];
}
if (isset ( $_REQUEST ['country'] ) && strlen ( $_REQUEST ['country'] ) > 0) {
if (strcasecmp ( $_REQUEST ['country'], "---" ) > 0)
$filters ['country'] = $_REQUEST ['country'];
}
if (isset ( $searchform ['countrycode'] ) && strlen ( $searchform ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $searchform ['countrycode'];
}
if (isset ( $_REQUEST ['countrycode'] ) && strlen ( $_REQUEST ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $_REQUEST ['countrycode'];
}
if (isset ( $searchform ['id'] ) && strlen ( $searchform ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $searchform ['id'];
}
if (isset ( $_REQUEST ['id'] ) && strlen ( $_REQUEST ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $_REQUEST ['id'];
}
if (isset ( $searchform ['unitID'] ) && strlen ( $searchform ['unitID'] ) > 0) {
$filters ['unitID'] = $searchform ['unitID'];
}
if (isset ( $_REQUEST ['unitID'] ) && strlen ( $_REQUEST ['unitID'] ) > 0) {
$filters ['unitID'] = $_REQUEST ['unitID'];
}
if (isset ( $_REQUEST ['geneticlocus'] ) && strlen ( $_REQUEST ['geneticlocus'] ) > 0) {
if (strcasecmp ( $_REQUEST ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $_REQUEST ['geneticlocus'];
}
if (isset ( $searchform ['geneticlocus'] ) && strlen ( $searchform ['geneticlocus'] ) > 0) {
if (strcasecmp ( $searchform ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $searchform ['geneticlocus'];
}
if (isset ( $_REQUEST ['continent'] ) && strlen ( $_REQUEST ['continent'] ) > 0) {
if (strcasecmp ( $_REQUEST ['continent'], "---" ) > 0)
$filters ['continent'] = $_REQUEST ['continent'];
}
if (isset ( $searchform ['continent'] ) && strlen ( $searchform ['continent'] ) > 0) {
if (strcasecmp ( $searchform ['continent'], "---" ) > 0)
$filters ['continent'] = $searchform ['continent'];
}
if (isset ( $_REQUEST ['sea'] ) && strlen ( $_REQUEST ['sea'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sea'], "---" ) > 0)
$filters ['sea'] = $_REQUEST ['sea'];
}
if (isset ( $searchform ['sea'] ) && strlen ( $searchform ['sea'] ) > 0) {
if (strcasecmp ( $searchform ['sea'], "---" ) > 0)
$filters ['sea'] = $searchform ['sea'];
}
if (isset ( $_REQUEST ['ocean'] ) && strlen ( $_REQUEST ['ocean'] ) > 0) {
if (strcasecmp ( $_REQUEST ['ocean'], "---" ) > 0)
$filters ['ocean'] = $_REQUEST ['ocean'];
}
if (isset ( $searchform ['ocean'] ) && strlen ( $searchform ['ocean'] ) > 0) {
if (strcasecmp ( $searchform ['ocean'], "---" ) > 0)
$filters ['ocean'] = $searchform ['ocean'];
}
if (isset ( $_REQUEST ['locality'] ) && strlen ( $_REQUEST ['locality'] ) > 0) {
$filters ['locality'] = $_REQUEST ['locality'];
}
if (isset ( $searchform ['locality'] ) && strlen ( $searchform ['locality'] ) > 0) {
$filters ['locality'] = $searchform ['locality'];
}
if (isset ( $_REQUEST ['collectors'] ) && strlen ( $_REQUEST ['collectors'] ) > 0) {
$filters ['collectors'] = $_REQUEST ['collectors'];
}
if (isset ( $searchform ['collectors'] ) && strlen ( $searchform ['collectors'] ) > 0) {
$filters ['collectors'] = $searchform ['collectors'];
}
if (isset ( $searchform ['collectornumber'] ) && strlen ( $searchform ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $searchform ['collectornumber'];
}
if (isset ( $_REQUEST ['collectornumber'] ) && strlen ( $_REQUEST ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $_REQUEST ['collectornumber'];
}
if (isset ( $_REQUEST ['institution'] ) && strlen ( $_REQUEST ['institution'] ) > 0) {
$filters ['institution'] = $_REQUEST ['institution'];
}
if (isset ( $searchform ['institution'] ) && strlen ( $searchform ['institution'] ) > 0) {
$filters ['institution'] = $searchform ['institution'];
}
if (isset ( $_REQUEST ['voucherCol'] ) && strlen ( $_REQUEST ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $_REQUEST ['voucherCol'];
}
if (isset ( $searchform ['voucherCol'] ) && strlen ( $searchform ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $searchform ['voucherCol'];
}
if (isset ( $searchform ['sampletype'] ) && strlen ( $searchform ['sampletype'] ) > 0) {
if (strcasecmp ( $searchform ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $searchform ['sampletype'];
}
if (isset ( $_REQUEST ['sampletype'] ) && strlen ( $_REQUEST ['sampletype'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $_REQUEST ['sampletype'];
}
if (isset ( $_REQUEST ['collectionYearFrom'] ) && strlen ( $_REQUEST ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $_REQUEST ['collectionYearFrom'];
}
if (isset ( $searchform ['collectionYearFrom'] ) && strlen ( $searchform ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $searchform ['collectionYearFrom'];
}
if (isset ( $_REQUEST ['collectionYearTo'] ) && strlen ( $_REQUEST ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $_REQUEST ['collectionYearTo'];
}
if (isset ( $searchform ['collectionYearTo'] ) && strlen ( $searchform ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $searchform ['collectionYearTo'];
}
if (isset ( $_REQUEST ['latitudeTo'] ) && strlen ( $_REQUEST ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $_REQUEST ['latitudeTo'];
}
if (isset ( $searchform ['latitudeTo'] ) && strlen ( $searchform ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $searchform ['latitudeTo'];
}
if (isset ( $_REQUEST ['latitudeFrom'] ) && strlen ( $_REQUEST ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $_REQUEST ['latitudeFrom'];
}
if (isset ( $searchform ['latitudeFrom'] ) && strlen ( $searchform ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $searchform ['latitudeFrom'];
}
if (isset ( $_REQUEST ['longitudeTo'] ) && strlen ( $_REQUEST ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $_REQUEST ['longitudeTo'];
}
if (isset ( $searchform ['longitudeTo'] ) && strlen ( $searchform ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $searchform ['longitudeTo'];
}
if (isset ( $_REQUEST ['longitudeFrom'] ) && strlen ( $_REQUEST ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $_REQUEST ['longitudeFrom'];
}
if (isset ( $searchform ['longitudeFrom'] ) && strlen ( $searchform ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $searchform ['longitudeFrom'];
}
if (isset ( $_REQUEST ['cites'] ) && strlen ( $_REQUEST ['cites'] ) > 0) {
$filters ['cites'] = $_REQUEST ['cites'];
}
if (isset ( $searchform ['cites'] ) && strlen ( $searchform ['cites'] ) > 0) {
$filters ['cites'] = $searchform ['cites'];
}
// HERE THE TRICK FOR THE NICE URL
if ($filters && isset ( $_REQUEST ['SearchForm'] )) {
$this->redirect ( Url::to ( array_merge ( [
'search/result'
], $filters ) ) );
} else
return $this->performSearch ( $filters, $model );
}
private function performSearch($filters, $model) {
// Yii::info ( "actionperformSearch" );
// we get all the lists for the drop-down lists in the form -- why??
$this->collectDropDownAttributesLists ( $model );
$submitURL = $this->createUrl ( [
'search/create'
], $filters );
// validate user input
if ($model->validate ()) {
$config = SOLRQueryManager::getConfigDetails ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$fq = "{!join from=lowestTripleIDs to=tripleidstoreid fromIndex=" . Yii::$app->params ['solrcorename'] . "}";
$q = [ ];
$filterInstitution = false;
$filterVouchercol = false;
foreach ( $filters as $key => $value ) {
$value = str_replace ( " ", "\ ", $value );
$value = str_replace ( "(", "\(", $value );
$value = str_replace ( ")", "\)", $value );
$value = str_replace ( ":", "\:", $value );
if ($key == "institution") {
$q [] = SOLRQueryManager::getPartialQuery ( $key, $value, $filters, False );
$filterInstitution = true;
}
if ($key == "voucherCol") {
$q [] = SOLRQueryManager::getPartialQuery ( $key, $value, $filters, False );
$filterVouchercol = true;
}
}
if (! $filterInstitution && ! $filterVouchercol)
$q = [
"*:*"
];
$raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, implode ( " AND ", $q ), $fq, $filters, False );
$doc = $raw_response->getDocuments ();
$numFound = $raw_response->getNumFound ();
return $this->render ( 'show/listView', array (
"model" => $model,
'response' => $doc,
// 'shownAttributes' => $this->shownAttributes,
'keyForLink' => $this->key_link,
'recordFilters' => $this->recordFilters,
'item_count' => $numFound,
'selectionLists' => $this->selectionLists,
'submitURL' => $this->submitURL,
'filters' => $filters
) ); // Rukeia 26-03-2015: hinzugefügt, damit listView auch auf selectionLists zugreifen kann
// 'submitURL'=>$this->$submitURL,
} else {
$errors = $model->errors;
return $this->render ( 'search/result', [
"model" => $model,
"filters" => $filters,
"errors" => $errors
] );
}
}
public function createUrl($destination, $formParameters) {
$nonEmptyFormParameters = array_filter ( $formParameters, 'strlen' );
unset ( $nonEmptyFormParameters ['yt0'] );
return Yii::$app->getUrlManager ()->createUrl ( $destination, $nonEmptyFormParameters );
}
public function actionRecord() {
$model = new SearchForm ();
$model->attributes = Yii::$app->request->post ();
// get the values that came from url back to an array
$requestedAttributes = $this->requestedAttributes;
if ($model->validate ()) {
$output = SingleRecordManager::createOutput ( $requestedAttributes, $model );
if (isset ( $output ) && sizeof ( $output ) > 0) {
$output ['display'] = 'tab';
return $this->render ( 'show/recordViewTabs', $output );
} else
return "Nothing found, check your tripleid!";
} else {
$errors = $model->errors;
return $this->render ( 'search/result', [
"filters" => $filters,
"errors" => $errors,
"model" => $model
] );
}
}
public function getTripleID($tid){
$config = SOLRQueryManager::getConfigCore ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, "tripleidstoreid:".$tid, null, null, False );
$doc = $raw_response->getDocuments ();
foreach ($doc as $d)
return [$d->unitID, $d->collectioncode,$d->institutioncode];
}
public function actionBrowse() {
// Yii::info ( "actionIndexbrowse" );
$elts = Yii::$app->request->get ();
if (isset ( $elts ["page"] ))
$page = $elts ["page"];
else
$page = 0;
$fqs = [ ];
$q = [ ];
$rawfqs = [ ];
$filters = [
"recordbasis",
"fullScientificName",
"familyName",
"unitID",
"institutioncode",
"collectioncode",
"country",
"institution",
"voucherCol",
"sampletype"
];
foreach ( $filters as $filter ) {
if (isset ( $elts [$filter] )) {
$rawfq = $elts [$filter];
$rawfqs [] = $filter . "=" . $rawfq;
$fq = str_replace ( " ", "\ ", $rawfq );
$fq = str_replace ( "(", "\(", $fq );
$fq = str_replace ( ")", "\)", $fq );
$fq = str_replace ( ":", "\:", $fq );
$fq = str_replace ( "'", "\'", $fq );
$fq = str_replace ( "[", "\[", $fq );
$fq = str_replace ( "]", "\]", $fq );
$fq = str_replace ( "+", "\+", $fq );
$fqs [] = $filter . ":" . $fq;
$tmp = SOLRQueryManager::getPartialQuery ( $filter, $fq, $filters, False );
// echo $tmp;
$q [] = $tmp;
}
}
if (empty ( $q ))
$q [] = "*:*";
$filters = [ ];
// $config = SOLRQueryManager::getConfigDetails ();
$config = SOLRQueryManager::getConfigCore ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$sortScientificName = "fullScientificName_asc";
$sortUnitID = "unitID_asc";
$sortRecordbasis = "recordbasis_asc";
$sortInstitutioncode = "institutioncode_asc";
$sortCollectioncode = "collectioncode_asc";
if (isset ( $elts ["sort"] )) {
$field = explode ( "_", $elts ["sort"] )[0];
$direction = explode ( "_", $elts ["sort"] )[1];
$query->addSort ( $field, $direction );
switch ($field) {
case "fullScientificName" :
if ($direction === "asc")
$sortScientificName = "fullScientificName_desc";
else
$sortScientificName = "fullScientificName_asc";
break;
case "recordbasis" :
if ($direction === "asc")
$sortRecordbasis = "recordbasis_desc";
else
$sortRecordbasis = "recordbasis_asc";
break;
case "UnitID" :
if ($direction === "asc")
$sortUnitID = "UnitID_desc";
else
$sortUnitID = "UnitID_asc";
break;
case "institutioncode" :
if ($direction === "asc")
$sortInstitutioncode = "institutioncode_desc";
else
$sortInstitutioncode = "institutioncode_asc";
break;
case "collectioncode" :
if ($direction === "asc")
$sortCollectioncode = "collectioncode_desc";
else
$sortCollectioncode = "collectioncode_asc";
break;
default :
$sortScientificName = "fullScientificName_asc";
$sortUnitID = "unitID_asc";
$sortRecordbasis = "recordbasis_asc";
$sortInstitutioncode = "institutioncode_asc";
$sortCollectioncode = "collectioncode_asc";
}
}
$facetnames = [
'country',
'institution',
'recordbasis',
'sampletype'
];
try{
$raw_response = SOLRQueryManager::browseQuery ( $query, implode ( " AND ", $q ), $fqs, $page, $facetnames );
} catch (\Solarium\Exception\HttpException $e) {
Yii::$app->mailer->compose()
->setFrom('errorggbn@bgbm.org')
->setTo('p.kelbert@bgbm.org')
->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 = [ ];
foreach ( $facetnames as $fname ) {
$tmp = [
"";
$facets [$fname] = implode ( "", $tmp );
}
$doc = $raw_response->getDocuments ();
$lowestDoc=[];
foreach ($doc as $unitdoc){
$lowestUnits=$unitdoc->lowestTripleIDs;
$currentID=$unitdoc->tripleidstoreid;
if(in_array($currentID, $lowestUnits)){
$lowestDoc[$currentID]=[$unitdoc->unitID, $unitdoc->collectioncode,$unitdoc->institutioncode];
}
else{
$lowestDoc[$currentID]=$this->getTripleID($lowestUnits[0]);
}
}
$numFound = $raw_response->getNumFound ();
$nbPages = $numFound / Yii::$app->params ['listPerPage'];
$pages = new Pagination ( [
'totalCount' => $numFound,
'pageSize' => Yii::$app->params ['listPerPage']
] );
$from = Yii::$app->params ['listPerPage'] * $page;
$to = $from + Yii::$app->params ['listPerPage'];
if (sizeof ( $rawfqs ) > 0)
return $this->render ( 'browse', [
"lowestDoc"=>$lowestDoc,
"doc" => $doc,
"fq" => implode ( "&", $rawfqs ),
"pages" => $pages,
"page" => $page,
"sortScientificName" => $sortScientificName,
"sortRecordbasis" => $sortRecordbasis,
"sortInstitutioncode" => $sortInstitutioncode,
"sortUnitID" => $sortUnitID,
"sortCollectioncode" => $sortCollectioncode,
"facets" => $facets,
"recordsFrom" => $from,
"recordsTo" => $to,
"recordsTotal" => $numFound
] );
else
return $this->render ( 'browse', [
"lowestDoc"=>$lowestDoc,
"doc" => $doc,
"pages" => $pages,
"page" => $page,
"sortScientificName" => $sortScientificName,
"sortRecordbasis" => $sortRecordbasis,
"sortInstitutioncode" => $sortInstitutioncode,
"sortUnitID" => $sortUnitID,
"sortCollectioncode" => $sortCollectioncode,
"facets" => $facets,
"recordsFrom" => $from,
"recordsTo" => $to,
"recordsTotal" => $numFound
] );
}
dropDownAttributes )) {
$this->dropDownAttributes = array ();
foreach ( $model->getParameters () as $name => $list ) {
if (isset ( $list ['type'] ) && $list ['type'] == 'select') {
array_push ( $this->dropDownAttributes, $name );
}
}
}
if (! isset ( $this->selectionLists )) {
$this->selectionLists = FormSelectionQueryManager::getAllLists ( $this->dropDownAttributes, $model->getSelectionListNonChosen () );
}
}
// ------------------- controller actions ----------------
/**
* this does all the thing for searching the index:
*/
public function actionIndex() {
Yii::info ( "actionIndexSearch" );
$model = new SearchForm ();
$model->attributes = Yii::$app->request->post ();
$modelwebsite = new WebsitesearchForm();
// we get all the lists for the drop-down lists in the form -- why??
$this->collectDropDownAttributesLists ( $model );
// Rukeia 23-02-2013: we store all form parameter values in $filters
$filters = array ();
if (isset ( $_REQUEST ['SearchForm'] )) {
$searchform = $_REQUEST ['SearchForm'];
} else
$searchform = [ ];
if (isset ( $searchform ['fullScientificName'] ) && strlen ( $searchform ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $searchform ['fullScientificName'];
}
if (isset ( $_REQUEST ['fullScientificName'] ) && strlen ( $_REQUEST ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $_REQUEST ['fullScientificName'];
}
if (isset ( $searchform ['familyName'] ) && strlen ( $searchform ['familyName'] ) > 0) {
$filters ['familyName'] = $searchform ['familyName'];
}
if (isset ( $_REQUEST ['familyName'] ) && strlen ( $_REQUEST ['familyName'] ) > 0) {
$filters ['familyName'] = $_REQUEST ['familyName'];
}
if (isset ( $searchform ['kingdom'] ) && strlen ( $searchform ['kingdom'] ) > 0) {
$filters ['kingdom'] = $searchform ['kingdom'];
}
if (isset ( $_REQUEST ['kingdom'] ) && strlen ( $_REQUEST ['kingdom'] ) > 0) {
$filters ['kingdom'] = $_REQUEST ['kingdom'];
}
if (isset ( $searchform ['country'] ) && strlen ( $searchform ['country'] ) > 0) {
if (strcasecmp ( $searchform ['country'], "---" ) > 0)
$filters ['country'] = $searchform ['country'];
}
if (isset ( $_REQUEST ['country'] ) && strlen ( $_REQUEST ['country'] ) > 0) {
if (strcasecmp ( $_REQUEST ['country'], "---" ) > 0)
$filters ['country'] = $_REQUEST ['country'];
}
if (isset ( $searchform ['countrycode'] ) && strlen ( $searchform ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $searchform ['countrycode'];
}
if (isset ( $_REQUEST ['countrycode'] ) && strlen ( $_REQUEST ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $_REQUEST ['countrycode'];
}
if (isset ( $searchform ['id'] ) && strlen ( $searchform ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $searchform ['id'];
}
if (isset ( $_REQUEST ['id'] ) && strlen ( $_REQUEST ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $_REQUEST ['id'];
}
if (isset ( $searchform ['unitID'] ) && strlen ( $searchform ['unitID'] ) > 0) {
$filters ['unitID'] = $searchform ['unitID'];
}
if (isset ( $_REQUEST ['unitID'] ) && strlen ( $_REQUEST ['unitID'] ) > 0) {
$filters ['unitID'] = $_REQUEST ['unitID'];
}
if (isset ( $_REQUEST ['geneticlocus'] ) && strlen ( $_REQUEST ['geneticlocus'] ) > 0) {
if (strcasecmp ( $_REQUEST ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $_REQUEST ['geneticlocus'];
}
if (isset ( $searchform ['geneticlocus'] ) && strlen ( $searchform ['geneticlocus'] ) > 0) {
if (strcasecmp ( $searchform ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $searchform ['geneticlocus'];
}
if (isset ( $_REQUEST ['continent'] ) && strlen ( $_REQUEST ['continent'] ) > 0) {
if (strcasecmp ( $_REQUEST ['continent'], "---" ) > 0)
$filters ['continent'] = $_REQUEST ['continent'];
}
if (isset ( $searchform ['continent'] ) && strlen ( $searchform ['continent'] ) > 0) {
if (strcasecmp ( $searchform ['continent'], "---" ) > 0)
$filters ['continent'] = $searchform ['continent'];
}
if (isset ( $_REQUEST ['sea'] ) && strlen ( $_REQUEST ['sea'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sea'], "---" ) > 0)
$filters ['sea'] = $_REQUEST ['sea'];
}
if (isset ( $searchform ['sea'] ) && strlen ( $searchform ['sea'] ) > 0) {
if (strcasecmp ( $searchform ['sea'], "---" ) > 0)
$filters ['sea'] = $searchform ['sea'];
}
if (isset ( $_REQUEST ['ocean'] ) && strlen ( $_REQUEST ['ocean'] ) > 0) {
if (strcasecmp ( $_REQUEST ['ocean'], "---" ) > 0)
$filters ['ocean'] = $_REQUEST ['ocean'];
}
if (isset ( $searchform ['ocean'] ) && strlen ( $searchform ['ocean'] ) > 0) {
if (strcasecmp ( $searchform ['ocean'], "---" ) > 0)
$filters ['ocean'] = $searchform ['ocean'];
}
if (isset ( $_REQUEST ['locality'] ) && strlen ( $_REQUEST ['locality'] ) > 0) {
$filters ['locality'] = $_REQUEST ['locality'];
}
if (isset ( $searchform ['locality'] ) && strlen ( $searchform ['locality'] ) > 0) {
$filters ['locality'] = $searchform ['locality'];
}
if (isset ( $_REQUEST ['collectors'] ) && strlen ( $_REQUEST ['collectors'] ) > 0) {
$filters ['collectors'] = $_REQUEST ['collectors'];
}
if (isset ( $searchform ['collectors'] ) && strlen ( $searchform ['collectors'] ) > 0) {
$filters ['collectors'] = $searchform ['collectors'];
}
if (isset ( $searchform ['collectornumber'] ) && strlen ( $searchform ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $searchform ['collectornumber'];
}
if (isset ( $_REQUEST ['collectornumber'] ) && strlen ( $_REQUEST ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $_REQUEST ['collectornumber'];
}
if (isset ( $_REQUEST ['institution'] ) && strlen ( $_REQUEST ['institution'] ) > 0) {
$filters ['institution'] = $_REQUEST ['institution'];
}
if (isset ( $searchform ['institution'] ) && strlen ( $searchform ['institution'] ) > 0) {
$filters ['institution'] = $searchform ['institution'];
}
if (isset ( $_REQUEST ['voucherCol'] ) && strlen ( $_REQUEST ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $_REQUEST ['voucherCol'];
}
if (isset ( $searchform ['voucherCol'] ) && strlen ( $searchform ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $searchform ['voucherCol'];
}
if (isset ( $searchform ['sampletype'] ) && strlen ( $searchform ['sampletype'] ) > 0) {
if (strcasecmp ( $searchform ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $searchform ['sampletype'];
}
if (isset ( $_REQUEST ['sampletype'] ) && strlen ( $_REQUEST ['sampletype'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $_REQUEST ['sampletype'];
}
if (isset ( $_REQUEST ['collectionYearFrom'] ) && strlen ( $_REQUEST ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $_REQUEST ['collectionYearFrom'];
}
if (isset ( $searchform ['collectionYearFrom'] ) && strlen ( $searchform ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $searchform ['collectionYearFrom'];
}
if (isset ( $_REQUEST ['collectionYearTo'] ) && strlen ( $_REQUEST ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $_REQUEST ['collectionYearTo'];
}
if (isset ( $searchform ['collectionYearTo'] ) && strlen ( $searchform ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $searchform ['collectionYearTo'];
}
if (isset ( $_REQUEST ['latitudeTo'] ) && strlen ( $_REQUEST ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $_REQUEST ['latitudeTo'];
}
if (isset ( $searchform ['latitudeTo'] ) && strlen ( $searchform ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $searchform ['latitudeTo'];
}
if (isset ( $_REQUEST ['latitudeFrom'] ) && strlen ( $_REQUEST ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $_REQUEST ['latitudeFrom'];
}
if (isset ( $searchform ['latitudeFrom'] ) && strlen ( $searchform ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $searchform ['latitudeFrom'];
}
if (isset ( $_REQUEST ['longitudeTo'] ) && strlen ( $_REQUEST ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $_REQUEST ['longitudeTo'];
}
if (isset ( $searchform ['longitudeTo'] ) && strlen ( $searchform ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $searchform ['longitudeTo'];
}
if (isset ( $_REQUEST ['longitudeFrom'] ) && strlen ( $_REQUEST ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $_REQUEST ['longitudeFrom'];
}
if (isset ( $searchform ['longitudeFrom'] ) && strlen ( $searchform ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $searchform ['longitudeFrom'];
}
if (isset ( $_REQUEST ['cites'] ) && strlen ( $_REQUEST ['cites'] ) > 0) {
$filters ['cites'] = $_REQUEST ['cites'];
}
if (isset ( $searchform ['cites'] ) && strlen ( $searchform ['cites'] ) > 0) {
$filters ['cites'] = $searchform ['cites'];
}
$submitWebsearch = Yii::$app->getUrlManager ()->createUrl (['websitesearch/search']);
// Yii::info ( "Filters: " . implode ( $filters, "\n" ) );
if ($filters) {
if ($model->validate ()) {
$this->redirect ( Url::to ( array_merge ( [
'search/result'
], $filters ) ) );
} else {
$errors = $model->errors;
$shopM = new CartForm();
if(!Yii::$app->user->isGuest){
$shoppingCart = sizeof(DBInterface::getShoppingCart ( Yii::$app->user->identity->id));
}
else{
$shoppingCart='';
}
return $this->render ( 'show/listView', [
'model' => $model,
'selectionLists' => $this->selectionLists,
"filters" => $filters,
"errors" => $errors ,
'submitWebsearch'=>$submitWebsearch ,
'shoppingCart'=> $shoppingCart,
'shopM' =>$shopM
] );
}
}
return $this->render ( 'search', array (
'model' => $model,
'selectionLists' => $this->selectionLists,
'modelwebsite'=>$modelwebsite,
'submitWebsearch'=>$submitWebsearch ,
) );
}
public function actionResult() {
Yii::info ( "actionResult" );
$filters = [ ];
$model = new SearchForm ();
$model->attributes = Yii::$app->request->post ();
foreach ( $model->attributes as $att )
Yii::info ( "ATTR" + $att );
if (isset ( $_REQUEST ['SearchForm'] )) {
$searchform = $_REQUEST ['SearchForm'];
} else
$searchform = [ ];
if (isset ( $searchform ['fullScientificName'] ) && strlen ( $searchform ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $searchform ['fullScientificName'];
}
if (isset ( $_REQUEST ['fullScientificName'] ) && strlen ( $_REQUEST ['fullScientificName'] ) > 0) {
$filters ['fullScientificName'] = $_REQUEST ['fullScientificName'];
}
if (isset ( $searchform ['familyName'] ) && strlen ( $searchform ['familyName'] ) > 0) {
$filters ['familyName'] = $searchform ['familyName'];
}
if (isset ( $_REQUEST ['familyName'] ) && strlen ( $_REQUEST ['familyName'] ) > 0) {
$filters ['familyName'] = $_REQUEST ['familyName'];
}
if (isset ( $searchform ['kingdom'] ) && strlen ( $searchform ['kingdom'] ) > 0) {
$filters ['kingdom'] = $searchform ['kingdom'];
}
if (isset ( $_REQUEST ['kingdom'] ) && strlen ( $_REQUEST ['kingdom'] ) > 0) {
$filters ['kingdom'] = $_REQUEST ['kingdom'];
}
if (isset ( $searchform ['country'] ) && strlen ( $searchform ['country'] ) > 0) {
if (strcasecmp ( $searchform ['country'], "---" ) > 0)
$filters ['country'] = $searchform ['country'];
}
if (isset ( $_REQUEST ['country'] ) && strlen ( $_REQUEST ['country'] ) > 0) {
if (strcasecmp ( $_REQUEST ['country'], "---" ) > 0)
$filters ['country'] = $_REQUEST ['country'];
}
if (isset ( $searchform ['countrycode'] ) && strlen ( $searchform ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $searchform ['countrycode'];
}
if (isset ( $_REQUEST ['countrycode'] ) && strlen ( $_REQUEST ['countrycode'] ) > 0) {
$filters ['isocountrycode'] = $_REQUEST ['countrycode'];
}
if (isset ( $searchform ['id'] ) && strlen ( $searchform ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $searchform ['id'];
}
if (isset ( $_REQUEST ['id'] ) && strlen ( $_REQUEST ['id'] ) > 0) {
$filters ['sequenceaccessionIdentifier'] = $_REQUEST ['id'];
}
if (isset ( $searchform ['unitID'] ) && strlen ( $searchform ['unitID'] ) > 0) {
$filters ['unitID'] = $searchform ['unitID'];
}
if (isset ( $_REQUEST ['unitID'] ) && strlen ( $_REQUEST ['unitID'] ) > 0) {
$filters ['unitID'] = $_REQUEST ['unitID'];
}
if (isset ( $_REQUEST ['geneticlocus'] ) && strlen ( $_REQUEST ['geneticlocus'] ) > 0) {
if (strcasecmp ( $_REQUEST ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $_REQUEST ['geneticlocus'];
}
if (isset ( $searchform ['geneticlocus'] ) && strlen ( $searchform ['geneticlocus'] ) > 0) {
if (strcasecmp ( $searchform ['geneticlocus'], "---" ) > 0)
$filters ['geneticlocus'] = $searchform ['geneticlocus'];
}
if (isset ( $_REQUEST ['continent'] ) && strlen ( $_REQUEST ['continent'] ) > 0) {
if (strcasecmp ( $_REQUEST ['continent'], "---" ) > 0)
$filters ['continent'] = $_REQUEST ['continent'];
}
if (isset ( $searchform ['continent'] ) && strlen ( $searchform ['continent'] ) > 0) {
if (strcasecmp ( $searchform ['continent'], "---" ) > 0)
$filters ['continent'] = $searchform ['continent'];
}
if (isset ( $_REQUEST ['sea'] ) && strlen ( $_REQUEST ['sea'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sea'], "---" ) > 0)
$filters ['sea'] = $_REQUEST ['sea'];
}
if (isset ( $searchform ['sea'] ) && strlen ( $searchform ['sea'] ) > 0) {
if (strcasecmp ( $searchform ['sea'], "---" ) > 0)
$filters ['sea'] = $searchform ['sea'];
}
if (isset ( $_REQUEST ['ocean'] ) && strlen ( $_REQUEST ['ocean'] ) > 0) {
if (strcasecmp ( $_REQUEST ['ocean'], "---" ) > 0)
$filters ['ocean'] = $_REQUEST ['ocean'];
}
if (isset ( $searchform ['ocean'] ) && strlen ( $searchform ['ocean'] ) > 0) {
if (strcasecmp ( $searchform ['ocean'], "---" ) > 0)
$filters ['ocean'] = $searchform ['ocean'];
}
if (isset ( $_REQUEST ['locality'] ) && strlen ( $_REQUEST ['locality'] ) > 0) {
$filters ['locality'] = $_REQUEST ['locality'];
}
if (isset ( $searchform ['locality'] ) && strlen ( $searchform ['locality'] ) > 0) {
$filters ['locality'] = $searchform ['locality'];
}
if (isset ( $_REQUEST ['collectors'] ) && strlen ( $_REQUEST ['collectors'] ) > 0) {
$filters ['collectors'] = $_REQUEST ['collectors'];
}
if (isset ( $searchform ['collectors'] ) && strlen ( $searchform ['collectors'] ) > 0) {
$filters ['collectors'] = $searchform ['collectors'];
}
if (isset ( $searchform ['collectornumber'] ) && strlen ( $searchform ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $searchform ['collectornumber'];
}
if (isset ( $_REQUEST ['collectornumber'] ) && strlen ( $_REQUEST ['collectornumber'] ) > 0) {
$filters ['collectornumber'] = $_REQUEST ['collectornumber'];
}
if (isset ( $_REQUEST ['institution'] ) && strlen ( $_REQUEST ['institution'] ) > 0) {
$filters ['institution'] = $_REQUEST ['institution'];
}
if (isset ( $searchform ['institution'] ) && strlen ( $searchform ['institution'] ) > 0) {
$filters ['institution'] = $searchform ['institution'];
}
if (isset ( $_REQUEST ['voucherCol'] ) && strlen ( $_REQUEST ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $_REQUEST ['voucherCol'];
}
if (isset ( $searchform ['voucherCol'] ) && strlen ( $searchform ['voucherCol'] ) > 0) {
$filters ['voucherCol'] = $searchform ['voucherCol'];
}
if (isset ( $searchform ['sampletype'] ) && strlen ( $searchform ['sampletype'] ) > 0) {
if (strcasecmp ( $searchform ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $searchform ['sampletype'];
}
if (isset ( $_REQUEST ['sampletype'] ) && strlen ( $_REQUEST ['sampletype'] ) > 0) {
if (strcasecmp ( $_REQUEST ['sampletype'], "---" ) > 0)
$filters ['sampletype'] = $_REQUEST ['sampletype'];
}
if (isset ( $_REQUEST ['collectionYearFrom'] ) && strlen ( $_REQUEST ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $_REQUEST ['collectionYearFrom'];
}
if (isset ( $searchform ['collectionYearFrom'] ) && strlen ( $searchform ['collectionYearFrom'] ) > 0) {
$filters ['collectionYearFrom'] = $searchform ['collectionYearFrom'];
}
if (isset ( $_REQUEST ['collectionYearTo'] ) && strlen ( $_REQUEST ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $_REQUEST ['collectionYearTo'];
}
if (isset ( $searchform ['collectionYearTo'] ) && strlen ( $searchform ['collectionYearTo'] ) > 0) {
$filters ['collectionYearTo'] = $searchform ['collectionYearTo'];
}
if (isset ( $_REQUEST ['latitudeTo'] ) && strlen ( $_REQUEST ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $_REQUEST ['latitudeTo'];
}
if (isset ( $searchform ['latitudeTo'] ) && strlen ( $searchform ['latitudeTo'] ) > 0) {
$filters ['latitudeTo'] = $searchform ['latitudeTo'];
}
if (isset ( $_REQUEST ['latitudeFrom'] ) && strlen ( $_REQUEST ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $_REQUEST ['latitudeFrom'];
}
if (isset ( $searchform ['latitudeFrom'] ) && strlen ( $searchform ['latitudeFrom'] ) > 0) {
$filters ['latitudeFrom'] = $searchform ['latitudeFrom'];
}
if (isset ( $_REQUEST ['longitudeTo'] ) && strlen ( $_REQUEST ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $_REQUEST ['longitudeTo'];
}
if (isset ( $searchform ['longitudeTo'] ) && strlen ( $searchform ['longitudeTo'] ) > 0) {
$filters ['longitudeTo'] = $searchform ['longitudeTo'];
}
if (isset ( $_REQUEST ['longitudeFrom'] ) && strlen ( $_REQUEST ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $_REQUEST ['longitudeFrom'];
}
if (isset ( $searchform ['longitudeFrom'] ) && strlen ( $searchform ['longitudeFrom'] ) > 0) {
$filters ['longitudeFrom'] = $searchform ['longitudeFrom'];
}
if (isset ( $_REQUEST ['cites'] ) && strlen ( $_REQUEST ['cites'] ) > 0) {
$filters ['cites'] = $_REQUEST ['cites'];
}
if (isset ( $searchform ['cites'] ) && strlen ( $searchform ['cites'] ) > 0) {
$filters ['cites'] = $searchform ['cites'];
}
// HERE THE TRICK FOR THE NICE URL
if ($filters && isset ( $_REQUEST ['SearchForm'] )) {
$this->redirect ( Url::to ( array_merge ( [
'search/result'
], $filters ) ) );
} else
return $this->performSearch ( $filters, $model );
}
private function performSearch($filters, $model) {
Yii::info ( "actionperformSearch" );
// we get all the lists for the drop-down lists in the form -- why??
$this->collectDropDownAttributesLists ( $model );
$submitURL = $this->createUrl ( [
'search/create'
], $filters );
// validate user input
if ($model->validate ()) {
$config = SOLRQueryManager::getConfigDetails ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$fq = "{!join from=lowestTripleIDs to=tripleidstoreid fromIndex=".Yii::$app->params ['solrcorename']."}";
$q = [ ];
$filterInstitution = false;
$filterVouchercol=false;
foreach ( $filters as $key => $value ) {
$value = str_replace ( " ", "\ ", $value );
$value = str_replace ( "(", "\(", $value );
$value = str_replace ( ")", "\)", $value );
$value = str_replace ( ":", "\:", $value );
if ($key == "institution") {
$q [] = SOLRQueryManager::getPartialQuery ( $key, $value, $filters, False );
$filterInstitution = true;
}
if ($key == "voucherCol") {
$q [] = SOLRQueryManager::getPartialQuery ( $key, $value, $filters, False );
$filterVouchercol = true;
}
}
if (! $filterInstitution && ! $filterVouchercol)
$q = [
"*:*"
];
$raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, implode ( " AND ", $q ), $fq, $filters, False );
$doc = $raw_response->getDocuments ();
$numFound = $raw_response->getNumFound ();
$ids = [];
foreach($raw_response as $id){
$ids[] = $id->unitID;
}
//Repeat query because Solr won't permit queries with more OR clauses, didn't find a better solution :(
//Executed in batches of 200
$SOLR_QUERY_CONSTANT = 200;
$shoppingArray = [];
for($i=0; $iunitID] = $l;
}
}
$shopM = new CartForm();
if(!Yii::$app->user->isGuest){
$shoppingCart = sizeof(DBInterface::getShoppingCart ( Yii::$app->user->identity->id));
}
else{
$shoppingCart='';
}
return $this->render ( 'show/listView', array (
"model" => $model,
'response' => $doc,
// 'shownAttributes' => $this->shownAttributes,
'keyForLink' => $this->key_link,
'recordFilters' => $this->recordFilters,
'item_count' => $numFound,
'selectionLists' => $this->selectionLists,
'submitURL' => $this->submitURL,
'filters' => $filters,
'shopping' =>$shoppingArray,
'shopM'=> $shopM,
'shoppingCart' =>$shoppingCart
) ); // Rukeia 26-03-2015: hinzugefügt, damit listView auch auf selectionLists zugreifen kann
// 'submitURL'=>$this->$submitURL,
} else {
$errors = $model->errors;
return $this->render ( 'search/result', [
"model" => $model,
"filters" => $filters,
"errors" => $errors
] );
}
}
public function createUrl($destination, $formParameters) {
$nonEmptyFormParameters = array_filter ( $formParameters, 'strlen' );
unset ( $nonEmptyFormParameters ['yt0'] );
return Yii::$app->getUrlManager ()->createUrl ( $destination, $nonEmptyFormParameters );
}
public function actionRecord() {
$model = new SearchForm ();
$model->attributes = Yii::$app->request->post ();
// get the values that came from url back to an array
$requestedAttributes = $this->requestedAttributes;
if ($model->validate ()) {
$output = SingleRecordManager::createOutput ( $requestedAttributes, $model );
if (isset ( $output ) && sizeof ( $output ) > 0) {
$output ['display'] = 'tab';
return $this->render ( 'show/recordViewTabs', $output );
} else
return "Nothing found, check your tripleid!";
} else {
$errors = $model->errors;
return $this->render ( 'search/result', [
"filters" => $filters,
"errors" => $errors,
"model" => $model
] );
}
}
public function actionBrowse() {
Yii::info ( "actionIndexbrowse" );
$elts = Yii::$app->request->get ();
if (isset ( $elts ["page"] ))
$page = $elts ["page"];
else
$page = 0;
$fqs = [ ];
$q = [ ];
$rawfqs = [ ];
$filters = [
"recordbasis",
"fullScientificName",
"familyName",
"unitID",
"institutioncode",
"collectioncode",
"country",
"institution",
"voucherCol",
"sampletype"
];
foreach ( $filters as $filter ) {
if (isset ( $elts [$filter] )) {
$rawfq = urldecode ( $elts [$filter] );
$rawfqs [] = $filter . "=" . urlencode ( $rawfq );
$fq = str_replace ( " ", "\ ", $rawfq );
$fq = str_replace ( "(", "\(", $fq );
$fq = str_replace ( ")", "\)", $fq );
$fq = str_replace ( ":", "\:", $fq );
$fqs [] = $filter . ":" . $fq;
$tmp = SOLRQueryManager::getPartialQuery ( $filter, $fq, $filters, False );
// echo $tmp;
$q [] = $tmp;
}
}
if (empty ( $q ))
$q [] = "*:*";
$filters = [ ];
// $config = SOLRQueryManager::getConfigDetails ();
$config = SOLRQueryManager::getConfigCore ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$sortScientificName = "fullScientificName_asc";
$sortUnitID = "unitID_asc";
$sortRecordbasis = "recordbasis_asc";
$sortInstitutioncode = "institutioncode_asc";
$sortCollectioncode = "collectioncode_asc";
if (isset ( $elts ["sort"] )) {
$field = explode ( "_", $elts ["sort"] )[0];
$direction = explode ( "_", $elts ["sort"] )[1];
$query->addSort ( $field, $direction );
switch ($field) {
case "fullScientificName" :
if ($direction === "asc")
$sortScientificName = "fullScientificName_desc";
else
$sortScientificName = "fullScientificName_asc";
break;
case "recordbasis" :
if ($direction === "asc")
$sortRecordbasis = "recordbasis_desc";
else
$sortRecordbasis = "recordbasis_asc";
break;
case "UnitID" :
if ($direction === "asc")
$sortUnitID = "UnitID_desc";
else
$sortUnitID = "UnitID_asc";
break;
case "institutioncode" :
if ($direction === "asc")
$sortInstitutioncode = "institutioncode_desc";
else
$sortInstitutioncode = "institutioncode_asc";
break;
case "collectioncode" :
if ($direction === "asc")
$sortCollectioncode = "collectioncode_desc";
else
$sortCollectioncode = "collectioncode_asc";
break;
default :
$sortScientificName = "fullScientificName_asc";
$sortUnitID = "unitID_asc";
$sortRecordbasis = "recordbasis_asc";
$sortInstitutioncode = "institutioncode_asc";
$sortCollectioncode = "collectioncode_asc";
}
}
$facetnames = [
'country',
'institution',
'recordbasis',
'sampletype',
];
$raw_response = SOLRQueryManager::browseQuery ( $query, implode ( " AND ", $q ), $fqs, $page, $facetnames );
$rawfacets = $raw_response->getFacetSet ();
$facets = [ ];
foreach ( $facetnames as $fname ) {
$tmp = [
"";
$facets [$fname] = implode ( "", $tmp );
}
$doc = $raw_response->getDocuments ();
$numFound = $raw_response->getNumFound ();
$nbPages = $numFound / Yii::$app->params ['listPerPage'];
$pages = new Pagination ( [
'totalCount' => $numFound,
'pageSize' => Yii::$app->params ['listPerPage']
] );
$from=Yii::$app->params ['listPerPage']*$page;
$to=$from+Yii::$app->params ['listPerPage'];
if (sizeof ( $rawfqs ) > 0)
return $this->render ( 'browse', [
"doc" => $doc,
"fq" => implode ( "&", $rawfqs ),
"pages" => $pages,
"page" => $page,
"sortScientificName" => $sortScientificName,
"sortRecordbasis" => $sortRecordbasis,
"sortInstitutioncode" => $sortInstitutioncode,
"sortUnitID"=>$sortUnitID,
"sortCollectioncode"=>$sortCollectioncode,
"facets"=>$facets,
"recordsFrom"=>$from,
"recordsTo"=>$to,
"recordsTotal"=>$numFound
] );
else
return $this->render ( 'browse', [
"doc" => $doc,
"pages" => $pages,
"page" => $page,
"sortScientificName" => $sortScientificName,
"sortRecordbasis" =>$sortRecordbasis,
"sortInstitutioncode"=>$sortInstitutioncode,
"sortUnitID"=>$sortUnitID,
"sortCollectioncode"=>$sortCollectioncode ,
"facets"=>$facets,
"recordsFrom"=>$from,
"recordsTo"=>$to,
"recordsTotal"=>$numFound
] );
}
public function actionTree() {
$config = SOLRQueryManager::getConfigCore ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$facetname = 'kingdom';
$k = "kingdom:*";
// $p ="phylum:*";
$c = "classis:*";
$f ="family:*";
$o ="ordo:*";
$link="";
$elts = Yii::$app->request->get ();
if (isset ( $elts ["k"] )){
$k = "kingdom:".$elts ["k"];
$facetname = 'classis';
}
// if (isset ( $elts ["p"] )){
// $p ="phylum:". $elts ["p"];
// }
if (isset ( $elts ["c"] )){
$c = "classis:".$elts ["c"];
$facetname = 'ordo';
}
if (isset ( $elts ["o"] )){
$o ="ordo:". $elts ["o"];
$facetname = 'family';
}
if (isset ( $elts ["f"] )){
$f ="family:". $elts ["f"];
$facetname = 'fullScientificName';
}
// $refine=[$k,$c,$p,$f,$o];
$refine=[$k,$c,$f,$o];
$raw_response = SOLRQueryManager::treeQuery ( $query, "*:* AND ".implode(" AND ", $refine), $facetname );
$tree;
$rawfacets = $raw_response->getFacetSet ();
foreach ( $rawfacets->getFacet ( $facetname ) as $doc => $count ){
$tree[$doc."__".$facetname]=$count;
}
return $this->render ( 'treeoflife', ["tree"=>$tree]);
}
public function actionTree() {
$elts = Yii::$app->request->get ();
if (isset ( $elts ["institution"] ))
$institution = $elts ["institution"];
else
$institution = null;
$model = new SearchForm ();
$elements = $model->getParameters ();
$this->collectDropDownAttributesLists ( $model );
$facetnames = [
'institution'
];
$facets = [ ];
foreach ( $elements as $key => $param ) {
if (in_array ( $key, $facetnames )) {
$attributeList = isset ( $this->selectionLists ) ? $this->selectionLists [$key] : array ();
$selectField = [ ];
foreach ( $attributeList as $kk => $vv ) {
if (preg_match ( "/ \(\d* \/ \d*\)/", $vv ))
$selectField [preg_replace ( "/ \(\d* \/ \d*\)/", "", $vv )] = $vv;
else
$selectField [preg_replace ( "/ \(\d*\)/", "", $vv )] = $vv;
}
if (! empty ( $institution ))
$facets [] = Html::dropDownList ( $key, $institution, $selectField, $htmlOptions = [
'class' => "dropDownLabel",
'id2' => $key
] );
else
$facets [] = Html::dropDownList ( $key, $key, $selectField, $htmlOptions = [
'class' => "dropDownLabel",
'id2' => $key
] );
}
}
$connection = new \yii\db\Connection ( Yii::$app->db );
$connection->open ();
$command = $connection->createCommand ( "SELECT distinct taxon_id, name, total_species_extant from _taxon_tree where rank='kingdom' order by name asc" );
// $command = $connection->createCommand ( "SELECT distinct taxon_id, name, number_of_children from _taxon_tree where rank='kingdom' order by name asc" );
$dataReader = $command->queryAll ();
$tree = [ ];
$config = SOLRQueryManager::getConfigBackbone ();
foreach ( $dataReader as $row ) {
$sql = "select count(distinct fullscientificname) as nbChildren,
count(distinct occurrenceid) as nbOccurrences, kingdom
from treeoflife
where kingdom='" . $row ["name"] . "'";
if (isset ( $institution ))
$sql .= " AND institution='" . $institution . "'";
$sql .= "group by kingdom";
$command2 = $connection->createCommand ( $sql );
$dataReader2 = $command2->queryAll ();
// $value = $row['name'];
// $value = str_replace (" ", "\ ", $value );
// $q="rank:KINGDOM AND kingdom:".$value;
// // $fq="{!join from=colKey to=Keys fromIndex=ggbn_details_local}*:*";
// $fq=null;
// $query = SOLRQueryManager::createSearchQuery ( $config );
// $raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, $q , $fq, null, False);
// $docs=$raw_response->getDocuments ();
// $nbOccurrences=0;
// $nbTaxChildren=0;
// foreach ($docs as $doc){
// $nbOccurrences =$doc->occurrenceCount;
// $nbTaxChildren =$doc->childrenCount;
// if(empty($nbOccurrences))
// $nbOccurrences = 0;
// $nbTaxChildren = $doc->childrenCount;
// if(empty($nbTaxChildren))
// $nbTaxChildren = 0;
// }
$ok = false;
foreach ( $dataReader2 as $row2 ) {
$ok = true;
$nbOccurrences = $row2 ['nbOccurrences'];
$nbTaxChildren = $row2 ['nbChildren'];
$mykingdom = $row2 ['kingdom'];
$tree [$row ["taxon_id"]] = [
$mykingdom,
$nbTaxChildren,
$nbOccurrences
];
// $tree[$row["taxon_id"]]=[$row["name"],$row["number_of_children"]];
}
if(!$ok)
$tree [$row ["taxon_id"]] = [
$row["name"],
0,
0
];
}
Yii::$app->db->close ();
return $this->render ( 'treeoflife', [
"tree" => $tree,
"facets" => $facets
] );
}
public function actionTreesearch($canonicalName, $parentName, $parentRank, $institution) {
$filters = [ ];
if ($parentRank == "genus") {
$filters ['fullScientificName'] = $canonicalName . "*";
}
if ($parentRank == "family") {
$filters ['genus'] = $canonicalName;
$filters ['familyName'] = $parentName;
}
if ($parentRank == "order") {
$filters ['familyName'] = $canonicalName;
$filters ['orderName'] = $parentName;
}
if ($parentRank == "class") {
$filters ['orderName'] = $canonicalName;
$filters ['className'] = $parentName;
}
if ($parentRank == "phylum") {
$filters ['className'] = $canonicalName;
$filters ['phylumName'] = $parentName;
}
if ($parentRank == "kingdom") {
$filters ['phylumName'] = $canonicalName;
$filters ['kingdom'] = $parentName;
}
if(isset($institution) && !empty(str_ireplace("---", "", $institution)))
$filters ['institution'] = $institution;
$this->redirect ( Url::to ( array_merge ( [
'search/result'
], $filters ) ) );
}
}