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


PHP learnpath::add_item方法代码示例

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


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

示例1: dealPerPage

 /**
  * Manages page splitting
  * @param	string	Page header
  * @param	string	Page body
  * @return	void
  */
 function dealPerPage($header, $body)
 {
     $em = Database::getManager();
     $_course = api_get_course_info();
     // Split document to pages.
     $pages = explode('||page_break||', $body);
     $first_item = 0;
     foreach ($pages as $key => $page_content) {
         // For every pages, we create a new file.
         $key += 1;
         $page_content = $this->format_page_content($header, $page_content, $this->base_work_dir . $this->created_dir);
         $html_file = $this->created_dir . '-' . $key . '.html';
         $handle = fopen($this->base_work_dir . $this->created_dir . '/' . $html_file, 'w+');
         fwrite($handle, $page_content);
         fclose($handle);
         $document_id = add_document($_course, $this->created_dir . $html_file, 'file', filesize($this->base_work_dir . $this->created_dir . $html_file), $html_file);
         $slide_name = '';
         if ($document_id) {
             // Put the document in item_property update.
             api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', api_get_user_id(), 0, 0, null, null, api_get_session_id());
             $infos = pathinfo($this->filepath);
             $slide_name = 'Page ' . str_repeat('0', 2 - strlen($key)) . $key;
             $previous = learnpath::add_item(0, $previous, 'document', $document_id, $slide_name, '');
             if ($this->first_item == 0) {
                 $this->first_item = $previous;
             }
             // Code for text indexing.
             if (api_get_setting('search.search_enabled') == 'true') {
                 if (isset($_POST['index_document']) && $_POST['index_document']) {
                     //Display::display_normal_message(print_r($_POST));
                     $di = new ChamiloIndexer();
                     isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
                     $di->connectDb(NULL, NULL, $lang);
                     $ic_slide = new IndexableChunk();
                     $ic_slide->addValue('title', $slide_name);
                     $specific_fields = get_specific_field_list();
                     $all_specific_terms = '';
                     foreach ($specific_fields as $specific_field) {
                         if (isset($_REQUEST[$specific_field['code']])) {
                             $sterms = trim($_REQUEST[$specific_field['code']]);
                             $all_specific_terms .= ' ' . $sterms;
                             if (!empty($sterms)) {
                                 $sterms = explode(',', $sterms);
                                 foreach ($sterms as $sterm) {
                                     $ic_slide->addTerm(trim($sterm), $specific_field['code']);
                                 }
                             }
                         }
                     }
                     $page_content = $all_specific_terms . ' ' . $page_content;
                     $ic_slide->addValue('content', $page_content);
                     // Add a comment to say terms separated by commas.
                     $courseid = api_get_course_id();
                     $ic_slide->addCourseId($courseid);
                     $ic_slide->addToolId(TOOL_LEARNPATH);
                     $lp_id = $this->lp_id;
                     $xapian_data = array(SE_COURSE_ID => $courseid, SE_TOOL_ID => TOOL_LEARNPATH, SE_DATA => array('lp_id' => $lp_id, 'lp_item' => $previous, 'document_id' => $document_id), SE_USER => (int) api_get_user_id());
                     $ic_slide->xapian_data = serialize($xapian_data);
                     $di->addChunk($ic_slide);
                     // Index and return search engine document id.
                     $did = $di->index();
                     if ($did) {
                         $course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id());
                         // Save it to db.
                         $searchEngineRef = new \Chamilo\CoreBundle\Entity\SearchEngineRef();
                         $searchEngineRef->setCourse($course)->setToolId(TOOL_LEARNPATH)->setRefIdHighLevel($lp_id)->setRefIdSecondLevel($previous)->setSearchDid($did);
                         $em->persist($searchEngineRef);
                         $em->flush();
                     }
                 }
             }
         }
     }
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:80,代码来源:openoffice_text.class.php

