Updaiting search files

skala
Julio Montoya 16 years ago
parent a5402c829c
commit d7870d84d4
  1. 1
      main/inc/lib/search/DokeosQuery.php
  2. 35
      main/inc/lib/search/search_widget.php
  3. 4
      main/inc/lib/search/xapian/XapianQuery.php
  4. 71
      main/newscorm/learnpath.class.php
  5. 23
      main/newscorm/lp_list.php
  6. 8
      main/newscorm/lp_list_search.php
  7. 6
      main/search/index.php

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
/*
* Script defining generic functions against a search engine api. Just only if one day the search engine changes
* @package: dokeos.search

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
/**
* Search widget. Shows the search screen contents.
* @package dokeos.search
@ -22,8 +22,7 @@ function search_widget_prepare(&$htmlHeadXtra) {
<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.autocomplete.js"></script>
<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'search/search_widget.js"></script>
<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.autocomplete.css" />
<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_LIBRARY_PATH).'search/search_widget.css" />
';
<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_LIBRARY_PATH).'search/search_widget.css" />';
}
/**
@ -120,13 +119,24 @@ function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) {
if (isset($_GET['action']) && strcmp(trim($_GET['action']),'search')===0) {
$action='index.php';
}
$navigator_info = api_get_navigator();
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$submit_button1 = '<input type="submit" id="submit" value="'. get_lang('Search') .'" />';
$submit_button2 = '<input class="lower-submit" type="submit" value="'. get_lang('Search') .'" />';
$reset_button = '<input type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />';
} else {
$submit_button1 = '<button class="search" type="submit" id="submit" value="'. get_lang("Search") .'" /> '. get_lang('Search') .'</button>';
$submit_button2 = '<button class="search" type="submit" value="'. get_lang('Search') .'" />'. get_lang('Search') .'</button>';
$reset_button = '<button class="save" type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'. get_lang('SearchResetKeywords') .'</button> ';
}
$form = '
<form id="dokeos_search" action="'. $action .'" method="GET">
<input type="text" id="query" name="query" size="40" />
<input type="text" id="query" name="query" size="40" value="'.stripslashes(Security::remove_XSS($_REQUEST['query'])).'" />
<input type="hidden" name="mode" value="'. $mode .'"/>
<input type="hidden" name="type" value="'. $type .'"/>
<input type="hidden" name="tablename_page_nr" value="1" />
<input type="submit" id="submit" value="'. get_lang("Search") .'" />
'.$submit_button1.'
<br /><br />
<span class="search-links-box">'. $thesaurus_icon . $advanced_options .'&nbsp;</span>
<div id="tags" class="tags" style="display:'. $display_thesaurus .';">
@ -153,8 +163,8 @@ function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) {
<td></td>
<td>
<br />
<input class="lower-submit" type="submit" value="'. get_lang('Search') .'" />
<input type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />
'.$reset_button.'
'. $submit_button2.'
</td>
</tr>
</table>
@ -198,8 +208,7 @@ function search_widget_prefilter_form($action, $show_thesaurus, $sf_terms, $op,
<div id="tags" class="tags" style="display:'. $display_thesaurus .';">
<div class="search-help-box">'. $help .'</div>
<table>
<tr>
';
<tr>';
if (!is_null($prefilter_prefix)) {
//sorting the array of terms
@ -301,9 +310,11 @@ function search_widget_show($action='index.php') {
//prepare specific fields names (and also get possible URL param names)
foreach ($specific_fields as $specific_field) {
$temp = array();
foreach($dkterms[1] as $obj) {
$temp = array_merge($obj['sf-'.$specific_field['code']], $temp);
}
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);

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
require_once 'xapian.php';
require_once dirname(__FILE__) . '/../IndexableChunk.class.php';
//TODO: think another way without including specific fields here
@ -22,8 +23,7 @@ define('XAPIAN_DB', api_get_path(SYS_PATH).'searchdb/');
* @param int $count_type Number of items to retrieve
* @return array An array of nids corresponding to the results.
*/
function xapian_query($query_string, $db = NULL, $start = 0, $length = 10,
$extra = array(), $count_type = 0) {
function xapian_query($query_string, $db = NULL, $start = 0, $length = 10, $extra = array(), $count_type = 0) {
try {
if (!is_object($db)) {

@ -1,25 +1,5 @@
<?php
// $Id: index.php 16620 2008-10-25 20:03:54Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2009 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, rue Notre Dame, 152, B-1140 Evere, Belgium, info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /dokeos_license.txt */
/**
* This (abstract?) class defines the parent attributes and methods for the dokeos learnpaths and scorm
@ -3991,7 +3971,7 @@ class learnpath {
$items_table = Database :: get_course_table(TABLE_LP_ITEM);
//TODO: make query secure agains XSS : use member attr instead of post var
$lp_id = $_POST['lp_id'];
$lp_id = intval($_POST['lp_id']);
$sql = "SELECT * FROM $items_table WHERE lp_id = $lp_id";
$result = api_sql_query($sql);
$di = new DokeosIndexer();
@ -4001,33 +3981,38 @@ class learnpath {
$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 AND ref_id_second_level=%d LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $this->cc, TOOL_LEARNPATH, $lp_id, $lp_item['id']);
$res = api_sql_query($sql, __FILE__, __LINE__);
$se_ref = Database :: fetch_array($res);
if (Database::num_rows($res)>0) {
// compare terms
$doc = $di->get_document($se_ref['search_did']);
$xapian_terms = xapian_get_doc_terms($doc, $prefix);
//var_dump($xapian_terms);
$xterms = array ();
foreach ($xapian_terms as $xapian_term)
$xterms[] = substr($xapian_term['name'], 1);
$se_ref = Database :: fetch_array($res);
$dterms = $terms;
//var_dump($xterms);
//var_dump($dterms);
// compare terms
$doc = $di->get_document($se_ref['search_did']);
$missing_terms = array_diff($dterms, $xterms);
$deprecated_terms = array_diff($xterms, $dterms);
$xapian_terms = xapian_get_doc_terms($doc, $prefix);
//var_dump($xapian_terms);
$xterms = array ();
foreach ($xapian_terms as $xapian_term)
$xterms[] = substr($xapian_term['name'], 1);
// save it to search engine
foreach ($missing_terms as $term) {
$doc->add_term($prefix . $term, 1);
}
foreach ($deprecated_terms as $term) {
$doc->remove_term($prefix . $term);
$dterms = $terms;
//var_dump($xterms);
//var_dump($dterms);
$missing_terms = array_diff($dterms, $xterms);
$deprecated_terms = array_diff($xterms, $dterms);
// save it to search engine
foreach ($missing_terms as $term) {
$doc->add_term($prefix . $term, 1);
}
foreach ($deprecated_terms as $term) {
$doc->remove_term($prefix . $term);
}
$di->getDb()->replace_document((int) $se_ref['search_did'], $doc);
$di->getDb()->flush();
}
$di->getDb()->replace_document((int) $se_ref['search_did'], $doc);
$di->getDb()->flush();
}
return true;

@ -1,26 +1,5 @@
<?php //$id:$
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2004 Denes Nagy
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact: Dokeos, rue du Corbeau, 108, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /dokeos_license.txt */
/**
==============================================================================
* This file was origially the copy of document.php, but many modifications happened since then ;

@ -1,4 +1,6 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
/**
* Script to draw the results from a query
* @package: dokeos.learnpath
@ -7,12 +9,10 @@
*/
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).'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH).'/specific_fields_manager.lib.php';
$htmlHeadXtra[] = '
<link rel="stylesheet" type="text/css" href="'. api_get_path(WEB_PATH) .'main/newscorm/lp_list_search.css" />
';
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'. api_get_path(WEB_PATH) .'main/newscorm/lp_list_search.css" />';
event_access_tool(TOOL_SEARCH);
if (isset($_SESSION['gradebook'])){

@ -1,11 +1,13 @@
<?php
/*
/* For licensing terms, see /dokeos_license.txt */
/**
* This file includes lp_list_search to avoid duplication of code, it
* bootstraps dokeos api enough to make lp_list_search work.
*/
$language_file = array('admin');
require_once ('../inc/global.inc.php');
//var_dump(api_get_path(LIBRARY_PATH));
$this_section = SECTION_COURSES;
if (extension_loaded('xapian')) {
include_once (api_get_path(LIBRARY_PATH).'course.lib.php');

Loading…
Cancel
Save