當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Course::model方法代碼示例

本文整理匯總了PHP中Course::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Course::model方法的具體用法?PHP Course::model怎麽用?PHP Course::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Course的用法示例。


在下文中一共展示了Course::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadModel

 public function loadModel($id)
 {
     if (($model = Course::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:7,代碼來源:CourseBackendController.php

示例2: loadCourse

 /**
  * 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;
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:15,代碼來源:CaController.php

示例3: beforeAction

 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);
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:9,代碼來源:PackageBackendController.php

示例4: actionNote

 /**
  * 列出某個課程下的所有筆記
  * 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));
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:14,代碼來源:MeController.php

示例5: getProgramsNavigation

 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);
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:9,代碼來源:ClassroomModule.php

示例6: actionShow

 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));
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:10,代碼來源:CourseController.php

示例7: actionCourseRate

 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();
     }
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:12,代碼來源:ViewCountController.php

示例8: beforeAction

 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);
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:14,代碼來源:CourseImageBackendController.php

示例9: getNavigation

 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;
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:15,代碼來源:PageModule.php

示例10: actionView

 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()
 }
開發者ID:jayrulez,項目名稱:kcconline,代碼行數:15,代碼來源:CourseController.php

示例11: allowOnlyAdmin

 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;
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:15,代碼來源:AnnouncementController.php

示例12: parseUrl

 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;  // не применяем правило
 }
開發者ID:nico13051995,項目名稱:IntITA,代碼行數:16,代碼來源:CoursesRule.php

示例13: actionCreate

 /**
  * 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;
 }
開發者ID:stan5621,項目名稱:jp_edu_online,代碼行數:22,代碼來源:CourseController.php

示例14: actionIndex

 /**
  * Отображение главной страницы
  *
  * @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));
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:22,代碼來源:SiteController.php

示例15: actionCreate

 /**
  * 添加課程
  * @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);
 }
開發者ID:stan5621,項目名稱:eduwind,代碼行數:22,代碼來源:ChapterController.php


注:本文中的Course::model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。