示例2: dealPerPage

 /**
  * Manages page splitting
  * @param	string	Page header
  * @param	string	Page body
  * @return	void
  */
 function dealPerPage($header, $body)
 {
     $_course = api_get_course_info();
     // Split document to pages.
     $pages = explode('||page_break||', $body);
     $first_item = 0;
     foreach ($pages as $key => $page_content) {
         // For every pages, we create a new file.
         $key += 1;
         $page_content = $this->format_page_content($header, $page_content, $this->base_work_dir . $this->created_dir);
         $html_file = $this->created_dir . '-' . $key . '.html';
         $handle = fopen($this->base_work_dir . $this->created_dir . '/' . $html_file, 'w+');
         fwrite($handle, $page_content);
         fclose($handle);
         $document_id = add_document($_course, $this->created_dir . $html_file, 'file', filesize($this->base_work_dir . $this->created_dir . $html_file), $html_file);
         $slide_name = '';
         if ($document_id) {
             // Put the document in item_property update.
             api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_SESSION['_uid'], 0, 0, null, null, api_get_session_id());
             $infos = pathinfo($this->filepath);
             $slide_name = 'Page ' . str_repeat('0', 2 - strlen($key)) . $key;
             $previous = learnpath::add_item(0, $previous, 'document', $document_id, $slide_name, '');
             if ($this->first_item == 0) {
                 $this->first_item = $previous;
             }
             // Code for text indexing.
             if (isset($_POST['index_document']) && $_POST['index_document']) {
                 //Display::display_normal_message(print_r($_POST));
                 $di = new ChamiloIndexer();
                 isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
                 $di->connectDb(NULL, NULL, $lang);
                 $ic_slide = new IndexableChunk();
                 $ic_slide->addValue('title', $slide_name);
                 $specific_fields = get_specific_field_list();
                 $all_specific_terms = '';
                 foreach ($specific_fields as $specific_field) {
                     if (isset($_REQUEST[$specific_field['code']])) {
                         $sterms = trim($_REQUEST[$specific_field['code']]);
                         $all_specific_terms .= ' ' . $sterms;
                         if (!empty($sterms)) {
                             $sterms = explode(',', $sterms);
                             foreach ($sterms as $sterm) {
                                 $ic_slide->addTerm(trim($sterm), $specific_field['code']);
                             }
                         }
                     }
                 }
                 $page_content = $all_specific_terms . ' ' . $page_content;
                 $ic_slide->addValue('content', $page_content);
                 // Add a comment to say terms separated by commas.
                 $courseid = api_get_course_id();
                 $ic_slide->addCourseId($courseid);
                 $ic_slide->addToolId(TOOL_LEARNPATH);
                 $lp_id = $this->lp_id;
                 $xapian_data = array(SE_COURSE_ID => $courseid, SE_TOOL_ID => TOOL_LEARNPATH, SE_DATA => array('lp_id' => $lp_id, 'lp_item' => $previous, 'document_id' => $document_id), SE_USER => (int) api_get_user_id());
                 $ic_slide->xapian_data = serialize($xapian_data);
                 $di->addChunk($ic_slide);
                 // Index and return search engine document id.
                 $did = $di->index();
                 if ($did) {
                     // Save it to db.
                     $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
                     $sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, ref_id_second_level, search_did)
                             VALUES (NULL , \'%s\', \'%s\', %s, %s, %s)';
                     $sql = sprintf($sql, $tbl_se_ref, api_get_course_id(), TOOL_LEARNPATH, $lp_id, $previous, $did);
                     Database::query($sql);
                 }
             }
         }
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:77,代码来源:openoffice_text_document.class.php

示例3: WSCreateLp

/**
 * @param array $params
 * @return null|soap_fault
 */
function WSCreateLp($params)
{
    global $debug;
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    if ($debug) {
        error_log('WSCreateLp');
    }
    $courseIdName = $params['course_id_name'];
    $courseIdValue = $params['course_id_value'];
    $lpName = $params['lp_name'];
    $lpItemList = $params['lp_item_list'];
    /*$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
      $sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;*/
    $courseInfo = CourseManager::getCourseInfoFromOriginalId($courseIdValue, $courseIdName);
    if (empty($courseInfo)) {
        if ($debug) {
            error_log('Course not found');
        }
    }
    $courseId = $courseInfo['real_id'];
    $courseCode = $courseInfo['code'];
    /*$sessionId = 0;
        if (!empty($sessionIdName) && !empty($sessionIdValue)) {
            $sessionId = SessionManager::get_session_id_from_original_id(
                $sessionIdValue,
                $sessionIdName
            );
    
            if (empty($sessionId)) {
    
                if ($debug) {
                    error_log('Session not found');
                }
    
                return 'Session not found';
            }
        }*/
    $lpId = learnpath::add_lp($courseCode, $lpName, '', 'chamilo', 'manual');
    if ($lpId) {
        if ($debug) {
            error_log('LP created');
        }
        $lp = new learnpath($courseCode, $lpId, null);
        $previousId = 0;
        foreach ($lpItemList as $lpItem) {
            $info = pathinfo($lpItem['filename']);
            $extension = $info['extension'];
            $data = base64_decode($lpItem['data']);
            $documentId = $lp->create_document($courseInfo, $data, $info['filename'], $extension);
            if ($documentId) {
                if ($debug) {
                    error_log("Document created {$documentId}");
                    $itemId = $lp->add_item(null, $previousId, 'document', $documentId, $lpItem['title'], '', '');
                    $previousId = $itemId;
                    if ($itemId) {
                        if ($debug) {
                            error_log("Item added");
                        }
                    } else {
                        if ($debug) {
                            error_log("Item not added");
                        }
                    }
                }
            } else {
                if ($debug) {
                    error_log("Document NOT created");
                }
            }
        }
        return 1;
    } else {
        if ($debug) {
            error_log('LP not created');
        }
    }
    return 0;
}
开发者ID:daffef,项目名称:chamilo-lms,代码行数:84,代码来源:lp.php


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