本文整理汇总了PHP中add_specific_field_value函数的典型用法代码示例。如果您正苦于以下问题:PHP add_specific_field_value函数的具体用法?PHP add_specific_field_value怎么用?PHP add_specific_field_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_specific_field_value函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getcwd
$cwdir = getcwd();
if (isset($_FILES['user_file'])) {
$allowed_extensions = array('odp', 'sxi', 'ppt', 'pps', 'sxd', 'pptx');
if (in_array(strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)), $allowed_extensions)) {
require_once api_get_path(SYS_CODE_PATH) . 'newscorm/lp_upload.php';
if (isset($o_ppt) && $first_item_id != 0) {
if (api_get_setting('search.search_enabled') == 'true') {
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if (!empty($values)) {
foreach ($values as $value) {
$value = trim($value);
if (!empty($value)) {
add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_ppt->lp_id, $value);
}
}
}
}
}
header('Location: ../newscorm/lp_controller.php?' . api_get_cidreq() . '&lp_id=' . $o_ppt->lp_id . '&action=view_item&id=' . $first_item_id);
exit;
} else {
if (!empty($o_ppt->error)) {
$errorMessage = $o_ppt->error;
} else {
$errorMessage = get_lang('OogieUnknownError');
}
}
} else {
示例2: api_get_path
}
if ($_FILES['lp_preview_image']['size'] > 0) {
$_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
}
if (api_get_setting('search_enabled') === 'true') {
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']);
$new_values = explode(',', trim($_REQUEST[$specific_field['code']]));
if (!empty($new_values)) {
array_walk($new_values, 'trim');
delete_all_specific_field_value(api_get_course_id(), $specific_field['id'], TOOL_LEARNPATH, $_SESSION['oLP']->lp_id);
foreach ($new_values as $value) {
if (!empty($value)) {
add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $_SESSION['oLP']->lp_id, $value);
}
}
}
}
}
require 'lp_list.php';
}
break;
case 'add_sub_item':
//add an item inside a chapter
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
if ($debug > 0) {
error_log('New LP - add sub item action triggered', 0);
示例3: editLink
/**
* @param int $id
* @param array $values
*/
public static function editLink($id, $values = array())
{
$tbl_link = Database::get_course_table(TABLE_LINK);
$_course = api_get_course_info();
$course_id = $_course['real_id'];
$values['url'] = trim($values['url']);
$values['title'] = trim($values['title']);
$values['description'] = trim($values['description']);
$values['target'] = empty($values['target']) ? '_self' : $values['target'];
$values['on_homepage'] = isset($values['on_homepage']) ? $values['on_homepage'] : '';
$categoryId = intval($values['category_id']);
// We ensure URL to be absolute.
if (strpos($values['url'], '://') === false) {
$values['url'] = 'http://' . $_POST['url'];
}
// If the title is empty, we use the URL as title.
if ($values['title'] == '') {
$values['title'] = $values['url'];
}
// If the URL is invalid, an error occurs.
if (!api_valid_url($values['url'], true)) {
Display::addFlash(Display::return_message(get_lang('GiveURL'), 'error'));
return false;
}
// Finding the old category_id.
$sql = "SELECT * FROM " . $tbl_link . "\n WHERE c_id = {$course_id} AND id='" . $id . "'";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$category_id = $row['category_id'];
if ($category_id != $values['category_id']) {
$sql = "SELECT MAX(display_order)\n FROM " . $tbl_link . "\n WHERE\n c_id = {$course_id} AND\n category_id='" . intval($values['category_id']) . "'";
$result = Database::query($sql);
list($max_display_order) = Database::fetch_row($result);
$max_display_order++;
} else {
$max_display_order = $row['display_order'];
}
$params = ['url' => $values['url'], 'title' => $values['title'], 'description' => $values['description'], 'category_id' => $values['category_id'], 'display_order' => $max_display_order, 'on_homepage' => $values['on_homepage'], 'target' => $values['target'], 'category_id' => $values['category_id']];
Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id]]);
// Update search enchine and its values table if enabled.
if (api_get_setting('search_enabled') == 'true') {
$course_int_id = api_get_course_int_id();
$course_id = api_get_course_id();
$link_title = Database::escape_string($values['title']);
$link_description = Database::escape_string($values['description']);
// Actually, it consists on delete terms from db, insert new ones, create a new search engine document, and remove the old one.
// Get search_did.
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $id);
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$se_ref = Database::fetch_array($res);
$specific_fields = get_specific_field_list();
$ic_slide = new IndexableChunk();
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_LINK, $id);
if (isset($_REQUEST[$specific_field['code']])) {
$sterms = trim($_REQUEST[$specific_field['code']]);
if (!empty($sterms)) {
$all_specific_terms .= ' ' . $sterms;
$sterms = explode(',', $sterms);
foreach ($sterms as $sterm) {
$ic_slide->addTerm(trim($sterm), $specific_field['code']);
add_specific_field_value($specific_field['id'], $course_id, TOOL_LINK, $id, $sterm);
}
}
}
}
// Build the chunk to index.
$ic_slide->addValue("title", $link_title);
$ic_slide->addCourseId($course_id);
$ic_slide->addToolId(TOOL_LINK);
$xapian_data = array(SE_COURSE_ID => $course_id, SE_TOOL_ID => TOOL_LINK, SE_DATA => array('link_id' => (int) $id), SE_USER => (int) api_get_user_id());
$ic_slide->xapian_data = serialize($xapian_data);
$link_description = $all_specific_terms . ' ' . $link_description;
$ic_slide->addValue('content', $link_description);
// Add category name if set.
if (isset($categoryId) && $categoryId > 0) {
$table_link_category = Database::get_course_table(TABLE_LINK_CATEGORY);
$sql_cat = 'SELECT * FROM %s WHERE id=%d and c_id = %d LIMIT 1';
$sql_cat = sprintf($sql_cat, $table_link_category, $categoryId, $course_int_id);
$result = Database::query($sql_cat);
if (Database::num_rows($result) == 1) {
$row = Database::fetch_array($result);
$ic_slide->addValue('category', $row['category_title']);
}
}
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
$di->connectDb(null, null, $lang);
$di->remove_document((int) $se_ref['search_did']);
//.........这里部分代码省略.........
示例4: index_document
//.........这里部分代码省略.........
// Actually, it consists on a delete of terms from db,
// insert new ones, create a new search engine document,
// and remove the old one
// Get search_did
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $course_code, TOOL_DOCUMENT, $docid);
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$se_ref = Database::fetch_array($res);
if (!$simulation) {
$di->remove_document($se_ref['search_did']);
}
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
if (!$simulation) {
delete_all_specific_field_value($course_code, $specific_field['id'], TOOL_DOCUMENT, $docid);
}
// Update search engine
if (isset($specific_fields_values[$specific_field['code']])) {
$sterms = trim($specific_fields_values[$specific_field['code']]);
} else {
//if the specific field is not defined, force an empty one
$sterms = '';
}
$all_specific_terms .= ' ' . $sterms;
$sterms = explode(',', $sterms);
foreach ($sterms as $sterm) {
$sterm = trim($sterm);
if (!empty($sterm)) {
$ic_slide->addTerm($sterm, $specific_field['code']);
// updated the last param here from $value to $sterm without being sure - see commit15464
if (!$simulation) {
add_specific_field_value($specific_field['id'], $course_code, TOOL_DOCUMENT, $docid, $sterm);
}
}
}
}
// Add terms also to content to make terms findable by probabilistic search
$file_content = $all_specific_terms . ' ' . $file_content;
if (!$simulation) {
$ic_slide->addValue('content', $file_content);
$di->addChunk($ic_slide);
// Index and return a new search engine document id
$did = $di->index();
if ($did) {
// update the search_did on db
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'UPDATE %s SET search_did=%d WHERE id=%d LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, (int) $did, (int) $se_ref['id']);
Database::query($sql);
}
}
}
} else {
// Add all terms
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
if (isset($specific_fields_values[$specific_field['code']])) {
$sterms = trim($specific_fields_values[$specific_field['code']]);
} else {
//if the specific field is not defined, force an empty one
$sterms = '';
}
$all_specific_terms .= ' ' . $sterms;
if (!empty($sterms)) {
示例5: search_engine_edit
function search_engine_edit()
{
// update search enchine and its values table if enabled
if (api_get_setting('search.search_enabled') == 'true' && extension_loaded('xapian')) {
$course_id = api_get_course_id();
// actually, it consists on delete terms from db,
// insert new ones, create a new search engine document, and remove the old one
// get search_did
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id);
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$se_ref = Database::fetch_array($res);
$specific_fields = get_specific_field_list();
$ic_slide = new IndexableChunk();
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id);
if (isset($_REQUEST[$specific_field['code']])) {
$sterms = trim($_REQUEST[$specific_field['code']]);
$all_specific_terms .= ' ' . $sterms;
$sterms = explode(',', $sterms);
foreach ($sterms as $sterm) {
$ic_slide->addTerm(trim($sterm), $specific_field['code']);
add_specific_field_value($specific_field['id'], $course_id, TOOL_QUIZ, $this->id, $sterm);
}
}
}
// build the chunk to index
$ic_slide->addValue("title", $this->exercise);
$ic_slide->addCourseId($course_id);
$ic_slide->addToolId(TOOL_QUIZ);
$xapian_data = array(SE_COURSE_ID => $course_id, SE_TOOL_ID => TOOL_QUIZ, SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), SE_USER => (int) api_get_user_id());
$ic_slide->xapian_data = serialize($xapian_data);
$exercise_description = $all_specific_terms . ' ' . $this->description;
$ic_slide->addValue("content", $exercise_description);
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
$di->connectDb(NULL, NULL, $lang);
$di->remove_document((int) $se_ref['search_did']);
$di->addChunk($ic_slide);
//index and return search engine document id
$did = $di->index();
if ($did) {
// save it to db
$sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=\'%s\'';
$sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id);
Database::query($sql);
$sql = 'INSERT INTO %s (id, course_code, tool_id, ref_id_high_level, search_did)
VALUES (NULL , \'%s\', \'%s\', %s, %s)';
$sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_QUIZ, $this->id, $did);
Database::query($sql);
}
} else {
$this->search_engine_save();
}
}
}
示例6: search_engine_edit
function search_engine_edit()
{
// update search enchine and its values table if enabled
if (api_get_setting('search.search_enabled') == 'true' && extension_loaded('xapian')) {
$em = Database::getManager();
$course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id());
// actually, it consists on delete terms from db,
// insert new ones, create a new search engine document, and remove the old one
// get search_did
$se_ref = $em->getRepository('ChamiloCoreBundle:SearchEngineRef')->findOneBy(['course' => $course, 'toolId' => TOOL_QUIZ, 'refIdHighLevel' => $this->id]);
if ($se_ref) {
require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
$ic_slide = new IndexableChunk();
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
delete_all_specific_field_value($course->getCode(), $specific_field['id'], TOOL_QUIZ, $this->id);
if (isset($_REQUEST[$specific_field['code']])) {
$sterms = trim($_REQUEST[$specific_field['code']]);
$all_specific_terms .= ' ' . $sterms;
$sterms = explode(',', $sterms);
foreach ($sterms as $sterm) {
$ic_slide->addTerm(trim($sterm), $specific_field['code']);
add_specific_field_value($specific_field['id'], $course->getCode(), TOOL_QUIZ, $this->id, $sterm);
}
}
}
// build the chunk to index
$ic_slide->addValue("title", $this->exercise);
$ic_slide->addCourseId($course->getCode());
$ic_slide->addToolId(TOOL_QUIZ);
$xapian_data = array(SE_COURSE_ID => $course->getCode(), SE_TOOL_ID => TOOL_QUIZ, SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), SE_USER => (int) api_get_user_id());
$ic_slide->xapian_data = serialize($xapian_data);
$exercise_description = $all_specific_terms . ' ' . $this->description;
$ic_slide->addValue("content", $exercise_description);
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
$di->connectDb(NULL, NULL, $lang);
$di->remove_document($se_ref->getSearchDid());
$di->addChunk($ic_slide);
//index and return search engine document id
$did = $di->index();
if ($did) {
// save it to db
$em->createQuery('
delete from ChamiloCoreBundle:SearchEngineRef ser
where ser.course = ?1 and ser.toolId = ?2 and ser.refIdHighLevel = ?3
')->execute([1 => $course, 2 => TOOL_QUIZ, 3 => $this->id]);
$searchEngineRef = new \Chamilo\CoreBundle\Entity\SearchEngineRef();
$searchEngineRef->setCourse($course)->setToolId(TOOL_QUIZ)->setRefIdHighLevel($this->id)->setSearchDid($did);
$em->persist($searchEngineRef);
$em->flush();
}
} else {
$this->search_engine_save();
}
}
}
示例7: editlinkcategory
//.........这里部分代码省略.........
$sql = "UPDATE " . $tbl_link . " SET " . "url='" . Database::escape_string($_POST['urllink']) . "', " . "title='" . Database::escape_string($_POST['title']) . "', " . "description='" . Database::escape_string($_POST['description']) . "', " . "category_id='" . Database::escape_string($_POST['selectcategory']) . "', " . "display_order='" . $max_display_order . "', " . "on_homepage= '" . Database::escape_string($onhomepage) . "' {$mytarget} " . " WHERE c_id = {$course_id} AND id='" . intval($_POST['id']) . "'";
Database::query($sql);
// Update search enchine and its values table if enabled.
if (api_get_setting('search_enabled') == 'true') {
$link_id = intval($_POST['id']);
$course_int_id = api_get_course_int_id();
$course_id = api_get_course_id();
$link_url = Database::escape_string($_POST['urllink']);
$link_title = Database::escape_string($_POST['title']);
$link_description = Database::escape_string($_POST['description']);
// Actually, it consists on delete terms from db, insert new ones, create a new search engine document, and remove the old one.
// Get search_did.
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id);
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$se_ref = Database::fetch_array($res);
$specific_fields = get_specific_field_list();
$ic_slide = new IndexableChunk();
$all_specific_terms = '';
foreach ($specific_fields as $specific_field) {
delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_LINK, $link_id);
if (isset($_REQUEST[$specific_field['code']])) {
$sterms = trim($_REQUEST[$specific_field['code']]);
if (!empty($sterms)) {
$all_specific_terms .= ' ' . $sterms;
$sterms = explode(',', $sterms);
foreach ($sterms as $sterm) {
$ic_slide->addTerm(trim($sterm), $specific_field['code']);
add_specific_field_value($specific_field['id'], $course_id, TOOL_LINK, $link_id, $sterm);
}
}
}
}
// Build the chunk to index.
$ic_slide->addValue("title", $link_title);
$ic_slide->addCourseId($course_id);
$ic_slide->addToolId(TOOL_LINK);
$xapian_data = array(SE_COURSE_ID => $course_id, SE_TOOL_ID => TOOL_LINK, SE_DATA => array('link_id' => (int) $link_id), SE_USER => (int) api_get_user_id());
$ic_slide->xapian_data = serialize($xapian_data);
$link_description = $all_specific_terms . ' ' . $link_description;
$ic_slide->addValue('content', $link_description);
// Add category name if set.
if (isset($_POST['selectcategory']) && $selectcategory > 0) {
$table_link_category = Database::get_course_table(TABLE_LINK_CATEGORY);
$sql_cat = 'SELECT * FROM %s WHERE id=%d and c_id = %d LIMIT 1';
$sql_cat = sprintf($sql_cat, $table_link_category, (int) $selectcategory, $course_int_id);
$result = Database::query($sql_cat);
if (Database::num_rows($result) == 1) {
$row = Database::fetch_array($result);
$ic_slide->addValue('category', $row['category_title']);
}
}
$di = new ChamiloIndexer();
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : ($lang = 'english');
$di->connectDb(null, null, $lang);
$di->remove_document((int) $se_ref['search_did']);
$di->addChunk($ic_slide);
// Index and return search engine document id.
$did = $di->index();
if ($did) {
// Save it to db.