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]);
 }
                    <?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>
                <span class="label blue-grey">
                    <strong>
 public function actionRemoveoraddfollow()
 {
     if (Yii::$app->request->isAjax) {
         $data = Yii::$app->request->post();
         $program_id = $data['program_id'];
         $follow_status = $data['follow_status'];
         $program = ProgramRecord::findOne($program_id);
         if ($follow_status == 'Follow') {
             $follow_program = new FollowerProgram();
             $follow_program->program_id = $program_id;
             $follow_program->user_id = \Yii::$app->user->identity->getId();
             if ($follow_program->save()) {
                 $program->noOfFollowers += 1;
                 $program->save();
                 $return_message = 0;
             }
         } else {
             $follow_program = FollowerProgram::findOne(['program_id' => $program_id, 'user_id' => \Yii::$app->user->identity->getId()]);
             if ($follow_program->delete()) {
                 $program->noOfFollowers -= 1;
                 $program->save();
                 $return_message = 1;
             }
         }
         return $return_message;
     }
 }
 public function suggestionsForPrograms()
 {
     $current_user = \Yii::$app->user->identity->getId();
     $programsFollowedByCurrentUser = FollowerProgram::find()->where(['user_id' => $current_user])->all();
     if (empty($programsFollowedByCurrentUser)) {
         $programs = ProgramRecord::find()->all();
         $scoresOfEachProgram = [];
         $models = [];
         foreach ($programs as $program) {
             $follows = $program->noOfFollowers;
             $likes = $program->noOLikes;
             $dislikes = $program->noOfDislikes;
             $score = 2 * $follows + $likes - 0.5 * $dislikes;
             $scoresOfEachProgram[$program->id] = $score;
         }
         arsort($scoresOfEachProgram);
         foreach (array_keys($scoresOfEachProgram) as $id) {
             $program = ProgramRecord::findOne($id);
             array_push($models, $program);
         }
         return $models;
     } else {
         $targetPrograms = [];
         foreach ($programsFollowedByCurrentUser as $followedProgram) {
             $allFollowersOfFollowedProgram = FollowerProgram::find()->where(['program_id' => $followedProgram->program_id])->all();
             foreach ($allFollowersOfFollowedProgram as $singleFollowerOfFollowee) {
                 $followeesOfFollowerOfFolloweesOfCurrentUser = FollowerProgram::find()->where(['user_id' => $singleFollowerOfFollowee->user_id])->all();
                 foreach ($followeesOfFollowerOfFolloweesOfCurrentUser as $targetProgram) {
                     array_push($targetPrograms, $targetProgram);
                 }
             }
         }
         $followingProgramsIds = ArrayHelper::getColumn($programsFollowedByCurrentUser, 'program_id');
         $targetProgramsIds = ArrayHelper::getColumn($targetPrograms, 'program_id');
         $resultProgramsIds = array_diff($targetProgramsIds, $followingProgramsIds);
         $countOfPrograms = array_count_values($resultProgramsIds);
         $scoresOfEachProgram = [];
         foreach (array_unique($resultProgramsIds) as $programId) {
             $followersOfProgram = FollowerProgram::find()->where(['program_id' => $programId])->all();
             $firstWeight = count($followersOfProgram);
             $secondWeight = $countOfPrograms[$programId];
             $scoresOfEachProgram[$programId] = ($firstWeight + $secondWeight) / 2;
         }
         $models = [];
         arsort($scoresOfEachProgram);
         foreach (array_keys($scoresOfEachProgram) as $id) {
             $program = ProgramRecord::findOne($id);
             array_push($models, $program);
         }
         return $models;
     }
 }
Beispiel #5
0
use yii\helpers\Html;
$university = \common\models\university\UniversityRecord::findOne($university_id)->name;
$this->params['breadcrumbs'][] = $university;
?>
<!--1 Coulm horizontal listing-->
<div class="card-panel horizontal-listing no-padding search-class">
    <div class="container-fluid">
        <h4 class="black-text"><?php 
echo $university;
?>
<i class="material-icons"></i></h4>
        <hr>
        <?php 
foreach ($models as $model) {
    $programs = \common\models\program\ProgramRecord::find()->where(['faculty_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_faculty = '<h5 class="title">' . $model->name . '</h5>';
    echo Html::a($link_faculty, ['/program/index', 'university' => $university, 'faculty_id' => $model->id]);
    ?>
                        <ul class="list-inline item-details">
                            <li><i class="fa fa-clock-o"> 05/10/2015 | </i></li>
                            <li><a>Programs <?php 
    echo $programs->count();
Beispiel #6
0
<?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();
    ?>