Gabi: verworfen, SOLR-Extension von Yii macht das von selbst // private $showRequest = true; // define here, which parameters of the record to be shown in the list overview of the matches. // !!!! // Gabi: für Trefferliste werden die nicht mehr benötigt, ganz verwerfen?? private $shownAttributes = array ( 'fullScientificName', 'familyName', 'orderName', 'className', 'phylumName', 'kingdomName', 'isocountrycode', 'unitID' => 'unitID', 'collectioncode', // 'sampletype', 'institutioncode', 'unitID2' => 'unitID' ); // -------------------------------------------------------- // these are the attributes that will be used for calculation // and also these ones that are mandatory shown // do not change this unless you also adapt the whole programm private $requestedAttributes = array ( 'unitID', 'kindofunit', 'fk_tripleidstoreid', /* 'fk2', 'associationstatus', 'accessPoint', 'accessPoint2', 'protocolname', 'protocolname2', 'basedirectory', 'basedirectory2', 'digirresourcename2', 'schemaname', 'schemaname2', 'schemaurl', 'schemaurl2', */ 'collectioncode', 'collectioncode2', 'institutioncode', 'institutioncode2' ); private $key_link = 'fullScientificName'; private $recordFilters = array ( 'unitID', 'collectioncode', 'institutioncode' ); public $layout = '//layouts/layout_wide'; // ------------ end settings -------------- // we store all list for the drop down fields here private $selectionLists; private $dropDownAttributes; // ------------ functions -------------------- private function collectDropDownAttributesLists($model) { if (! isset ( $this->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 () ); } } // ------------------------ access ------------------------- /** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * * @return array access control rules */ public function accessRules() { return array ( array ( 'allow', // allow all users to perform 'search' and 'test' action 'actions' => array ( 'search', 'test' ), 'users' => array ( '*' ) ), array ( 'deny', // deny all users 'users' => array ( '*' ) ) ); } // Rukeia 11-03-2015: this functions redirects to the shortened URL public function actionCreate() { if ($_REQUEST) { $url = SearchController::createShortUrl ( $_REQUEST ); $this->redirect ( $url ); } } // Rukeia 11-03-2015: this functions excludes all empty form parameters as well as the Search Button ID and Label (yt0=Search) public function createShortUrl($formParameters) { $nonEmptyFormParameters = array_filter ( $formParameters, 'strlen' ); unset ( $nonEmptyFormParameters ['yt0'] ); return Yii::app ()->createUrl ( 'search/index', $nonEmptyFormParameters ); } // ------------------- controller actions ---------------- /** * this does all the thing for searching the index: */ public function actionIndex() { $model = new SearchForm (); // we get all the lists for the drop-down lists in the form $this->collectDropDownAttributesLists ( $model ); // Rukeia 23-02-2013: we store all form parameter values in $filters $filters = array (); if (isset ( $_REQUEST ['name'] )) { $filters ['fullScientificName'] = $_REQUEST ['name']; } if (isset ( $_REQUEST ['family'] )) { $filters ['familyName'] = $_REQUEST ['family']; } if (isset ( $_REQUEST ['country'] )) { $filters ['country'] = $_REQUEST ['country']; } if (isset ( $_REQUEST ['countrycode'] )) { $filters ['isocountrycode'] = $_REQUEST ['countrycode']; } if (isset ( $_REQUEST ['id'] )) { $filters ['sequenceaccessionIdentifier'] = $_REQUEST ['id']; } if (isset ( $_REQUEST ['unitID'] )) { $filters ['unitID'] = $_REQUEST ['unitID']; } if (isset ( $_REQUEST ['locus'] )) { $filters ['geneticlocus'] = $_REQUEST ['locus']; } if (isset ( $_REQUEST ['continent'] )) { $filters ['continent'] = $_REQUEST ['continent']; } if (isset ( $_REQUEST ['sea'] )) { $filters ['sea'] = $_REQUEST ['sea']; } if (isset ( $_REQUEST ['ocean'] )) { $filters ['ocean'] = $_REQUEST ['ocean']; } if (isset ( $_REQUEST ['locality'] )) { $filters ['locality'] = $_REQUEST ['locality']; } if (isset ( $_REQUEST ['collectors'] )) { $filters ['collectors'] = $_REQUEST ['collectors']; } if (isset ( $_REQUEST ['collectornumber'] )) { $filters ['collectornumber'] = $_REQUEST ['collectornumber']; } if (isset ( $_REQUEST ['repository'] )) { $filters ['institution'] = $_REQUEST ['repository']; } if (isset ( $_REQUEST ['sampletype'] )) { $filters ['sampletype'] = $_REQUEST ['sampletype']; } if ($filters) { // Rukeia 25-02-2015: testen ob Array ausgefüllt ist (oder ob es existiert?), sonst gibt es eine Fehlermeldung. Es gibt noch Probleme, wenn das Formular leer abgeschickt wird. // collect user input data $model->attributes = $filters; // TODO check if at least one field is filled in // validate user input if ($model->validate ()) { $criteria = SOLRQueryManager::createSearchQuery ( $model, $this->selectionLists ); $raw_response = SOLRQueryManager::getQueryResponseDetails ( $criteria, $modelClass = "ASolrDocument" ); $response = $raw_response->Results; // Rukeia 18-03-2015: Pagination auskommentiert // Pagination $pages = new CPagination ( $response->total ); $pages->setPageSize ( Yii::app ()->params ['listPerPage'] ); $pages->applyLimit ( $criteria ); $this->render ( 'show/listView', array ( 'response' => $response, // 'shownAttributes' => $this->shownAttributes, 'keyForLink' => $this->key_link, 'recordFilters' => $this->recordFilters, 'item_count' => $response->total, 'page_size' => Yii::app ()->params ['listPerPage'], // Rukeia 18-03-2015: Pagination auskommentiert 'pages' => $pages, // Rukeia 18-03-2015: Pagination auskommentiert 'selectionLists' => $this->selectionLists ) // Rukeia 26-03-2015: hinzugefügt, damit listView auch auf selectionLists zugreifen kann ); return; // Rukeia 16_03_2015: auskommentiert - wenn das return weggelassen wird, dann erscheint die Suchform (funktionsfähig, mit Text-User-Input) UNTER den Ergebnissen (aber auch mit Leiste und allem) } } $this->render ( 'search', array ( 'model' => $model, 'selectionLists' => $this->selectionLists ) ); } public function actionRecord() { $model = new SearchForm (); // get the values that came from url back to an array $requestedAttributes = $this->requestedAttributes; if ($model->validate ()) { $output = SingleRecordManager::createOutput ( $requestedAttributes, $model ); $this->render ( 'show/recordView', $output ); } } // testing the Tab function public function actionRecordTab() { $model = new SearchForm (); // get the values that came from url back to an array $requestedAttributes = $this->requestedAttributes; if ($model->validate ()) { $output = SingleRecordManager::createOutput ( $requestedAttributes, $model ); $this->render ( 'show/recordViewTabs', $output ); } } }