public function loadModel($id) { if (($model = Course::model()->findByPk($id)) === null) { throw new CHttpException(404, 'Страница не найдена'); } return $model; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Lesson the loaded model * @throws CHttpException */ public function loadCourse($courseId) { $model = Course::model()->findByPk($courseId); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
protected function beforeAction($action) { $actions = array('index', 'create'); if (in_array($action->id, $actions)) { $this->course_id = (int) Yii::app()->getRequest()->getParam('course_id'); $this->course = Course::model()->findByPk($this->course_id); } return parent::beforeAction($action); }
/** * 列出某个课程下的所有笔记 * Enter description here ... * @param unknown_type $courseId */ public function actionNote($courseId) { $courseId = intval($courseId); $course = Course::model()->findByPk($courseId); $sql = "select n.*,l.id as lessonId from ew_course c inner join ew_lesson l on c.id=l.courseId inner join ew_note n on n.noteableEntityId=l.entityId where c.id={$courseId}"; $notes = Note::model()->findAllBySql($sql); $dataProvider = new CArrayDataProvider($notes); $this->render('my_notes', array('dataProvider' => $dataProvider, 'course' => $course)); }
public function getProgramsNavigation() { $programsMenu = array('icon' => 'list', 'label' => 'Программы', 'items' => array()); $programs = Course::model()->findAll(); foreach ($programs as $program) { $programsMenu['items'][] = array('icon' => 'list', 'label' => $program->title, 'items' => array(array('icon' => 'list-alt', 'label' => 'Виды', 'url' => array('/classroom/courseTypeBackend/index', 'course_id' => $program->id)), array('icon' => 'list-alt', 'label' => 'Пакеты', 'url' => array('/classroom/packageBackend/index', 'course_id' => $program->id)), array('icon' => 'list-alt', 'label' => 'Таблицы', 'url' => array('/bazi/tableBackend/index', 'course_id' => $program->id)), array('icon' => 'list-alt', 'label' => 'Опросы', 'url' => array('/poll/pollBackend/index', 'course_id' => $program->id)))); } return array($programsMenu); }
public function actionShow($alias) { // Курс $model = Course::model()->published()->with(array('types' => array('scopes' => 'published'), 'blocks' => array('scopes' => 'published'), 'images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->find('t.alias = :alias', array(':alias' => $alias)); if (!$model || $model->disabled) { throw new CHttpException(404); } // Вывод в шаблон $this->render('show', array('model' => $model)); }
public function actionCourseRate($courseId) { $course = Course::model()->findByPk($courseId); $course->viewNum = $course->viewNum + 1; if ($course->save()) { $courseRateView = new CourseRateView(); $courseRateView->userId = Yii::app()->user->isGuest ? 0 : Yii::app()->user->id; $courseRateView->ip = Yii::app()->request->getUserHostAddress(); $courseRateView->courseId = $courseId; $courseRateView->save(); } }
protected function beforeAction($action) { $actions = array('index', 'create'); if (in_array($action->id, $actions)) { $this->item_id = (int) Yii::app()->getRequest()->getParam('item_id'); if (!$this->item_id) { throw new CHttpException(400, 'Не установлен ID программы'); } if (($item = Course::model()->findByPk($this->item_id)) === null) { throw new CHttpException(404, 'Программа не найдена'); } } return parent::beforeAction($action); }
public function getNavigation($full = true) { if ($full) { Yii::import("application.modules.classroom.models.Course"); $programsMenu = array('icon' => 'list', 'label' => 'Страницы программ', 'items' => array()); $programs = Course::model()->findAll(); foreach ($programs as $program) { $programsMenu['items'][] = array('icon' => 'list', 'label' => $program->title, 'items' => array(array('icon' => 'list-alt', 'label' => 'Страница', 'url' => array('/classroom/courseBackend/update', 'id' => $program->id)), array('icon' => 'list-alt', 'label' => 'Блоки', 'url' => array('/classroom/blockBackend/index', 'entity_type' => 'Course', 'entity_id' => $program->id)), array('icon' => 'list-alt', 'label' => 'Отзывы', 'url' => array('/classroom/courseImageBackend/index', 'item_id' => $program->id)))); } } else { $programsMenu = array(); } $menu = array_merge(array($programsMenu), array(array('icon' => 'list', 'label' => 'Общие страницы', 'items' => array(array('icon' => 'list-alt', 'label' => Yii::t('PageModule.page', 'Pages list'), 'url' => array('/page/pageBackend/index')), array('icon' => 'plus-sign', 'label' => Yii::t('PageModule.page', 'Create page'), 'url' => array('/page/pageBackend/create')))), array('icon' => 'list', 'label' => 'Способы оплаты', 'items' => array(array('icon' => 'list-alt', 'label' => 'Способы оплаты', 'url' => array('/dictionary/dictionaryDataBackend/index', 'group_id' => 1)), array('icon' => 'plus-sign', 'label' => 'Добавить способ оплаты', 'url' => array('/dictionary/dictionaryDataBackend/create', 'group_id' => 1)))))); return $menu; }
public function actionView() { if (isset($_REQUEST['code'])) { if ($model = Course::model()->with('category')->findByPk(trim($_REQUEST['code']))) { $this->render('view', array('model' => $model)); Yii::app()->end(); } else { $this->render('//misc/unavailable', array('messageTitle' => 'Page Not Found', 'message' => 'The requested page does not exist.')); Yii::app()->end(); } } $this->render('//misc/unavailable', array('messageTitle' => 'Page Not Found', 'message' => 'The requested page does not exist.')); Yii::app()->end(); //Yii::app()->getUser() }
public function allowOnlyAdmin() { // 如果是站点管理员 if (Yii::app()->user->checkAccess('admin')) { return true; } // 如果是课程管理员 $course = Course::model()->findByPk(intval($_GET['courseId'])); $member = $course->findMember(array('userId' => Yii::app()->user->id)); if ($member && $member->inRoles(array('admin', 'superAdmin'))) { return true; } // 否则返回false return false; }
public function parseUrl($manager,$request,$pathInfo,$rawPathInfo) { if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches)) { // совпадают ли $matches[1] и $matches[3] с // производителем и моделью в базе? // если да, выставляем $_GET['manufacturer'] и/или $_GET['model'] // и возвращаем 'car/index' $alias = Course::model()->findByAttributes(array('alias' => $matches[1]))->course_ID; if($alias){ $_GET['id'] = $alias; return 'course/index'; } } return false; // не применяем правило }
/** * Create * @param integer $groupId * @param integer $courseId */ public function actionCreate($groupId, $courseId) { $model = new GroupCourse(); $course = Course::model()->findByPk($courseId); $group = Group::model()->findByPk($groupId); // $member = $group->findMember(array('userId'=>Yii::app()->user->id)); $member = GroupMember::model()->findByAttributes(array('groupId' => $groupId, 'userId' => Yii::app()->user->id)); if ($course && $member && $member->inRoles(array('admin', 'superAdmin'))) { $model->groupId = $groupId; $model->courseId = $courseId; $model->userId = Yii::app()->user->id; $model->addTime = time(); echo $model->save(); Yii::app()->user->setFlash('success', '收藏成功!'); } echo false; }
/** * Отображение главной страницы * * @return void */ public function actionIndex() { // Загружаем главную страницу Yii::import("application.modules.page.models.Page"); $page = Page::model()->findByPath("index"); // Страница не найдена if ($page === null) { throw new CHttpException('404', Yii::t('PageModule.page', 'Страница не найдена')); } // Список блоков Yii::import("application.modules.block.models.MainPageBlock"); $blocks = MainPageBlock::model()->published()->root()->findAll(); // Список программ Yii::import("application.modules.classroom.models.*"); $programs = Course::model()->published()->subscribeEnabled()->with(array('images' => array('scopes' => 'published', 'order' => 'images.sort ASC')))->findAll(array('order' => 't.sort ASC')); $this->render('index', array('page' => $page, 'blocks' => $blocks, 'programs' => $programs)); }
/** * 添加课程 * @param unknown_type $id */ public function actionCreate($courseId) { $course = Course::model()->findByPk($courseId); $model = new Chapter(); if (isset($_POST['Chapter'])) { $model->attributes = $_POST['Chapter']; $model->userId = Yii::app()->user->id; if ($model->save()) { Yii::app()->user->setFlash('success', Yii::t('app', '添加成功!')); } else { Yii::app()->user->setFlash('error', Yii::t('app', '添加失败!')); } $this->redirect(array('lesson/index', 'courseId' => $model->courseId)); } $model->courseId = $courseId; $this->layout = "/layouts/nonav_column1"; $this->renderPartial('create_fancy', array('course' => $course, 'model' => $model), false, true); }
public function actionShow($alias) { if (Yii::app()->user->isAuthenticated() === false) { $this->controller->redirect(Yii::app()->user->loginUrl); } if (($user = Yii::app()->user->getProfile()) === null) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.')); Yii::app()->user->logout(); $this->controller->redirect((array) '/user/account/login'); } $course = Course::model()->published()->find('t.alias = :alias', array(':alias' => $alias)); if (!$course) { throw new CHttpException(404); } // ToDO // Пакет $package = Package::model()->findByPK(1); // День $dayId = Yii::app()->getRequest()->getParam('day', null); if ($dayId) { $day = Day::model()->published()->package($package->id)->findByPK((int) $dayId); } else { $day = Day::model()->published()->package($package->id)->find(array('order' => 't.number ASC')); } if (!$day) { throw new CHttpException(404); } // Страница $pageId = Yii::app()->getRequest()->getParam('page', null); if ($pageId) { $page = Page::model()->published()->day($day->id)->findByPK((int) $pageId); } else { $page = Page::model()->published()->day($day->id)->find(array('order' => 't.number ASC')); } if (!$page) { throw new CHttpException(404); } // Вывод в шаблон $this->render('show', array('course' => $course, 'package' => $package, 'day' => $day, 'page' => $page)); }
public function actionPayNow(){ if (!isset($_POST['module']) ) { Yii::app()->user->setFlash('error', "<br>Будь-ласка, оберіть курс та модуль для оплати."); $this->redirect(Yii::app()->request->urlReferrer); } $permission = new Permissions(); $lectures = Yii::app()->db->createCommand(array( 'select' => array('id'), 'from' => 'lectures', 'where' => 'idModule=:id', 'params' => array(':id'=>$_POST["module"]), ))->queryAll(); $count = count($lectures); for($i = 0; $i < $count; $i++){ $permission->setRead($_POST['user'], $lectures[$i]["id"]); } Yii::app()->user->setFlash('pay', '<br /><h4>Вітаємо!</h4> Модуль <strong>'. Module::model()->findByPk($_POST["module"])->module_name.'</strong> курса <strong>'. Course::model()->findByPk($_POST['course'])->course_name.'</strong> оплачено. <br />Тепер у Вас є доступ до усіх лекцій цього модуля. <h4>Enjoy it!</h4>'); $this->redirect(Yii::app()->request->urlReferrer); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Semester(); if (!isset($_SESSION['course_id'])) { $_SESSION['course_id'] = 1; } if (isset($_GET['ID'])) { $_SESSION['course_id'] = $_GET['ID']; } $course = Course::model()->find('ID=:ID', array("ID" => $_SESSION['course_id'])); $model->ID_Course = $course->Name; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Semester'])) { $model->attributes = $_POST['Semester']; $model->ID_Course = $_SESSION['course_id']; if ($model->save()) { $this->redirect(array('index', 'id' => $model->ID)); } } $this->render('create', array('model' => $model)); }
private static function getMenuItems($modelRow) { if (!$modelRow) { return; } if (empty($_SESSION['course_id'])) { $course = Course::model()->find(); $_SESSION['course_id'] = (int) $course->ID; } if (isset($_GET['ID'])) { $_SESSION['course_id'] = $_GET['ID']; } if (isset($modelRow->Childs)) { $chump = self::getMenuItems($modelRow->Childs); $controller = Yii::app()->controller->id; $href = Yii::app()->createUrl($controller . '/index/', array('ID' => $modelRow->ID)); $class = ''; if ($_SESSION['course_id'] == $modelRow->ID) { $class = 'class="current-item"'; } if ($chump != null) { $res = array('text' => '<a href="' . $href . '"' . $class . '>' . $modelRow->Name . '</a>', 'children' => $chump); } else { $res = array('text' => '<a href="' . $href . '"' . $class . '>' . $modelRow->Name . '</a>'); //, 'url' => Yii::app()->createUrl('', array('ID' => $modelRow->ID)); } return $res; } else { if (is_array($modelRow)) { $arr = array(); foreach ($modelRow as $leaves) { $arr[] = self::getMenuItems($leaves); } return $arr; } else { return array('text' => $modelRow->Name, 'url' => Yii::app()->createUrl('', array('ID' => $modelRow->ID))); } } }
td{border:0.4px solid #74b9f0;height:24px;} .label{text-align:left;font-weight:normal;color:#990a10;width:110px;height:24px;} </style> <?php $StudentInfo = StudentInfo::model()->findByPk($student_transaction[0]->student_transaction_student_id); $AcademicTermPeriod = AcademicTermPeriod::model()->findByPk($student_transaction[0]->academic_term_period_id); $AcademicTerm = AcademicTerm::model()->findByPk($student_transaction[0]->academic_term_id); if($student_transaction[0]->student_transaction_nationality_id != null) $Nationality = Nationality::model()->findByPk($student_transaction[0]->student_transaction_nationality_id); else $Nationality = new Nationality; $Batch = Batch::model()->findByPk($student_transaction[0]->student_transaction_batch_id); $Course = Course::model()->findByPk($student_transaction[0]->course_id); if($student_transaction[0]->student_transaction_languages_known_id != null) $LanguagesKnown = LanguagesKnown::model()->findByPk($student_transaction[0]->student_transaction_languages_known_id); if($student_transaction[0]->student_transaction_student_address_id != null) $StudentAddress = StudentAddress::model()->findByPk($student_transaction[0]->student_transaction_student_address_id); else $StudentAddress = new StudentAddress; if($student_transaction[0]->student_transaction_parent_id != null || $student_transaction[0]->student_transaction_parent_id != 0) $parent = ParentLogin::model()->findByPk($student_transaction[0]->student_transaction_parent_id); else $parent = new ParentLogin; ?> <h3 class="title">Student Detail</h3> <table class="no_border">
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { if (!is_numeric($id)) { $this->redirect(array('site/error')); } $data = WUserTest::getAllTestByCourseId($id); $arrCourse = Course::model()->find('id=:id', array(':id' => $id)); $this->render('view', array('model' => $data, 'course' => $arrCourse)); }
<div class="row" style="margin-top:50px"> <div class="col-xs-12"> <div style="margin-bottom:26px;font-size:2em;" class="light-green"><?php echo $data->name; ?> <?php //echo CHtml::link('<em>更多</em>',array('group/index'),array('style'=>'font-size:16px;font-weight:normal;')); ?> <div class="pull-right" style="font-size:14px; line-height:40px;"> <?php echo CHtml::link(Yii::t('app', '查看全部 》'), array('course/index'), array('class' => 'theme-color')); ?> </div> </div> <?php $this->widget('booster.widgets.TbThumbnails', array('dataProvider' => Course::model()->getDataProviderByCategory($data->id, 4), 'template' => "{items}", 'itemView' => '_course_item_2', 'emptyText' => Yii::t('app', '暂时还没有该类课程'))); ?> </div> </div>
<?php $courses = Course::model()->active()->findAll(array('order' => 't.sort ASC')); if (!empty($courses)) { $toc = array('label' => 'Программы', 'template' => ' {menu} <i class="icn icn_submenu-arrow-bottom"></i> <i class="icn icn_submenu-arrow-top"></i>', 'items' => array()); foreach ($courses as $course) { $toc['items'][] = array('label' => $course->title, 'url' => $course->getUrl()); } array_splice($this->params['items'], 3, 0, array($toc)); } ?> <ul class="nav"> <li class="nav__item"> <i class="icn icn_nav-menu"></i> <span class="nav__item-label">меню</span> <?php $this->widget('application.modules.menu.widgets.MainMenu', array('items' => $this->params['items'], 'activateParents' => true, 'tagContainer' => 'ul', 'activeCssClass' => 'nav-submenu__item_state_active', 'itemCssClass' => 'nav-submenu__item', 'htmlOptions' => array('class' => 'nav-submenu nav-submenu_level_1 js-nav-submenu_level_1'), 'submenuHtmlOptions' => array('class' => 'nav-submenu nav-submenu_level_2 nav-submenu_level_2'))); ?> </li> </ul>
public function actionAjaxCreate() { $model = new Classmanager(); $_SESSION['course_id'] = 1; if (isset($_GET['ID'])) { $_SESSION['course_id'] = $_GET['ID']; } $course = Course::model()->find(' ID = :id', array('id' => $_SESSION['course_id'])); if (!empty($course)) { $model->ID_course = $course->Name; } // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Classmanager'])) { $model->attributes = $_POST['Classmanager']; $model->ID_course = $_SESSION['course_id']; if ($model->save()) { $this->redirect(array('index', 'id' => $model->ID)); } } $this->renderPartial('_form', array('model' => $model), false, true); }
<?php /* @var $this LessonPrivateNoteController */ /* @var $data LessonPrivateNote */ ?> <li class="thumbnail dxd-lesson-private-note-course-item" > <a style="color:#333;display:block;" href="<?php echo $this->createUrl("lesson/myNotes", array('courseId' => $data->courseId)); ?> "> <h4 style="text-align:center"> <?php $course = Course::model()->findByPk($data->courseId); echo $course->name; ?> </h4> <div class="dxd-private-note-content"> <?php echo mb_substr(strip_tags($data->content), 0, 130, 'utf-8'); ?> </div> <br/> <div class="muted" style="font-size: 0.8em;position: absolute;float: none;bottom: 5px;right: 10px;"> 共 <?php echo $data->siblingCount; ?> 条笔记 </div> <div class="clearfix"></div>
public function getCourse() { $Course = Course::model()->findByAttributes(array('entityId' => $this->rateableEntityId)); return $Course; }
<th>OutStanding Amount</th> </tr> <?php $i=1; $course_fees=$course->course_fees; $totalcollection=count($student_data)*$course_fees; $total_paid=0; $total_out=0; foreach($student_data as $stu_details) { echo '<tr align="center">'; echo '<td>'.$i.'</td>'; echo '<td>'.$stu_details['student_roll_no'].'</td>'; echo '<td>'.$stu_details['student_first_name']." ".$stu_details['student_middle_name']." ".$stu_details['student_last_name'].'</td>'; echo '<td>'.AcademicTermPeriod::model()->findByPk($stu_details['academic_term_period_id'])->academic_term_period.'</td>'; echo '<td>'.Course::model()->findByPk($stu_details['course_id'])->course_name.'</td>'; echo '<td>'.AcademicTerm::model()->findByPk($stu_details['academic_term_id'])->academic_term_name.'</td>'; echo '<td>'.Batch::model()->findByPk($stu_details['student_transaction_batch_id'])->batch_name.'</td>'; echo '<td>'.$course_fees.'</td>'; $paidfees_tmp = Yii::app()->db->createCommand() ->select('sum(fees_payment_amount) as paidfees') ->from('fees_payment_transaction') ->where('fees_payment_student_id = '.$stu_details['student_transaction_id']) ->queryRow(); $paidfees = array_filter($paidfees_tmp); if(!empty($paidfees)) $stu_paidfees = $paidfees['paidfees']; else $stu_paidfees = 0; echo '<td>'.$stu_paidfees.'</td>';
/** * Performs update courses in dropdown list. */ public function actionUpdateCourses() { $courses = Course::model()->findAll('faculty_id=:X', array(':X' => (int) $_POST['faculty_id'])); echo CHtml::label('Mata Kuliah', false); echo CHtml::dropDownList('Note[course_id]', '', CHtml::listData($courses, 'id', 'name'), array('prompt' => '(semua)')); }
<i class="icon-reorder"></i> <div class="portlet-title"><span class="box-title">Automatic SMS Schedule For Absent Student</span> </div> <div class="form"> <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'student-sms-email-details-form', 'enableAjaxValidation'=>true, 'clientOptions'=>array('validateOnSubmit'=>true), )); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php //echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model,'student_sms_email_details_course_id'); ?> <?php echo $form->dropDownList($model,'student_sms_email_details_course_id',CHtml::listData(Course::model()->findAll(),'course_id','course_name'),array( 'prompt' => 'Select Course', 'ajax' => array( 'type'=>'POST', 'url'=>CController::createUrl('dependent/getSmsEmailBatch'), 'update'=>'#StudentSmsEmailDetails_student_sms_email_details_batch_id', //selector to update ))); ?><span class="status"> </span> <?php echo $form->error($model,'student_sms_email_details_course_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'student_sms_email_details_batch_id'); ?> <?php echo $form->dropDownList($model,'student_sms_email_details_batch_id',array(), array('empty' => 'Select Batch')); ?><span class="status"> </span> <?php echo $form->error($model,'student_sms_email_details_course_id'); ?> </div>
/** * 一次性导入优酷视频 * Enter description here ... * @param unknown_type $courseId */ public function actionYoukuPlayList($courseId = 0) { if (isset($_POST['url'])) { $url = $_POST['url']; // $output = Yii::app()->curl->get($_POST['url']); // $partern = ""; Yii::import('ext.SimpleHTMLDOM.SimpleHTMLDOM'); // Create DOM from URL or file $simpleHTML = new SimpleHTMLDOM(); $html = $simpleHTML->file_get_html($url); $urlDict = array('playlist' => array('pattern' => "/\\/playlist_show\\/id_/i", 'selector' => '#list1_1 .items li.v_title a'), 'episode' => array('pattern' => "/\\/show_page\\/id_/i", 'selector' => '#episode li.ititle_w a')); foreach ($urlDict as $key => $item) { if (preg_match($item['pattern'], $url)) { $type = $key; $selector = $item['selector']; break; } } // Find all images foreach ($html->find($selector) as $elem) { $lesson = new Lesson(); $lesson->courseId = $courseId; $lesson->title = $elem->getAttribute("title") ? $elem->getAttribute("title") : $elem->innertext; $pattern = "/id_(.*)\\/?\\.html/i"; preg_match($pattern, $elem->href, $matches); if ($matches[1]) { // http://player.youku.com/player.php/sid/XNTk5MTQ3OTQ0/v.swf $lesson->url = "http://player.youku.com/player.php/sid/{$matches['1']}/v.swf"; } else { continue; } $lesson->addTime = time(); $lesson->save(); } $this->redirect(array('lesson/editByCourse', 'courseId' => $courseId)); Yii::app()->end(); } $course = Course::model()->findByPk($courseId); $this->renderPartial("youkuPlayList", array('course' => $course), false, true); }