Example #1
0
 public function actionDelete()
 {
     $model = BlogPost::findByPk($_POST['BlogPost']);
     $model->status = BlogPost::STATUS_DELETED;
     $model->save();
     $this->goToAction('index');
 }
Example #2
0
 public function actionRead($id)
 {
     $this->assign('article', $art = BlogPost::findByPk($id));
     if ($art->allow_comments) {
         $model = new BlogComment();
         $model->post_id = $id;
         if (isset($_POST['BlogComment']) && $model->setAttributes($_POST['BlogComment'])->save()) {
             Messages::get()->success("Comment saved!");
             $this->goBack();
         }
         $this->assign('model', $model);
         $this->assign('comments', BlogComment::findAllByAttributes(['post_id' => $id, 'status' => BlogComment::STATUS_OK]));
     }
 }
Example #3
0
<?php

require_once dirname(dirname(__DIR__)) . '/layout/header.php';
echo \mpf\widgets\datatable\Table::get(['dataProvider' => $model->getDataProvider(), 'columns' => ['url', 'author_id' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\app\models\User::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogPost $model) {
    return $model->author->name;
}], 'category_id' => ['filter' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\blog\models\BlogCategory::findAll(), ['id' => 'name']), 'value' => function (\mpf\modules\blog\models\BlogPost $model) {
    return $model->category->name;
}], 'time_written' => ['class' => 'Date'], 'time_published' => ['class' => 'Date'], 'status' => ['filter' => \mpf\modules\blog\models\BlogPost::getStatuses(), 'value' => function (\mpf\modules\blog\models\BlogPost $model) {
    $all = \mpf\modules\blog\models\BlogPost::getStatuses();
    return $all[$model->status];
}], ['class' => 'Actions', 'buttons' => ['delete' => ['class' => 'Delete'], 'edit' => ['class' => 'Edit'], 'publish' => ['post' => ['{{modelKey}}' => '$row->id'], 'confirmation' => \app\components\htmltools\Translator::get()->t("Are you sure that you want to publish the article?"), 'title' => '"Publish Article"', 'url' => "\\mpf\\WebApp::get()->request()->createURL('articles', 'publish')", 'icon' => '%MPF_ASSETS%images/oxygen/%SIZE%/actions/view-task.png', 'visible' => "\$row->status != " . \mpf\modules\blog\models\BlogPost::STATUS_PUBLISHED]], 'headerHtmlOptions' => ['style' => 'width:60px;']]]])->display();
require_once dirname(dirname(__DIR__)) . '/layout/footer.php';
Example #4
0
<?php

require_once dirname(dirname(__DIR__)) . '/layout/header.php';
echo \mpf\widgets\form\Form::get(['name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'formHtmlOptions' => ['enctype' => 'multipart/form-data'], 'fields' => \mpf\modules\blog\models\BlogPost::getFormFields()])->display();
require_once dirname(dirname(__DIR__)) . '/layout/footer.php';