protected function getModelsByField($field) { if (!isset(static::$models[$field])) { static::$models[$field] = Lookup::find()->where(['table' => $this->tableName(), 'field' => $field])->orderBy(['position' => SORT_ASC, 'name' => SORT_ASC])->all(); } return static::$models[$field]; }
private static function loadItems($type) { self::$_items[$type] = array(); $models = Lookup::find()->where(['type' => $type])->orderBy('position')->all(); foreach ($models as $model) { self::$_items[$type][$model->code] = $model->name; } }
public function actionIndex() { $data = Route::find()->andWhere(['status' => 1, 'author_id' => Yii::$app->user->identity->id])->orderBy('id desc'); $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '9']); $model = $data->offset($pages->offset)->limit($pages->limit)->all(); foreach ($model as $item) { $item->status = ucfirst(strtolower(Lookup::item("RouteStatus", $item->status))); } return $this->render('index', ['model' => $model, 'pages' => $pages]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Lookup::find()->with(['creater', 'updater', 'deleter'])->asArray(true); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['label' => SORT_ASC]]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['enabled' => $this->enabled]); $query->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'return_type', $this->return_type]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Lookup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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(['id' => $this->id, 'code' => $this->code, 'position' => $this->position]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
public function search($params) { $query = Lookup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->addCondition($query, 'id'); $this->addCondition($query, 'name', true); $this->addCondition($query, 'code'); $this->addCondition($query, 'type', true); $this->addCondition($query, 'position'); return $dataProvider; }
public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Job::find(), 'pagination' => ['pageSize' => 1]]); $model = new DynamicModel(['search_keyword', 'search_location', 'search_type']); $model->addRule('search_type', 'integer')->addRule('search_location', 'string', ['max' => 128])->addRule('search_keyword', 'string', ['max' => 128]); if ($model->load(Yii::$app->request->post())) { switch ($model->search_type) { case Lookup::item_code('SearchType', 'Organizations'): return $this->redirect(['organization/index', 'search_keyword' => $model->search_keyword]); break; case Lookup::item_code('SearchType', 'Opportunities'): return $this->redirect(['job/index', 'search_keyword' => $model->search_keyword]); break; default: throw new NotFoundHttpException('Your search:' . $model->search_keyword); break; } } return $this->render('index', ['model' => $model, 'dataProvider' => $dataProvider]); }
?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'org_type')->dropDownList(Lookup::items('OrganizationType')); ?> <?php echo $form->field($model, 'work_domain')->dropDownList(Lookup::items('WorkDomain')); ?> <?php echo $form->field($model, 'website')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'found_date')->widget(DatePicker::classname(), ['pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]); ?> <?php echo $form->field($model, 'imageFile')->fileInput(); ?> <div class="form-group">
use yii\helpers\Html; use yii\widgets\DetailView; use app\models\Lookup; /* @var $this yii\web\View */ /* @var $model app\models\Comment */ $this->title = $model->id; $this->params['breadcrumbs'][] = ['label' => '评论管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="comment-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('修改', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('删除', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => '确定要删除吗?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'content:ntext', ['attribute' => 'status', 'value' => Lookup::item("CommentStatus", $model->status)], ['attribute' => 'create_time', 'value' => date("Y-m-d H:i:s", $model->create_time)], 'author', 'email:email', 'url:url', ['attribute' => 'post_id', 'value' => $model->post->title . "(ID:" . $model->post_id . ")"]]]); ?> </div>
$form = ActiveForm::begin(['id' => 'form-lookups', 'action' => ['index'], 'method' => 'get']); ?> <div class="entry"> <?php echo $form->field($model, 'label'); ?> <?php echo $form->field($model, 'description'); ?> </div> <div class="entry"> <?php echo $form->field($model, 'return_type')->dropDownList(Lookup::returnTypeOptions(), ['prompt' => '']); ?> <?php echo $form->field($model, 'enabled')->dropDownList(Option::booleanOptions(), ['prompt' => '']); ?> </div> <div class="form-group buttons"> <?php echo Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']); ?> <?php echo Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']); ?> </div>
$this->params['breadcrumbs'][] = $this->title; ?> <div class="row"> <table class="col-md-offset-half"> <tr> <td class="col-md-5"> <h1><?php echo Html::encode($this->title); ?> </h1> <h5><?php echo Lookup::item('WorkDomain', $model->work_domain); ?> | <?php echo Lookup::item('OrganizationType', $model->org_type); ?> </h5> <?php echo Html::a('Follow', [''], ['class' => 'btn btn-default']); ?> <br/><br/> </td> <td class="col-md-2"> <?php if ($model->logo) { echo '<img src=' . Yii::$app->urlManager->createUrl($model->logo) . ' height="116" width="116" alt="Logo">'; } ?> </td>
use app\models\Lookup; /** * @var yii\web\View $this * @var app\models\Post $model */ $this->title = $model->title; $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Posts'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="post-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'category_id', 'title', ['label' => Yii::t('app', 'Type'), 'value' => Lookup::item("{{post}}type", $model->type)], 'thumbnail', 'url:url', 'summary', 'source', 'writer', 'content:ntext', 'tags', 'seo_title', 'seo_keywords', 'seo_description', 'published_at', 'views', 'likes', 'comment_count', 'disallow_comment', 'status', ['label' => Yii::t('app', 'Status'), 'value' => Lookup::item("{{post}}status", $model->status)], 'created_by', 'updated_by', 'created_at', 'updated_at']]); ?> </div>
<?php Yii::info(".................................."); Yii::info($model['name']); ?> <h4><b><?php echo Html::a($model['name'], ['view', 'id' => $model['id']], ['title' => $model['name'], 'target' => '_blank']); ?> </b></h4> <p><?php echo $model['description']; ?> </p> <hr/> <p><?php echo Lookup::item('WorkDomain', $model['work_domain']); ?> | <?php echo Lookup::item('OrganizationType', $model['org_type']); ?> <?php echo Yii::$app->user->id == $model['user_id'] ? Html::a('Edit', ['profile', 'id' => $model['id']], ['title' => 'Edit' . $model['name'], 'class' => 'btn btn-default pull-right']) : ''; ?> </p> </div> </div> </div>
/** * Finds the Lookup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Lookup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Lookup::find()->where(['id' => (int) $id])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="box-body"> <?php echo $form->field($model, 'label')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'value')->textarea(); ?> <?php echo $form->field($model, 'return_type')->dropDownList(Lookup::returnTypeOptions()); ?> <?php echo $form->field($model, 'enabled')->checkbox(); ?> </div> <div class="box-footer"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => 'btn btn-info pull-right']); ?> </div> <?php
/* @var $searchModel app\models\SearchPost */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = '文章'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="post-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('创建文章', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', 'content:ntext', 'tags:ntext', ['attribute' => 'status', 'value' => function ($model) { $lookup = new Lookup(); $lookupModel = $lookup->findOne($model->status); return $lookupModel->name; }], ['attribute' => 'create_time', 'format' => ['date', 'php:Y-m-d']], 'author_id', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
<h4><b><?php echo Html::a($model['title'], ['view', 'id' => $model['id']], ['title' => $model['title'], 'target' => '_blank']); ?> </b></h4> <p><?php echo $model['description']; ?> </p> <p><?php echo Lookup::item('JobType', $model['job_type']); ?> </p> <hr/> <p><?php echo Lookup::item('EmploymentType', $model['employment_type']); ?> | <?php echo $model['start_date']; ?> to <?php echo $model['end_date']; ?> <?php echo Html::a('Apply', [''], ['class' => 'btn btn-default pull-right']); ?> </p> </div> </div> </div>
<div class="panel-body"> <?php echo $form->field($model, 'job_type')->checkboxList(Lookup::items('JobType'), ['separator' => '<br>']); ?> <div class="form-group"> <?php echo Html::submitButton('Filter', ['class' => 'btn btn-success margin-left-1 pull-right']); ?> </div> </div> </div> <div class="panel panel-default"> <div class="panel-body"> <?php echo $form->field($model, 'work_domain')->checkboxList(Lookup::items('WorkDomain'), ['separator' => '<br>']); ?> <div class="form-group"> <?php echo Html::submitButton('Filter', ['class' => 'btn btn-success margin-left-1 pull-right']); ?> </div> </div> </div> <?php ActiveForm::end(); ?> </div> </div>
/** * Finds the Lookup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Lookup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Lookup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo isset($model->thumbnail) && !empty($model->thumbnail) ? $model->thumbnail : "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOTMiIGhlaWdodD0iMTkzIj48cmVjdCB3aWR0aD0iMTkzIiBoZWlnaHQ9IjE5MyIgZmlsbD0iI2VlZSI+PC9yZWN0Pjx0ZXh0IHRleHQtYW5jaG9yPSJtaWRkbGUiIHg9Ijk2IiB5PSI5NiIgc3R5bGU9ImZpbGw6I2FhYTtmb250LXdlaWdodDpib2xkO2ZvbnQtc2l6ZToxOHB4O2ZvbnQtZmFtaWx5OkFyaWFsLEhlbHZldGljYSxzYW5zLXNlcmlmO2RvbWluYW50LWJhc2VsaW5lOmNlbnRyYWwiPnRodW1ibmFpbDwvdGV4dD48L3N2Zz4="; ?> " class="img-rounded" style="max-width:194px;max-height:194px;"> <input class="ke-input-text" type="text" id="url" value="" readonly="readonly" /> <input type="button" id="uploadButton" value="<?php echo Yii::t('app', 'Upload'); ?> " /> <?php echo Html::activeHiddenInput($model, 'thumbnail'); ?> </div> </div> <div class="panel panel-default"> <div class="panel-body"> <?php echo $form->field($model, 'status')->dropDownList(Lookup::items("{{post}}status")); ?> <?php $model->isNewRecord ? $model->published_at = date("Y-m-d H:i:s") : ($model->published_at = date("Y-m-d H:i:s", $model->published_at)); ?> <?php echo $form->field($model, 'published_at')->textInput(['maxlength' => 255]); ?> <button id="set-it-now" type="button" class="btn btn-default form-control"><?php echo Yii::t('app', 'Set It Now'); ?> </button> </div> </div> <div class="panel panel-default"> <div class="panel-body">
?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'content')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'tags')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'status')->dropDownList(Lookup::items('PostStatus')); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? ' 新 增 ' : '修 改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
*/ $this->title = Yii::t('app', 'Posts'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="post-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => 'Post']), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'category_id', 'title', ['attribute' => 'type', 'value' => function ($data) { return Lookup::item("{{post}}type", $data->type); }, 'filter' => Lookup::items("{{post}}type")], 'published_at:date', 'views', 'likes', 'comment_count', ['attribute' => 'status', 'value' => function ($data) { return Lookup::item("{{post}}status", $data->status); }, 'filter' => Lookup::items("{{post}}status")], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
use app\models\Lookup; /* @var $this yii\web\View */ /* @var $searchModel app\models\PostSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = '文章管理'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="post-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('新建文章', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'title', 'content:ntext', 'tags:ntext', ['attribute' => 'status', 'value' => function ($model) { return Lookup::item("PostStatus", $model->status); }], 'author.username', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = '评论管理'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="comment-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php /* echo $this->render('_search', ['model' => $searchModel]); // <p> // <?= Html::a('新增', ['create'], ['class' => 'btn btn-success']) ?> // </p> */ ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'content', 'format' => 'ntext', 'contentOptions' => ['width' => "460px"]], ['attribute' => 'status', 'value' => function ($model) { return Lookup::item("CommentStatus", $model->status); }, 'contentOptions' => function ($model) { return $model->status == Comment::STATUS_PENDING ? ['class' => 'bg-danger'] : []; }], ['attribute' => 'create_time', 'format' => ['date', 'php:Y-m-d H:i:s']], 'author', 'post.title', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {approve}', 'buttons' => ['approve' => function ($url, $model, $key) { $options = ['title' => Yii::t('yii', '审核'), 'aria-label' => Yii::t('yii', '审核'), 'data-pjax' => '0']; return Html::a('<span class="glyphicon glyphicon-check"></span>', $url, $options); }]]]]); ?> </div>
<div class="col-md-6 col-md-offset-3"> <h2>We connect idealists with opportunities for action.</h2> <div class="panel panel-default"> <div class="panel-body"> <h4 class="text-center"><?php echo Html::encode("What are you looking for?"); ?> </h4> <div class="organization-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'search_type')->dropDownList(Lookup::items('SearchType'))->label(false); ?> <?php echo $form->field($model, 'search_keyword', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'Name or Keyword or interest']])->textInput(['maxlength' => true])->label(false); ?> <?php echo $form->field($model, 'search_location', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'Where?']])->textInput(['maxlength' => true])->label(false); ?> <div class="form-group text-center"> <?php echo Html::submitButton('Search', ['class' => 'btn btn-success']); ?> </div>
use kartik\tabs\TabsX; /* @var $this yii\web\View */ /* @var $model app\models\Organization */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => 'Organizations', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="organization-view col-md-9 col-md-offset-1-half"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo DetailView::widget(['model' => $model, 'condensed' => true, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'hAlign' => DetailView::ALIGN_LEFT, 'vAlign' => DetailView::ALIGN_TOP, 'panel' => ['heading' => 'Organization details', 'type' => DetailView::TYPE_INFO], 'buttons1' => '{update}', 'buttons2' => '{reset} {save}', 'attributes' => ['name', 'description', ['attribute' => 'org_type', 'value' => Lookup::item('OrganizationType', $model->org_type), 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Lookup::items('OrganizationType')], ['attribute' => 'work_domain', 'value' => Lookup::item('WorkDomain', $model->work_domain), 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Lookup::items('WorkDomain')], 'website', ['attribute' => 'found_date', 'type' => DetailView::INPUT_DATE, 'widgetOptions' => ['pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]]]]); ?> <br/> <?php echo DetailView::widget(['model' => $workModel, 'condensed' => true, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'hAlign' => DetailView::ALIGN_LEFT, 'vAlign' => DetailView::ALIGN_TOP, 'panel' => ['heading' => 'Work details', 'type' => DetailView::TYPE_INFO], 'buttons1' => '{update}', 'buttons2' => '{reset} {save}', 'attributes' => ['vision', 'mission', 'who', 'what', 'why', 'how', 'short_term_goals', 'long_term_goals']]); ?> <br/> <h2>Locations</h2> <?php echo DetailView::widget(['model' => $addressModel, 'condensed' => true, 'hover' => true, 'mode' => DetailView::MODE_VIEW, 'hAlign' => DetailView::ALIGN_LEFT, 'vAlign' => DetailView::ALIGN_TOP, 'hideIfEmpty' => true, 'panel' => ['heading' => 'Add new location', 'type' => DetailView::TYPE_INFO], 'buttons1' => '{update}', 'updateOptions' => ['label' => '<span class="glyphicon glyphicon-plus"></span>'], 'buttons2' => '{reset} {save}', 'attributes' => ['address1', 'address2', 'landmark', 'city', 'state', 'country', 'pincode']]); ?> <?php $i = 1; foreach ($addressDataProvider->models as $address) {
/** * 返回类型 * @param integer $value * @return mixed */ public function asLookupReturnType($value) { if ($value === null) { return $this->nullDisplay; } $options = Lookup::returnTypeOptions(); return isset($options[$value]) ? $options[$value] : $this->nullDisplay; }
<b><?php echo $model->start_date; ?> </b> to <b><?php echo $model->end_date; ?> </b> <br/><br/> <h4 style="font-weight: 600">Where ?</h4> <?php echo $model->location; ?> <br/><br/> <h4 style="font-weight: 600">Engagement ?</h4> <?php echo Lookup::item('EmploymentType', $model->employment_type); ?> </div> </div> </div> <div class="row"> <div class="panel panel-default"> <div class="panel-body"> <h4 style="font-weight: 600">Contact Person</h4> </div> </div> </div> </div>
use app\models\Lookup; /* @var $this yii\web\View */ /* @var $model app\models\Post */ $this->title = $model->title; $this->params['breadcrumbs'][] = ['label' => '文章管理', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="post-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <p> <?php echo Html::a('修改', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a('删除', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'title', 'content:ntext', 'tags:ntext', ['attribute' => 'status', 'value' => Lookup::item("PostStatus", $model->status)], ['attribute' => 'create_time', 'value' => date("Y-m-d H:i:s", $model->create_time)], ['attribute' => 'update_time', 'value' => date("Y-m-d H:i:s", $model->update_time)], ['attribute' => 'author_id', 'value' => $model->author->username]]]); ?> </div>
public function beforeSave() { if ($this->isNewRecord) { $this->create_time = date('Y-m-d H:i:s'); $this->user_id = Yii::$app->user->id; } $this->org_type_text = Lookup::item("OrganizationType", $this->org_type); $this->work_domain_text = Lookup::item("WorkDomain", $this->work_domain); return true; }