예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProfileField::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->controller->module->fields_page_size]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'varname', $this->varname])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'field_type', $this->field_type])->andFilterWhere(['like', 'field_size', $this->field_size])->andFilterWhere(['like', 'field_size_min', $this->field_size_min])->andFilterWhere(['like', 'required', $this->required])->andFilterWhere(['like', 'match', $this->match])->andFilterWhere(['like', 'range', $this->range])->andFilterWhere(['like', 'error_message', $this->error_message])->andFilterWhere(['like', 'other_validator', $this->other_validator])->andFilterWhere(['like', 'default', $this->default])->andFilterWhere(['like', 'widget', $this->widget])->andFilterWhere(['like', 'widgetparams', $this->widgetparams])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'visible', $this->visible]);
     return $dataProvider;
 }
예제 #2
0
$this->title = Yii::$app->name . ' - ' . Module::t("Profile");
$this->params['breadcrumbs'][] = Module::t("Profile");
$menu = [['label' => Module::t('List User'), 'url' => ['/user/user/index']], ['label' => Module::t('Edit'), 'url' => ['edit']], ['label' => Module::t('Change password'), 'url' => ['changepassword']], ['label' => Module::t('Logout'), 'url' => ['/user/logout']]];
if (Module::isAdmin()) {
    array_unshift($menu, ['label' => Module::t('Manage Users'), 'url' => ['/user/admin']]);
}
Module::getInstance()->setMenu($menu);
?>
    <h1><?php 
echo Module::t('Your profile');
?>
</h1>

<?php 
$attributes = ['username', 'email:email', 'create_at:date', 'lastvisit_at:date'];
$profileFields = ProfileField::find()->forOwner()->sort()->all();
if ($profileFields) {
    foreach ($profileFields as $field) {
        $val = '';
        if ($field->widgetView($model->profile)) {
            $val = $field->widgetView($model->profile);
        } else {
            if ($field->range) {
                $val = Profile::range($field->range, $model->profile->getAttribute($field->varname));
            } else {
                $val = $model->profile->getAttribute($field->varname);
            }
        }
        $type = 'html';
        if ($field->field_type == "DATE" || $field->widget == "UWjuidate") {
            $type = 'date';
예제 #3
0
 /**
  * @return ProfileField[]
  */
 public static function getFields()
 {
     if (self::$regMode) {
         if (!self::$modelReg) {
             self::$modelReg = ProfileField::find()->forRegistration()->all();
         }
         return self::$modelReg;
     } else {
         if (!self::$model) {
             self::$model = ProfileField::find()->forOwner()->all();
         }
         return self::$model;
     }
 }
예제 #4
0
echo $form->field($model, 'default')->textInput(['size' => 60, 'maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'widget')->textInput(['size' => 60, 'maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'widgetparams')->textInput(['size' => 60, 'maxlength' => 5000]);
?>

    <?php 
echo $form->field($model, 'position');
?>

    <?php 
echo $form->field($model, 'visible')->dropDownList(ProfileField::itemAlias('visible'));
?>

    <div class="form-group">
        <div class="col-lg-offset-1 col-lg-11">
            <?php 
echo Html::submitButton(\marsoltys\yii2user\Module::t('search'), ['class' => 'btn btn-primary']);
?>
        </div>
    </div>
    <?php 
ActiveForm::end();
?>

</div><!-- search-form --> 
예제 #5
0
</h1>

<p><?php 
echo Module::t("You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.");
?>
</p>

<?php 
echo Html::a(Module::t('Advanced Search'), '#', ['class' => 'search-button']);
?>
<div class="search-form" style="display:none">
    <?php 
echo $this->render('_search', ['model' => $searchModel]);
?>
</div><!-- search-form -->

<?php 
\yii\widgets\Pjax::begin();
?>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'varname', 'format' => 'raw', 'value' => function ($data) {
    return UHtml::markSearch($data, "varname");
}], ['attribute' => 'title', 'value' => function ($data) {
    return Module::t($data->title);
}], ['attribute' => 'field_type', 'filter' => ProfileField::itemAlias("field_type")], 'field_size', ['attribute' => 'required', 'value' => function ($data) {
    return ProfileField::itemAlias("required", $data->required);
}, 'filter' => ProfileField::itemAlias("required")], 'position', ['attribute' => 'visible', 'value' => function ($data) {
    return ProfileField::itemAlias("visible", $data->visible);
}, 'filter' => ProfileField::itemAlias("visible")], ['class' => 'yii\\grid\\ActionColumn']]]);
\yii\widgets\Pjax::end();
예제 #6
0
list($widgetsList) = ProfileFieldController::getWidgets($model->field_type);
?>
        <?php 
echo $form->field($model, 'widget', ['options' => ['class' => 'form-group widget']])->dropDownList($widgetsList, ['id' => 'widgetlist'])->hint(Module::t('Widget name.'));
?>

        <?php 
echo $form->field($model, 'widgetparams', ['options' => ['class' => 'form-group widgetparams']])->textInput(['size' => 60, 'maxlength' => 5000, 'id' => 'widgetparams'])->hint(Module::t('JSON string (example: {example}).', ['{example}' => Json::encode(['param1' => ['val1', 'val2'], 'param2' => ['k1' => 'v1', 'k2' => 'v2']])]));
?>

        <?php 
echo $form->field($model, 'position', ['options' => ['class' => 'form-group position']])->hint(Module::t('Display order of fields.'));
?>

        <?php 
echo $form->field($model, 'visible', ['options' => ['class' => 'form-group visible']])->dropDownList(ProfileField::itemAlias('visible'));
?>

        <div class="form-group">
            <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('Create') : Module::t('Save'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        </div>

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

</div><!-- form -->
<div id="dialog-form" title="<?php 
예제 #7
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->model === null) {
         if (Yii::$app->request->get('id')) {
             $this->model = ProfileField::findOne(Yii::$app->request->get('id'));
         }
         if ($this->model === null) {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     }
     return $this->model;
 }