• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_specific_field_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_specific_field_list函数的典型用法代码示例。如果您正苦于以下问题:PHP get_specific_field_list函数的具体用法?PHP get_specific_field_list怎么用?PHP get_specific_field_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_lang

// Author
$form->addElement('html_editor', 'lp_author', get_lang('Author'), array('size' => 80), array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px'));
$form->applyFilter('lp_author', 'html_filter');
// LP image
$form->add_progress_bar();
if (strlen($_SESSION['oLP']->get_preview_image()) > 0) {
    $show_preview_image = '<img src=' . api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/upload/learning_path/images/' . $_SESSION['oLP']->get_preview_image() . '>';
    $form->addElement('label', get_lang('ImagePreview'), $show_preview_image);
    $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
$label = $_SESSION['oLP']->get_preview_image() != '' ? get_lang('UpdateImage') : get_lang('AddImage');
$form->addElement('file', 'lp_preview_image', array($label, get_lang('ImageWillResizeMsg')));
$form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'filetype', array('jpg', 'jpeg', 'png', 'gif'));
// Search terms (only if search is activated).
if (api_get_setting('search_enabled') === 'true') {
    $specific_fields = get_specific_field_list();
    foreach ($specific_fields as $specific_field) {
        $form->addElement('text', $specific_field['code'], $specific_field['name']);
        $filter = array('c_id' => "'" . api_get_course_int_id() . "'", 'field_id' => $specific_field['id'], 'ref_id' => $_SESSION['oLP']->lp_id, 'tool_id' => '\'' . TOOL_LEARNPATH . '\'');
        $values = get_specific_field_values_list($filter, array('value'));
        if (!empty($values)) {
            $arr_str_values = array();
            foreach ($values as $value) {
                $arr_str_values[] = $value['value'];
            }
            $defaults[$specific_field['code']] = implode(', ', $arr_str_values);
        }
    }
}
$defaults['lp_encoding'] = Security::remove_XSS($_SESSION['oLP']->encoding);
$defaults['lp_name'] = Security::remove_XSS($_SESSION['oLP']->get_name());
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:lp_edit.php


示例2: get_lang

    $tool_name = get_lang('EditSpecificSearchField');
}
// Create the form
$form = new FormValidator('specific_fields_add');
// Field variable name
$form->addElement('hidden', 'field_id', (int) $_REQUEST['field_id']);
$form->addElement('text', 'field_name', get_lang('FieldName'));
$form->applyFilter('field_name', 'html_filter');
$form->applyFilter('field_name', 'trim');
$form->addRule('field_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('field_name', get_lang('OnlyLettersAndNumbersAllowed'), 'username');
$form->addRule('field_name', '', 'maxlength', 20);
// Set default values (only not empty when editing)
$defaults = array();
if (is_numeric($_REQUEST['field_id'])) {
    $form_information = get_specific_field_list(array('id' => (int) $_GET['field_id']));
    $defaults['field_name'] = $form_information[0]['name'];
}
$form->setDefaults($defaults);
// Submit button
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="add"');
// Validate form
if ($form->validate()) {
    $field = $form->exportValues();
    $field_name = $field['field_name'];
    if (is_numeric($field['field_id']) && $field['field_id'] != 0 && !empty($field['field_id'])) {
        edit_specific_field($field['field_id'], $field['field_name']);
        $message = get_lang('FieldEdited');
    } else {
        $field_id = add_specific_field($field_name);
        $message = get_lang('FieldAdded');
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:specific_fields_add.php


示例3: make_lp


//.........这里部分代码省略.........
            $my_new_image->send_image($this->base_work_dir.$this->created_dir .'/'. $thumb_name, -1, 'png');

            // Adding the thumbnail to documents.
            $document_id_thumb = add_document(
                $_course,
                $this->created_dir.'/'.urlencode($thumb_name),
                'file',
                filesize($this->base_work_dir.$this->created_dir.'/'.$thumb_name),
                $slide_name
            );

            api_item_property_update($_course, TOOL_THUMBNAIL, $document_id_thumb, 'DocumentAdded', api_get_user_id(), 0, 0);

            // Create an html file.
            $html_file = $file_name.'.html';
            $fp = fopen($this->base_work_dir.$this->created_dir.'/'.$html_file, 'w+');

            $slide_src = api_get_path(REL_COURSE_PATH).$_course['path'].'/document/'.$this->created_dir.'/'.utf8_encode($file_name);
            $slide_src = str_replace('//', '/', $slide_src);
            fwrite($fp,
'<html>
    <head>
    </head>
    <body>
        <img src="'.$slide_src.'" />
    </body>
</html>');  // This indentation is to make the generated html files to look well.

            fclose($fp);
            $document_id = add_document(
                $_course,
                $this->created_dir.'/'.urlencode($html_file),
                'file',
                filesize($this->base_work_dir.$this->created_dir.'/'.$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());

                $previous = $this->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_enabled') == 'true') {

                if (isset($_POST['index_document']) && $_POST['index_document']) {
                    $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']);
                                }
                            }
                        }
                    }
                    $slide_body = $all_specific_terms .' '. $slide_body;
                    $ic_slide->addValue('content', $slide_body);
                    /* FIXME:  cidReq:lp_id:doc_id al indexar  */
                    // 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:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:openoffice_presentation.class.php


示例4: getLinkForm

 /**
  * @param int $linkId
  * @param $action
  * @param null $urlview
  * @param null $token
  * @return FormValidator
  */
 public static function getLinkForm($linkId, $action, $token = null)
 {
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $linkInfo = Link::get_link_info($linkId);
     $categoryId = isset($linkInfo['category_id']) ? $linkInfo['category_id'] : '';
     $lpId = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null;
     $category = 0;
     $form = new FormValidator('link', 'post', api_get_self() . '?action=' . $action . '&category_id=' . $categoryId . '&' . api_get_cidreq() . '&id=' . $linkId . '&sec_token=' . $token);
     if ($action == 'addlink') {
         $form->addHeader(get_lang('LinkAdd'));
     } else {
         $form->addHeader(get_lang('LinkMod'));
     }
     $target_link = "_blank";
     $title = '';
     $category = '';
     $onhomepage = '';
     $description = '';
     if (!empty($linkInfo)) {
         $urllink = $linkInfo['url'];
         $title = $linkInfo['title'];
         $description = $linkInfo['description'];
         $category = $linkInfo['category_id'];
         if ($linkInfo['on_homepage'] != 0) {
             $onhomepage = 1;
         }
         $target_link = $linkInfo['target'];
     }
     $form->addHidden('id', $linkId);
     $form->addText('url', 'URL');
     $form->addRule('url', get_lang('GiveURL'), 'url');
     $form->addText('title', get_lang('LinkName'));
     $form->addTextarea('description', get_lang('Description'));
     $resultcategories = Link::getLinkCategories($course_id, $session_id);
     $options = ['0' => '--'];
     if (!empty($resultcategories)) {
         foreach ($resultcategories as $myrow) {
             $options[$myrow['id']] = $myrow['category_title'];
         }
     }
     $form->addSelect('category_id', get_lang('Category'), $options);
     $form->addCheckBox('on_homepage', null, get_lang('OnHomepage'));
     $targets = array('_self' => get_lang('LinkOpenSelf'), '_blank' => get_lang('LinkOpenBlank'), '_parent' => get_lang('LinkOpenParent'), '_top' => get_lang('LinkOpenTop'));
     $form->addSelect('target', array(get_lang('LinkTarget'), get_lang('AddTargetOfLinkOnHomepage')), $targets);
     $defaults = array('url' => empty($urllink) ? 'http://' : Security::remove_XSS($urllink), 'title' => Security::remove_XSS($title), 'category_id' => $category, 'on_homepage' => $onhomepage, 'description' => $description, 'target' => $target_link);
     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();
         $form->addCheckBox('index_document', get_lang('SearchFeatureDoIndexLink'), get_lang('Yes'));
         foreach ($specific_fields as $specific_field) {
             $default_values = '';
             if ($action == 'editlink') {
                 $filter = array('field_id' => $specific_field['id'], 'ref_id' => intval($_GET['id']), 'tool_id' => '\'' . TOOL_LINK . '\'');
                 $values = get_specific_field_values_list($filter, array('value'));
                 if (!empty($values)) {
                     $arr_str_values = array();
                     foreach ($values as $value) {
                         $arr_str_values[] = $value['value'];
                     }
                     $default_values = implode(', ', $arr_str_values);
                 }
             }
             $form->addText($specific_field['name'], $specific_field['code']);
             $defaults[$specific_field['name']] = $default_values;
         }
     }
     $form->addHidden('lp_id', $lpId);
     $form->addButtonSave(get_lang('SaveLink'), 'submitLink');
     $form->setDefaults($defaults);
     return $form;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:79,代码来源:link.lib.php


示例5: 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


示例6: index_document

 /**
  * Index a given document.
  * @param   int     Document ID inside its corresponding course
  * @param   string  Course code
  * @param   int     Session ID (not used yet)
  * @param   string  Language of document's content (defaults to course language)
  * @param   array   Array of specific fields (['code'=>'value',...])
  * @param   string  What to do if the file already exists (default or overwrite)
  * @param   bool    When set to true, this runs the indexer without actually saving anything to any database
  * @return  bool    Returns true on presumed success, false on failure
  */
 public static function index_document($docid, $course_code, $session_id = 0, $lang = 'english', $specific_fields_values = array(), $if_exists = '', $simulation = false)
 {
     if (api_get_setting('search.search_enabled') !== 'true') {
         return false;
     }
     if (empty($docid) or $docid != intval($docid)) {
         return false;
     }
     if (empty($session_id)) {
         $session_id = api_get_session_id();
     }
     $course_info = api_get_course_info($course_code);
     $course_dir = $course_info['path'] . '/document';
     $sys_course_path = api_get_path(SYS_COURSE_PATH);
     $base_work_dir = $sys_course_path . $course_dir;
     $course_id = $course_info['real_id'];
     $table_document = Database::get_course_table(TABLE_DOCUMENT);
     $qry = "SELECT path, title FROM {$table_document} WHERE c_id = {$course_id} AND id = '{$docid}' LIMIT 1";
     $result = Database::query($qry);
     if (Database::num_rows($result) == 1) {
         $row = Database::fetch_array($result);
         $doc_path = api_get_path(SYS_COURSE_PATH) . $course_dir . $row['path'];
         //TODO: mime_content_type is deprecated, fileinfo php extension is enabled by default as of PHP 5.3.0
         // now versions of PHP on Debian testing(5.2.6-5) and Ubuntu(5.2.6-2ubuntu) are lower, so wait for a while
         $doc_mime = mime_content_type($doc_path);
         $allowed_mime_types = self::file_get_mime_type(true);
         // mime_content_type does not detect correctly some formats that are going to be supported for index, so an extensions array is used for the moment
         if (empty($doc_mime)) {
             $allowed_extensions = array('doc', 'docx', 'ppt', 'pptx', 'pps', 'ppsx', 'xls', 'xlsx', 'odt', 'odp', 'ods', 'pdf', 'txt', 'rtf', 'msg', 'csv', 'html', 'htm');
             $extensions = preg_split("/[\\/\\.]/", $doc_path);
             $doc_ext = strtolower($extensions[count($extensions) - 1]);
             if (in_array($doc_ext, $allowed_extensions)) {
                 switch ($doc_ext) {
                     case 'ppt':
                     case 'pps':
                         $doc_mime = 'application/vnd.ms-powerpoint';
                         break;
                     case 'xls':
                         $doc_mime = 'application/vnd.ms-excel';
                         break;
                 }
             }
         }
         //@todo move this nightmare in a search controller or something like that!!! J.M
         if (in_array($doc_mime, $allowed_mime_types)) {
             $file_title = $row['title'];
             $file_content = self::get_text_content($doc_path, $doc_mime);
             $course_code = Database::escape_string($course_code);
             require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
             require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
             $ic_slide = new IndexableChunk();
             $ic_slide->addValue('title', $file_title);
             $ic_slide->addCourseId($course_code);
             $ic_slide->addToolId(TOOL_DOCUMENT);
             $xapian_data = array(SE_COURSE_ID => $course_code, SE_TOOL_ID => TOOL_DOCUMENT, SE_DATA => array('doc_id' => $docid), SE_USER => api_get_user_id());
             $ic_slide->xapian_data = serialize($xapian_data);
             $di = new ChamiloIndexer();
             $return = $di->connectDb(null, null, $lang);
             require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
             $specific_fields = get_specific_field_list();
             // process different depending on what to do if file exists
             /**
              * @TODO Find a way to really verify if the file had been
              * overwriten. Now all work is done at
              * handle_uploaded_document() and it's difficult to verify it
              */
             if (!empty($if_exists) && $if_exists == 'overwrite') {
                 // Overwrite the file on search engine
                 // 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']]);
//.........这里部分代码省略.........
开发者ID:daffef,项目名称:chamilo-lms,代码行数:101,代码来源:document.lib.php


示例7: search_widget_show

/**
 * Show the search widget
 *
 * The form will post to index.php by default, you can pass a value to
 * $action to use a custom action.
 * IMPORTANT: you have to call search_widget_prepare() before calling this
 * function or otherwise the form will not behave correctly.
 *
 * @param   string $action     Just in case your action is not
 * index.php
 */
function search_widget_show($action = 'index.php')
{
    require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloQuery.php';
    // TODO: load images dinamically when they're avalaible from specific field ui to add
    $groupId = api_get_group_id();
    $sf_terms = array();
    $specific_fields = get_specific_field_list();
    $url_params = array();
    if (($cid = api_get_course_id()) != -1) {
        // with cid
        // get search engine terms
        $course_filter = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID . $cid);
        $dkterms = chamilo_query_simple_query('', 0, 1000, array($course_filter));
        //prepare specific fields names (and also get possible URL param names)
        foreach ($specific_fields as $specific_field) {
            $temp = array();
            if (is_array($dkterms) && count($dkterms) > 0) {
                foreach ($dkterms[1] as $obj) {
                    $temp = array_merge($obj['sf-' . $specific_field['code']], $temp);
                }
            }
            $sf_terms[$specific_field['code']] = $temp;
            $url_params[] = 'sf_' . $specific_field['code'];
            unset($temp);
        }
    } else {
        // without cid
        // prepare specific fields names (and also get possible URL param names)
        foreach ($specific_fields as $specific_field) {
            //get Xapian terms for a specific term prefix, in ISO, apparently
            $sf_terms[$specific_field['code']] = xapian_get_all_terms(1000, $specific_field['code']);
            $url_params[] = 'sf_' . $specific_field['code'];
        }
    }
    echo '<h2>' . get_lang('Search') . '</h2>';
    // Tool introduction
    // TODO: Settings for the online editor to be checked (insert an image for example). Probably this is a special case here.
    if (api_get_course_id() !== -1) {
        if (!empty($groupId)) {
            Display::display_introduction_section(TOOL_SEARCH . $groupId);
        } else {
            Display::display_introduction_section(TOOL_SEARCH);
        }
    }
    $op = 'or';
    if (!empty($_REQUEST['operator']) && in_array($op, array('or', 'and'))) {
        $op = $_REQUEST['operator'];
    }
    //check if URL params are defined (to see if we show the thesaurus or not)
    $show_thesaurus = false;
    foreach ($url_params as $param) {
        if (isset($_REQUEST[$param]) && is_array($_REQUEST[$param])) {
            $thesaurus_decided = FALSE;
            foreach ($_REQUEST[$param] as $term) {
                if (!empty($term)) {
                    $show_thesaurus = true;
                    $thesaurus_decided = TRUE;
                    break;
                }
            }
            if ($thesaurus_decided) {
                break;
            }
        }
    }
    // create the form
    // TODO: use FormValidator
    display_search_form($action, $show_thesaurus, $sf_terms, $op);
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:80,代码来源:search_widget.php


示例8: import_manifest


//.........这里部分代码省略.........
             $path = '';
             $type = 'dir';
             if (isset($this->resources[$item['identifierref']])) {
                 $oRes =& $this->resources[$item['identifierref']];
                 $path = @$oRes->get_path();
                 if (!empty($path)) {
                     $temptype = $oRes->get_scorm_type();
                     if (!empty($temptype)) {
                         $type = $temptype;
                     }
                 }
             }
             $level = $item['level'];
             $field_add = '';
             $value_add = '';
             if (!empty($item['masteryscore'])) {
                 $field_add .= 'mastery_score, ';
                 $value_add .= $item['masteryscore'] . ',';
             }
             if (!empty($item['maxtimeallowed'])) {
                 $field_add .= 'max_time_allowed, ';
                 $value_add .= "'" . $item['maxtimeallowed'] . "',";
             }
             $title = Database::escape_string($item['title']);
             $title = api_utf8_decode($title);
             $max_score = Database::escape_string($item['max_score']);
             if ($max_score == 0 || is_null($max_score) || $max_score == '') {
                 //If max score is not set The use_max_score parameter is check in order to use 100 (chamilo style) or '' (strict scorm)
                 if ($use_max_score) {
                     $max_score = "'100'";
                 } else {
                     $max_score = "NULL";
                 }
             } else {
                 //Otherwise save the max score
                 $max_score = "'{$max_score}'";
             }
             $identifier = Database::escape_string($item['identifier']);
             if (empty($title)) {
                 $title = get_lang('Untitled');
             }
             $prereq = Database::escape_string($item['prerequisites']);
             $sql_item = "INSERT INTO {$new_lp_item} (c_id, lp_id,item_type,ref,title, path,min_score,max_score, {$field_add} parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,launch_data, parameters) VALUES " . "({$course_id}, {$lp_id}, '{$type}','{$identifier}', '{$title}', '{$path}' , 0, {$max_score}, {$value_add}" . "{$parent}, {$previous}, 0, " . "'{$prereq}', " . $item['rel_order'] . ", '" . $item['datafromlms'] . "'," . "'" . $item['parameters'] . "'" . ")";
             $res_item = Database::query($sql_item);
             if ($this->debug > 1) {
                 error_log('New LP - In import_manifest(), inserting item : ' . $sql_item . ' : ' . Database::error(), 0);
             }
             $item_id = Database::insert_id();
             // Now update previous item to change next_item_id.
             $upd = "UPDATE {$new_lp_item} SET next_item_id = {$item_id} WHERE c_id = {$course_id} AND id = {$previous}";
             $upd_res = Database::query($upd);
             // Update previous item id.
             $previous = $item_id;
             // Code for indexing, now only index specific fields like terms and the title.
             if (!empty($_POST['index_document'])) {
                 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';
                 $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', $title);
                 $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']);
                             }
                         }
                     }
                 }
                 $body_to_index = $all_specific_terms . ' ' . $title;
                 $ic_slide->addValue("content", $body_to_index);
                 // TODO: Add a comment to say terms separated by commas.
                 $courseid = api_get_course_id();
                 $ic_slide->addCourseId($courseid);
                 $ic_slide->addToolId(TOOL_LEARNPATH);
                 $xapian_data = array(SE_COURSE_ID => $courseid, SE_TOOL_ID => TOOL_LEARNPATH, SE_DATA => array('lp_id' => $lp_id, 'lp_item' => $previous, '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:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:scorm.class.php


示例9: 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();
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:62,代码来源:exercise.class.php


示例10: editlinkcategory


//.........这里部分代码省略.........
            $sql = "SELECT * FROM " . $tbl_link . "\n                    WHERE c_id = {$course_id} AND id='" . intval($_POST['id']) . "'";
            $result = Database::query($sql);
            $row = Database::fetch_array($result);
            $category_id = $row['category_id'];
            if ($category_id != $_POST['selectcategory']) {
                $sql = "SELECT MAX(display_order)\n                        FROM " . $tbl_link . "\n                        WHERE c_id = {$course_id}\n                        AND category_id='" . intval($_POST['selectcategory']) . "'";
                $result = Database::query($sql);
                list($max_display_order) = Database::fetch_row($result);
                $max_display_order++;
            } else {
                $max_display_order = $row['display_order'];
            }
            $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);
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:67,代码来源:link.lib.php


示例11: 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();
         }
     }
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:60,代码来源:exercise.class.php


示例12: handle_search

/**
 * Search options
 * TODO: support for multiple site. aka $_configuration['access_url'] == 1
 * @author Marco Villegas <[email protected]>
 */
function handle_search()
{
    global $SettingsStored, $_configuration;
    require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
    $search_enabled = api_get_setting('search.search_enabled');
    $form = new FormValidator('search-options', 'post', api_get_self() . '?category=Search');
    $values = api_get_settings_options('search_enabled');
    $form->addElement('header', null, get_lang('SearchEnabledTitle'));
    $group = array();
    if (is_array($values)) {
        foreach ($values as $key => $value) {
            $element =& $form->createElement('radio', 'search_enabled', '', get_lang($value['display_text']), $value['value']);
            $group[] = $element;
        }
    }
    //SearchEnabledComment
    $form->addGroup($group, 'search_enabled', array(get_lang('SearchEnabledTitle'), get_lang('SearchEnabledComment')), '<br />', false);
    $search_enabled = api_get_setting('search.search_enabled');
    if ($form->validate()) {
        $formvalues = $form->exportValues();
        $r = api_set_settings_category('Search', 'false', $_configuration['access_url']);
        // Save the settings.
        foreach ($formvalues as $key => $value) {
            $result = api_set_setting($key, $value, null, null);
        }
        $search_enabled = $formvalues['search_enabled'];
        Display::display_confirmation_message($SettingsStored);
    }
    $specific_fields = get_specific_field_list();
    if ($search_enabled == 'true') {
        $values = api_get_settings_options('search_show_unlinked_results');
        $group = array();
        foreach ($values as $key => $value) {
            $element =& $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']);
            $group[] = $element;
  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_specimen_by_id函数代码示例发布时间:2022-05-15
下一篇:
PHP get_spec_image函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap