array ( 'getSuggestionList', 'setSession' ), 'users' => array ( '*' ) ), array ( 'deny', // deny all users 'users' => array ( '*' ) ) ); } // public function actionIndex() { // return "pof"; // } public function actionIndex($q = null) { return "pif"; } function getConfig() { $config = array ( 'endpoint' => array ( 'bgbm-web01' => array ( 'host' => Yii::$app->params ['solrhost'], 'port' => 8080, 'path' => Yii::$app->params ['solrsearch'] ) ) ); return $config; } public function actionSuggestionList($q = null) { Yii::info ( "actionSuggestionList for query".$q ); if (isset ( $_GET ['kingdom'] )) $kingdom = $_GET ['kingdom']; else $kingdom = ""; if (! empty ( $kingdom )) $filteropt = "regnum:" . $kingdom; else $filteropt = ""; $prefixFilter = $_GET ['term']; $prefixFilter = str_replace ( " ", "\ ", $prefixFilter ); $prefixFilter = str_replace ( "(", "\(", $prefixFilter ); $prefixFilter = str_replace ( ")", "\)", $prefixFilter ); $prefixFilter = str_replace ( ":", "\:", $prefixFilter ); // Yii::info ( "prefix " . $prefixFilter ); $listTitle = $_GET ['listTitle']; $result = FormSuggestionsQueryManager::newFacetsList ( $listTitle, $prefixFilter, $filteropt, $this->getConfig () ); $list = array (); // show documents using the resultset iterator foreach ( $result as $attributeVal => $count ) { // Yii::info("attributeVal: ".$attributeVal); if (! (strpos ( $attributeVal, "hierarchy" ) === 0)) { try { if (isset ( $result ["hierarchy" . $attributeVal] )) $hierarchy = $result ["hierarchy" . $attributeVal]; else $hierarchy = NULL; } catch ( Exception $e ) { $hierarchy = NULL; } } else $hierarchy = NULL; if (! empty ( $hierarchy )) { $hierarchy_p1 = [ ]; if (stripos ( $hierarchy, $prefixFilter ) !== FALSE) { $pos1 = stripos ( strtolower ( $hierarchy ), strtolower ( $_GET ['term'] ) ); $hierarchy_p1 [] = substr ( $hierarchy, 0, $pos1 ); $pos2 = $pos1 + strlen ( $_GET ['term'] ); $hierarchy_p1 [] = substr ( $hierarchy, $pos1, strlen ( $_GET ['term'] ) ); $hierarchy_p1 [] = substr ( $hierarchy, $pos2 ); } else $hierarchy_p1 = [ $hierarchy, '', '' ]; } else $hierarchy_p1 = [ ]; if (! (strpos ( $attributeVal, "reason" ) === 0)) { // Yii::info("R"); try { if (isset ( $result ["reason" . $attributeVal] )) $reason = $result ["reason" . $attributeVal]; else $reason = NULL; } catch ( Exception $e ) { $reason = NULL; } } else $reason = NULL; if (! empty ( $reason )) { $reason_p1 = [ ]; if (stripos ( $reason, $prefixFilter ) !== FALSE) { $pos1 = stripos ( strtolower ( $reason ), strtolower ( $_GET ['term'] ) ); $reason_p1 [] = substr ( $reason, 0, $pos1 ); $pos2 = $pos1 + strlen ( $_GET ['term'] ); $reason_p1 [] = substr ( $reason, $pos1, strlen ( $_GET ['term'] ) ); $reason_p1 [] = substr ( $reason, $pos2 ); } else $reason_p1 = [ $reason, '', '' ]; } else $reason_p1 = [ ]; if (is_array ( $attributeVal )) $attributeVal = implode ( ', ', $attributeVal ); // Yii::info ( "attributeVal : " . $attributeVal ); if (! (strpos ( $attributeVal, "hierarchy" ) === 0) && ! (strpos ( $attributeVal, "reason" ) === 0)) { if (is_array ( $count )) $count = implode ( ', ', $count ); if (isset ( $hierarchy ) && $hierarchy != NULL && isset ( $reason ) && $reason != NULL && ! empty ( $reason_p1 )) { $list [] = [ 'label' => $attributeVal . " (" . $count . ")", // 'label' => $acceptedName . " (" . $count . ")", 'value' => $attributeVal, 'hierarchy0' => $hierarchy_p1 [0], 'hierarchy1' => $hierarchy_p1 [1], 'hierarchy2' => $hierarchy_p1 [2], 'reason0' => $reason_p1 [0], 'reason1' => $reason_p1 [1], 'reason2' => $reason_p1 [2] ]; } elseif (isset ( $hierarchy ) && $hierarchy != NULL) { $list [] = [ 'label' => $attributeVal . " (" . $count . ")", // 'label' => $acceptedName . " (" . $count . ")", 'value' => $attributeVal, 'hierarchy0' => $hierarchy_p1 [0], 'hierarchy1' => $hierarchy_p1 [1], 'hierarchy2' => $hierarchy_p1 [2] ]; } else { // Yii::info("something is missing but whaattt? ".$hierarchy." -- ".$acceptedName); $list [] = [ 'label' => $attributeVal . " (" . $count . ")", 'value' => $attributeVal ]; } } // $list[]=['value'=>$attributeVal]; } // Yii::info("JSON ".Json::encode ( $list )); echo Json::encode ( $list ); Yii::$app->end (); } }