Esempio n. 1
0
 /**
  * Render file browser for editor and file input
  *
  * @param int|null $post_id
  * @param bool     $editor
  *
  * @throws \yii\web\NotFoundHttpException
  * @return string
  */
 public function actionPopup($post_id = null, $editor = false)
 {
     $this->layout = "blank";
     $model = new Media(['scenario' => 'upload']);
     $showButtons = Yii::$app->request->post('show_buttons') == 'false' ? false : true;
     if ($post_id) {
         if ($post = Post::findOne($post_id)) {
             return $this->render('popup', ['post' => $post, 'model' => $model, 'editor' => $editor, 'showButtons' => $showButtons]);
         } else {
             throw new NotFoundHttpException(Yii::t('content', 'The requested page does not exist.'));
         }
     }
     return $this->render('popup', ['model' => $model, 'editor' => $editor, 'showButtons' => $showButtons]);
 }
Esempio n. 2
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, it will return false.
  *
  * @param integer $id
  *
  * @return Post|bool|null|static
  */
 protected function findPost($id)
 {
     if (($model = Post::findOne($id)) !== null) {
         return $model;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param integer $id
  *
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Post::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
            <div class="col-sm-7 col-sm-push-2">
                <?php 
echo Html::radioList('Option[show_on_front][option_value]', $model->show_on_front->option_value, ['page' => Yii::t('content', 'Static page')], ['separator' => '<br />', 'class' => 'radio']);
?>
                <?php 
echo Html::label(Yii::t('content', 'Front page: '), 'option-front_page');
?>
                <?php 
echo Html::dropDownList('Option[front_page][option_value]', $model->front_page->option_value, Post::findOne($model->front_page->option_value) ? ArrayHelper::map(Post::find()->select(['id', 'post_title'])->where(['id' => $model->front_page->option_value])->all(), 'id', 'post_title') : [], ['class' => 'search-post', 'disabled']);
?>

                <?php 
echo Html::label(Yii::t('content', 'Posts page: '), 'option-posts_page');
?>
                <?php 
echo Html::dropDownList('Option[posts_page][option_value]', $model->posts_page->option_value, Post::findOne($model->posts_page->option_value) ? ArrayHelper::map(Post::find()->select(['id', 'post_title'])->where(['id' => $model->posts_page->option_value])->all(), 'id', 'post_title') : [], ['class' => 'search-post', 'disabled']);
?>
            </div>
        </div>

        <div class="form-group">
            <?php 
echo Html::label(Yii::t('content', 'Posts per page'), 'option-post_per_page', ['class' => 'col-sm-2 control-label']);
?>
            <div class="col-sm-7">
                <?php 
echo Html::input('number', 'Option[posts_per_page][option_value]', $model->posts_per_page->option_value, ['id' => 'option-post_per_page', 'min' => 1, 'step' => 1]);
?>
            </div>
        </div>
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param string $post_slug
  *
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModelBySlug($post_slug)
 {
     $model = Post::findOne(['post_slug' => $post_slug, 'post_status' => 'publish']);
     if ($model) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }