Esempio n. 1
0
 /**
  * Prepare data for frontend controller
  * @return array
  */
 public static function getPreparedJsonEntries()
 {
     $entries = Entry::find()->orderBy('name')->asArray()->all();
     $categories = Category::find()->orderBy('name')->asArray()->all();
     // Sort entries
     $sortedEntries = [];
     foreach ($entries as $k => $e) {
         $e['type'] = self::TYPE_ENTRY;
         $sortedEntries[$e['category']][] = $e;
     }
     return static::recursiveTree($categories, $sortedEntries);
 }
Esempio n. 2
0
    <h2>@<?php 
echo Html::encode($model->user->screen_name);
?>
</h2>

    <p class="well well-sm"><?php 
echo Html::encode($model->text);
?>
</p>  

    <?php 
echo $form->field($model, 'contest_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Contest::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select a Contest ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'entry_id')->widget(DepDrop::classname(), ['data' => ArrayHelper::map(Entry::find()->where(['contest_id' => $model->contest_id])->all(), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Select a Entry ...')], 'type' => DepDrop::TYPE_SELECT2, 'select2Options' => ['pluginOptions' => ['allowClear' => true]], 'pluginOptions' => ['depends' => ['tweet-contest_id'], 'url' => Url::to(['/entry/contest-entries']), 'loadingText' => Yii::t('app', 'Loading Entries ...')]]);
?>

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

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

    <?php 
ActiveForm::end();
?>
 /**
  * Returns a list of possible 
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionContestEntries()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $id = end($_POST['depdrop_parents']);
         $list = Entry::find()->where(['contest_id' => $id])->asArray()->all();
         $selected = null;
         if ($id != null && count($list) > 0) {
             $selected = '';
             foreach ($list as $i => $entry) {
                 $out[] = ['id' => $entry['id'], 'name' => $entry['name']];
                 if ($i == 0) {
                     $selected = $entry['id'];
                 }
             }
             // Shows how you can preselect a value
             echo Json::encode(['output' => $out, 'selected' => $selected]);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
Esempio n. 4
0
?>
            </p>

            <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['trigger', 'year', 'active:boolean', 'last_parse', 'parse_from', 'parse_to']]);
?>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <h2><?php 
echo Yii::t('app', 'Entries');
?>
</h2>

        <?php 
if (!Yii::$app->user->isGuest) {
    echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => 'Entry']), ['entry/create', 'id' => $model->id], ['class' => 'btn btn-success']);
}
?>


        <?php 
echo GridView::widget(['dataProvider' => new ActiveDataProvider(['query' => Entry::find()->where(['contest_id' => $model->id])]), 'columns' => [['attribute' => 'contest_entry_id', 'format' => 'raw', 'value' => function ($data) {
    return Html::a(Html::encode($data->contest_entry_id), ['entry/view', 'id' => $data->id]);
}], 'avg_rating', ['attribute' => 'min_rating', 'contentOptions' => ['class' => 'hidden-xs'], 'headerOptions' => ['class' => 'hidden-xs']], ['attribute' => 'max_rating', 'contentOptions' => ['class' => 'hidden-xs'], 'headerOptions' => ['class' => 'hidden-xs']], 'votes']]);
?>
    </div>
</div>
Esempio n. 5
0
 /**
  *
  * @param $id
  */
 public function destroy($id)
 {
     Entry::find($id)->delete();
     return $this->responseNoContent();
 }