当前位置: 首页>>代码示例>>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;未经允许,请勿转载。