<div class="col-xs-3"> <div class="pull-right"> <a href="/delete?id=<?php echo $model->id; ?> " title="Удалить пост" ><span class="glyphicon glyphicon-remove text-danger"></span></a> </div> </div> </div> <div class="well"> <?php $model->text = ContentGenerator::Format($model->text); if ($data = json_decode($model->text)) { // анализ и вывод соответствующего объекта: картинка, галлерея, файл, музыка, видео, гиперссылка echo ContentGenerator::parse($data); } else { echo str_replace("\n", "<br>", $model->text); /*Html::encode()*/ // plain text, not json } ?> <?php if (!empty($model->tags)) { ?> <br>-- <br> <?php foreach ($model->tags as $tag) { ?> <?php
public function actionEdit($id) { $model = Moderation::findOne((int) $id); if (!$model) { throw new Exception("Запись не найдена!"); } if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post(), $model->formName()) && $model->validate() && !Yii::$app->request->post('nosave', false)) { $post = new Post(); $post->attributes = $model->attributes; $post->visible = true; $tags = Yii::$app->request->post($model->formName(), ['tags' => []])['tags']; if ($post->save()) { if (!empty($tags)) { foreach ($tags as $tag) { $modelTag = Tag::add($tag); if ($modelTag) { $post->link('tags', $modelTag); } } } $model->delete(); // публикация в твиттере ContentGenerator::Twitter($post); return $this->redirect('moderate'); } } return $this->render('_edit', ['model' => $model]); }