Beispiel #1
0
 public function run()
 {
     if (isset($this->model->rating)) {
         $rating = $this->model->rating;
     } else {
         $rating = Rating::getValue($this->model);
         $rating = Rating::getHtml($rating);
     }
     $model_id = get_class($this->model);
     $value = null;
     if (!Yii::app()->user->isGuest) {
         $value = Rating::model()->fetchScalarByAttributes(array('user_id' => Yii::app()->user->id, 'object_id' => $this->model->id, 'model_id' => $model_id), 'value');
     }
     $this->render('RatingWidget', array('object_id' => $this->model->id, 'user_id' => $this->model->getUserId(), 'model_id' => $model_id, 'rating' => $rating, 'value' => $value));
 }
 public function actionCreate()
 {
     if (!isset($_POST['Rating'])) {
         $this->badRequest();
     }
     $rating = Rating::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'object_id' => $_POST['Rating']['object_id'], 'model_id' => $_POST['Rating']['model_id']));
     if (!$rating) {
         $rating = new Rating();
     }
     $rating->attributes = $_POST['Rating'];
     if ($rating->save()) {
         $rating = Rating::getValue($rating->model_id, $rating->object_id);
         echo Rating::getHtml($rating);
     } else {
         echo CJSON::encode(array('errors' => $rating->errors_flat_array));
     }
 }
Beispiel #3
0
                        </div>
                        <div class="published" style="float:right"><?php 
            echo $last_comment->value('date_create');
            ?>
</div>
                    <?php 
        } else {
            ?>
                        <span class="span.italic-12">отсутсвует</span>
                    <?php 
        }
        ?>
                </td>
                <td class="align-center">
                    <?php 
        echo Rating::getHtml($page, ['style' => 'float:none']);
        ?>
                </td>
                <td class="align-center">
                    <?php 
        echo $page->comments_count;
        ?>
                </td>
                <td class="align-center">
                    <?php 
        echo $page->comments_count;
        ?>
                </td>
            </tr>
        <?php 
    }