Exemplo n.º 1
0
 /**
  * 返回对应的Entity
  */
 public function getEntity()
 {
     if (!$this->_entity) {
         $this->_entity = Entity::model()->findByAttributes(array('id' => $this->entityId));
     }
     return $this->_entity;
 }
Exemplo n.º 2
0
 public static function getIdByType($type)
 {
     $entity = Entity::model()->find('type=:type', array(':type' => $type));
     if ($entity) {
         return $entity->id;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
<?php

/* @var $this NoticeController */
/* @var $data Notice */
$comment = Comment::model()->findByPk($data['commentId']);
$entity = Entity::model()->findByPk($comment->commentableEntityId);
if (!$comment || !$entity->getModel()) {
    return false;
}
?>
	<?php 
echo CHtml::link($comment->user->name, $comment->user->pageUrl);
?>
回复了
	<?php 
echo $entity->getTypeLabel();
?>
	<?php 
echo CHtml::link($entity->getTypeLabel(), array($entity->type . '/view', 'id' => $entity->getModel()->id));
Exemplo n.º 4
0
<?php

/* @var $this NoticeController */
/* @var $data Notice */
$vote = Vote::model()->findByPk($data['voteid']);
$entity = @Entity::model()->findByPk($vote->voteableEntityId);
$model = @$entity->getModel();
if (!$vote || !$model) {
    return false;
}
?>
你的
<?php 
echo $entity->getTypeLabel();
echo CHtml::link($entity->getTitle(), array($entity->type . '/view', 'id' => $model->id));
?>
新增加一个<em><?php 
echo $vote->value > 0 ? "<span style=\"color:green\">赞同</span>" : "<span style=\"color:red\">反对</span>";
?>
</em>
Exemplo n.º 5
0
 public function actionAddComment($commentableEntityId)
 {
     $comment = new Comment();
     //$model = $this->loadModel($id?$id:$lessonId);
     $entity = Entity::model()->findByPk($commentableEntityId);
     $model = $entity->getModel();
     if (isset($_POST['Comment'])) {
         $comment->attributes = $_POST['Comment'];
         if ($model->addComment($comment)) {
             Yii::app()->user->setFlash('success', Yii::t('app', '发表成功!'));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('app', '抱歉,发表失败!'));
         }
         if ($model instanceof Lesson) {
             $course = $model->course;
         } else {
             $course = $model;
         }
         //if($model->addComment($comment)){
         $commentDataProvider = $course->getCommentDataProvider();
         //	var_dump($commentDataProvider->getData());
         $this->renderPartial('_comments', array('commentDataProvider' => $commentDataProvider, 'course' => $course), false, true);
         //	}
     }
 }