当前位置: 首页>>代码示例>>PHP>>正文


PHP WebModule::initializeForPage方法代码示例

本文整理汇总了PHP中WebModule::initializeForPage方法的典型用法代码示例。如果您正苦于以下问题:PHP WebModule::initializeForPage方法的具体用法?PHP WebModule::initializeForPage怎么用?PHP WebModule::initializeForPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebModule的用法示例。


在下文中一共展示了WebModule::initializeForPage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initializeForPage

 protected function initializeForPage()
 {
     $this->controller = DataRetriever::factory('MoodleDataRetriever', array());
     switch ($this->page) {
         case 'index':
             $this->assign('message', 'Hello World');
             # hard coded values
             # should be replaced by authentication
             //
             //                $user = array(
             //                    'username' => '620065739',
             //                    'password' => '19941206',
             //                    'service' => 'moodle_mobile_app'
             //                );
             //
             //                # get user's moodle token
             //                $this->token = $this->controller->getToken($user); #JSON obj
             //                $this->assign('token', $this->token['token']);
             $userParam = array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742', 'wsfunction' => 'core_webservice_get_site_info');
             # Retrieve user information
             $userInfo = $this->controller->getUserId($userParam);
             $this->assign('info', $userInfo['userid']);
             # Retrieve json list of courses
             $coursesParam = array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742', 'wsfunction' => 'core_enrol_get_users_courses', 'userid' => $userInfo['userid']);
             # Retrieve user courses and converts json to php array
             $userCourses = $this->controller->getCourses($coursesParam);
             //                print_r($userCourses);
             # prep list for courses
             $coursesList = array();
             //                foreach ($userCourses as $courseData)
             //                {
             //                    $course = array(
             //                        'id' => $courseData['id'],
             //                        'shortname' => $courseData['shortname'],
             //                        'fullname' => $courseData['fullname'],
             //                        'usercount' => $courseData['enrolledusercount'],
             //                        'idnumber' => $courseData['idnumber'],
             //                        'url' =>  '/courses/details?wstoken=47aae912ad404c743d7b66ad0c6c0742&wsfunction=core_course_get_contents&courseid=' . $courseData['id']
             //                    );
             //                    $coursesList[] = $course;
             //                }
             foreach ($userCourses as $courseData) {
                 $course = array('subtitle' => $courseData['shortname'], 'title' => $courseData['fullname'], 'url' => $this->buildBreadcrumbURL('details', array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742', 'wsfunction' => 'core_course_get_contents', 'courseid' => $courseData['id'])));
                 $coursesList[] = $course;
             }
             $this->assign('coursesList', $coursesList);
             break;
             # 'url' => $this->buildBreadcrumbURL('details', array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742','wsfunction' => 'core_course_get_contents', 'courseid' => $courseData['id']), false)
         # 'url' => $this->buildBreadcrumbURL('details', array('wstoken' => '47aae912ad404c743d7b66ad0c6c0742','wsfunction' => 'core_course_get_contents', 'courseid' => $courseData['id']), false)
         case 'details':
             $id = $this->getArg('courseid');
             $token = $this->getArg('wstoken');
             $func = $this->getArg('wsfunction');
             $this->assign('wstoken', $token);
             $this->assign('id', $id);
             $this->assign('func', $func);
             if ($courseContent = $this->controller->getContent($id, $token, $func)) {
                 $contentList = array();
                 foreach ($courseContent as $section) {
                     $detail = array('subtitle' => $section['id'], 'title' => $section['name']);
                     $contentList[] = $detail;
                 }
                 $this->assign('contentList', $contentList);
             }
             //                else {
             //                    $this->redirectTo('index');
             //                }
             break;
         default:
             parent::initializeForPage();
     }
     //<KEY name="idnumber"> &wsfunction=core_course_get_contents&courseid=76
     //<VALUE>JAPA10010</VALUE>
     //</KEY>
     //  wsfunction=core_enrol_get_users_courses&userid=9742
     //
     //        switch($this->page)
     //        {
     //            case 'index':
     //                # Retrieve user information
     //                $userInfo = $this->$controller->getUserId($userParam);
     //
     //                # Retrieve json list of courses
     //                $coursesParam = array(
     //                    'wstoken' => $this->$token['wstoken'],
     //                    'wsfunction' => 'moodlewsrestformat',
     //                    'moodlewsrestformat' => 'json'
     //                );
     //                $userCourses = $this->controller->getCourses($coursesParam);
     //
     //                $courseList = array();
     //                foreach ($userCourses as $courseData) {
     //                    $course = array(
     //                        'wstoken' => $this->$token['wstoken'],
     //                        'shortname' => $courseData['shortname'],
     //                        'fullname' => $courseData['fullname'],
     //                        'url' => $this->buildBreadcrumbURL('content', array('id' => $courseData['id'], 'token' => $token['wstoken'], 'name' => $courseData['shortname']))
     //                    );
     //                    $courseList[] = $course;
     //                }
//.........这里部分代码省略.........
开发者ID:sponto,项目名称:msbm-mobile,代码行数:101,代码来源:CoursesWebModule.php


注:本文中的WebModule::initializeForPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。