Beispiel #1
0
 /**
  * Отобразить карточку темы
  *
  * @param string $alias - url темы
  * @throws CHttpException
  *
  * @return void
  */
 public function actionShow($alias = null)
 {
     $topic = ForumTopic::model()->findByAttributes(array('alias' => $alias));
     if ($topic === null) {
         throw new CHttpException(404, Yii::t('ForumModule.forum', 'Page was not found!'));
     }
     if (($data = Yii::app()->getRequest()->getPost('ForumMessage')) !== null) {
         $model = new ForumMessage();
         $model->setAttributes($data);
         $model->topic_id = $topic->id;
         $model->user_id = Yii::app()->user->id;
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, 'Сообщение добавлено');
             $this->redirect(Yii::app()->createUrl($this->getRoute(), array('alias' => $topic->alias)));
         }
     }
     $this->render('show', array('topic' => $topic));
 }
Beispiel #2
0
 public function getFormattedList()
 {
     $topics = ForumTopic::model()->findAll();
     $list = array();
     foreach ($topics as $topic) {
         $list[$topic->id] = $topic->title;
     }
     return $list;
 }
 /**
  * Возвращает модель по указанному идентификатору
  * Если модель не будет найдена - возникнет HTTP-исключение.
  *
  * @param integer идентификатор нужной модели
  * @return ForumTopic $model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = ForumTopic::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('ForumModule.forum', 'Page was not found!'));
     }
     return $model;
 }
Beispiel #4
0
echo Yii::t('ForumModule.forum', 'Fields with');
?>
    <span class="required">*</span>
    <?php 
echo Yii::t('ForumModule.forum', 'are required.');
?>
</div>

<?php 
echo $form->errorSummary($model);
?>

<div class="row">
    <div class="col-sm-3">
        <?php 
echo $form->dropDownListGroup($model, 'topic_id', ['widgetOptions' => ['data' => ForumTopic::model()->getFormattedList(), 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('topic_id'), 'data-content' => $model->getAttributeDescription('topic_id'), 'empty' => Yii::t('ForumModule.forum', '--no--')]]]);
?>
    </div>
    <div class="col-sm-4">
        <?php 
echo $form->dropDownListGroup($model, 'user_id', ['widgetOptions' => ['data' => $model->getUserList(), 'htmlOptions' => ['class' => 'popover-help', 'data-original-title' => $model->getAttributeLabel('user_id'), 'data-content' => $model->getAttributeDescription('user_id'), 'empty' => Yii::t('ForumModule.forum', '--no--')]]]);
?>
    </div>
</div>

<div class="row">
    <div class="col-sm-12 form-group popover-help"
         data-original-title='<?php 
echo $model->getAttributeLabel('message');
?>
'
Beispiel #5
0
<?php

$this->breadcrumbs = [Yii::t('ForumModule.forum', 'Forums') => ['/forum/forumBackend/index'], Yii::t('ForumModule.forum', 'Topics') => ['/forum/messageBackend/index'], Yii::t('ForumModule.forum', 'Manage')];
$this->pageTitle = Yii::t('ForumModule.forum', 'Messages - manage');
$this->menu = Yii::app()->getModule('forum')->getNavigation();
?>
<div class="page-header">
    <h1>
        <?php 
echo Yii::t('ForumModule.forum', 'Messages');
?>
        <small><?php 
echo Yii::t('ForumModule.forum', 'manage');
?>
</small>
    </h1>
</div>

<p><?php 
echo Yii::t('ForumModule.forum', 'This section describes forum management');
?>
</p>

<?php 
$this->widget('yupe\\widgets\\CustomGridView', ['id' => 'forum-message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['name' => 'id', 'htmlOptions' => ['style' => 'width:20px'], 'type' => 'raw', 'value' => 'CHtml::link($data->id, ["/forum/forumBackend/update", "id" => $data->id])', 'filter' => CHtml::activeTextField($model, 'id', ['class' => 'form-control', 'style' => 'width:20px'])], ['name' => 'topic_id', 'value' => '$data->getTopicTitle()', 'filter' => CHtml::activeDropDownList($model, 'topic_id', ForumTopic::model()->getFormattedList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'user_id', 'value' => '$data->getUserNickname()', 'filter' => CHtml::activeDropDownList($model, 'user_id', ForumMessage::model()->getUserList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'message', 'type' => 'ntext'], ['name' => 'date', 'htmlOptions' => ['style' => 'width:150px'], 'filter' => false], ['class' => 'bootstrap.widgets.TbButtonColumn']]]);
Beispiel #6
0
<?php

$this->breadcrumbs = array(Yii::t('ForumModule.forum', 'Forums') => array('/forum/forumBackend/index'), Yii::t('ForumModule.forum', 'Topics') => array('/forum/messageBackend/index'), Yii::t('ForumModule.forum', 'Manage'));
$this->pageTitle = Yii::t('ForumModule.forum', 'Messages - manage');
$this->menu = Yii::app()->getModule('forum')->getNavigation();
?>
    <div class="page-header">
        <h1>
            <?php 
echo Yii::t('ForumModule.forum', 'Messages');
?>
            <small><?php 
echo Yii::t('ForumModule.forum', 'manage');
?>
</small>
        </h1>
    </div>

    <p><?php 
echo Yii::t('ForumModule.forum', 'This section describes forum management');
?>
</p>

<?php 
$this->widget('yupe\\widgets\\CustomGridView', array('id' => 'forum-message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('style' => 'width:20px'), 'type' => 'raw', 'value' => 'CHtml::link($data->id, array("/forum/forumBackend/update", "id" => $data->id))'), array('name' => 'topic_id', 'value' => '$data->getTopicTitle()', 'filter' => CHtml::activeDropDownList($model, 'topic_id', ForumTopic::model()->getFormattedList(), array('encode' => false, 'empty' => ''))), array('name' => 'user_id', 'value' => '$data->getUserNickname()', 'filter' => CHtml::activeDropDownList($model, 'user_id', ForumMessage::model()->getUserList(), array('encode' => false, 'empty' => ''))), array('name' => 'message', 'type' => 'ntext'), 'date', array('class' => 'bootstrap.widgets.TbButtonColumn'))));
Beispiel #7
0
 public function getTopics($limit = -1)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('forum_id', $this->id);
     $criteria->join = 'LEFT JOIN ' . ForumMessage::model()->tableName() . ' AS fm ON fm.topic_id=t.id';
     $criteria->order = 'fm.topic_id DESC';
     $criteria->group = 't.id';
     $criteria->limit = $limit;
     return ForumTopic::model()->findAll($criteria);
 }
Beispiel #8
0
    <span class="required">*</span>
    <?php 
echo Yii::t('ForumModule.forum', 'are required.');
?>
</div>

<?php 
echo $form->errorSummary($model);
?>

<div class='control-group <?php 
echo $model->hasErrors("topic_id") ? "error" : "";
?>
'>
    <?php 
echo $form->dropDownListRow($model, 'topic_id', ForumTopic::model()->getFormattedList(), array('class' => 'span7', 'encode' => false));
?>
</div>

<div class='control-group <?php 
echo $model->hasErrors("user_id") ? "error" : "";
?>
'>
    <?php 
echo $form->dropDownListRow($model, 'user_id', $model->getUserList(), array('class' => 'span7'));
?>
</div>

<div class="row-fluid control-group <?php 
echo $model->hasErrors('message') ? 'error' : '';
?>