/** * Lists all ContentRecord models. * @return mixed */ public function actionIndex($topic_id) { $profile_videos = ContentRecord::find()->where(['topic_id' => $topic_id, 'type' => 'video'])->all(); $profile_pdf = ContentRecord::find()->where(['topic_id' => $topic_id, 'type' => 'pdf'])->all(); $profile_img = ContentRecord::find()->where(['topic_id' => $topic_id, 'type' => 'img'])->all(); $topic = TopicRecord::findOne($topic_id); return $this->render('index', ['topic' => $topic, 'model_videos' => $profile_videos, 'model_pdf' => $profile_pdf, 'model_img' => $profile_img]); }
/** * Lists all TopicRecord models. * @return mixed */ public function actionIndex($course_id, $university, $faculty, $program) { $model = TopicRecord::findAll(['course_id' => $course_id]); //$university=UniversityRecord::findOne(['id'=>$university])->name; //$faculty=FacultyRecord::findOne($faculty)->name; $course = CourseRecord::findOne($course_id)->name; return $this->render('index', ['model' => $model, 'university' => $university, 'faculty' => $faculty, 'program' => $program, 'course' => $course]); }
public function actionShow($id) { $program = ProgramRecord::findOne($id); $courses = CourseRecord::find()->where(['program_id' => $id])->all(); $course_ids = ArrayHelper::getColumn($courses, 'id'); $topics = TopicRecord::find()->where(['course_id' => $course_ids])->all(); $topic_ids = ArrayHelper::getColumn($topics, 'id'); $program_videos = ContentRecord::find()->where(['topic_id' => $topic_ids, 'type' => 'video'])->all(); $program_pdf = ContentRecord::find()->where(['topic_id' => $topic_ids, 'type' => 'pdf'])->all(); $program_img = ContentRecord::find()->where(['topic_id' => $topic_ids, 'type' => 'img'])->all(); return $this->render('show', ['model_videos' => $program_videos, 'model_pdf' => $program_pdf, 'model_img' => $program_img, 'id' => $id, 'program' => $program]); }
</object> <?php } else { ?> <?php echo Html::img('@web/assets/Uploads/' . $model->name, ['class' => "img-responsive", 'style' => 'margin:0 auto;']); ?> <?php } ?> </div> <span class="label green"> <strong> <?php $topic = \common\models\topic\TopicRecord::findOne($model->topic_id); $course = \common\models\course\CourseRecord::findOne($topic->course_id); $program = \common\models\program\ProgramRecord::findOne($course->program_id); $faculty = \common\models\faculty\FacultyRecord::findOne($program->faculty_id); $univ = \common\models\university\UniversityRecord::findOne($faculty->university_id); echo Html::a($topic->name, ['content/index', 'topic_id' => $topic->id, 'university' => $univ->name, 'faculty' => $faculty->name, 'program' => $program->name, 'course' => $course->name], ['style' => 'color:black;']); ?> </strong> </span> <span class="label blue"> <strong> <?php echo Html::a($course->name, ['topic/index', 'course_id' => $course->id, 'university' => $univ->name, 'faculty' => $faculty->name, 'program' => $program->name], ['style' => 'color:black;']); ?> </strong> </span>
/** * @return \yii\db\ActiveQuery */ public function getTopicRecords() { return $this->hasMany(TopicRecord::className(), ['parent_id' => 'id']); }
public function actionUpdate() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; $data = Yii::$app->request->post(); $like_status = $data['like_status']; $present_status = $data['present_status']; $id = $data['id']; //echo $data; //for finding program of content $topic_id = ContentRecord::findOne($id)->topic_id; $course_id = TopicRecord::findOne($topic_id)->course_id; $program_id = CourseRecord::findOne($course_id)->program_id; $program = ProgramRecord::findOne($program_id); //end of finding program of content if ($like_status != $present_status) { if ($like_status == -1) { $likeOrDislike = new LikeDislikeContent(); $likeOrDislike->content = $id; $likeOrDislike->likedOrDislikedBy = \Yii::$app->user->identity->getId(); $likeOrDislike->likeOrDislike = $present_status; $likeOrDislike->save(); //for program like counter if ($present_status == 0) { $program->noOfDislikes += 1; } else { $program->noOLikes += 1; } $program->save(); } else { $likeOrDislike = LikeDislikeContent::findOne(['content' => $id, 'likedOrDislikedBy' => \Yii::$app->user->identity->getId()]); $likeOrDislike->likeOrDislike = $present_status; $likeOrDislike->save(); //for program counter if ($present_status == 0) { $program->noOfDislikes += 1; $program->noOLikes -= 1; } else { $program->noOfDislikes -= 1; $program->noOLikes += 1; } $program->save(); } } else { $likeOrDislike = LikeDislikeContent::findOne(['content' => $id, 'likedOrDislikedBy' => \Yii::$app->user->identity->getId()]); $likeOrDislike->delete(); //for program like counter if ($present_status == 0) { $program->noOfDislikes -= 1; } else { $program->noOLikes -= 1; } $program->save(); } $likes = LikeDislikeContent::find()->where(['content' => $id, 'likeOrDislike' => 1]); $dislikes = LikeDislikeContent::find()->where(['content' => $id, 'likeOrDislike' => 0]); $likeOrDislike = LikeDislikeContent::findOne(['content' => $id, 'likedOrDislikedBy' => \Yii::$app->user->identity->getId()]); if ($likeOrDislike == null) { $new_like_status = -1; } else { $new_like_status = $likeOrDislike->likeOrDislike; } return ['new_like_status' => $new_like_status, 'new_id' => $id, 'likes' => $likes->count(), 'dislikes' => $dislikes->count()]; } }
<?php use yii\helpers\Html; $program = \common\models\program\ProgramRecord::findOne($program_id)->name; ?> <div class="card-panel horizontal-listing no-padding search-class"> <div class="container-fluid"> <h4 class="black-text"><?php echo $program; ?> <i class="material-icons"></i></h4> <hr> <?php foreach ($models as $model) { $topics = \common\models\topic\TopicRecord::find()->where(['course_id' => $model->id]); ?> <a> <div class="row hoverable"> <div class="col-sm-4"> <img src="http://mdbootstrap.com/images/reg/reg%20(54).jpg" class="img-responsive z-depth-2"> </div> <div class="col-sm-8"> <?php $link_course = '<h5 class="title">' . $model->name . '</h5>'; echo Html::a($link_course, ['/topic/index', 'course_id' => $model->id, 'university' => $university, 'faculty' => $faculty, 'program' => $program]); ?> <ul class="list-inline item-details"> <li><i class="fa fa-clock-o"> 05/10/2015 | </i></li> <li><a>Topics <?php echo $topics->count(); ?>
public function actionTopics($id) { $first = 1; $count = TopicRecord::find()->where(['course_id' => $id])->count(); $topics = TopicRecord::find()->where(['course_id' => $id])->all(); if ($count > 0) { echo "<option value='" . $first . "'>" . 'select' . "</option>"; foreach ($topics as $topic) { echo "<option value='" . $topic->id . "'>" . $topic->name . "</option>"; } } else { echo "<option>-</option>"; } }