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


PHP CCourse::GetSiteId方法代码示例

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


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

示例1: OnSearchReindex

 public static function OnSearchReindex($NS = array(), $oCallback = null, $callback_method = '')
 {
     global $DB;
     static $arCourseToSiteCache = array();
     $arResult = array();
     $arAllSitesPathes = array();
     $elementStartId = 0;
     $indexElementType = 'C';
     // start reindex from courses
     $by = $order = '';
     $sites = CLang::GetList($by, $order, array('TYPE' => 'C'));
     while ($site = $sites->Fetch()) {
         $arAllSitesPathes[$site['LID']] = array('C' => CCourse::GetSitePathes($site['LID'], 'C'), 'H' => CCourse::GetSitePathes($site['LID'], 'H'), 'L' => CCourse::GetSitePathes($site['LID'], 'L'));
     }
     $arCoursesFilter = array();
     $arLessonsFilter = array('LINKED_LESSON_ID' => '');
     if ($NS['MODULE'] === 'learning' && strlen($NS['ID']) > 0) {
         $indexElementType = substr($NS['ID'], 0, 1);
         $elementStartId = (int) substr($NS['ID'], 1);
         if (strlen($NS['SITE_ID']) > 0) {
             $arCoursesFilter['SITE_ID'] = $NS['SITE_ID'];
         }
     }
     $arCoursesFilter['>ID'] = $elementStartId;
     if ($indexElementType === 'C') {
         $rsCourse = CCourse::GetList(array('ID' => 'ASC'), $arCoursesFilter);
         while ($arCourse = $rsCourse->Fetch()) {
             try {
                 $arCourse["SITE_ID"] = CCourse::GetSiteId($arCourse['ID']);
                 $arPathes = $arAllSitesPathes[$arCourse['SITE_ID']]['C'];
                 $linkedLessonId = CCourse::CourseGetLinkedLesson($arCourse['ID']);
                 if ($linkedLessonId === false) {
                     continue;
                 }
                 $arGroupPermissions = CLearnAccess::GetSymbolsAccessibleToLesson($linkedLessonId, CLearnAccess::OP_LESSON_READ);
             } catch (LearnException $e) {
                 continue;
                 // skip indexation of this item
             }
             $arSiteIds = array();
             foreach ($arPathes as $k => $path) {
                 $arCourse["PATH"] = $path;
                 $Url = str_replace("#COURSE_ID#", $arCourse["ID"], $arCourse["PATH"]);
                 $arSiteIds[$arCourse['SITE_ID']] = $Url;
             }
             if ($arCourse["DETAIL_TEXT_TYPE"] !== 'text') {
                 $detailText = CSearch::KillTags($arCourse['DETAIL_TEXT']);
             } else {
                 $detailText = strip_tags($arCourse['DETAIL_TEXT']);
             }
             if (strlen($detailText) > 0) {
                 $dataBody = $detailText;
             } else {
                 $dataBody = $arCourse['NAME'];
             }
             $Result = array("ID" => "C" . $arCourse["ID"], "LAST_MODIFIED" => $arCourse["TIMESTAMP_X"], "TITLE" => $arCourse["NAME"], "BODY" => $dataBody, "SITE_ID" => $arSiteIds, "PERMISSIONS" => $arGroupPermissions, "COURSE_ID" => "C" . $arCourse["ID"]);
             if ($oCallback) {
                 $res = call_user_func(array($oCallback, $callback_method), $Result);
                 if (!$res) {
                     return "C" . $arCourse["ID"];
                 }
             } else {
                 $arResult[] = $Result;
             }
         }
         // Reindex of courses finished. Let's reindex lessons now.
         $indexElementType = 'U';
         $elementStartId = 0;
     }
     $arLessonsFilter['>LESSON_ID'] = $elementStartId;
     if ($indexElementType === 'U') {
         $rsLessons = CLearnLesson::GetList(array('LESSON_ID' => 'ASC'), $arLessonsFilter);
         while ($arLessonFromDb = $rsLessons->Fetch()) {
             $arLessonsWithCourse = array();
             // list of lessons in context of some course
             $arOParentPathes = CLearnLesson::GetListOfParentPathes($arLessonFromDb['LESSON_ID']);
             foreach ($arOParentPathes as $oParentPath) {
                 $arParentLessons = $oParentPath->GetPathAsArray();
                 foreach ($arParentLessons as $lessonId) {
                     $linkedCourseId = CLearnLesson::GetLinkedCourse($lessonId);
                     if ($linkedCourseId !== false && $linkedCourseId > 0) {
                         $arLessonsWithCourse[] = array_merge($arLessonFromDb, array('PARENT_COURSE_ID' => $linkedCourseId));
                     }
                 }
             }
             foreach ($arLessonsWithCourse as $arLesson) {
                 try {
                     $arGroupPermissions = CLearnAccess::GetSymbolsAccessibleToLesson($arLesson['LESSON_ID'], CLearnAccess::OP_LESSON_READ);
                     $courseId = $arLesson['PARENT_COURSE_ID'];
                     if (!isset($arCourseToSiteCache[$courseId])) {
                         $strSql = "SELECT SITE_ID FROM b_learn_course_site WHERE COURSE_ID=" . (int) $courseId;
                         $rc = $DB->Query($strSql, true);
                         if ($rc === false) {
                             continue;
                         }
                         $arCourseToSiteCache[$courseId] = array();
                         while ($arCourseSite = $rc->fetch()) {
                             $arCourseToSiteCache[$courseId][] = $arCourseSite['SITE_ID'];
                         }
                     }
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:course.php


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