array ( 'getSuggestionList', 'setSession' ), 'users' => array ( '*' ) ), array ( 'deny', // deny all users 'users' => array ( '*' ) ) ); } // public function actionIndex() { // return "pof"; // } public function actionIndex($q = null) { return "pif"; } public function actionSuggestionList($q = null) { // Yii::info ( "actionSuggestionList" ); // echo("actionGetSuggestionList"); // foreach ( $_GET as $key => $value ) // Yii::info ( "Key: $key Val: $value\n" ); // foreach ( $_POST as $key => $value ) // Yii::info ( "Post Key: $key Val: $value\n" ); $prefixFilter = $_GET ['term']; $prefixFilter = str_replace ( " ", "\ ", $prefixFilter ); $prefixFilter = str_replace ( "(", "\(", $prefixFilter ); $prefixFilter = str_replace ( ")", "\)", $prefixFilter ); $prefixFilter = str_replace ( ":", "\:", $prefixFilter ); // Yii::info ( "prefix " . $prefixFilter ); // get list with all items of this field //TODO no hardcoding $listTitle = $_GET ['listTitle']; $result = FormSuggestionsQueryManager::newFacetsList ( $listTitle, $prefixFilter ); $list = array (); // show documents using the resultset iterator foreach ( $result as $attributeVal => $count ) { 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 (is_array ( $attributeVal )) $attributeVal = implode ( ', ', $attributeVal ); // Yii::info ( "attributeVal : " . $attributeVal ); if (! (strpos ( $attributeVal, "hierarchy" ) === 0)){ if (is_array ( $count )) $count = implode ( ', ', $count ); if (isset ( $hierarchy ) && $hierarchy!=NULL){ $list [] = [ 'label' => $attributeVal . " (" . $count . ")", 'value' => $attributeVal, 'hierarchy' =>$hierarchy, ]; } else{ $list [] = [ 'label' => $attributeVal . " (" . $count . ")", 'value' => $attributeVal, ]; } } // $list[]=['value'=>$attributeVal]; } // Yii::info(Json::encode ( $list )); echo Json::encode ( $list ); Yii::$app->end (); } }