123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- define('SE_COURSE_ID', 0);
- define('SE_TOOL_ID', 1);
- define('SE_DATA', 2);
- define('SE_USER', 3);
- define('SE_DOCTYPE_EXERCISE_EXERCISE', 0);
- define('SE_DOCTYPE_EXERCISE_QUESTION', 1);
- define('XAPIAN_PREFIX_COURSEID', 'C');
- define('XAPIAN_PREFIX_TOOLID', 'O');
- abstract class _IndexableChunk
- {
-
- public $data;
-
- public $xapian_data;
-
- public $terms;
-
- public function __construct()
- {
- $this->data = [];
- }
-
- public function __destruct()
- {
- unset($this->data);
- unset($this->terms);
- }
-
- public function addValue($key, $value)
- {
- $this->data[$key] = $value;
- }
-
- public function addTerm($term, $flag)
- {
- global $charset;
- if (strlen($flag) == 1) {
- $this->terms[] = ['name' => api_convert_encoding(stripslashes($term), 'UTF-8', $charset), 'flag' => $flag];
- }
- }
- }
- class IndexableChunk extends _IndexableChunk
- {
-
- public function addCourseId($course_id)
- {
- $this->addTerm($course_id, XAPIAN_PREFIX_COURSEID);
- }
-
- public function addToolId($tool_id)
- {
- $this->addTerm($tool_id, XAPIAN_PREFIX_TOOLID);
- }
- }
|