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


PHP learnpath::search_engine_save方法代碼示例

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


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

示例1: while

 /**
  * Static admin function allowing addition of a learnpath to a course.
  * @param	string	Course code
  * @param	string	Learnpath name
  * @param	string	Learnpath description string, if provided
  * @param	string	Type of learnpath (default = 'guess', others = 'dokeos', 'aicc',...)
  * @param	string	Type of files origin (default = 'zip', others = 'dir','web_dir',...)
  * @param	string	Zip file containing the learnpath or directory containing the learnpath
  * @param	string	Keyword tags to add to the document
  * @return	integer	The new learnpath ID on success, 0 on failure
  */
 function add_lp($course, $name, $description = '', $learnpath = 'guess', $origin = 'zip', $zipname = '', $keyword = '')
 {
     global $charset;
     //if($this->debug>0){error_log('New LP - In learnpath::add_lp()',0);}
     //TODO
     $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
     //check course code exists
     //check lp_name doesn't exist, otherwise append something
     $i = 0;
     $name = learnpath::escape_string($name);
     //session_id
     $session_id = api_get_session_id();
     $check_name = "SELECT * FROM {$tbl_lp} WHERE name = '{$name}'";
     //if($this->debug>2){error_log('New LP - Checking the name for new LP: '.$check_name,0);}
     $res_name = Database::query($check_name, __FILE__, __LINE__);
     while (Database::num_rows($res_name)) {
         //there is already one such name, update the current one a bit
         $i++;
         $name = $name . ' - ' . $i;
         $check_name = "SELECT * FROM {$tbl_lp} WHERE name = '{$name}'";
         //if($this->debug>2){error_log('New LP - Checking the name for new LP: '.$check_name,0);}
         $res_name = Database::query($check_name, __FILE__, __LINE__);
     }
     //new name does not exist yet; keep it
     //escape description
     $description = learnpath::escape_string(api_htmlentities($description, ENT_QUOTES, $charset));
     //Kevin: added htmlentities()
     $type = 1;
     switch ($learnpath) {
         case 'guess':
             break;
         case 'dokeos':
             $type = 1;
             break;
         case 'aicc':
             break;
     }
     switch ($origin) {
         case 'zip':
             //check zipname string. If empty, we are currently creating a new Dokeos learnpath
             break;
         case 'manual':
         default:
             $get_max = "SELECT MAX(display_order) FROM {$tbl_lp}";
             $res_max = Database::query($get_max, __FILE__, __LINE__);
             if (Database::num_rows($res_max) < 1) {
                 $dsp = 1;
             } else {
                 $row = Database::fetch_array($res_max);
                 $dsp = $row[0] + 1;
             }
             $sql_insert = "INSERT INTO {$tbl_lp} " . "(lp_type,name,description,path,default_view_mod," . "default_encoding,display_order,content_maker," . "content_local,js_lib,session_id) " . "VALUES ({$type},'{$name}','{$description}','','embedded'," . "'UTF-8','{$dsp}','Dokeos'," . "'local','','" . Database::escape_string($session_id) . "')";
             //if($this->debug>2){error_log('New LP - Inserting new lp '.$sql_insert,0);}
             $res_insert = Database::query($sql_insert, __FILE__, __LINE__);
             $id = Database::insert_id();
             if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
                 //save search engine keyword
                 $searchkey = new SearchEngineManager();
                 $searchkey->idobj = $id;
                 $searchkey->course_code = api_get_course_id();
                 $searchkey->tool_id = TOOL_LEARNPATH;
                 $searchkey->value = $keyword;
                 $searchkey->save();
                 $lp = new learnpath(api_get_course_id(), $id, api_get_user_id());
                 $lp->search_engine_save();
             }
             if ($id > 0) {
                 //insert into item_property
                 api_item_property_update(api_get_course_info(), TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id());
                 return $id;
             }
             break;
     }
 }
開發者ID:Eidn,項目名稱:shanghai,代碼行數:85,代碼來源:learnpath.class.php


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