';
+
Display::display_footer();
?>
\ No newline at end of file
diff --git a/main/newscorm/lp_list.php b/main/newscorm/lp_list.php
index 5ec30ef1d7..3c45db66cf 100644
--- a/main/newscorm/lp_list.php
+++ b/main/newscorm/lp_list.php
@@ -394,14 +394,10 @@ if (is_array($flat_list))
echo "";
echo "
";
-/* search widget */
-if (api_get_setting('search_enabled') == 'true')
- search_widget_show();
-
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
-?>
\ No newline at end of file
+?>
diff --git a/main/newscorm/lp_list_search.php b/main/newscorm/lp_list_search.php
index 4e53f051f4..ca8f3bb643 100644
--- a/main/newscorm/lp_list_search.php
+++ b/main/newscorm/lp_list_search.php
@@ -6,7 +6,8 @@
*/
require api_get_path(LIBRARY_PATH).'search/search_widget.php';
require api_get_path(LIBRARY_PATH).'search/DokeosQuery.php';
-
+require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
+require_once api_get_path(LIBRARY_PATH).'/specific_fields_manager.lib.php';
$htmlHeadXtra[] = '
';
search_widget_prepare(&$htmlHeadXtra);
-event_access_tool(TOOL_LEARNPATH);
-$interbreadcrumb[]= array ("url"=>"./lp_controller.php?action=list", "name"=> get_lang(ucfirst(TOOL_LEARNPATH)));
+event_access_tool(TOOL_SEARCH);
+$interbreadcrumb[]= array ("url"=>"./index.php", "name"=> get_lang('LectureLibrary'));//get_lang(ucfirst(TOOL_SEARCH))
Display::display_header(null,'Path');
if (api_get_setting('search_enabled') !== 'true') {
@@ -51,118 +64,105 @@ else
search_widget_show(empty($search_action)?null:'index.php');
}
-
-/**
- * Utility function to get a table for a specific course.
- *
- * @param string $course_code The course_code as in cidReq
- * @param string $table The desired table, this is just concat'd.
- * @return string
- */
-function get_course_table($course_code, $table) {
- $ret = NULL;
-
- $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
- $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
- $sql = "SELECT
- $course_table.db_name, $course_cat_table.code
- FROM $course_table
- LEFT JOIN $course_cat_table
- ON
- $course_table.category_code = $course_cat_table.code
- WHERE
- $course_table.code = '$course_code'
- LIMIT 1";
- $res = api_sql_query($sql, __FILE__, __LINE__);
- $result = Database::fetch_array($res);
-
- $ret = sprintf ("%s.%s",
- $result[0],
- $table);
-
- return $ret;
+$tag_array = array();
+$specific_fields = get_specific_field_list();
+foreach ($specific_fields as $specific_field) {
+ if (isset($_REQUEST[ 'sf_'. $specific_field['code'] ])) {
+ $values = $_REQUEST[ 'sf_'. $specific_field['code'] ];
+ foreach ($values as $term) {
+ if (!empty($term)) {
+ $prefix = $specific_field['code'];
+ $tag_array[] = dokeos_get_boolean_query($prefix . $term);
+ }
+ }
+ }
}
-$tags = explode(",", trim($_REQUEST['tags']));
-$tags2 = '';
+$query = $_REQUEST['query'];
+$query = stripslashes(htmlspecialchars_decode($query,ENT_QUOTES));
-foreach ($tags as $tag)
- if (strlen($tag)> 1)
- $tags2 .= " tag:".trim($tag);
+$op = 'or';
+if (!empty($_REQUEST['operator']) && $_REQUEST['operator'] == 'and') {
+ $op = $_REQUEST['operator'];
+}
+
+$fixed_queries = array();
+$course_filter = NULL;
+if ( ($cid=api_get_course_id()) != -1 ) {
+ // results only from actual course
+ $course_filter = dokeos_get_boolean_query(XAPIAN_PREFIX_COURSEID . $cid);
+}
-$query = $_REQUEST['query'] . ' ' . $tags2;
+if (count($tag_array)) {
+ $fixed_queries = dokeos_join_queries($tag_array,null,$op);
+ if ($course_filter != NULL) {
+ $fixed_queries = dokeos_join_queries($fixed_queries, $course_filter, 'and');
+ }
+} else {
+ if (!empty($query)) {
+ $fixed_queries = array($course_filter);
+ }
+}
-$query_results = dokeos_query_query($query, 0, 1000);
-$count = $query_results[0];
-$results = $query_results[1];
+list($count, $results) = dokeos_query_query(mb_convert_encoding($query,'UTF-8',$charset), 0, 1000, $fixed_queries);
$blocks = array();
$url = api_get_path(WEB_CODE_PATH)."/newscorm/lp_controller.php";
-$search_url = sprintf('%s?action=search&query=%s&tags=%s',
- $url, $_REQUEST['query'], $_REQUEST['tags']);
+$search_url = sprintf('%s?action=search&query=%s',
+ $url, $_REQUEST['query']);
$link_format = $url.'?cidReq=%s&action=view&lp_id=%s&item_id=%s';
+$learnings_id_list = array();
+$mode = ($_GET['mode']!='default') ? 'gallery' : 'default';
if ($count > 0) {
foreach ($results as $result) {
- /* FIXME:diegoe: marco debe darme los valores adecuados. */
- $ids = explode(":", $result->ids);
- $course_id = $ids[0];
- $lp_id = $ids[1];
- $doc_id = $ids[2];
-
- if (!api_is_course_visible_for_user(NULL, $course_id))
- continue;
-
$tags = '';
foreach ($result->terms as $term) {
- $tags .= trim($term['name'], 'T') . ", ";
+ $tags .= $term['name'] . ", ";
}
//remove trailing comma
$tags = substr($tags,0,-2);
-
- $lpi_table = get_course_table($course_id, TABLE_LP_ITEM);
- $lp_table = get_course_table($course_id, TABLE_LP_MAIN);
- $doc_table = get_course_table($course_id, TABLE_DOCUMENT);
- $sql = "SELECT
- $doc_table.title, $doc_table.path, $lpi_table.id,
- $lp_table.name, $lp_table.author
- FROM $lp_table, $lpi_table INNER JOIN $doc_table
- ON $lpi_table.path = $doc_table.id
- WHERE
- $lpi_table.lp_id = $lp_id
- AND
- $doc_table.id = $doc_id
- AND
- $lp_table.id = $lpi_table.lp_id
- LIMIT 1";
-
- $dk_result = api_sql_query ($sql);
-
- while ($row = Database::fetch_array ($dk_result)) {
- /* Get the image path */
- $img_path = str_replace ('.png.html', '_thumb.png', $row['path']);
- $doc_id = $row['id'];
- $title = get_lang('Title').': '.'
'.get_lang('Author').': '.$row['author']);
-
- $href = sprintf($link_format, $course_id, $lp_id, $doc_id);
-
- /* Fill the result array */
- $blocks[] = array(
- '
', //put a link to the learning path item directly on the image
- $title,
- $tags,
- $href
- );
+ if (!empty($result['url'])) {
+ $a_prefix = '
';
+ }
+ else {
+ $a_prefix = '';
+ $a_sufix = '';
+ }
+
+ if ($mode == 'gallery') {
+ $title = $a_prefix.str_replace('_',' ',$result['title']). $a_sufix; //TODO: get author.(empty($row['author'])?'':''.$row['author']);
+ } else {
+ $title = '
'. $a_prefix . $result['title']. $a_sufix .(!empty($result['author'])?$result['author']:'').'
';
+ }
+
+ // Fill the result array
+ if (empty($result['thumbnail'])) { // or !file_exists('../../courses/'.api_get_course_path($course_id)."/document/".$img_path)
+ $result['thumbnail'] = '../img/no_document_thumb.jpg';
+ }
+
+ if ($mode == 'gallery') {
+ $blocks[] = array(
+ //'
'.get_lang('GoToLearningPath').'').'" rel="lightbox" href="'.$result['image'].'">

',
+ $a_prefix .'

'. $a_sufix .'
'.$title.'
'.$result['author'],
+ //$title,
+ );
+ } else {
+ $blocks[] = array(
+ $title,
+ );
}
}
}
+
if (count($blocks) < 1) {
- Display::display_normal_message(get_lang('SearchFeatureSearchExplanation'), FALSE);
+// Display::display_normal_message(get_lang('SearchFeatureSearchExplanation'), FALSE);
}
else
{
@@ -171,18 +171,41 @@ else
}
$s = new SortableTableFromArray($blocks);
- $s->additional_parameters = array(
- 'action' => 'search',
- 'query' => $_REQUEST['query'],
- 'tags' => $_REQUEST['tags'],
- );
- $s->set_header(0, get_lang('Preview'),false,array('width="300px"'));
- $s->set_header(1, get_lang('Title'));
- $s->set_header(2, get_lang('Tags'));
- $s->set_header(3, get_lang('Learning path'));
- $s->set_column_filter(3,'to_link');
+ $s->display_mode = $mode;//default
+ $s->display_mode_params = 3;
+ $s->per_page = 9;
+ $additional_parameters = array(
+ 'mode' => $mode,
+ 'action' => 'search',
+ 'query' => $_REQUEST['query'],
+ );
+ $get_params = '';
+ foreach ($specific_fields as $specific_field) {
+ if (isset($_REQUEST[ 'sf_'. $specific_field['code'] ])) {
+ $values = $_REQUEST[ 'sf_'. $specific_field['code'] ];
+ $additional_parameters[ 'sf_'. $specific_field['code'] ] = $values;
+ foreach ( $values as $value ) {
+ $get_params .= '&sf_' . $specific_field['code'] .'[]='. $value;
+ }
+ $get_params .= '&';
+ }
+ }
+ $s->additional_parameters = $additional_parameters;
+
+ if ($mode == 'default') {
+ $s->set_header(0, get_lang('Lectures'));
+ }
+
+ $search_url = api_get_path(WEB_CODE_PATH)."search/index.php";
+
+ echo '
';
+ echo '
?'ButtonGallOn':'ButtonGallOff').'.png)
?'ButtonListOn':'ButtonListOff').'.png)
+
';
+
$s->display();
+ echo '
';
}
-
Display::display_footer();
-?>
\ No newline at end of file
+?>
diff --git a/main/newscorm/openoffice_presentation.class.php b/main/newscorm/openoffice_presentation.class.php
index 85607a9db8..93772b50f6 100644
--- a/main/newscorm/openoffice_presentation.class.php
+++ b/main/newscorm/openoffice_presentation.class.php
@@ -12,12 +12,10 @@
* @package dokeos.learnpath.openofficedocument
*/
require_once('openoffice_document.class.php');
-if(api_get_setting('search_enabled')==='true') //the true condition here should be if xapian module is installed
-{
- require_once(api_get_path(LIBRARY_PATH).'search/DokeosIndexer.class.php');
- require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
-}
-
+require_once(api_get_path(LIBRARY_PATH).'search/DokeosIndexer.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');
+
class OpenofficePresentation extends OpenofficeDocument {
public $take_slide_name;
@@ -67,8 +65,13 @@ class OpenofficePresentation extends OpenofficeDocument {
$document_id = add_document($_course,$this->created_dir.'/'.urlencode($file_name),'file',filesize($this->base_work_dir.$this->created_dir.'/'.$file_name),$slide_name);
api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',api_get_user_id(),0,0);
+
// Generating the thumbnail
$image = $this->base_work_dir.$this->created_dir .'/'. $file_name;
+
+ $pattern = '/(\w+)\.png$/';
+ $replacement = '${1}_thumb.png';
+ $thumb_name = preg_replace($pattern, $replacement, $file_name);
// calculate thumbnail size
list($width, $height) = getimagesize($image);
$thumb_width = 300;
@@ -79,10 +82,15 @@ class OpenofficePresentation extends OpenofficeDocument {
// resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
// output
- $pattern = '/(\w+)\.png$/';
- $replacement = '${1}_thumb.png';
- $thumb_name = preg_replace($pattern, $replacement, $file_name);
imagepng($thumb, $this->base_work_dir.$this->created_dir .'/'. $thumb_name);
+ /*
+ // new resizing method usign imagemagick
+ $im = new Imagick( $image );
+ $im->thumbnailImage($thumb_width, $thumb_height);
+ //file_put_contents($this->base_work_dir.$this->created_dir .'/'. $thumb_name,$im);
+ $im->writeImage($this->base_work_dir.$this->created_dir .'/'. $thumb_name);
+ */
+
// 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);
@@ -111,40 +119,52 @@ class OpenofficePresentation extends OpenofficeDocument {
}
}
// code for text indexing
- if (isset($_POST['index_document']) && $_POST['index_document'] && api_get_setting('search_enabled')==='true') {
+ if (isset($_POST['index_document']) && $_POST['index_document']) {
//Display::display_normal_message(print_r($_POST));
$di = new DokeosIndexer();
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);
- if (isset($_POST['terms'])) {
- foreach (explode(',', Database::escape_string($_POST['terms'])) as $term){
- $ic_slide->addTerm(trim($term),'T');
- }
+ $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->addTerm($courseid,'C');
- //TODO: add dokeos tool type instead of filetype
+ $ic_slide->addCourseId($courseid);
+ $ic_slide->addToolId(TOOL_LEARNPATH);
$lp_id = $this->lp_id;
- // TODO: get "path" field
- $ic_slide->addValue('ids', $courseid .':'. $this->lp_id
- .':'.$document_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_lp_item = Database::get_course_table('lp_item');
- $sql_update = "
- UPDATE " . $tbl_lp_item . "
- SET search_did = " . $did . ",
- terms = '".Database::escape_string($_POST['terms'])."'
- WHERE id = " . $previous;
- api_sql_query($sql_update, __FILE__, __LINE__);
+ $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);
+ api_sql_query($sql,__FILE__,__LINE__);
}
}
}
diff --git a/main/newscorm/openoffice_text_document.class.php b/main/newscorm/openoffice_text_document.class.php
index 6ae31cd936..4bcbf25b17 100644
--- a/main/newscorm/openoffice_text_document.class.php
+++ b/main/newscorm/openoffice_text_document.class.php
@@ -11,6 +11,9 @@
* @package dokeos.learnpath.openofficedocument
*/
require_once('openoffice_document.class.php');
+require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
+require_once(api_get_path(LIBRARY_PATH).'search/DokeosIndexer.class.php');
+require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php');
class OpenOfficeTextDocument extends OpenofficeDocument {
@@ -201,7 +204,9 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
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
@@ -213,6 +218,54 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
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 DokeosIndexer();
+ 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);
+ api_sql_query($sql,__FILE__,__LINE__);
+ }
+ }
}
}
diff --git a/main/newscorm/scorm.class.php b/main/newscorm/scorm.class.php
index 477151ec1a..113eb10a99 100644
--- a/main/newscorm/scorm.class.php
+++ b/main/newscorm/scorm.class.php
@@ -473,6 +473,58 @@ class scorm extends learnpath {
$upd_res = api_sql_query($upd);
//update previous item id
$previous = $item_id;
+
+ // code for indexing, now only index specific fields like terms and the title
+ if (isset($_POST['index_document']) && $_POST['index_document']) {
+ require_once(api_get_path(LIBRARY_PATH).'search/DokeosIndexer.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 DokeosIndexer();
+ 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' => ''), //TODO unify with other lp types
+ 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);
+ api_sql_query($sql,__FILE__,__LINE__);
+ }
+ }
+
}
}
}
diff --git a/main/search/index.php b/main/search/index.php
index c5304cf654..e83f2b6923 100644
--- a/main/search/index.php
+++ b/main/search/index.php
@@ -3,15 +3,16 @@
* This file includes lp_list_search to avoid duplication of code, it
* bootstraps dokeos api enough to make lp_list_search work.
*/
+
include_once ('../inc/global.inc.php');
+ //var_dump(api_get_path(LIBRARY_PATH));
include_once (api_get_path(LIBRARY_PATH).'course.lib.php');
include_once (api_get_path(LIBRARY_PATH).'debug.lib.inc.php');
include_once (api_get_path(LIBRARY_PATH).'system_announcements.lib.php');
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
include_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+include_once (api_get_path(LIBRARY_PATH).'events.lib.inc.php');
+//api_block_anonymous_users(); // only users who are logged in can proceed
-api_block_anonymous_users(); // only users who are logged in can proceed
-
-$search_action = 'index.php';
require '../newscorm/lp_list_search.php';
?>
diff --git a/main/search/search_suggestions.php b/main/search/search_suggestions.php
new file mode 100644
index 0000000000..8c11d87f63
--- /dev/null
+++ b/main/search/search_suggestions.php
@@ -0,0 +1,102 @@
+ $course_id) {
+ foreach ($course_id as $ti => $item_tool_id) {
+ foreach ($item_tool_id as $ri => $item_ref_id) {
+ //natsort($item_ref_id);
+ $output = array();
+ $field_val = array();
+ $sql2 = "SELECT * FROM $table_sfv where course_code = '$cc' AND tool_id = '$ti' AND ref_id = '$ri' ORDER BY field_id";
+ $res2 = api_sql_query($sql2,__FILE__,__LINE__);
+ // TODO this code doesn't manage multiple terms in one same field just yet (should duplicate results in this case)
+ $field_id = 0;
+ while ($row2 = Database::fetch_array($res2)) {
+ //TODO : this code is not perfect yet. It overrides the
+ // first match set, so having 1:Yannick,Julio;2:Rectum;3:LASER
+ // will actually never return: Yannick - Rectum - LASER
+ // because it is overwriteen by Julio - Rectum - LASER
+ // We should have recursivity here to avoid this problem!
+ //Store the new set of results (only one per combination
+ // of all fields)
+ $field_val[$row2['field_id']] = $row2['value'];
+ $current_field_val = '';
+ foreach ($field_val as $id => $val) {
+ $current_field_val .= $val.' - ';
+ }
+ //Check whether we have a field repetition or not. Results
+ // have been ordered by field_id, so we should catch them
+ // all here
+ if ($field_id == $row2['field_id']) {
+ //We found the same field id twice, split the output
+ // array to allow for two sets of results (copy all
+ // existing array elements into copies and update the
+ // copies) eg. Yannick - Car - Driving in $output[1]
+ // will create a copy as Yannick - Car - Speed
+ // in $output[3]
+ $c = count($output);
+ for ($i=0;$i<$c; $i++) {
+ $output[($c+$i)] = $current_field_val;
+ }
+ } else {
+ //no identical field id, continue as usual
+ $c = count($output);
+ if ($c == 0) {
+ $output[] = $row2['value'].' - ';
+ } else {
+ foreach ($output as $i=>$out) {
+ //use the latest combination of fields
+ $output[$i] .= $row2['value'].' - ';
+ }
+ }
+ $field_id = $row2['field_id'];
+ }
+ }
+ foreach ($output as $i=>$out) {
+ if (stristr($out,$q) === false) {continue;}
+ $s = mb_convert_encoding(substr($out,0,-3),'UTF-8',$charset) . "| value\n";
+ if (!in_array($s,$more_sugg)) {
+ $more_sugg[] = $s;
+ }
+ }
+ }
+ }
+ }
+ foreach ($more_sugg as $sugg) {
+ echo $sugg;
+ }
+}
+
+$q = strtolower($_GET["q"]);
+if (!$q) return;
+//echo $q . "| value\n";
+get_suggestions_from_search_engine($q);
+?>
diff --git a/main/upload/form.scorm.php b/main/upload/form.scorm.php
index 58a6a4d29c..99c93cacf0 100644
--- a/main/upload/form.scorm.php
+++ b/main/upload/form.scorm.php
@@ -36,9 +36,11 @@ $interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "
Display::display_header($nameTools,"Path");
//show the title
api_display_tool_title(get_lang("Learnpath")." - ".$nameTools.$add_group_to_title);
+//TODO: Include right language file
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
include('../newscorm/content_makers.inc.php');
+require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
$form = new FormValidator('','POST','upload.php','','id="upload_form" enctype="multipart/form-data" style="background-image: url(\'../img/scorm.jpg\'); background-repeat: no-repeat; background-position: 600px;"');
@@ -58,6 +60,15 @@ $select_content_proximity = &$form->addElement('select','content_proximity',get_
$select_content_proximity->addOption(get_lang('Remote'),"remote");
$select_content_proximity -> setSelected("local");
+if(api_get_setting('search_enabled')=='true')
+{
+ $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
+
+ $specific_fields = get_specific_field_list();
+ foreach ($specific_fields as $specific_field) {
+ $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
+ }
+}
$form->addElement('submit', 'submit', get_lang('Send'));
$form->addElement('html', '
');
@@ -77,6 +88,7 @@ else{
$form->add_real_progress_bar('uploadScorm','user_file');
+$defaults = array('index_document'=>'checked="checked"');
$form->setDefaults($defaults);
$form->display();
diff --git a/main/upload/upload.scorm.php b/main/upload/upload.scorm.php
index 82001e3bd1..464e9e9efa 100644
--- a/main/upload/upload.scorm.php
+++ b/main/upload/upload.scorm.php
@@ -18,7 +18,22 @@ if($error=='not_a_learning_path')
{
$msg = urlencode(get_lang('UnknownPackageFormat'));
}else{
- $msg = urlencode(get_lang('UplUploadSucceeded'));
+ 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, $oScorm->lp_id, $value);
+ }
+ }
+ }
+ }
+
+ $msg = urlencode(get_lang('UplUploadSucceeded'));
}
header('location: ../newscorm/lp_controller.php?action=list&dialog_box='.$msg);
?>
\ No newline at end of file
diff --git a/main/upload/upload_ppt.php b/main/upload/upload_ppt.php
index 1eaef7fc39..b8c5a28fc6 100644
--- a/main/upload/upload_ppt.php
+++ b/main/upload/upload_ppt.php
@@ -19,6 +19,7 @@ include("../inc/global.inc.php");
require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
require_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
+require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
@@ -31,6 +32,13 @@ $form_style= '
background: url("../img/scorm.gif") 0px 0px no-repeat;
padding: 2px 0px 2px 22px;
}
+.sub-form{
+ width: 25em;
+}
+.sub-form input{
+ float:right;
+ margin-top:-1.2em;
+}
#dynamic_div_container{float:left;margin-right:10px;}
#dynamic_div_waiter_container{float:left;}
';
@@ -40,6 +48,7 @@ $htmlHeadXtra[] = '';
$htmlHeadXtra[] = $form_style;
+$specific_fields = get_specific_field_list();
if(isset($_POST['convert'])){
$cwdir = getcwd();
@@ -50,6 +59,17 @@ if(isset($_POST['convert'])){
{
require('../newscorm/lp_upload.php');
if(isset($o_ppt) && $first_item_id != 0){
+ 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);
}
else {
@@ -134,7 +154,7 @@ $form = new FormValidator('upload_ppt', 'POST', '', '');
// build the form
-$form -> addElement ('html','
');
+$form -> addElement ('html','
');
$div_upload_limit = ' '.get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
@@ -164,18 +184,25 @@ $renderer->setElementTemplate($user_file_template);
$form -> addElement ('file', 'user_file','

');
$form -> addElement ('checkbox', 'take_slide_name','', get_lang('TakeSlideName'));
-if(api_get_setting('search_enabled')==='true')
+if(api_get_setting('search_enabled')=='true')
{
- $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
- $form -> addElement ('text', 'terms', get_lang('SearchFeatureDocumentTagsIfIndexing').': ');
- $form -> addElement ('html', get_lang('SearchFeatureDocumentLanguage').': '. api_get_languages_combo());
+ $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
+ //$form -> addElement ('text', 'terms', get_lang('SearchFeatureDocumentTagsIfIndexing').': ');
+ $form -> addElement ('html','
');
+ $form -> addElement ('html', get_lang('SearchFeatureDocumentLanguage').': '. api_get_languages_combo());
+ $form -> addElement ('html','
');
+ foreach ($specific_fields as $specific_field) {
+ $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
+ }
+ $form -> addElement ('html','
');
}
+
$form -> addElement ('submit', 'convert', get_lang('ConvertToLP'), 'class="convert_button"');
$form -> addElement ('hidden', 'ppt2lp', 'true');
$form -> add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
-$defaults = array('take_slide_name'=>'checked="checked"');
+$defaults = array('take_slide_name'=>'checked="checked"','index_document'=>'checked="checked"');
$form->setDefaults($defaults);
// display the form
$form -> display();
diff --git a/main/upload/upload_word.php b/main/upload/upload_word.php
index 5b82c47d9e..58e18c0ae9 100644
--- a/main/upload/upload_word.php
+++ b/main/upload/upload_word.php
@@ -20,6 +20,7 @@ require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
require_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
+require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
$form_style= '
@@ -40,6 +41,7 @@ $htmlHeadXtra[] = '';
$htmlHeadXtra[] = $form_style;
+$specific_fields = get_specific_field_list();
if(isset($_POST['convert'])){
$cwdir = getcwd();
@@ -50,6 +52,17 @@ if(isset($_POST['convert'])){
{
require('../newscorm/lp_upload.php');
if(isset($o_doc) && $first_item_id != 0){
+ 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_doc->lp_id, $value);
+ }
+ }
+ }
+ }
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
}
else {
@@ -155,6 +168,17 @@ EOT;
$renderer->setElementTemplate($user_file_template);
$form -> addElement ('file', 'user_file','

');
+if (api_get_setting('search_enabled')=='true')
+{
+ $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
+ $form -> addElement ('html','
');
+ $form -> addElement ('html', get_lang('SearchFeatureDocumentLanguage').': '. api_get_languages_combo());
+ $form -> addElement ('html','
');
+ foreach ($specific_fields as $specific_field) {
+ $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
+ }
+ $form -> addElement ('html','
');
+}
/*
* commented because SplitStepsPerChapter is not stable at all
@@ -169,7 +193,7 @@ $form -> addElement ('hidden', 'woogie', 'true');
$form -> add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
-$defaults['split_steps'] = 'per_page';
+$defaults = array('split_steps'=>'per_page','index_document'=>'checked="checked"');
$form -> setDefaults($defaults);
// display the form