예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Facet::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function getValues()
 {
     $values = parent::getValues();
     if (!$values && strncmp($this->attribute_name, 'eAttributes.', 12) === 0) {
         $name = substr($this->attribute_name, 12);
         $attribute = Attribute::findByNameAndEntityType($name, $this->entity_type);
         if ($attribute->isValuesPredefined()) {
             $values = $attribute->getValues();
             if ($values) {
                 foreach ($values as $value) {
                     $values[] = new FacetTerm(['facet' => $this, 'term' => $value->value, 'display' => $value->presentation]);
                 }
                 $this->populateRelation('values', $values);
             }
         }
     }
     return $values;
 }
예제 #3
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model im\search\models\FacetSet */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="index-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'facets')->widget(Select2::classname(), ['data' => ArrayHelper::map(Facet::find()->asArray()->orderBy('name')->all(), 'id', 'name'), 'options' => ['multiple' => true]]);
?>

    <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('module', 'Create') : Module::t('module', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-primary' : 'btn btn-success']);
?>

    <?php 
ActiveForm::end();
?>

</div>
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFacetRelation()
 {
     return $this->hasOne(Facet::className(), ['id' => 'facet_id']);
 }
예제 #5
0
 /**
  * @inheritdoc
  */
 public function setValues($values)
 {
     parent::setValues($values);
     $this->_intervals = $values;
 }
예제 #6
0
 /**
  * Finds the Facet model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Facet the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Facet::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFacetsRelation()
 {
     return $this->hasMany(Facet::className(), ['id' => 'facet_id'])->viaTable('{{%facet_set_facets}}', ['set_id' => 'id']);
 }