r106928 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106927‎ | r106928 | r106929 >
Date:03:59, 21 December 2011
Author:adamw
Status:deferred (Comments)
Tags:
Comment:
Initial checkin of extension Offline, v0.6.1
Modified paths:
  • /trunk/extensions/Offline (added) (history)
  • /trunk/extensions/Offline/CachedStorage.php (added) (history)
  • /trunk/extensions/Offline/DatabaseBz2.php (added) (history)
  • /trunk/extensions/Offline/DumpReader.php (added) (history)
  • /trunk/extensions/Offline/Offline.aliases.php (added) (history)
  • /trunk/extensions/Offline/Offline.i18n.php (added) (history)
  • /trunk/extensions/Offline/Offline.php (added) (history)
  • /trunk/extensions/Offline/README.txt (added) (history)
  • /trunk/extensions/Offline/RELEASE.NOTES (added) (history)
  • /trunk/extensions/Offline/SearchBz2.php (added) (history)
  • /trunk/extensions/Offline/SpecialOffline.php (added) (history)
  • /trunk/extensions/Offline/xapian.php (added) (history)

Diff [purge]

Index: trunk/extensions/Offline/CachedStorage.php
@@ -0,0 +1,47 @@
 2+<?php
 3+/**
 4+ * Do the dirty work.
 5+ */
 6+
 7+class CachedStorage
 8+{
 9+ static function fetchIdByTitle($title) {
 10+ global $wgRevisionCacheExpiry, $wgMemc;
 11+ if ($wgRevisionCacheExpiry) { // TODO a better test for caching
 12+ $titlekey = wfMemcKey( 'textid', 'titlehash', md5($title) );
 13+ $textid = $wgMemc->get($titlekey);
 14+ if (is_int($textid) && $textid > 0)
 15+ return $textid;
 16+ }
 17+ return false;
 18+ }
 19+
 20+ static function set($title, $content) {
 21+ global $wgRevisionCacheExpiry, $wgMemc;
 22+ if (!$wgRevisionCacheExpiry) // caching is not possible
 23+ return false;
 24+
 25+ // we need to assign a sequence to revision text, because
 26+ // Article::loadContent expects page.text_id to be an integer.
 27+ $seq_key = wfMemcKey('offline', 'textid_seq');
 28+ if (!$wgMemc->get($seq_key))
 29+ $wgMemc->set($seq_key, 1); // and clear the cache??
 30+
 31+ $textid = $wgMemc->incr($seq_key);
 32+
 33+ // cache a lookup from title to fake textid
 34+ $titlekey = wfMemcKey( 'textid', 'titlehash', md5($title) );
 35+ $wgMemc->set( $titlekey, $textid, $wgRevisionCacheExpiry );
 36+
 37+ // TODO interfering with the cache is necessary to avoid a
 38+ // second query on Revision::newFromId. It would be much
 39+ // smarter to directly retrieve article markup, and optionally
 40+ // cache in the usual way.
 41+ $textkey = wfMemcKey( 'revisiontext', 'textid', $textid );
 42+ $wgMemc->delete( $textkey );
 43+ $wgMemc->set( $textkey, $content, $wgRevisionCacheExpiry );
 44+ //wfDebug('Stuffing the cache with '.strlen($content).' bytes, at id='.$textid."\n");
 45+
 46+ return $textid;
 47+ }
 48+}
Index: trunk/extensions/Offline/Offline.i18n.php
@@ -0,0 +1,46 @@
 2+<?php
 3+$messages = array();
 4+$messages['en'] = array(
 5+ 'offline_desc' => 'Read articles offline, from *pedia dump files. See page [[Special:Offline]] for status.',
 6+ 'offline' => 'Offline configuration helper', // special page title
 7+ //'special_page_title' => 'Offline configuration',
 8+ 'offline_special_desc' => 'Status and diagnostics for the Offline extension.',
 9+
 10+ 'offline_heading_status' => 'Current Status',
 11+
 12+ 'offline_test_article' => 'Andalusia', // a word likely to be found
 13+ 'offline_bad_test_article' => 'Internal error: the test_article "$1" was not found, but the index database seems to be good.',
 14+
 15+ 'offline_index_test_pass' => 'Dump index was read successfully.',
 16+ 'offline_index_test_fail' => 'Dump index cannot be read!',
 17+ 'offlinewikipath_not_configured' => 'You have not set the $wgOfflineWikiPath variable in LocalSettings.php',
 18+ 'offlinewikipath_not_found' => 'The directory specified by $wgOfflineWikiPath, <em>$1</em>, does not exist',
 19+ 'offline_dbdir_not_found' => 'The database directory, <em>$1/db</em>, is missing index data files. These must be downloaded or built.',
 20+ 'offline_unknown_index_error' => 'The index to your dump could not be read for an unknown reason. Perhaps the database files are damaged.',
 21+
 22+ 'offline_bzload_test_pass' => 'Compressed dump files can be opened.',
 23+ 'offline_bzload_test_fail' => 'Compressed dump files were not loaded!',
 24+ 'offline_bz2_ext_needed' => 'Your PHP installation is missing the Bzip2 library.',
 25+ 'offline_bz2_file_gone' => 'The index pointed to a missing dump file: <em>$1</em>',
 26+ 'offline_unknown_bz2_error' => 'There was an unknown problem reading dump file <em>$1</em>.',
 27+
 28+ 'offline_article_test_pass' => 'Article data was found where expected.',
 29+ 'offline_article_test_fail' => 'Indexed page has changed. Perhaps your index was made for another dump?',
 30+
 31+ 'offline_hooks_test_pass' => 'Mediawiki article loader will fetch from dump data.', //, from GRAMMAR(a) %1 encyclopedia called %2.
 32+ 'offline_hooks_test_fail' => 'Mediawiki article loader is not fetching from dump data. ',
 33+ 'offline_cache_needed' => 'You need to set up a cache, such as `php-pecl-apc`.',
 34+
 35+ 'offline_all_tests_pass' => 'You are good to go.',
 36+
 37+ // user preferences
 38+ 'offline_subdir_status' => 'Index files were found in subdirectory named $1',
 39+ 'offline_change_subdir' => 'Use the following directory prefix instead:',
 40+
 41+ 'offline_change_language' => 'Dumps of the following languages have been detected. Check all dumps you want to make available.',
 42+ 'offline_live_data_preferred' => 'Matches from the so-called live database will be preferred over dump text.',
 43+);
 44+
 45+$messages['tl'] = array(
 46+ 'offline_test_article' => 'Myanmar', // a word likely to be found
 47+);
Index: trunk/extensions/Offline/xapian.php
@@ -0,0 +1,3404 @@
 2+<?php
 3+
 4+/* ----------------------------------------------------------------------------
 5+ * This file was automatically generated by SWIG (http://www.swig.org).
 6+ * Version 2.0.5
 7+ *
 8+ * This file is not intended to be easily readable and contains a number of
 9+ * coding conventions designed to improve portability and efficiency. Do not make
 10+ * changes to this file unless you know what you are doing--modify the SWIG
 11+ * interface file instead.
 12+ * ----------------------------------------------------------------------------- */
 13+
 14+// Try to load our extension if it's not already loaded.
 15+//IF phpversion() >= 5_3
 16+/*
 17+if (!extension_loaded('xapian')) {
 18+ if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
 19+ if (!dl('php_xapian.dll')) return;
 20+ } else {
 21+ // PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'.
 22+ if (PHP_SHLIB_SUFFIX === 'dylib') {
 23+ if (!dl('xapian.so')) return;
 24+ } else {
 25+ if (!dl('xapian.'.PHP_SHLIB_SUFFIX)) return;
 26+ }
 27+ }
 28+}
 29+*/
 30+
 31+
 32+
 33+abstract class Xapian {
 34+ static function BAD_VALUENO_get() {
 35+ return BAD_VALUENO_get();
 36+ }
 37+
 38+ static function version_string() {
 39+ return version_string();
 40+ }
 41+
 42+ static function major_version() {
 43+ return major_version();
 44+ }
 45+
 46+ static function minor_version() {
 47+ return minor_version();
 48+ }
 49+
 50+ static function revision() {
 51+ return revision();
 52+ }
 53+
 54+ const DB_CREATE_OR_OPEN = DB_CREATE_OR_OPEN;
 55+
 56+ const DB_CREATE = DB_CREATE;
 57+
 58+ const DB_CREATE_OR_OVERWRITE = DB_CREATE_OR_OVERWRITE;
 59+
 60+ const DB_OPEN = DB_OPEN;
 61+
 62+ static function auto_open_stub($file) {
 63+ $r=auto_open_stub($file);
 64+ if (is_resource($r)) {
 65+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 66+ if (class_exists($c)) return new $c($r);
 67+ return new XapianDatabase($r);
 68+ }
 69+ return $r;
 70+ }
 71+
 72+ static function brass_open($dir,$action=null,$block_size=8192) {
 73+ switch (func_num_args()) {
 74+ case 1: $r=brass_open($dir); break;
 75+ default: $r=brass_open($dir,$action,$block_size);
 76+ }
 77+ if (!is_resource($r)) return $r;
 78+ switch (get_resource_type($r)) {
 79+ case '_p_Xapian__WritableDatabase': return new XapianWritableDatabase($r);
 80+ default: return new XapianDatabase($r);
 81+ }
 82+ }
 83+
 84+ static function chert_open($dir,$action=null,$block_size=8192) {
 85+ switch (func_num_args()) {
 86+ case 1: $r=chert_open($dir); break;
 87+ default: $r=chert_open($dir,$action,$block_size);
 88+ }
 89+ if (!is_resource($r)) return $r;
 90+ switch (get_resource_type($r)) {
 91+ case '_p_Xapian__WritableDatabase': return new XapianWritableDatabase($r);
 92+ default: return new XapianDatabase($r);
 93+ }
 94+ }
 95+
 96+ static function flint_open($dir,$action=null,$block_size=8192) {
 97+ switch (func_num_args()) {
 98+ case 1: $r=flint_open($dir); break;
 99+ default: $r=flint_open($dir,$action,$block_size);
 100+ }
 101+ if (!is_resource($r)) return $r;
 102+ switch (get_resource_type($r)) {
 103+ case '_p_Xapian__WritableDatabase': return new XapianWritableDatabase($r);
 104+ default: return new XapianDatabase($r);
 105+ }
 106+ }
 107+
 108+ static function inmemory_open() {
 109+ $r=inmemory_open();
 110+ if (is_resource($r)) {
 111+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 112+ if (class_exists($c)) return new $c($r);
 113+ return new XapianWritableDatabase($r);
 114+ }
 115+ return $r;
 116+ }
 117+
 118+ static function remote_open($host_or_program,$port_or_args,$timeout=10000,$connect_timeout=null) {
 119+ switch (func_num_args()) {
 120+ case 2: case 3: $r=remote_open($host_or_program,$port_or_args,$timeout); break;
 121+ default: $r=remote_open($host_or_program,$port_or_args,$timeout,$connect_timeout);
 122+ }
 123+ if (is_resource($r)) {
 124+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 125+ if (class_exists($c)) return new $c($r);
 126+ return new XapianDatabase($r);
 127+ }
 128+ return $r;
 129+ }
 130+
 131+ static function remote_open_writable($host_or_program,$port_or_args,$timeout=10000,$connect_timeout=null) {
 132+ switch (func_num_args()) {
 133+ case 2: case 3: $r=remote_open_writable($host_or_program,$port_or_args,$timeout); break;
 134+ default: $r=remote_open_writable($host_or_program,$port_or_args,$timeout,$connect_timeout);
 135+ }
 136+ if (is_resource($r)) {
 137+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 138+ if (class_exists($c)) return new $c($r);
 139+ return new XapianWritableDatabase($r);
 140+ }
 141+ return $r;
 142+ }
 143+
 144+ static function sortable_serialise($value) {
 145+ return sortable_serialise($value);
 146+ }
 147+
 148+ static function sortable_unserialise($value) {
 149+ return sortable_unserialise($value);
 150+ }
 151+}
 152+
 153+/* PHP Proxy Classes */
 154+class XapianPositionIterator {
 155+ public $_cPtr=null;
 156+ protected $_pData=array();
 157+
 158+ function __set($var,$value) {
 159+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 160+ $this->_pData[$var] = $value;
 161+ }
 162+
 163+ function __isset($var) {
 164+ if ($var === 'thisown') return true;
 165+ return array_key_exists($var, $this->_pData);
 166+ }
 167+
 168+ function __get($var) {
 169+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 170+ return $this->_pData[$var];
 171+ }
 172+
 173+ function __construct($other=null) {
 174+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__PositionIterator') {
 175+ $this->_cPtr=$other;
 176+ return;
 177+ }
 178+ switch (func_num_args()) {
 179+ case 0: $this->_cPtr=new_PositionIterator(); break;
 180+ default: $this->_cPtr=new_PositionIterator($other);
 181+ }
 182+ }
 183+
 184+ function get_termpos() {
 185+ return PositionIterator_get_termpos($this->_cPtr);
 186+ }
 187+
 188+ function next() {
 189+ PositionIterator_next($this->_cPtr);
 190+ }
 191+
 192+ function equals($other) {
 193+ return PositionIterator_equals($this->_cPtr,$other);
 194+ }
 195+
 196+ function skip_to($pos) {
 197+ PositionIterator_skip_to($this->_cPtr,$pos);
 198+ }
 199+
 200+ function get_description() {
 201+ return PositionIterator_get_description($this->_cPtr);
 202+ }
 203+}
 204+
 205+class XapianPostingIterator {
 206+ public $_cPtr=null;
 207+ protected $_pData=array();
 208+
 209+ function __set($var,$value) {
 210+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 211+ $this->_pData[$var] = $value;
 212+ }
 213+
 214+ function __isset($var) {
 215+ if ($var === 'thisown') return true;
 216+ return array_key_exists($var, $this->_pData);
 217+ }
 218+
 219+ function __get($var) {
 220+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 221+ return $this->_pData[$var];
 222+ }
 223+
 224+ function __construct($other=null) {
 225+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__PostingIterator') {
 226+ $this->_cPtr=$other;
 227+ return;
 228+ }
 229+ switch (func_num_args()) {
 230+ case 0: $this->_cPtr=new_PostingIterator(); break;
 231+ default: $this->_cPtr=new_PostingIterator($other);
 232+ }
 233+ }
 234+
 235+ function skip_to($did) {
 236+ PostingIterator_skip_to($this->_cPtr,$did);
 237+ }
 238+
 239+ function get_doclength() {
 240+ return PostingIterator_get_doclength($this->_cPtr);
 241+ }
 242+
 243+ function get_wdf() {
 244+ return PostingIterator_get_wdf($this->_cPtr);
 245+ }
 246+
 247+ function positionlist_begin() {
 248+ $r=PostingIterator_positionlist_begin($this->_cPtr);
 249+ if (is_resource($r)) {
 250+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 251+ if (class_exists($c)) return new $c($r);
 252+ return new XapianPositionIterator($r);
 253+ }
 254+ return $r;
 255+ }
 256+
 257+ function positionlist_end() {
 258+ $r=PostingIterator_positionlist_end($this->_cPtr);
 259+ if (is_resource($r)) {
 260+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 261+ if (class_exists($c)) return new $c($r);
 262+ return new XapianPositionIterator($r);
 263+ }
 264+ return $r;
 265+ }
 266+
 267+ function get_description() {
 268+ return PostingIterator_get_description($this->_cPtr);
 269+ }
 270+
 271+ function get_docid() {
 272+ return PostingIterator_get_docid($this->_cPtr);
 273+ }
 274+
 275+ function next() {
 276+ PostingIterator_next($this->_cPtr);
 277+ }
 278+
 279+ function equals($other) {
 280+ return PostingIterator_equals($this->_cPtr,$other);
 281+ }
 282+}
 283+
 284+class XapianTermIterator {
 285+ public $_cPtr=null;
 286+ protected $_pData=array();
 287+
 288+ function __set($var,$value) {
 289+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 290+ $this->_pData[$var] = $value;
 291+ }
 292+
 293+ function __isset($var) {
 294+ if ($var === 'thisown') return true;
 295+ return array_key_exists($var, $this->_pData);
 296+ }
 297+
 298+ function __get($var) {
 299+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 300+ return $this->_pData[$var];
 301+ }
 302+
 303+ function __construct($other=null) {
 304+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__TermIterator') {
 305+ $this->_cPtr=$other;
 306+ return;
 307+ }
 308+ switch (func_num_args()) {
 309+ case 0: $this->_cPtr=new_TermIterator(); break;
 310+ default: $this->_cPtr=new_TermIterator($other);
 311+ }
 312+ }
 313+
 314+ function get_term() {
 315+ return TermIterator_get_term($this->_cPtr);
 316+ }
 317+
 318+ function next() {
 319+ TermIterator_next($this->_cPtr);
 320+ }
 321+
 322+ function equals($other) {
 323+ return TermIterator_equals($this->_cPtr,$other);
 324+ }
 325+
 326+ function skip_to($tname) {
 327+ return TermIterator_skip_to($this->_cPtr,$tname);
 328+ }
 329+
 330+ function get_wdf() {
 331+ return TermIterator_get_wdf($this->_cPtr);
 332+ }
 333+
 334+ function get_termfreq() {
 335+ return TermIterator_get_termfreq($this->_cPtr);
 336+ }
 337+
 338+ function positionlist_count() {
 339+ return TermIterator_positionlist_count($this->_cPtr);
 340+ }
 341+
 342+ function positionlist_begin() {
 343+ $r=TermIterator_positionlist_begin($this->_cPtr);
 344+ if (is_resource($r)) {
 345+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 346+ if (class_exists($c)) return new $c($r);
 347+ return new XapianPositionIterator($r);
 348+ }
 349+ return $r;
 350+ }
 351+
 352+ function positionlist_end() {
 353+ $r=TermIterator_positionlist_end($this->_cPtr);
 354+ if (is_resource($r)) {
 355+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 356+ if (class_exists($c)) return new $c($r);
 357+ return new XapianPositionIterator($r);
 358+ }
 359+ return $r;
 360+ }
 361+
 362+ function get_description() {
 363+ return TermIterator_get_description($this->_cPtr);
 364+ }
 365+}
 366+
 367+class XapianValueIterator {
 368+ public $_cPtr=null;
 369+ protected $_pData=array();
 370+
 371+ function __set($var,$value) {
 372+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 373+ $this->_pData[$var] = $value;
 374+ }
 375+
 376+ function __isset($var) {
 377+ if ($var === 'thisown') return true;
 378+ return array_key_exists($var, $this->_pData);
 379+ }
 380+
 381+ function __get($var) {
 382+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 383+ return $this->_pData[$var];
 384+ }
 385+
 386+ function __construct($other=null) {
 387+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__ValueIterator') {
 388+ $this->_cPtr=$other;
 389+ return;
 390+ }
 391+ switch (func_num_args()) {
 392+ case 0: $this->_cPtr=new_ValueIterator(); break;
 393+ default: $this->_cPtr=new_ValueIterator($other);
 394+ }
 395+ }
 396+
 397+ function get_value() {
 398+ return ValueIterator_get_value($this->_cPtr);
 399+ }
 400+
 401+ function next() {
 402+ ValueIterator_next($this->_cPtr);
 403+ }
 404+
 405+ function equals($other) {
 406+ return ValueIterator_equals($this->_cPtr,$other);
 407+ }
 408+
 409+ function get_docid() {
 410+ return ValueIterator_get_docid($this->_cPtr);
 411+ }
 412+
 413+ function get_valueno() {
 414+ return ValueIterator_get_valueno($this->_cPtr);
 415+ }
 416+
 417+ function skip_to($docid_or_slot) {
 418+ ValueIterator_skip_to($this->_cPtr,$docid_or_slot);
 419+ }
 420+
 421+ function check($docid) {
 422+ return ValueIterator_check($this->_cPtr,$docid);
 423+ }
 424+
 425+ function get_description() {
 426+ return ValueIterator_get_description($this->_cPtr);
 427+ }
 428+}
 429+
 430+class XapianDocument {
 431+ public $_cPtr=null;
 432+ protected $_pData=array();
 433+
 434+ function __set($var,$value) {
 435+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 436+ $this->_pData[$var] = $value;
 437+ }
 438+
 439+ function __isset($var) {
 440+ if ($var === 'thisown') return true;
 441+ return array_key_exists($var, $this->_pData);
 442+ }
 443+
 444+ function __get($var) {
 445+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 446+ return $this->_pData[$var];
 447+ }
 448+
 449+ function __construct($other=null) {
 450+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__Document') {
 451+ $this->_cPtr=$other;
 452+ return;
 453+ }
 454+ switch (func_num_args()) {
 455+ case 0: $this->_cPtr=new_Document(); break;
 456+ default: $this->_cPtr=new_Document($other);
 457+ }
 458+ }
 459+
 460+ function get_value($slot) {
 461+ return Document_get_value($this->_cPtr,$slot);
 462+ }
 463+
 464+ function add_value($slot,$value) {
 465+ return Document_add_value($this->_cPtr,$slot,$value);
 466+ }
 467+
 468+ function remove_value($slot) {
 469+ Document_remove_value($this->_cPtr,$slot);
 470+ }
 471+
 472+ function clear_values() {
 473+ Document_clear_values($this->_cPtr);
 474+ }
 475+
 476+ function get_data() {
 477+ return Document_get_data($this->_cPtr);
 478+ }
 479+
 480+ function set_data($data) {
 481+ return Document_set_data($this->_cPtr,$data);
 482+ }
 483+
 484+ function add_posting($tname,$tpos,$wdfinc=1) {
 485+ return Document_add_posting($this->_cPtr,$tname,$tpos,$wdfinc);
 486+ }
 487+
 488+ function add_term($tname,$wdfinc=1) {
 489+ return Document_add_term($this->_cPtr,$tname,$wdfinc);
 490+ }
 491+
 492+ function add_boolean_term($term) {
 493+ return Document_add_boolean_term($this->_cPtr,$term);
 494+ }
 495+
 496+ function remove_posting($tname,$tpos,$wdfdec=1) {
 497+ return Document_remove_posting($this->_cPtr,$tname,$tpos,$wdfdec);
 498+ }
 499+
 500+ function remove_term($tname) {
 501+ return Document_remove_term($this->_cPtr,$tname);
 502+ }
 503+
 504+ function clear_terms() {
 505+ Document_clear_terms($this->_cPtr);
 506+ }
 507+
 508+ function termlist_count() {
 509+ return Document_termlist_count($this->_cPtr);
 510+ }
 511+
 512+ function termlist_begin() {
 513+ $r=Document_termlist_begin($this->_cPtr);
 514+ if (is_resource($r)) {
 515+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 516+ if (class_exists($c)) return new $c($r);
 517+ return new XapianTermIterator($r);
 518+ }
 519+ return $r;
 520+ }
 521+
 522+ function termlist_end() {
 523+ $r=Document_termlist_end($this->_cPtr);
 524+ if (is_resource($r)) {
 525+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 526+ if (class_exists($c)) return new $c($r);
 527+ return new XapianTermIterator($r);
 528+ }
 529+ return $r;
 530+ }
 531+
 532+ function values_count() {
 533+ return Document_values_count($this->_cPtr);
 534+ }
 535+
 536+ function values_begin() {
 537+ $r=Document_values_begin($this->_cPtr);
 538+ if (is_resource($r)) {
 539+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 540+ if (class_exists($c)) return new $c($r);
 541+ return new XapianValueIterator($r);
 542+ }
 543+ return $r;
 544+ }
 545+
 546+ function values_end() {
 547+ $r=Document_values_end($this->_cPtr);
 548+ if (is_resource($r)) {
 549+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 550+ if (class_exists($c)) return new $c($r);
 551+ return new XapianValueIterator($r);
 552+ }
 553+ return $r;
 554+ }
 555+
 556+ function get_docid() {
 557+ return Document_get_docid($this->_cPtr);
 558+ }
 559+
 560+ function serialise() {
 561+ return Document_serialise($this->_cPtr);
 562+ }
 563+
 564+ static function unserialise($s) {
 565+ $r=Document_unserialise($s);
 566+ if (is_resource($r)) {
 567+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 568+ if (class_exists($c)) return new $c($r);
 569+ return new XapianDocument($r);
 570+ }
 571+ return $r;
 572+ }
 573+
 574+ function get_description() {
 575+ return Document_get_description($this->_cPtr);
 576+ }
 577+}
 578+
 579+abstract class XapianPostingSource {
 580+ public $_cPtr=null;
 581+ protected $_pData=array();
 582+
 583+ function __set($var,$value) {
 584+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 585+ $this->_pData[$var] = $value;
 586+ }
 587+
 588+ function __isset($var) {
 589+ if ($var === 'thisown') return true;
 590+ return array_key_exists($var, $this->_pData);
 591+ }
 592+
 593+ function __get($var) {
 594+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 595+ return $this->_pData[$var];
 596+ }
 597+
 598+ protected function __construct($res=null) {
 599+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__PostingSource') {
 600+ $this->_cPtr=$res;
 601+ return;
 602+ }
 603+ if (get_class($this) === 'XapianPostingSource') {
 604+ $_this = null;
 605+ } else {
 606+ $_this = $this;
 607+ }
 608+ $this->_cPtr=new_PostingSource($_this);
 609+ }
 610+
 611+ function get_termfreq_min() {
 612+ return PostingSource_get_termfreq_min($this->_cPtr);
 613+ }
 614+
 615+ function get_termfreq_est() {
 616+ return PostingSource_get_termfreq_est($this->_cPtr);
 617+ }
 618+
 619+ function get_termfreq_max() {
 620+ return PostingSource_get_termfreq_max($this->_cPtr);
 621+ }
 622+
 623+ function get_maxweight() {
 624+ return PostingSource_get_maxweight($this->_cPtr);
 625+ }
 626+
 627+ function get_weight() {
 628+ return PostingSource_get_weight($this->_cPtr);
 629+ }
 630+
 631+ function get_docid() {
 632+ return PostingSource_get_docid($this->_cPtr);
 633+ }
 634+
 635+ function next($min_wt) {
 636+ PostingSource_next($this->_cPtr,$min_wt);
 637+ }
 638+
 639+ function skip_to($did,$min_wt) {
 640+ PostingSource_skip_to($this->_cPtr,$did,$min_wt);
 641+ }
 642+
 643+ function check($did,$min_wt) {
 644+ return PostingSource_check($this->_cPtr,$did,$min_wt);
 645+ }
 646+
 647+ function at_end() {
 648+ return PostingSource_at_end($this->_cPtr);
 649+ }
 650+
 651+ function name() {
 652+ return PostingSource_name($this->_cPtr);
 653+ }
 654+
 655+ function init($db) {
 656+ PostingSource_init($this->_cPtr,$db);
 657+ }
 658+
 659+ function get_description() {
 660+ return PostingSource_get_description($this->_cPtr);
 661+ }
 662+}
 663+
 664+class XapianValuePostingSource extends XapianPostingSource {
 665+ public $_cPtr=null;
 666+
 667+ function __set($var,$value) {
 668+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 669+ XapianPostingSource::__set($var,$value);
 670+ }
 671+
 672+ function __isset($var) {
 673+ if ($var === 'thisown') return true;
 674+ return XapianPostingSource::__isset($var);
 675+ }
 676+
 677+ function __get($var) {
 678+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 679+ return XapianPostingSource::__get($var);
 680+ }
 681+
 682+ function __construct($slot_) {
 683+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__ValuePostingSource') {
 684+ $this->_cPtr=$slot_;
 685+ return;
 686+ }
 687+ $this->_cPtr=new_ValuePostingSource($slot_);
 688+ }
 689+
 690+ function get_termfreq_min() {
 691+ return ValuePostingSource_get_termfreq_min($this->_cPtr);
 692+ }
 693+
 694+ function get_termfreq_est() {
 695+ return ValuePostingSource_get_termfreq_est($this->_cPtr);
 696+ }
 697+
 698+ function get_termfreq_max() {
 699+ return ValuePostingSource_get_termfreq_max($this->_cPtr);
 700+ }
 701+
 702+ function next($min_wt) {
 703+ ValuePostingSource_next($this->_cPtr,$min_wt);
 704+ }
 705+
 706+ function skip_to($min_docid,$min_wt) {
 707+ ValuePostingSource_skip_to($this->_cPtr,$min_docid,$min_wt);
 708+ }
 709+
 710+ function check($min_docid,$min_wt) {
 711+ return ValuePostingSource_check($this->_cPtr,$min_docid,$min_wt);
 712+ }
 713+
 714+ function at_end() {
 715+ return ValuePostingSource_at_end($this->_cPtr);
 716+ }
 717+
 718+ function get_docid() {
 719+ return ValuePostingSource_get_docid($this->_cPtr);
 720+ }
 721+
 722+ function init($db_) {
 723+ ValuePostingSource_init($this->_cPtr,$db_);
 724+ }
 725+}
 726+
 727+class XapianValueWeightPostingSource extends XapianValuePostingSource {
 728+ public $_cPtr=null;
 729+
 730+ function __set($var,$value) {
 731+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 732+ XapianValuePostingSource::__set($var,$value);
 733+ }
 734+
 735+ function __isset($var) {
 736+ if ($var === 'thisown') return true;
 737+ return XapianValuePostingSource::__isset($var);
 738+ }
 739+
 740+ function __get($var) {
 741+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 742+ return XapianValuePostingSource::__get($var);
 743+ }
 744+
 745+ function __construct($slot_) {
 746+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__ValueWeightPostingSource') {
 747+ $this->_cPtr=$slot_;
 748+ return;
 749+ }
 750+ $this->_cPtr=new_ValueWeightPostingSource($slot_);
 751+ }
 752+
 753+ function get_weight() {
 754+ return ValueWeightPostingSource_get_weight($this->_cPtr);
 755+ }
 756+
 757+ function name() {
 758+ return ValueWeightPostingSource_name($this->_cPtr);
 759+ }
 760+
 761+ function init($db_) {
 762+ ValueWeightPostingSource_init($this->_cPtr,$db_);
 763+ }
 764+
 765+ function get_description() {
 766+ return ValueWeightPostingSource_get_description($this->_cPtr);
 767+ }
 768+}
 769+
 770+class XapianDecreasingValueWeightPostingSource extends XapianValueWeightPostingSource {
 771+ public $_cPtr=null;
 772+
 773+ function __set($var,$value) {
 774+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 775+ XapianValueWeightPostingSource::__set($var,$value);
 776+ }
 777+
 778+ function __isset($var) {
 779+ if ($var === 'thisown') return true;
 780+ return XapianValueWeightPostingSource::__isset($var);
 781+ }
 782+
 783+ function __get($var) {
 784+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 785+ return XapianValueWeightPostingSource::__get($var);
 786+ }
 787+
 788+ function __construct($slot_,$range_start_=0,$range_end_=0) {
 789+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__DecreasingValueWeightPostingSource') {
 790+ $this->_cPtr=$slot_;
 791+ return;
 792+ }
 793+ $this->_cPtr=new_DecreasingValueWeightPostingSource($slot_,$range_start_,$range_end_);
 794+ }
 795+
 796+ function get_weight() {
 797+ return DecreasingValueWeightPostingSource_get_weight($this->_cPtr);
 798+ }
 799+
 800+ function name() {
 801+ return DecreasingValueWeightPostingSource_name($this->_cPtr);
 802+ }
 803+
 804+ function init($db_) {
 805+ DecreasingValueWeightPostingSource_init($this->_cPtr,$db_);
 806+ }
 807+
 808+ function next($min_wt) {
 809+ DecreasingValueWeightPostingSource_next($this->_cPtr,$min_wt);
 810+ }
 811+
 812+ function skip_to($min_docid,$min_wt) {
 813+ DecreasingValueWeightPostingSource_skip_to($this->_cPtr,$min_docid,$min_wt);
 814+ }
 815+
 816+ function check($min_docid,$min_wt) {
 817+ return DecreasingValueWeightPostingSource_check($this->_cPtr,$min_docid,$min_wt);
 818+ }
 819+
 820+ function get_description() {
 821+ return DecreasingValueWeightPostingSource_get_description($this->_cPtr);
 822+ }
 823+}
 824+
 825+class XapianValueMapPostingSource extends XapianValuePostingSource {
 826+ public $_cPtr=null;
 827+
 828+ function __set($var,$value) {
 829+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 830+ XapianValuePostingSource::__set($var,$value);
 831+ }
 832+
 833+ function __isset($var) {
 834+ if ($var === 'thisown') return true;
 835+ return XapianValuePostingSource::__isset($var);
 836+ }
 837+
 838+ function __get($var) {
 839+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 840+ return XapianValuePostingSource::__get($var);
 841+ }
 842+
 843+ function __construct($slot_) {
 844+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__ValueMapPostingSource') {
 845+ $this->_cPtr=$slot_;
 846+ return;
 847+ }
 848+ $this->_cPtr=new_ValueMapPostingSource($slot_);
 849+ }
 850+
 851+ function add_mapping($key,$wt) {
 852+ return ValueMapPostingSource_add_mapping($this->_cPtr,$key,$wt);
 853+ }
 854+
 855+ function clear_mappings() {
 856+ ValueMapPostingSource_clear_mappings($this->_cPtr);
 857+ }
 858+
 859+ function set_default_weight($wt) {
 860+ ValueMapPostingSource_set_default_weight($this->_cPtr,$wt);
 861+ }
 862+
 863+ function get_weight() {
 864+ return ValueMapPostingSource_get_weight($this->_cPtr);
 865+ }
 866+
 867+ function name() {
 868+ return ValueMapPostingSource_name($this->_cPtr);
 869+ }
 870+
 871+ function init($db_) {
 872+ ValueMapPostingSource_init($this->_cPtr,$db_);
 873+ }
 874+
 875+ function get_description() {
 876+ return ValueMapPostingSource_get_description($this->_cPtr);
 877+ }
 878+}
 879+
 880+class XapianFixedWeightPostingSource extends XapianPostingSource {
 881+ public $_cPtr=null;
 882+
 883+ function __set($var,$value) {
 884+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 885+ XapianPostingSource::__set($var,$value);
 886+ }
 887+
 888+ function __isset($var) {
 889+ if ($var === 'thisown') return true;
 890+ return XapianPostingSource::__isset($var);
 891+ }
 892+
 893+ function __get($var) {
 894+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 895+ return XapianPostingSource::__get($var);
 896+ }
 897+
 898+ function __construct($wt) {
 899+ if (is_resource($wt) && get_resource_type($wt) === '_p_Xapian__FixedWeightPostingSource') {
 900+ $this->_cPtr=$wt;
 901+ return;
 902+ }
 903+ $this->_cPtr=new_FixedWeightPostingSource($wt);
 904+ }
 905+
 906+ function get_termfreq_min() {
 907+ return FixedWeightPostingSource_get_termfreq_min($this->_cPtr);
 908+ }
 909+
 910+ function get_termfreq_est() {
 911+ return FixedWeightPostingSource_get_termfreq_est($this->_cPtr);
 912+ }
 913+
 914+ function get_termfreq_max() {
 915+ return FixedWeightPostingSource_get_termfreq_max($this->_cPtr);
 916+ }
 917+
 918+ function get_weight() {
 919+ return FixedWeightPostingSource_get_weight($this->_cPtr);
 920+ }
 921+
 922+ function next($min_wt) {
 923+ FixedWeightPostingSource_next($this->_cPtr,$min_wt);
 924+ }
 925+
 926+ function skip_to($min_docid,$min_wt) {
 927+ FixedWeightPostingSource_skip_to($this->_cPtr,$min_docid,$min_wt);
 928+ }
 929+
 930+ function check($min_docid,$min_wt) {
 931+ return FixedWeightPostingSource_check($this->_cPtr,$min_docid,$min_wt);
 932+ }
 933+
 934+ function at_end() {
 935+ return FixedWeightPostingSource_at_end($this->_cPtr);
 936+ }
 937+
 938+ function get_docid() {
 939+ return FixedWeightPostingSource_get_docid($this->_cPtr);
 940+ }
 941+
 942+ function name() {
 943+ return FixedWeightPostingSource_name($this->_cPtr);
 944+ }
 945+
 946+ function init($db_) {
 947+ FixedWeightPostingSource_init($this->_cPtr,$db_);
 948+ }
 949+
 950+ function get_description() {
 951+ return FixedWeightPostingSource_get_description($this->_cPtr);
 952+ }
 953+}
 954+
 955+class XapianMSet {
 956+ public $_cPtr=null;
 957+ protected $_pData=array();
 958+
 959+ function __set($var,$value) {
 960+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 961+ $this->_pData[$var] = $value;
 962+ }
 963+
 964+ function __isset($var) {
 965+ if ($var === 'thisown') return true;
 966+ return array_key_exists($var, $this->_pData);
 967+ }
 968+
 969+ function __get($var) {
 970+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 971+ return $this->_pData[$var];
 972+ }
 973+
 974+ function __construct($other=null) {
 975+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__MSet') {
 976+ $this->_cPtr=$other;
 977+ return;
 978+ }
 979+ switch (func_num_args()) {
 980+ case 0: $this->_cPtr=new_MSet(); break;
 981+ default: $this->_cPtr=new_MSet($other);
 982+ }
 983+ }
 984+
 985+ function fetch($begin_or_item=null,$end=null) {
 986+ switch (func_num_args()) {
 987+ case 0: MSet_fetch($this->_cPtr); break;
 988+ case 1: MSet_fetch($this->_cPtr,$begin_or_item); break;
 989+ default: MSet_fetch($this->_cPtr,$begin_or_item,$end);
 990+ }
 991+ }
 992+
 993+ function convert_to_percent($wt_or_item) {
 994+ return MSet_convert_to_percent($this->_cPtr,$wt_or_item);
 995+ }
 996+
 997+ function get_termfreq($tname) {
 998+ return MSet_get_termfreq($this->_cPtr,$tname);
 999+ }
 1000+
 1001+ function get_termweight($tname) {
 1002+ return MSet_get_termweight($this->_cPtr,$tname);
 1003+ }
 1004+
 1005+ function get_firstitem() {
 1006+ return MSet_get_firstitem($this->_cPtr);
 1007+ }
 1008+
 1009+ function get_matches_lower_bound() {
 1010+ return MSet_get_matches_lower_bound($this->_cPtr);
 1011+ }
 1012+
 1013+ function get_matches_estimated() {
 1014+ return MSet_get_matches_estimated($this->_cPtr);
 1015+ }
 1016+
 1017+ function get_matches_upper_bound() {
 1018+ return MSet_get_matches_upper_bound($this->_cPtr);
 1019+ }
 1020+
 1021+ function get_uncollapsed_matches_lower_bound() {
 1022+ return MSet_get_uncollapsed_matches_lower_bound($this->_cPtr);
 1023+ }
 1024+
 1025+ function get_uncollapsed_matches_estimated() {
 1026+ return MSet_get_uncollapsed_matches_estimated($this->_cPtr);
 1027+ }
 1028+
 1029+ function get_uncollapsed_matches_upper_bound() {
 1030+ return MSet_get_uncollapsed_matches_upper_bound($this->_cPtr);
 1031+ }
 1032+
 1033+ function get_max_possible() {
 1034+ return MSet_get_max_possible($this->_cPtr);
 1035+ }
 1036+
 1037+ function get_max_attained() {
 1038+ return MSet_get_max_attained($this->_cPtr);
 1039+ }
 1040+
 1041+ function size() {
 1042+ return MSet_size($this->_cPtr);
 1043+ }
 1044+
 1045+ function is_empty() {
 1046+ return MSet_is_empty($this->_cPtr);
 1047+ }
 1048+
 1049+ function begin() {
 1050+ $r=MSet_begin($this->_cPtr);
 1051+ if (is_resource($r)) {
 1052+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1053+ if (class_exists($c)) return new $c($r);
 1054+ return new XapianMSetIterator($r);
 1055+ }
 1056+ return $r;
 1057+ }
 1058+
 1059+ function end() {
 1060+ $r=MSet_end($this->_cPtr);
 1061+ if (is_resource($r)) {
 1062+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1063+ if (class_exists($c)) return new $c($r);
 1064+ return new XapianMSetIterator($r);
 1065+ }
 1066+ return $r;
 1067+ }
 1068+
 1069+ function back() {
 1070+ $r=MSet_back($this->_cPtr);
 1071+ if (is_resource($r)) {
 1072+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1073+ if (class_exists($c)) return new $c($r);
 1074+ return new XapianMSetIterator($r);
 1075+ }
 1076+ return $r;
 1077+ }
 1078+
 1079+ function get_hit($i) {
 1080+ $r=MSet_get_hit($this->_cPtr,$i);
 1081+ if (is_resource($r)) {
 1082+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1083+ if (class_exists($c)) return new $c($r);
 1084+ return new XapianMSetIterator($r);
 1085+ }
 1086+ return $r;
 1087+ }
 1088+
 1089+ function get_document_percentage($i) {
 1090+ return MSet_get_document_percentage($this->_cPtr,$i);
 1091+ }
 1092+
 1093+ function get_document($i) {
 1094+ $r=MSet_get_document($this->_cPtr,$i);
 1095+ if (is_resource($r)) {
 1096+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1097+ if (class_exists($c)) return new $c($r);
 1098+ return new XapianDocument($r);
 1099+ }
 1100+ return $r;
 1101+ }
 1102+
 1103+ function get_docid($i) {
 1104+ return MSet_get_docid($this->_cPtr,$i);
 1105+ }
 1106+
 1107+ function get_description() {
 1108+ return MSet_get_description($this->_cPtr);
 1109+ }
 1110+}
 1111+
 1112+class XapianMSetIterator {
 1113+ public $_cPtr=null;
 1114+ protected $_pData=array();
 1115+
 1116+ function __set($var,$value) {
 1117+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1118+ $this->_pData[$var] = $value;
 1119+ }
 1120+
 1121+ function __isset($var) {
 1122+ if ($var === 'thisown') return true;
 1123+ return array_key_exists($var, $this->_pData);
 1124+ }
 1125+
 1126+ function __get($var) {
 1127+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1128+ return $this->_pData[$var];
 1129+ }
 1130+
 1131+ function __construct($other=null) {
 1132+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__MSetIterator') {
 1133+ $this->_cPtr=$other;
 1134+ return;
 1135+ }
 1136+ switch (func_num_args()) {
 1137+ case 0: $this->_cPtr=new_MSetIterator(); break;
 1138+ default: $this->_cPtr=new_MSetIterator($other);
 1139+ }
 1140+ }
 1141+
 1142+ function get_docid() {
 1143+ return MSetIterator_get_docid($this->_cPtr);
 1144+ }
 1145+
 1146+ function next() {
 1147+ MSetIterator_next($this->_cPtr);
 1148+ }
 1149+
 1150+ function prev() {
 1151+ MSetIterator_prev($this->_cPtr);
 1152+ }
 1153+
 1154+ function equals($other) {
 1155+ return MSetIterator_equals($this->_cPtr,$other);
 1156+ }
 1157+
 1158+ function get_document() {
 1159+ $r=MSetIterator_get_document($this->_cPtr);
 1160+ if (is_resource($r)) {
 1161+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1162+ if (class_exists($c)) return new $c($r);
 1163+ return new XapianDocument($r);
 1164+ }
 1165+ return $r;
 1166+ }
 1167+
 1168+ function get_rank() {
 1169+ return MSetIterator_get_rank($this->_cPtr);
 1170+ }
 1171+
 1172+ function get_weight() {
 1173+ return MSetIterator_get_weight($this->_cPtr);
 1174+ }
 1175+
 1176+ function get_collapse_key() {
 1177+ return MSetIterator_get_collapse_key($this->_cPtr);
 1178+ }
 1179+
 1180+ function get_collapse_count() {
 1181+ return MSetIterator_get_collapse_count($this->_cPtr);
 1182+ }
 1183+
 1184+ function get_percent() {
 1185+ return MSetIterator_get_percent($this->_cPtr);
 1186+ }
 1187+
 1188+ function get_description() {
 1189+ return MSetIterator_get_description($this->_cPtr);
 1190+ }
 1191+}
 1192+
 1193+class XapianESet {
 1194+ public $_cPtr=null;
 1195+ protected $_pData=array();
 1196+
 1197+ function __set($var,$value) {
 1198+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1199+ $this->_pData[$var] = $value;
 1200+ }
 1201+
 1202+ function __isset($var) {
 1203+ if ($var === 'thisown') return true;
 1204+ return array_key_exists($var, $this->_pData);
 1205+ }
 1206+
 1207+ function __get($var) {
 1208+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1209+ return $this->_pData[$var];
 1210+ }
 1211+
 1212+ function __construct($other=null) {
 1213+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__ESet') {
 1214+ $this->_cPtr=$other;
 1215+ return;
 1216+ }
 1217+ switch (func_num_args()) {
 1218+ case 0: $this->_cPtr=new_ESet(); break;
 1219+ default: $this->_cPtr=new_ESet($other);
 1220+ }
 1221+ }
 1222+
 1223+ function get_ebound() {
 1224+ return ESet_get_ebound($this->_cPtr);
 1225+ }
 1226+
 1227+ function size() {
 1228+ return ESet_size($this->_cPtr);
 1229+ }
 1230+
 1231+ function is_empty() {
 1232+ return ESet_is_empty($this->_cPtr);
 1233+ }
 1234+
 1235+ function begin() {
 1236+ $r=ESet_begin($this->_cPtr);
 1237+ if (is_resource($r)) {
 1238+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1239+ if (class_exists($c)) return new $c($r);
 1240+ return new XapianESetIterator($r);
 1241+ }
 1242+ return $r;
 1243+ }
 1244+
 1245+ function end() {
 1246+ $r=ESet_end($this->_cPtr);
 1247+ if (is_resource($r)) {
 1248+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1249+ if (class_exists($c)) return new $c($r);
 1250+ return new XapianESetIterator($r);
 1251+ }
 1252+ return $r;
 1253+ }
 1254+
 1255+ function back() {
 1256+ $r=ESet_back($this->_cPtr);
 1257+ if (is_resource($r)) {
 1258+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1259+ if (class_exists($c)) return new $c($r);
 1260+ return new XapianESetIterator($r);
 1261+ }
 1262+ return $r;
 1263+ }
 1264+
 1265+ function get_description() {
 1266+ return ESet_get_description($this->_cPtr);
 1267+ }
 1268+}
 1269+
 1270+class XapianESetIterator {
 1271+ public $_cPtr=null;
 1272+ protected $_pData=array();
 1273+
 1274+ function __set($var,$value) {
 1275+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1276+ $this->_pData[$var] = $value;
 1277+ }
 1278+
 1279+ function __isset($var) {
 1280+ if ($var === 'thisown') return true;
 1281+ return array_key_exists($var, $this->_pData);
 1282+ }
 1283+
 1284+ function __get($var) {
 1285+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1286+ return $this->_pData[$var];
 1287+ }
 1288+
 1289+ function __construct($other=null) {
 1290+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__ESetIterator') {
 1291+ $this->_cPtr=$other;
 1292+ return;
 1293+ }
 1294+ switch (func_num_args()) {
 1295+ case 0: $this->_cPtr=new_ESetIterator(); break;
 1296+ default: $this->_cPtr=new_ESetIterator($other);
 1297+ }
 1298+ }
 1299+
 1300+ function get_term() {
 1301+ return ESetIterator_get_term($this->_cPtr);
 1302+ }
 1303+
 1304+ function next() {
 1305+ ESetIterator_next($this->_cPtr);
 1306+ }
 1307+
 1308+ function prev() {
 1309+ ESetIterator_prev($this->_cPtr);
 1310+ }
 1311+
 1312+ function equals($other) {
 1313+ return ESetIterator_equals($this->_cPtr,$other);
 1314+ }
 1315+
 1316+ function get_weight() {
 1317+ return ESetIterator_get_weight($this->_cPtr);
 1318+ }
 1319+
 1320+ function get_description() {
 1321+ return ESetIterator_get_description($this->_cPtr);
 1322+ }
 1323+}
 1324+
 1325+class XapianRSet {
 1326+ public $_cPtr=null;
 1327+ protected $_pData=array();
 1328+
 1329+ function __set($var,$value) {
 1330+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1331+ $this->_pData[$var] = $value;
 1332+ }
 1333+
 1334+ function __isset($var) {
 1335+ if ($var === 'thisown') return true;
 1336+ return array_key_exists($var, $this->_pData);
 1337+ }
 1338+
 1339+ function __get($var) {
 1340+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1341+ return $this->_pData[$var];
 1342+ }
 1343+
 1344+ function __construct($other=null) {
 1345+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__RSet') {
 1346+ $this->_cPtr=$other;
 1347+ return;
 1348+ }
 1349+ switch (func_num_args()) {
 1350+ case 0: $this->_cPtr=new_RSet(); break;
 1351+ default: $this->_cPtr=new_RSet($other);
 1352+ }
 1353+ }
 1354+
 1355+ function size() {
 1356+ return RSet_size($this->_cPtr);
 1357+ }
 1358+
 1359+ function is_empty() {
 1360+ return RSet_is_empty($this->_cPtr);
 1361+ }
 1362+
 1363+ function add_document($did_or_i) {
 1364+ RSet_add_document($this->_cPtr,$did_or_i);
 1365+ }
 1366+
 1367+ function remove_document($did_or_i) {
 1368+ RSet_remove_document($this->_cPtr,$did_or_i);
 1369+ }
 1370+
 1371+ function contains($did_or_i) {
 1372+ return RSet_contains($this->_cPtr,$did_or_i);
 1373+ }
 1374+
 1375+ function get_description() {
 1376+ return RSet_get_description($this->_cPtr);
 1377+ }
 1378+}
 1379+
 1380+abstract class XapianMatchDecider {
 1381+ public $_cPtr=null;
 1382+ protected $_pData=array();
 1383+
 1384+ function __set($var,$value) {
 1385+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1386+ $this->_pData[$var] = $value;
 1387+ }
 1388+
 1389+ function __isset($var) {
 1390+ if ($var === 'thisown') return true;
 1391+ return array_key_exists($var, $this->_pData);
 1392+ }
 1393+
 1394+ function __get($var) {
 1395+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1396+ return $this->_pData[$var];
 1397+ }
 1398+
 1399+ function apply($doc) {
 1400+ return MatchDecider_apply($this->_cPtr,$doc);
 1401+ }
 1402+
 1403+ function __construct($res=null) {
 1404+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__MatchDecider') {
 1405+ $this->_cPtr=$res;
 1406+ return;
 1407+ }
 1408+ if (get_class($this) === 'XapianMatchDecider') {
 1409+ $_this = null;
 1410+ } else {
 1411+ $_this = $this;
 1412+ }
 1413+ $this->_cPtr=new_MatchDecider($_this);
 1414+ }
 1415+}
 1416+
 1417+abstract class XapianExpandDecider {
 1418+ public $_cPtr=null;
 1419+ protected $_pData=array();
 1420+
 1421+ function __set($var,$value) {
 1422+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1423+ $this->_pData[$var] = $value;
 1424+ }
 1425+
 1426+ function __isset($var) {
 1427+ if ($var === 'thisown') return true;
 1428+ return array_key_exists($var, $this->_pData);
 1429+ }
 1430+
 1431+ function __get($var) {
 1432+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1433+ return $this->_pData[$var];
 1434+ }
 1435+
 1436+ function apply($term) {
 1437+ return ExpandDecider_apply($this->_cPtr,$term);
 1438+ }
 1439+
 1440+ function __construct($res=null) {
 1441+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__ExpandDecider') {
 1442+ $this->_cPtr=$res;
 1443+ return;
 1444+ }
 1445+ if (get_class($this) === 'XapianExpandDecider') {
 1446+ $_this = null;
 1447+ } else {
 1448+ $_this = $this;
 1449+ }
 1450+ $this->_cPtr=new_ExpandDecider($_this);
 1451+ }
 1452+}
 1453+
 1454+class XapianEnquire {
 1455+ public $_cPtr=null;
 1456+ protected $_pData=array();
 1457+
 1458+ function __set($var,$value) {
 1459+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1460+ $this->_pData[$var] = $value;
 1461+ }
 1462+
 1463+ function __isset($var) {
 1464+ if ($var === 'thisown') return true;
 1465+ return array_key_exists($var, $this->_pData);
 1466+ }
 1467+
 1468+ function __get($var) {
 1469+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1470+ return $this->_pData[$var];
 1471+ }
 1472+
 1473+ function __construct($databases) {
 1474+ if (is_resource($databases) && get_resource_type($databases) === '_p_Xapian__Enquire') {
 1475+ $this->_cPtr=$databases;
 1476+ return;
 1477+ }
 1478+ $this->_cPtr=new_Enquire($databases);
 1479+ }
 1480+
 1481+ function set_query($query,$qlen=0) {
 1482+ Enquire_set_query($this->_cPtr,$query,$qlen);
 1483+ }
 1484+
 1485+ function get_query() {
 1486+ $r=Enquire_get_query($this->_cPtr);
 1487+ if (is_resource($r)) {
 1488+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1489+ if (class_exists($c)) return new $c($r);
 1490+ return new XapianQuery($r);
 1491+ }
 1492+ return $r;
 1493+ }
 1494+
 1495+ function add_matchspy($spy) {
 1496+ Enquire_add_matchspy($this->_cPtr,$spy);
 1497+ }
 1498+
 1499+ function clear_matchspies() {
 1500+ Enquire_clear_matchspies($this->_cPtr);
 1501+ }
 1502+
 1503+ function set_weighting_scheme($weight) {
 1504+ Enquire_set_weighting_scheme($this->_cPtr,$weight);
 1505+ }
 1506+
 1507+ function set_collapse_key($collapse_key,$collapse_max=1) {
 1508+ Enquire_set_collapse_key($this->_cPtr,$collapse_key,$collapse_max);
 1509+ }
 1510+
 1511+ const ASCENDING = 1;
 1512+
 1513+ const DESCENDING = 0;
 1514+
 1515+ const DONT_CARE = 2;
 1516+
 1517+ function set_docid_order($order) {
 1518+ Enquire_set_docid_order($this->_cPtr,$order);
 1519+ }
 1520+
 1521+ function set_cutoff($percent_cutoff,$weight_cutoff=0.0) {
 1522+ Enquire_set_cutoff($this->_cPtr,$percent_cutoff,$weight_cutoff);
 1523+ }
 1524+
 1525+ function set_sort_by_relevance() {
 1526+ Enquire_set_sort_by_relevance($this->_cPtr);
 1527+ }
 1528+
 1529+ function set_sort_by_value($sort_key,$reverse=null) {
 1530+ switch (func_num_args()) {
 1531+ case 1: Enquire_set_sort_by_value($this->_cPtr,$sort_key); break;
 1532+ default: Enquire_set_sort_by_value($this->_cPtr,$sort_key,$reverse);
 1533+ }
 1534+ }
 1535+
 1536+ function set_sort_by_value_then_relevance($sort_key,$reverse=null) {
 1537+ switch (func_num_args()) {
 1538+ case 1: Enquire_set_sort_by_value_then_relevance($this->_cPtr,$sort_key); break;
 1539+ default: Enquire_set_sort_by_value_then_relevance($this->_cPtr,$sort_key,$reverse);
 1540+ }
 1541+ }
 1542+
 1543+ function set_sort_by_relevance_then_value($sort_key,$reverse=null) {
 1544+ switch (func_num_args()) {
 1545+ case 1: Enquire_set_sort_by_relevance_then_value($this->_cPtr,$sort_key); break;
 1546+ default: Enquire_set_sort_by_relevance_then_value($this->_cPtr,$sort_key,$reverse);
 1547+ }
 1548+ }
 1549+
 1550+ function set_sort_by_key($sorter,$reverse=null) {
 1551+ switch (func_num_args()) {
 1552+ case 1: Enquire_set_sort_by_key($this->_cPtr,$sorter); break;
 1553+ default: Enquire_set_sort_by_key($this->_cPtr,$sorter,$reverse);
 1554+ }
 1555+ }
 1556+
 1557+ function set_sort_by_key_then_relevance($sorter,$reverse=null) {
 1558+ switch (func_num_args()) {
 1559+ case 1: Enquire_set_sort_by_key_then_relevance($this->_cPtr,$sorter); break;
 1560+ default: Enquire_set_sort_by_key_then_relevance($this->_cPtr,$sorter,$reverse);
 1561+ }
 1562+ }
 1563+
 1564+ function set_sort_by_relevance_then_key($sorter,$reverse=null) {
 1565+ switch (func_num_args()) {
 1566+ case 1: Enquire_set_sort_by_relevance_then_key($this->_cPtr,$sorter); break;
 1567+ default: Enquire_set_sort_by_relevance_then_key($this->_cPtr,$sorter,$reverse);
 1568+ }
 1569+ }
 1570+
 1571+ const INCLUDE_QUERY_TERMS = Enquire_INCLUDE_QUERY_TERMS;
 1572+
 1573+ const USE_EXACT_TERMFREQ = Enquire_USE_EXACT_TERMFREQ;
 1574+
 1575+ function get_mset($first,$maxitems,$checkatleast_or_omrset=null,$omrset_or_mdecider=null,$mdecider=null,$matchspy=null) {
 1576+ switch (func_num_args()) {
 1577+ case 2: $r=Enquire_get_mset($this->_cPtr,$first,$maxitems); break;
 1578+ case 3: $r=Enquire_get_mset($this->_cPtr,$first,$maxitems,$checkatleast_or_omrset); break;
 1579+ case 4: $r=Enquire_get_mset($this->_cPtr,$first,$maxitems,$checkatleast_or_omrset,$omrset_or_mdecider); break;
 1580+ case 5: $r=Enquire_get_mset($this->_cPtr,$first,$maxitems,$checkatleast_or_omrset,$omrset_or_mdecider,$mdecider); break;
 1581+ default: $r=Enquire_get_mset($this->_cPtr,$first,$maxitems,$checkatleast_or_omrset,$omrset_or_mdecider,$mdecider,$matchspy);
 1582+ }
 1583+ if (is_resource($r)) {
 1584+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1585+ if (class_exists($c)) return new $c($r);
 1586+ return new XapianMSet($r);
 1587+ }
 1588+ return $r;
 1589+ }
 1590+
 1591+ function get_eset($maxitems,$omrset,$flags_or_edecider=null,$k=null,$edecider=null,$min_wt=null) {
 1592+ switch (func_num_args()) {
 1593+ case 2: $r=Enquire_get_eset($this->_cPtr,$maxitems,$omrset); break;
 1594+ case 3: $r=Enquire_get_eset($this->_cPtr,$maxitems,$omrset,$flags_or_edecider); break;
 1595+ case 4: $r=Enquire_get_eset($this->_cPtr,$maxitems,$omrset,$flags_or_edecider,$k); break;
 1596+ case 5: $r=Enquire_get_eset($this->_cPtr,$maxitems,$omrset,$flags_or_edecider,$k,$edecider); break;
 1597+ default: $r=Enquire_get_eset($this->_cPtr,$maxitems,$omrset,$flags_or_edecider,$k,$edecider,$min_wt);
 1598+ }
 1599+ if (is_resource($r)) {
 1600+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1601+ if (class_exists($c)) return new $c($r);
 1602+ return new XapianESet($r);
 1603+ }
 1604+ return $r;
 1605+ }
 1606+
 1607+ function get_matching_terms_begin($did_or_i) {
 1608+ $r=Enquire_get_matching_terms_begin($this->_cPtr,$did_or_i);
 1609+ if (is_resource($r)) {
 1610+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1611+ if (class_exists($c)) return new $c($r);
 1612+ return new XapianTermIterator($r);
 1613+ }
 1614+ return $r;
 1615+ }
 1616+
 1617+ function get_matching_terms_end($did_or_i) {
 1618+ $r=Enquire_get_matching_terms_end($this->_cPtr,$did_or_i);
 1619+ if (is_resource($r)) {
 1620+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1621+ if (class_exists($c)) return new $c($r);
 1622+ return new XapianTermIterator($r);
 1623+ }
 1624+ return $r;
 1625+ }
 1626+
 1627+ function get_matching_terms($hit) {
 1628+ return Enquire_get_matching_terms($this->_cPtr,$hit);
 1629+ }
 1630+
 1631+ function get_description() {
 1632+ return Enquire_get_description($this->_cPtr);
 1633+ }
 1634+}
 1635+
 1636+class XapianRegistry {
 1637+ public $_cPtr=null;
 1638+ protected $_pData=array();
 1639+
 1640+ function __set($var,$value) {
 1641+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1642+ $this->_pData[$var] = $value;
 1643+ }
 1644+
 1645+ function __isset($var) {
 1646+ if ($var === 'thisown') return true;
 1647+ return array_key_exists($var, $this->_pData);
 1648+ }
 1649+
 1650+ function __get($var) {
 1651+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1652+ return $this->_pData[$var];
 1653+ }
 1654+
 1655+ function __construct($other=null) {
 1656+ if (is_resource($other) && get_resource_type($other) === '_p_Xapian__Registry') {
 1657+ $this->_cPtr=$other;
 1658+ return;
 1659+ }
 1660+ switch (func_num_args()) {
 1661+ case 0: $this->_cPtr=new_Registry(); break;
 1662+ default: $this->_cPtr=new_Registry($other);
 1663+ }
 1664+ }
 1665+
 1666+ function register_weighting_scheme($wt) {
 1667+ Registry_register_weighting_scheme($this->_cPtr,$wt);
 1668+ }
 1669+
 1670+ function get_weighting_scheme($name) {
 1671+ $r=Registry_get_weighting_scheme($this->_cPtr,$name);
 1672+ $this->_cPtr = $r;
 1673+ return $this;
 1674+ }
 1675+
 1676+ function register_posting_source($source) {
 1677+ Registry_register_posting_source($this->_cPtr,$source);
 1678+ }
 1679+
 1680+ function get_posting_source($name) {
 1681+ $r=Registry_get_posting_source($this->_cPtr,$name);
 1682+ $this->_cPtr = $r;
 1683+ return $this;
 1684+ }
 1685+
 1686+ function register_match_spy($spy) {
 1687+ Registry_register_match_spy($this->_cPtr,$spy);
 1688+ }
 1689+
 1690+ function get_match_spy($name) {
 1691+ $r=Registry_get_match_spy($this->_cPtr,$name);
 1692+ $this->_cPtr = $r;
 1693+ return $this;
 1694+ }
 1695+}
 1696+
 1697+abstract class XapianWeight {
 1698+ public $_cPtr=null;
 1699+ protected $_pData=array();
 1700+
 1701+ function __set($var,$value) {
 1702+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1703+ $this->_pData[$var] = $value;
 1704+ }
 1705+
 1706+ function __isset($var) {
 1707+ if ($var === 'thisown') return true;
 1708+ return array_key_exists($var, $this->_pData);
 1709+ }
 1710+
 1711+ function __get($var) {
 1712+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1713+ return $this->_pData[$var];
 1714+ }
 1715+ function __construct($h) {
 1716+ $this->_cPtr=$h;
 1717+ }
 1718+
 1719+ function name() {
 1720+ return Weight_name($this->_cPtr);
 1721+ }
 1722+
 1723+ function get_sumpart($wdf,$doclen) {
 1724+ return Weight_get_sumpart($this->_cPtr,$wdf,$doclen);
 1725+ }
 1726+
 1727+ function get_maxpart() {
 1728+ return Weight_get_maxpart($this->_cPtr);
 1729+ }
 1730+
 1731+ function get_sumextra($doclen) {
 1732+ return Weight_get_sumextra($this->_cPtr,$doclen);
 1733+ }
 1734+
 1735+ function get_maxextra() {
 1736+ return Weight_get_maxextra($this->_cPtr);
 1737+ }
 1738+
 1739+ function get_sumpart_needs_doclength_() {
 1740+ return Weight_get_sumpart_needs_doclength_($this->_cPtr);
 1741+ }
 1742+
 1743+ function get_sumpart_needs_wdf_() {
 1744+ return Weight_get_sumpart_needs_wdf_($this->_cPtr);
 1745+ }
 1746+}
 1747+
 1748+class XapianBoolWeight extends XapianWeight {
 1749+ public $_cPtr=null;
 1750+
 1751+ function __set($var,$value) {
 1752+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1753+ XapianWeight::__set($var,$value);
 1754+ }
 1755+
 1756+ function __isset($var) {
 1757+ if ($var === 'thisown') return true;
 1758+ return XapianWeight::__isset($var);
 1759+ }
 1760+
 1761+ function __get($var) {
 1762+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1763+ return XapianWeight::__get($var);
 1764+ }
 1765+
 1766+ function __construct($res=null) {
 1767+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__BoolWeight') {
 1768+ $this->_cPtr=$res;
 1769+ return;
 1770+ }
 1771+ $this->_cPtr=new_BoolWeight();
 1772+ }
 1773+
 1774+ function name() {
 1775+ return BoolWeight_name($this->_cPtr);
 1776+ }
 1777+
 1778+ function serialise() {
 1779+ return BoolWeight_serialise($this->_cPtr);
 1780+ }
 1781+
 1782+ function unserialise($s) {
 1783+ $r=BoolWeight_unserialise($this->_cPtr,$s);
 1784+ if (is_resource($r)) {
 1785+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1786+ if (class_exists($c)) return new $c($r);
 1787+ return new XapianBoolWeight($r);
 1788+ }
 1789+ return $r;
 1790+ }
 1791+
 1792+ function get_sumpart($wdf,$doclen) {
 1793+ return BoolWeight_get_sumpart($this->_cPtr,$wdf,$doclen);
 1794+ }
 1795+
 1796+ function get_maxpart() {
 1797+ return BoolWeight_get_maxpart($this->_cPtr);
 1798+ }
 1799+
 1800+ function get_sumextra($doclen) {
 1801+ return BoolWeight_get_sumextra($this->_cPtr,$doclen);
 1802+ }
 1803+
 1804+ function get_maxextra() {
 1805+ return BoolWeight_get_maxextra($this->_cPtr);
 1806+ }
 1807+}
 1808+
 1809+class XapianBM25Weight extends XapianWeight {
 1810+ public $_cPtr=null;
 1811+
 1812+ function __set($var,$value) {
 1813+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1814+ XapianWeight::__set($var,$value);
 1815+ }
 1816+
 1817+ function __isset($var) {
 1818+ if ($var === 'thisown') return true;
 1819+ return XapianWeight::__isset($var);
 1820+ }
 1821+
 1822+ function __get($var) {
 1823+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1824+ return XapianWeight::__get($var);
 1825+ }
 1826+
 1827+ function __construct($k1=null,$k2=null,$k3=null,$b=null,$min_normlen=null) {
 1828+ if (is_resource($k1) && get_resource_type($k1) === '_p_Xapian__BM25Weight') {
 1829+ $this->_cPtr=$k1;
 1830+ return;
 1831+ }
 1832+ switch (func_num_args()) {
 1833+ case 0: $this->_cPtr=new_BM25Weight(); break;
 1834+ case 1: $this->_cPtr=new_BM25Weight($k1); break;
 1835+ case 2: $this->_cPtr=new_BM25Weight($k1,$k2); break;
 1836+ case 3: $this->_cPtr=new_BM25Weight($k1,$k2,$k3); break;
 1837+ case 4: $this->_cPtr=new_BM25Weight($k1,$k2,$k3,$b); break;
 1838+ default: $this->_cPtr=new_BM25Weight($k1,$k2,$k3,$b,$min_normlen);
 1839+ }
 1840+ }
 1841+
 1842+ function name() {
 1843+ return BM25Weight_name($this->_cPtr);
 1844+ }
 1845+
 1846+ function get_sumpart($wdf,$doclen) {
 1847+ return BM25Weight_get_sumpart($this->_cPtr,$wdf,$doclen);
 1848+ }
 1849+
 1850+ function get_maxpart() {
 1851+ return BM25Weight_get_maxpart($this->_cPtr);
 1852+ }
 1853+
 1854+ function get_sumextra($doclen) {
 1855+ return BM25Weight_get_sumextra($this->_cPtr,$doclen);
 1856+ }
 1857+
 1858+ function get_maxextra() {
 1859+ return BM25Weight_get_maxextra($this->_cPtr);
 1860+ }
 1861+}
 1862+
 1863+class XapianTradWeight extends XapianWeight {
 1864+ public $_cPtr=null;
 1865+
 1866+ function __set($var,$value) {
 1867+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1868+ XapianWeight::__set($var,$value);
 1869+ }
 1870+
 1871+ function __isset($var) {
 1872+ if ($var === 'thisown') return true;
 1873+ return XapianWeight::__isset($var);
 1874+ }
 1875+
 1876+ function __get($var) {
 1877+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1878+ return XapianWeight::__get($var);
 1879+ }
 1880+
 1881+ function __construct($k=1.0) {
 1882+ if (is_resource($k) && get_resource_type($k) === '_p_Xapian__TradWeight') {
 1883+ $this->_cPtr=$k;
 1884+ return;
 1885+ }
 1886+ $this->_cPtr=new_TradWeight($k);
 1887+ }
 1888+
 1889+ function name() {
 1890+ return TradWeight_name($this->_cPtr);
 1891+ }
 1892+
 1893+ function get_sumpart($wdf,$doclen) {
 1894+ return TradWeight_get_sumpart($this->_cPtr,$wdf,$doclen);
 1895+ }
 1896+
 1897+ function get_maxpart() {
 1898+ return TradWeight_get_maxpart($this->_cPtr);
 1899+ }
 1900+
 1901+ function get_sumextra($doclen) {
 1902+ return TradWeight_get_sumextra($this->_cPtr,$doclen);
 1903+ }
 1904+
 1905+ function get_maxextra() {
 1906+ return TradWeight_get_maxextra($this->_cPtr);
 1907+ }
 1908+}
 1909+
 1910+abstract class XapianMatchSpy {
 1911+ public $_cPtr=null;
 1912+ protected $_pData=array();
 1913+
 1914+ function __set($var,$value) {
 1915+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1916+ $this->_pData[$var] = $value;
 1917+ }
 1918+
 1919+ function __isset($var) {
 1920+ if ($var === 'thisown') return true;
 1921+ return array_key_exists($var, $this->_pData);
 1922+ }
 1923+
 1924+ function __get($var) {
 1925+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1926+ return $this->_pData[$var];
 1927+ }
 1928+
 1929+ protected function __construct($res=null) {
 1930+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__MatchSpy') {
 1931+ $this->_cPtr=$res;
 1932+ return;
 1933+ }
 1934+ if (get_class($this) === 'XapianMatchSpy') {
 1935+ $_this = null;
 1936+ } else {
 1937+ $_this = $this;
 1938+ }
 1939+ $this->_cPtr=new_MatchSpy($_this);
 1940+ }
 1941+
 1942+ function apply($doc,$wt) {
 1943+ MatchSpy_apply($this->_cPtr,$doc,$wt);
 1944+ }
 1945+
 1946+ function name() {
 1947+ return MatchSpy_name($this->_cPtr);
 1948+ }
 1949+
 1950+ function merge_results($s) {
 1951+ return MatchSpy_merge_results($this->_cPtr,$s);
 1952+ }
 1953+
 1954+ function get_description() {
 1955+ return MatchSpy_get_description($this->_cPtr);
 1956+ }
 1957+}
 1958+
 1959+class XapianValueCountMatchSpy extends XapianMatchSpy {
 1960+ public $_cPtr=null;
 1961+
 1962+ function __set($var,$value) {
 1963+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 1964+ XapianMatchSpy::__set($var,$value);
 1965+ }
 1966+
 1967+ function __isset($var) {
 1968+ if ($var === 'thisown') return true;
 1969+ return XapianMatchSpy::__isset($var);
 1970+ }
 1971+
 1972+ function __get($var) {
 1973+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 1974+ return XapianMatchSpy::__get($var);
 1975+ }
 1976+
 1977+ function __construct($slot_=null) {
 1978+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__ValueCountMatchSpy') {
 1979+ $this->_cPtr=$slot_;
 1980+ return;
 1981+ }
 1982+ switch (func_num_args()) {
 1983+ case 0: $this->_cPtr=new_ValueCountMatchSpy(); break;
 1984+ default: $this->_cPtr=new_ValueCountMatchSpy($slot_);
 1985+ }
 1986+ }
 1987+
 1988+ function get_total() {
 1989+ return ValueCountMatchSpy_get_total($this->_cPtr);
 1990+ }
 1991+
 1992+ function values_begin() {
 1993+ $r=ValueCountMatchSpy_values_begin($this->_cPtr);
 1994+ if (is_resource($r)) {
 1995+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 1996+ if (class_exists($c)) return new $c($r);
 1997+ return new XapianTermIterator($r);
 1998+ }
 1999+ return $r;
 2000+ }
 2001+
 2002+ function values_end() {
 2003+ $r=ValueCountMatchSpy_values_end($this->_cPtr);
 2004+ if (is_resource($r)) {
 2005+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2006+ if (class_exists($c)) return new $c($r);
 2007+ return new XapianTermIterator($r);
 2008+ }
 2009+ return $r;
 2010+ }
 2011+
 2012+ function top_values_begin($maxvalues) {
 2013+ $r=ValueCountMatchSpy_top_values_begin($this->_cPtr,$maxvalues);
 2014+ if (is_resource($r)) {
 2015+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2016+ if (class_exists($c)) return new $c($r);
 2017+ return new XapianTermIterator($r);
 2018+ }
 2019+ return $r;
 2020+ }
 2021+
 2022+ function top_values_end($arg1) {
 2023+ $r=ValueCountMatchSpy_top_values_end($this->_cPtr,$arg1);
 2024+ if (is_resource($r)) {
 2025+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2026+ if (class_exists($c)) return new $c($r);
 2027+ return new XapianTermIterator($r);
 2028+ }
 2029+ return $r;
 2030+ }
 2031+
 2032+ function apply($doc,$wt) {
 2033+ ValueCountMatchSpy_apply($this->_cPtr,$doc,$wt);
 2034+ }
 2035+
 2036+ function name() {
 2037+ return ValueCountMatchSpy_name($this->_cPtr);
 2038+ }
 2039+
 2040+ function merge_results($s) {
 2041+ return ValueCountMatchSpy_merge_results($this->_cPtr,$s);
 2042+ }
 2043+
 2044+ function get_description() {
 2045+ return ValueCountMatchSpy_get_description($this->_cPtr);
 2046+ }
 2047+}
 2048+
 2049+class XapianDatabase {
 2050+ public $_cPtr=null;
 2051+ protected $_pData=array();
 2052+
 2053+ function __set($var,$value) {
 2054+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2055+ $this->_pData[$var] = $value;
 2056+ }
 2057+
 2058+ function __isset($var) {
 2059+ if ($var === 'thisown') return true;
 2060+ return array_key_exists($var, $this->_pData);
 2061+ }
 2062+
 2063+ function __get($var) {
 2064+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2065+ return $this->_pData[$var];
 2066+ }
 2067+
 2068+ function add_database($database) {
 2069+ Database_add_database($this->_cPtr,$database);
 2070+ }
 2071+
 2072+ function __construct($path_or_other=null) {
 2073+ if (is_resource($path_or_other) && get_resource_type($path_or_other) === '_p_Xapian__Database') {
 2074+ $this->_cPtr=$path_or_other;
 2075+ return;
 2076+ }
 2077+ switch (func_num_args()) {
 2078+ case 0: $this->_cPtr=new_Database(); break;
 2079+ default: $this->_cPtr=new_Database($path_or_other);
 2080+ }
 2081+ }
 2082+
 2083+ function reopen() {
 2084+ Database_reopen($this->_cPtr);
 2085+ }
 2086+
 2087+ function close() {
 2088+ Database_close($this->_cPtr);
 2089+ }
 2090+
 2091+ function get_description() {
 2092+ return Database_get_description($this->_cPtr);
 2093+ }
 2094+
 2095+ function postlist_begin($tname) {
 2096+ $r=Database_postlist_begin($this->_cPtr,$tname);
 2097+ if (is_resource($r)) {
 2098+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2099+ if (class_exists($c)) return new $c($r);
 2100+ return new XapianPostingIterator($r);
 2101+ }
 2102+ return $r;
 2103+ }
 2104+
 2105+ function postlist_end($tname) {
 2106+ $r=Database_postlist_end($this->_cPtr,$tname);
 2107+ if (is_resource($r)) {
 2108+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2109+ if (class_exists($c)) return new $c($r);
 2110+ return new XapianPostingIterator($r);
 2111+ }
 2112+ return $r;
 2113+ }
 2114+
 2115+ function termlist_begin($did) {
 2116+ $r=Database_termlist_begin($this->_cPtr,$did);
 2117+ if (is_resource($r)) {
 2118+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2119+ if (class_exists($c)) return new $c($r);
 2120+ return new XapianTermIterator($r);
 2121+ }
 2122+ return $r;
 2123+ }
 2124+
 2125+ function termlist_end($did) {
 2126+ $r=Database_termlist_end($this->_cPtr,$did);
 2127+ if (is_resource($r)) {
 2128+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2129+ if (class_exists($c)) return new $c($r);
 2130+ return new XapianTermIterator($r);
 2131+ }
 2132+ return $r;
 2133+ }
 2134+
 2135+ function positionlist_begin($did,$tname) {
 2136+ $r=Database_positionlist_begin($this->_cPtr,$did,$tname);
 2137+ if (is_resource($r)) {
 2138+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2139+ if (class_exists($c)) return new $c($r);
 2140+ return new XapianPositionIterator($r);
 2141+ }
 2142+ return $r;
 2143+ }
 2144+
 2145+ function positionlist_end($did,$tname) {
 2146+ $r=Database_positionlist_end($this->_cPtr,$did,$tname);
 2147+ if (is_resource($r)) {
 2148+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2149+ if (class_exists($c)) return new $c($r);
 2150+ return new XapianPositionIterator($r);
 2151+ }
 2152+ return $r;
 2153+ }
 2154+
 2155+ function allterms_begin($prefix=null) {
 2156+ switch (func_num_args()) {
 2157+ case 0: $r=Database_allterms_begin($this->_cPtr); break;
 2158+ default: $r=Database_allterms_begin($this->_cPtr,$prefix);
 2159+ }
 2160+ if (is_resource($r)) {
 2161+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2162+ if (class_exists($c)) return new $c($r);
 2163+ return new XapianTermIterator($r);
 2164+ }
 2165+ return $r;
 2166+ }
 2167+
 2168+ function allterms_end($prefix=null) {
 2169+ switch (func_num_args()) {
 2170+ case 0: $r=Database_allterms_end($this->_cPtr); break;
 2171+ default: $r=Database_allterms_end($this->_cPtr,$prefix);
 2172+ }
 2173+ if (is_resource($r)) {
 2174+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2175+ if (class_exists($c)) return new $c($r);
 2176+ return new XapianTermIterator($r);
 2177+ }
 2178+ return $r;
 2179+ }
 2180+
 2181+ function get_doccount() {
 2182+ return Database_get_doccount($this->_cPtr);
 2183+ }
 2184+
 2185+ function get_lastdocid() {
 2186+ return Database_get_lastdocid($this->_cPtr);
 2187+ }
 2188+
 2189+ function get_avlength() {
 2190+ return Database_get_avlength($this->_cPtr);
 2191+ }
 2192+
 2193+ function get_termfreq($tname) {
 2194+ return Database_get_termfreq($this->_cPtr,$tname);
 2195+ }
 2196+
 2197+ function term_exists($tname) {
 2198+ return Database_term_exists($this->_cPtr,$tname);
 2199+ }
 2200+
 2201+ function get_collection_freq($tname) {
 2202+ return Database_get_collection_freq($this->_cPtr,$tname);
 2203+ }
 2204+
 2205+ function get_value_freq($valno) {
 2206+ return Database_get_value_freq($this->_cPtr,$valno);
 2207+ }
 2208+
 2209+ function get_value_lower_bound($valno) {
 2210+ return Database_get_value_lower_bound($this->_cPtr,$valno);
 2211+ }
 2212+
 2213+ function get_value_upper_bound($valno) {
 2214+ return Database_get_value_upper_bound($this->_cPtr,$valno);
 2215+ }
 2216+
 2217+ function get_doclength_lower_bound() {
 2218+ return Database_get_doclength_lower_bound($this->_cPtr);
 2219+ }
 2220+
 2221+ function get_doclength_upper_bound() {
 2222+ return Database_get_doclength_upper_bound($this->_cPtr);
 2223+ }
 2224+
 2225+ function get_wdf_upper_bound($term) {
 2226+ return Database_get_wdf_upper_bound($this->_cPtr,$term);
 2227+ }
 2228+
 2229+ function valuestream_begin($slot) {
 2230+ $r=Database_valuestream_begin($this->_cPtr,$slot);
 2231+ if (is_resource($r)) {
 2232+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2233+ if (class_exists($c)) return new $c($r);
 2234+ return new XapianValueIterator($r);
 2235+ }
 2236+ return $r;
 2237+ }
 2238+
 2239+ function valuestream_end($arg1) {
 2240+ $r=Database_valuestream_end($this->_cPtr,$arg1);
 2241+ if (is_resource($r)) {
 2242+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2243+ if (class_exists($c)) return new $c($r);
 2244+ return new XapianValueIterator($r);
 2245+ }
 2246+ return $r;
 2247+ }
 2248+
 2249+ function get_doclength($docid) {
 2250+ return Database_get_doclength($this->_cPtr,$docid);
 2251+ }
 2252+
 2253+ function keep_alive() {
 2254+ Database_keep_alive($this->_cPtr);
 2255+ }
 2256+
 2257+ function get_document($did) {
 2258+ $r=Database_get_document($this->_cPtr,$did);
 2259+ if (is_resource($r)) {
 2260+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2261+ if (class_exists($c)) return new $c($r);
 2262+ return new XapianDocument($r);
 2263+ }
 2264+ return $r;
 2265+ }
 2266+
 2267+ function get_spelling_suggestion($word,$max_edit_distance=2) {
 2268+ return Database_get_spelling_suggestion($this->_cPtr,$word,$max_edit_distance);
 2269+ }
 2270+
 2271+ function spellings_begin() {
 2272+ $r=Database_spellings_begin($this->_cPtr);
 2273+ if (is_resource($r)) {
 2274+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2275+ if (class_exists($c)) return new $c($r);
 2276+ return new XapianTermIterator($r);
 2277+ }
 2278+ return $r;
 2279+ }
 2280+
 2281+ function spellings_end() {
 2282+ $r=Database_spellings_end($this->_cPtr);
 2283+ if (is_resource($r)) {
 2284+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2285+ if (class_exists($c)) return new $c($r);
 2286+ return new XapianTermIterator($r);
 2287+ }
 2288+ return $r;
 2289+ }
 2290+
 2291+ function synonyms_begin($term) {
 2292+ $r=Database_synonyms_begin($this->_cPtr,$term);
 2293+ if (is_resource($r)) {
 2294+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2295+ if (class_exists($c)) return new $c($r);
 2296+ return new XapianTermIterator($r);
 2297+ }
 2298+ return $r;
 2299+ }
 2300+
 2301+ function synonyms_end($arg1) {
 2302+ $r=Database_synonyms_end($this->_cPtr,$arg1);
 2303+ if (is_resource($r)) {
 2304+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2305+ if (class_exists($c)) return new $c($r);
 2306+ return new XapianTermIterator($r);
 2307+ }
 2308+ return $r;
 2309+ }
 2310+
 2311+ function synonym_keys_begin($prefix=null) {
 2312+ switch (func_num_args()) {
 2313+ case 0: $r=Database_synonym_keys_begin($this->_cPtr); break;
 2314+ default: $r=Database_synonym_keys_begin($this->_cPtr,$prefix);
 2315+ }
 2316+ if (is_resource($r)) {
 2317+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2318+ if (class_exists($c)) return new $c($r);
 2319+ return new XapianTermIterator($r);
 2320+ }
 2321+ return $r;
 2322+ }
 2323+
 2324+ function synonym_keys_end($prefix=null) {
 2325+ switch (func_num_args()) {
 2326+ case 0: $r=Database_synonym_keys_end($this->_cPtr); break;
 2327+ default: $r=Database_synonym_keys_end($this->_cPtr,$prefix);
 2328+ }
 2329+ if (is_resource($r)) {
 2330+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2331+ if (class_exists($c)) return new $c($r);
 2332+ return new XapianTermIterator($r);
 2333+ }
 2334+ return $r;
 2335+ }
 2336+
 2337+ function get_metadata($key) {
 2338+ return Database_get_metadata($this->_cPtr,$key);
 2339+ }
 2340+
 2341+ function metadata_keys_begin($prefix=null) {
 2342+ switch (func_num_args()) {
 2343+ case 0: $r=Database_metadata_keys_begin($this->_cPtr); break;
 2344+ default: $r=Database_metadata_keys_begin($this->_cPtr,$prefix);
 2345+ }
 2346+ if (is_resource($r)) {
 2347+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2348+ if (class_exists($c)) return new $c($r);
 2349+ return new XapianTermIterator($r);
 2350+ }
 2351+ return $r;
 2352+ }
 2353+
 2354+ function metadata_keys_end($prefix=null) {
 2355+ switch (func_num_args()) {
 2356+ case 0: $r=Database_metadata_keys_end($this->_cPtr); break;
 2357+ default: $r=Database_metadata_keys_end($this->_cPtr,$prefix);
 2358+ }
 2359+ if (is_resource($r)) {
 2360+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2361+ if (class_exists($c)) return new $c($r);
 2362+ return new XapianTermIterator($r);
 2363+ }
 2364+ return $r;
 2365+ }
 2366+
 2367+ function get_uuid() {
 2368+ return Database_get_uuid($this->_cPtr);
 2369+ }
 2370+
 2371+ function has_positions() {
 2372+ return Database_has_positions($this->_cPtr);
 2373+ }
 2374+}
 2375+
 2376+class XapianWritableDatabase extends XapianDatabase {
 2377+ public $_cPtr=null;
 2378+
 2379+ function __set($var,$value) {
 2380+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2381+ XapianDatabase::__set($var,$value);
 2382+ }
 2383+
 2384+ function __isset($var) {
 2385+ if ($var === 'thisown') return true;
 2386+ return XapianDatabase::__isset($var);
 2387+ }
 2388+
 2389+ function __get($var) {
 2390+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2391+ return XapianDatabase::__get($var);
 2392+ }
 2393+
 2394+ function __construct($path_or_other=null,$action=null) {
 2395+ if (is_resource($path_or_other) && get_resource_type($path_or_other) === '_p_Xapian__WritableDatabase') {
 2396+ $this->_cPtr=$path_or_other;
 2397+ return;
 2398+ }
 2399+ switch (func_num_args()) {
 2400+ case 0: $this->_cPtr=new_WritableDatabase(); break;
 2401+ case 1: $this->_cPtr=new_WritableDatabase($path_or_other); break;
 2402+ default: $this->_cPtr=new_WritableDatabase($path_or_other,$action);
 2403+ }
 2404+ }
 2405+
 2406+ function commit() {
 2407+ WritableDatabase_commit($this->_cPtr);
 2408+ }
 2409+
 2410+ function flush() {
 2411+ WritableDatabase_flush($this->_cPtr);
 2412+ }
 2413+
 2414+ function begin_transaction($flushed=true) {
 2415+ WritableDatabase_begin_transaction($this->_cPtr,$flushed);
 2416+ }
 2417+
 2418+ function commit_transaction() {
 2419+ WritableDatabase_commit_transaction($this->_cPtr);
 2420+ }
 2421+
 2422+ function cancel_transaction() {
 2423+ WritableDatabase_cancel_transaction($this->_cPtr);
 2424+ }
 2425+
 2426+ function add_document($document) {
 2427+ return WritableDatabase_add_document($this->_cPtr,$document);
 2428+ }
 2429+
 2430+ function delete_document($did_or_unique_term) {
 2431+ return WritableDatabase_delete_document($this->_cPtr,$did_or_unique_term);
 2432+ }
 2433+
 2434+ function replace_document($did_or_unique_term,$document) {
 2435+ return WritableDatabase_replace_document($this->_cPtr,$did_or_unique_term,$document);
 2436+ }
 2437+
 2438+ function add_spelling($word,$freqinc=1) {
 2439+ return WritableDatabase_add_spelling($this->_cPtr,$word,$freqinc);
 2440+ }
 2441+
 2442+ function remove_spelling($word,$freqdec=1) {
 2443+ return WritableDatabase_remove_spelling($this->_cPtr,$word,$freqdec);
 2444+ }
 2445+
 2446+ function add_synonym($term,$synonym) {
 2447+ return WritableDatabase_add_synonym($this->_cPtr,$term,$synonym);
 2448+ }
 2449+
 2450+ function remove_synonym($term,$synonym) {
 2451+ return WritableDatabase_remove_synonym($this->_cPtr,$term,$synonym);
 2452+ }
 2453+
 2454+ function clear_synonyms($term) {
 2455+ return WritableDatabase_clear_synonyms($this->_cPtr,$term);
 2456+ }
 2457+
 2458+ function set_metadata($key,$value) {
 2459+ return WritableDatabase_set_metadata($this->_cPtr,$key,$value);
 2460+ }
 2461+
 2462+ function get_description() {
 2463+ return WritableDatabase_get_description($this->_cPtr);
 2464+ }
 2465+}
 2466+
 2467+class XapianQuery {
 2468+ public $_cPtr=null;
 2469+ protected $_pData=array();
 2470+
 2471+ function __set($var,$value) {
 2472+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2473+ $this->_pData[$var] = $value;
 2474+ }
 2475+
 2476+ function __isset($var) {
 2477+ if ($var === 'thisown') return true;
 2478+ return array_key_exists($var, $this->_pData);
 2479+ }
 2480+
 2481+ function __get($var) {
 2482+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2483+ return $this->_pData[$var];
 2484+ }
 2485+
 2486+ const OP_AND = 0;
 2487+
 2488+ const OP_OR = Query_OP_OR;
 2489+
 2490+ const OP_AND_NOT = Query_OP_AND_NOT;
 2491+
 2492+ const OP_XOR = Query_OP_XOR;
 2493+
 2494+ const OP_AND_MAYBE = Query_OP_AND_MAYBE;
 2495+
 2496+ const OP_FILTER = Query_OP_FILTER;
 2497+
 2498+ const OP_NEAR = Query_OP_NEAR;
 2499+
 2500+ const OP_PHRASE = Query_OP_PHRASE;
 2501+
 2502+ const OP_VALUE_RANGE = Query_OP_VALUE_RANGE;
 2503+
 2504+ const OP_SCALE_WEIGHT = Query_OP_SCALE_WEIGHT;
 2505+
 2506+ const OP_ELITE_SET = Query_OP_ELITE_SET;
 2507+
 2508+ const OP_VALUE_GE = Query_OP_VALUE_GE;
 2509+
 2510+ const OP_VALUE_LE = Query_OP_VALUE_LE;
 2511+
 2512+ const OP_SYNONYM = Query_OP_SYNONYM;
 2513+
 2514+ static function MatchAll() {
 2515+ $r=Query_MatchAll_get();
 2516+ if (is_resource($r)) {
 2517+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2518+ if (class_exists($c)) return new $c($r);
 2519+ return new XapianQuery($r);
 2520+ }
 2521+ return $r;
 2522+ }
 2523+
 2524+ static function MatchNothing() {
 2525+ $r=Query_MatchNothing_get();
 2526+ if (is_resource($r)) {
 2527+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2528+ if (class_exists($c)) return new $c($r);
 2529+ return new XapianQuery($r);
 2530+ }
 2531+ return $r;
 2532+ }
 2533+
 2534+ function get_length() {
 2535+ return Query_get_length($this->_cPtr);
 2536+ }
 2537+
 2538+ function get_terms_begin() {
 2539+ $r=Query_get_terms_begin($this->_cPtr);
 2540+ if (is_resource($r)) {
 2541+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2542+ if (class_exists($c)) return new $c($r);
 2543+ return new XapianTermIterator($r);
 2544+ }
 2545+ return $r;
 2546+ }
 2547+
 2548+ function get_terms_end() {
 2549+ $r=Query_get_terms_end($this->_cPtr);
 2550+ if (is_resource($r)) {
 2551+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2552+ if (class_exists($c)) return new $c($r);
 2553+ return new XapianTermIterator($r);
 2554+ }
 2555+ return $r;
 2556+ }
 2557+
 2558+ function is_empty() {
 2559+ return Query_is_empty($this->_cPtr);
 2560+ }
 2561+
 2562+ function serialise() {
 2563+ return Query_serialise($this->_cPtr);
 2564+ }
 2565+
 2566+ static function unserialise($s,$registry=null) {
 2567+ switch (func_num_args()) {
 2568+ case 1: $r=Query_unserialise($s); break;
 2569+ default: $r=Query_unserialise($s,$registry);
 2570+ }
 2571+ if (is_resource($r)) {
 2572+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2573+ if (class_exists($c)) return new $c($r);
 2574+ return new XapianQuery($r);
 2575+ }
 2576+ return $r;
 2577+ }
 2578+
 2579+ function get_description() {
 2580+ return Query_get_description($this->_cPtr);
 2581+ }
 2582+
 2583+ function __construct($copyme_or_tname__or_op__or_external_source_or_op=null,$wqf__or_left_or_q_or_slot_or_subqs=null,$pos__or_right_or_parameter_or_begin_or_value_or_param=null,$end=null) {
 2584+ if (is_resource($copyme_or_tname__or_op__or_external_source_or_op) && get_resource_type($copyme_or_tname__or_op__or_external_source_or_op) === '_p_Xapian__Query') {
 2585+ $this->_cPtr=$copyme_or_tname__or_op__or_external_source_or_op;
 2586+ return;
 2587+ }
 2588+ switch (func_num_args()) {
 2589+ case 0: $this->_cPtr=new_Query(); break;
 2590+ case 1: $this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op); break;
 2591+ case 2: $this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op,$wqf__or_left_or_q_or_slot_or_subqs); break;
 2592+ case 3: $this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op,$wqf__or_left_or_q_or_slot_or_subqs,$pos__or_right_or_parameter_or_begin_or_value_or_param); break;
 2593+ default: $this->_cPtr=new_Query($copyme_or_tname__or_op__or_external_source_or_op,$wqf__or_left_or_q_or_slot_or_subqs,$pos__or_right_or_parameter_or_begin_or_value_or_param,$end);
 2594+ }
 2595+ }
 2596+}
 2597+
 2598+abstract class XapianStopper {
 2599+ public $_cPtr=null;
 2600+ protected $_pData=array();
 2601+
 2602+ function __set($var,$value) {
 2603+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2604+ $this->_pData[$var] = $value;
 2605+ }
 2606+
 2607+ function __isset($var) {
 2608+ if ($var === 'thisown') return true;
 2609+ return array_key_exists($var, $this->_pData);
 2610+ }
 2611+
 2612+ function __get($var) {
 2613+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2614+ return $this->_pData[$var];
 2615+ }
 2616+
 2617+ function apply($term) {
 2618+ return Stopper_apply($this->_cPtr,$term);
 2619+ }
 2620+
 2621+ function get_description() {
 2622+ return Stopper_get_description($this->_cPtr);
 2623+ }
 2624+
 2625+ function __construct($res=null) {
 2626+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__Stopper') {
 2627+ $this->_cPtr=$res;
 2628+ return;
 2629+ }
 2630+ if (get_class($this) === 'XapianStopper') {
 2631+ $_this = null;
 2632+ } else {
 2633+ $_this = $this;
 2634+ }
 2635+ $this->_cPtr=new_Stopper($_this);
 2636+ }
 2637+}
 2638+
 2639+class XapianSimpleStopper extends XapianStopper {
 2640+ public $_cPtr=null;
 2641+
 2642+ function __set($var,$value) {
 2643+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2644+ XapianStopper::__set($var,$value);
 2645+ }
 2646+
 2647+ function __isset($var) {
 2648+ if ($var === 'thisown') return true;
 2649+ return XapianStopper::__isset($var);
 2650+ }
 2651+
 2652+ function __get($var) {
 2653+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2654+ return XapianStopper::__get($var);
 2655+ }
 2656+
 2657+ function __construct($res=null) {
 2658+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__SimpleStopper') {
 2659+ $this->_cPtr=$res;
 2660+ return;
 2661+ }
 2662+ $this->_cPtr=new_SimpleStopper();
 2663+ }
 2664+
 2665+ function add($word) {
 2666+ return SimpleStopper_add($this->_cPtr,$word);
 2667+ }
 2668+
 2669+ function apply($term) {
 2670+ return SimpleStopper_apply($this->_cPtr,$term);
 2671+ }
 2672+
 2673+ function get_description() {
 2674+ return SimpleStopper_get_description($this->_cPtr);
 2675+ }
 2676+}
 2677+
 2678+abstract class XapianValueRangeProcessor {
 2679+ public $_cPtr=null;
 2680+ protected $_pData=array();
 2681+
 2682+ function __set($var,$value) {
 2683+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2684+ $this->_pData[$var] = $value;
 2685+ }
 2686+
 2687+ function __isset($var) {
 2688+ if ($var === 'thisown') return true;
 2689+ return array_key_exists($var, $this->_pData);
 2690+ }
 2691+
 2692+ function __get($var) {
 2693+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2694+ return $this->_pData[$var];
 2695+ }
 2696+
 2697+ function apply($begin,$end) {
 2698+ return ValueRangeProcessor_apply($this->_cPtr,$begin,$end);
 2699+ }
 2700+
 2701+ function __construct($res=null) {
 2702+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__ValueRangeProcessor') {
 2703+ $this->_cPtr=$res;
 2704+ return;
 2705+ }
 2706+ if (get_class($this) === 'XapianValueRangeProcessor') {
 2707+ $_this = null;
 2708+ } else {
 2709+ $_this = $this;
 2710+ }
 2711+ $this->_cPtr=new_ValueRangeProcessor($_this);
 2712+ }
 2713+}
 2714+
 2715+class XapianStringValueRangeProcessor extends XapianValueRangeProcessor {
 2716+ public $_cPtr=null;
 2717+
 2718+ function __set($var,$value) {
 2719+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2720+ XapianValueRangeProcessor::__set($var,$value);
 2721+ }
 2722+
 2723+ function __isset($var) {
 2724+ if ($var === 'thisown') return true;
 2725+ return XapianValueRangeProcessor::__isset($var);
 2726+ }
 2727+
 2728+ function __get($var) {
 2729+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2730+ return XapianValueRangeProcessor::__get($var);
 2731+ }
 2732+
 2733+ function __construct($slot_,$str_=null,$prefix_=true) {
 2734+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__StringValueRangeProcessor') {
 2735+ $this->_cPtr=$slot_;
 2736+ return;
 2737+ }
 2738+ switch (func_num_args()) {
 2739+ case 1: $this->_cPtr=new_StringValueRangeProcessor($slot_); break;
 2740+ default: $this->_cPtr=new_StringValueRangeProcessor($slot_,$str_,$prefix_);
 2741+ }
 2742+ }
 2743+
 2744+ function apply($arg1,$arg2) {
 2745+ return StringValueRangeProcessor_apply($this->_cPtr,$arg1,$arg2);
 2746+ }
 2747+}
 2748+
 2749+class XapianDateValueRangeProcessor extends XapianStringValueRangeProcessor {
 2750+ public $_cPtr=null;
 2751+
 2752+ function __set($var,$value) {
 2753+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2754+ XapianStringValueRangeProcessor::__set($var,$value);
 2755+ }
 2756+
 2757+ function __isset($var) {
 2758+ if ($var === 'thisown') return true;
 2759+ return XapianStringValueRangeProcessor::__isset($var);
 2760+ }
 2761+
 2762+ function __get($var) {
 2763+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2764+ return XapianStringValueRangeProcessor::__get($var);
 2765+ }
 2766+
 2767+ function __construct($slot_,$prefer_mdy__or_str_=null,$epoch_year__or_prefix_=null,$prefer_mdy_=null,$epoch_year_=null) {
 2768+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__DateValueRangeProcessor') {
 2769+ $this->_cPtr=$slot_;
 2770+ return;
 2771+ }
 2772+ switch (func_num_args()) {
 2773+ case 1: $this->_cPtr=new_DateValueRangeProcessor($slot_); break;
 2774+ case 2: $this->_cPtr=new_DateValueRangeProcessor($slot_,$prefer_mdy__or_str_); break;
 2775+ case 3: $this->_cPtr=new_DateValueRangeProcessor($slot_,$prefer_mdy__or_str_,$epoch_year__or_prefix_); break;
 2776+ case 4: $this->_cPtr=new_DateValueRangeProcessor($slot_,$prefer_mdy__or_str_,$epoch_year__or_prefix_,$prefer_mdy_); break;
 2777+ default: $this->_cPtr=new_DateValueRangeProcessor($slot_,$prefer_mdy__or_str_,$epoch_year__or_prefix_,$prefer_mdy_,$epoch_year_);
 2778+ }
 2779+ }
 2780+
 2781+ function apply($begin,$end) {
 2782+ return DateValueRangeProcessor_apply($this->_cPtr,$begin,$end);
 2783+ }
 2784+}
 2785+
 2786+class XapianNumberValueRangeProcessor extends XapianStringValueRangeProcessor {
 2787+ public $_cPtr=null;
 2788+
 2789+ function __set($var,$value) {
 2790+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2791+ XapianStringValueRangeProcessor::__set($var,$value);
 2792+ }
 2793+
 2794+ function __isset($var) {
 2795+ if ($var === 'thisown') return true;
 2796+ return XapianStringValueRangeProcessor::__isset($var);
 2797+ }
 2798+
 2799+ function __get($var) {
 2800+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2801+ return XapianStringValueRangeProcessor::__get($var);
 2802+ }
 2803+
 2804+ function __construct($slot_,$str_=null,$prefix_=true) {
 2805+ if (is_resource($slot_) && get_resource_type($slot_) === '_p_Xapian__NumberValueRangeProcessor') {
 2806+ $this->_cPtr=$slot_;
 2807+ return;
 2808+ }
 2809+ switch (func_num_args()) {
 2810+ case 1: $this->_cPtr=new_NumberValueRangeProcessor($slot_); break;
 2811+ default: $this->_cPtr=new_NumberValueRangeProcessor($slot_,$str_,$prefix_);
 2812+ }
 2813+ }
 2814+
 2815+ function apply($begin,$end) {
 2816+ return NumberValueRangeProcessor_apply($this->_cPtr,$begin,$end);
 2817+ }
 2818+}
 2819+
 2820+class XapianQueryParser {
 2821+ public $_cPtr=null;
 2822+ protected $_pData=array();
 2823+
 2824+ function __set($var,$value) {
 2825+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2826+ $this->_pData[$var] = $value;
 2827+ }
 2828+
 2829+ function __isset($var) {
 2830+ if ($var === 'thisown') return true;
 2831+ return array_key_exists($var, $this->_pData);
 2832+ }
 2833+
 2834+ function __get($var) {
 2835+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 2836+ return $this->_pData[$var];
 2837+ }
 2838+
 2839+ const FLAG_BOOLEAN = 1;
 2840+
 2841+ const FLAG_PHRASE = 2;
 2842+
 2843+ const FLAG_LOVEHATE = 4;
 2844+
 2845+ const FLAG_BOOLEAN_ANY_CASE = 8;
 2846+
 2847+ const FLAG_WILDCARD = 16;
 2848+
 2849+ const FLAG_PURE_NOT = 32;
 2850+
 2851+ const FLAG_PARTIAL = 64;
 2852+
 2853+ const FLAG_SPELLING_CORRECTION = 128;
 2854+
 2855+ const FLAG_SYNONYM = 256;
 2856+
 2857+ const FLAG_AUTO_SYNONYMS = 512;
 2858+
 2859+ const FLAG_AUTO_MULTIWORD_SYNONYMS = QueryParser_FLAG_AUTO_MULTIWORD_SYNONYMS;
 2860+
 2861+ const FLAG_DEFAULT = QueryParser_FLAG_DEFAULT;
 2862+
 2863+ const STEM_NONE = 0;
 2864+
 2865+ const STEM_SOME = QueryParser_STEM_SOME;
 2866+
 2867+ const STEM_ALL = QueryParser_STEM_ALL;
 2868+
 2869+ function __construct($res=null) {
 2870+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__QueryParser') {
 2871+ $this->_cPtr=$res;
 2872+ return;
 2873+ }
 2874+ $this->_cPtr=new_QueryParser();
 2875+ }
 2876+
 2877+ function set_stemmer($stemmer) {
 2878+ QueryParser_set_stemmer($this->_cPtr,$stemmer);
 2879+ }
 2880+
 2881+ function set_stemming_strategy($strategy) {
 2882+ QueryParser_set_stemming_strategy($this->_cPtr,$strategy);
 2883+ }
 2884+
 2885+ function set_stopper($stop=null) {
 2886+ QueryParser_set_stopper($this->_cPtr,$stop);
 2887+ }
 2888+
 2889+ function set_default_op($default_op) {
 2890+ QueryParser_set_default_op($this->_cPtr,$default_op);
 2891+ }
 2892+
 2893+ function get_default_op() {
 2894+ return QueryParser_get_default_op($this->_cPtr);
 2895+ }
 2896+
 2897+ function set_database($db) {
 2898+ QueryParser_set_database($this->_cPtr,$db);
 2899+ }
 2900+
 2901+ function set_max_wildcard_expansion($limit) {
 2902+ QueryParser_set_max_wildcard_expansion($this->_cPtr,$limit);
 2903+ }
 2904+
 2905+ function parse_query($query_string,$flags=null,$default_prefix=null) {
 2906+ switch (func_num_args()) {
 2907+ case 1: $r=QueryParser_parse_query($this->_cPtr,$query_string); break;
 2908+ case 2: $r=QueryParser_parse_query($this->_cPtr,$query_string,$flags); break;
 2909+ default: $r=QueryParser_parse_query($this->_cPtr,$query_string,$flags,$default_prefix);
 2910+ }
 2911+ if (is_resource($r)) {
 2912+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2913+ if (class_exists($c)) return new $c($r);
 2914+ return new XapianQuery($r);
 2915+ }
 2916+ return $r;
 2917+ }
 2918+
 2919+ function add_prefix($field,$prefix) {
 2920+ return QueryParser_add_prefix($this->_cPtr,$field,$prefix);
 2921+ }
 2922+
 2923+ function add_boolean_prefix($field,$prefix,$exclusive=null) {
 2924+ switch (func_num_args()) {
 2925+ case 2: QueryParser_add_boolean_prefix($this->_cPtr,$field,$prefix); break;
 2926+ default: QueryParser_add_boolean_prefix($this->_cPtr,$field,$prefix,$exclusive);
 2927+ }
 2928+ return $r;
 2929+ }
 2930+
 2931+ function stoplist_begin() {
 2932+ $r=QueryParser_stoplist_begin($this->_cPtr);
 2933+ if (is_resource($r)) {
 2934+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2935+ if (class_exists($c)) return new $c($r);
 2936+ return new XapianTermIterator($r);
 2937+ }
 2938+ return $r;
 2939+ }
 2940+
 2941+ function stoplist_end() {
 2942+ $r=QueryParser_stoplist_end($this->_cPtr);
 2943+ if (is_resource($r)) {
 2944+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2945+ if (class_exists($c)) return new $c($r);
 2946+ return new XapianTermIterator($r);
 2947+ }
 2948+ return $r;
 2949+ }
 2950+
 2951+ function unstem_begin($term) {
 2952+ $r=QueryParser_unstem_begin($this->_cPtr,$term);
 2953+ if (is_resource($r)) {
 2954+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2955+ if (class_exists($c)) return new $c($r);
 2956+ return new XapianTermIterator($r);
 2957+ }
 2958+ return $r;
 2959+ }
 2960+
 2961+ function unstem_end($arg1) {
 2962+ $r=QueryParser_unstem_end($this->_cPtr,$arg1);
 2963+ if (is_resource($r)) {
 2964+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 2965+ if (class_exists($c)) return new $c($r);
 2966+ return new XapianTermIterator($r);
 2967+ }
 2968+ return $r;
 2969+ }
 2970+
 2971+ function add_valuerangeprocessor($vrproc) {
 2972+ QueryParser_add_valuerangeprocessor($this->_cPtr,$vrproc);
 2973+ }
 2974+
 2975+ function get_corrected_query_string() {
 2976+ return QueryParser_get_corrected_query_string($this->_cPtr);
 2977+ }
 2978+
 2979+ function get_description() {
 2980+ return QueryParser_get_description($this->_cPtr);
 2981+ }
 2982+}
 2983+
 2984+abstract class XapianStemImplementation {
 2985+ public $_cPtr=null;
 2986+ protected $_pData=array();
 2987+
 2988+ function __set($var,$value) {
 2989+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 2990+ $this->_pData[$var] = $value;
 2991+ }
 2992+
 2993+ function __isset($var) {
 2994+ if ($var === 'thisown') return true;
 2995+ return array_key_exists($var, $this->_pData);
 2996+ }
 2997+
 2998+ function __get($var) {
 2999+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3000+ return $this->_pData[$var];
 3001+ }
 3002+
 3003+ function apply($word) {
 3004+ return StemImplementation_apply($this->_cPtr,$word);
 3005+ }
 3006+
 3007+ function get_description() {
 3008+ return StemImplementation_get_description($this->_cPtr);
 3009+ }
 3010+
 3011+ function __construct($res=null) {
 3012+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__StemImplementation') {
 3013+ $this->_cPtr=$res;
 3014+ return;
 3015+ }
 3016+ if (get_class($this) === 'XapianStemImplementation') {
 3017+ $_this = null;
 3018+ } else {
 3019+ $_this = $this;
 3020+ }
 3021+ $this->_cPtr=new_StemImplementation($_this);
 3022+ }
 3023+}
 3024+
 3025+class XapianStem {
 3026+ public $_cPtr=null;
 3027+ protected $_pData=array();
 3028+
 3029+ function __set($var,$value) {
 3030+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3031+ $this->_pData[$var] = $value;
 3032+ }
 3033+
 3034+ function __isset($var) {
 3035+ if ($var === 'thisown') return true;
 3036+ return array_key_exists($var, $this->_pData);
 3037+ }
 3038+
 3039+ function __get($var) {
 3040+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3041+ return $this->_pData[$var];
 3042+ }
 3043+
 3044+ function __construct($language_or_p) {
 3045+ if (is_resource($language_or_p) && get_resource_type($language_or_p) === '_p_Xapian__Stem') {
 3046+ $this->_cPtr=$language_or_p;
 3047+ return;
 3048+ }
 3049+ $this->_cPtr=new_Stem($language_or_p);
 3050+ }
 3051+
 3052+ function apply($word) {
 3053+ return Stem_apply($this->_cPtr,$word);
 3054+ }
 3055+
 3056+ function get_description() {
 3057+ return Stem_get_description($this->_cPtr);
 3058+ }
 3059+
 3060+ static function get_available_languages() {
 3061+ return Stem_get_available_languages();
 3062+ }
 3063+}
 3064+
 3065+class XapianTermGenerator {
 3066+ public $_cPtr=null;
 3067+ protected $_pData=array();
 3068+
 3069+ function __set($var,$value) {
 3070+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3071+ $this->_pData[$var] = $value;
 3072+ }
 3073+
 3074+ function __isset($var) {
 3075+ if ($var === 'thisown') return true;
 3076+ return array_key_exists($var, $this->_pData);
 3077+ }
 3078+
 3079+ function __get($var) {
 3080+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3081+ return $this->_pData[$var];
 3082+ }
 3083+
 3084+ function __construct($res=null) {
 3085+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__TermGenerator') {
 3086+ $this->_cPtr=$res;
 3087+ return;
 3088+ }
 3089+ $this->_cPtr=new_TermGenerator();
 3090+ }
 3091+
 3092+ function set_stemmer($stemmer) {
 3093+ TermGenerator_set_stemmer($this->_cPtr,$stemmer);
 3094+ }
 3095+
 3096+ function set_stopper($stop=null) {
 3097+ TermGenerator_set_stopper($this->_cPtr,$stop);
 3098+ }
 3099+
 3100+ function set_document($doc) {
 3101+ TermGenerator_set_document($this->_cPtr,$doc);
 3102+ }
 3103+
 3104+ function get_document() {
 3105+ $r=TermGenerator_get_document($this->_cPtr);
 3106+ if (is_resource($r)) {
 3107+ $c='Xapian'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
 3108+ if (class_exists($c)) return new $c($r);
 3109+ return new XapianDocument($r);
 3110+ }
 3111+ return $r;
 3112+ }
 3113+
 3114+ function set_database($db) {
 3115+ TermGenerator_set_database($this->_cPtr,$db);
 3116+ }
 3117+
 3118+ const FLAG_SPELLING = 128;
 3119+
 3120+ function set_flags($toggle,$mask=null) {
 3121+ switch (func_num_args()) {
 3122+ case 1: $r=TermGenerator_set_flags($this->_cPtr,$toggle); break;
 3123+ default: $r=TermGenerator_set_flags($this->_cPtr,$toggle,$mask);
 3124+ }
 3125+ return $r;
 3126+ }
 3127+
 3128+ function index_text($text,$wdf_inc=1,$prefix=null) {
 3129+ switch (func_num_args()) {
 3130+ case 1: case 2: TermGenerator_index_text($this->_cPtr,$text,$wdf_inc); break;
 3131+ default: TermGenerator_index_text($this->_cPtr,$text,$wdf_inc,$prefix);
 3132+ }
 3133+ return $r;
 3134+ }
 3135+
 3136+ function index_text_without_positions($text,$wdf_inc=1,$prefix=null) {
 3137+ switch (func_num_args()) {
 3138+ case 1: case 2: TermGenerator_index_text_without_positions($this->_cPtr,$text,$wdf_inc); break;
 3139+ default: TermGenerator_index_text_without_positions($this->_cPtr,$text,$wdf_inc,$prefix);
 3140+ }
 3141+ return $r;
 3142+ }
 3143+
 3144+ function increase_termpos($delta=100) {
 3145+ TermGenerator_increase_termpos($this->_cPtr,$delta);
 3146+ }
 3147+
 3148+ function get_termpos() {
 3149+ return TermGenerator_get_termpos($this->_cPtr);
 3150+ }
 3151+
 3152+ function set_termpos($termpos) {
 3153+ TermGenerator_set_termpos($this->_cPtr,$termpos);
 3154+ }
 3155+
 3156+ function get_description() {
 3157+ return TermGenerator_get_description($this->_cPtr);
 3158+ }
 3159+}
 3160+
 3161+abstract class XapianKeyMaker {
 3162+ public $_cPtr=null;
 3163+ protected $_pData=array();
 3164+
 3165+ function __set($var,$value) {
 3166+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3167+ $this->_pData[$var] = $value;
 3168+ }
 3169+
 3170+ function __isset($var) {
 3171+ if ($var === 'thisown') return true;
 3172+ return array_key_exists($var, $this->_pData);
 3173+ }
 3174+
 3175+ function __get($var) {
 3176+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3177+ return $this->_pData[$var];
 3178+ }
 3179+
 3180+ function apply($doc) {
 3181+ return KeyMaker_apply($this->_cPtr,$doc);
 3182+ }
 3183+
 3184+ function __construct($res=null) {
 3185+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__KeyMaker') {
 3186+ $this->_cPtr=$res;
 3187+ return;
 3188+ }
 3189+ if (get_class($this) === 'XapianKeyMaker') {
 3190+ $_this = null;
 3191+ } else {
 3192+ $_this = $this;
 3193+ }
 3194+ $this->_cPtr=new_KeyMaker($_this);
 3195+ }
 3196+}
 3197+
 3198+class XapianMultiValueKeyMaker extends XapianKeyMaker {
 3199+ public $_cPtr=null;
 3200+
 3201+ function __set($var,$value) {
 3202+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3203+ XapianKeyMaker::__set($var,$value);
 3204+ }
 3205+
 3206+ function __isset($var) {
 3207+ if ($var === 'thisown') return true;
 3208+ return XapianKeyMaker::__isset($var);
 3209+ }
 3210+
 3211+ function __get($var) {
 3212+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3213+ return XapianKeyMaker::__get($var);
 3214+ }
 3215+
 3216+ function __construct($res=null) {
 3217+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__MultiValueKeyMaker') {
 3218+ $this->_cPtr=$res;
 3219+ return;
 3220+ }
 3221+ $this->_cPtr=new_MultiValueKeyMaker();
 3222+ }
 3223+
 3224+ function apply($doc) {
 3225+ return MultiValueKeyMaker_apply($this->_cPtr,$doc);
 3226+ }
 3227+
 3228+ function add_value($slot,$reverse=false) {
 3229+ MultiValueKeyMaker_add_value($this->_cPtr,$slot,$reverse);
 3230+ }
 3231+}
 3232+
 3233+abstract class XapianSorter extends XapianKeyMaker {
 3234+ public $_cPtr=null;
 3235+
 3236+ function __set($var,$value) {
 3237+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3238+ XapianKeyMaker::__set($var,$value);
 3239+ }
 3240+
 3241+ function __isset($var) {
 3242+ if ($var === 'thisown') return true;
 3243+ return XapianKeyMaker::__isset($var);
 3244+ }
 3245+
 3246+ function __get($var) {
 3247+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3248+ return XapianKeyMaker::__get($var);
 3249+ }
 3250+ function __construct($h) {
 3251+ $this->_cPtr=$h;
 3252+ }
 3253+}
 3254+
 3255+class XapianMultiValueSorter extends XapianSorter {
 3256+ public $_cPtr=null;
 3257+
 3258+ function __set($var,$value) {
 3259+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3260+ XapianSorter::__set($var,$value);
 3261+ }
 3262+
 3263+ function __isset($var) {
 3264+ if ($var === 'thisown') return true;
 3265+ return XapianSorter::__isset($var);
 3266+ }
 3267+
 3268+ function __get($var) {
 3269+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3270+ return XapianSorter::__get($var);
 3271+ }
 3272+
 3273+ function __construct($res=null) {
 3274+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__MultiValueSorter') {
 3275+ $this->_cPtr=$res;
 3276+ return;
 3277+ }
 3278+ $this->_cPtr=new_MultiValueSorter();
 3279+ }
 3280+
 3281+ function apply($doc) {
 3282+ return MultiValueSorter_apply($this->_cPtr,$doc);
 3283+ }
 3284+
 3285+ function add($slot,$forward=true) {
 3286+ MultiValueSorter_add($this->_cPtr,$slot,$forward);
 3287+ }
 3288+}
 3289+
 3290+class XapianValueSetMatchDecider extends XapianMatchDecider {
 3291+ public $_cPtr=null;
 3292+
 3293+ function __set($var,$value) {
 3294+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3295+ XapianMatchDecider::__set($var,$value);
 3296+ }
 3297+
 3298+ function __isset($var) {
 3299+ if ($var === 'thisown') return true;
 3300+ return XapianMatchDecider::__isset($var);
 3301+ }
 3302+
 3303+ function __get($var) {
 3304+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3305+ return XapianMatchDecider::__get($var);
 3306+ }
 3307+
 3308+ function __construct($slot,$inclusive_) {
 3309+ if (is_resource($slot) && get_resource_type($slot) === '_p_Xapian__ValueSetMatchDecider') {
 3310+ $this->_cPtr=$slot;
 3311+ return;
 3312+ }
 3313+ $this->_cPtr=new_ValueSetMatchDecider($slot,$inclusive_);
 3314+ }
 3315+
 3316+ function add_value($value) {
 3317+ return ValueSetMatchDecider_add_value($this->_cPtr,$value);
 3318+ }
 3319+
 3320+ function remove_value($value) {
 3321+ return ValueSetMatchDecider_remove_value($this->_cPtr,$value);
 3322+ }
 3323+
 3324+ function apply($doc) {
 3325+ return ValueSetMatchDecider_apply($this->_cPtr,$doc);
 3326+ }
 3327+}
 3328+
 3329+class XapianCompactor {
 3330+ public $_cPtr=null;
 3331+ protected $_pData=array();
 3332+
 3333+ function __set($var,$value) {
 3334+ if ($var === 'thisown') return swig_xapian_alter_newobject($this->_cPtr,$value);
 3335+ $this->_pData[$var] = $value;
 3336+ }
 3337+
 3338+ function __isset($var) {
 3339+ if ($var === 'thisown') return true;
 3340+ return array_key_exists($var, $this->_pData);
 3341+ }
 3342+
 3343+ function __get($var) {
 3344+ if ($var === 'thisown') return swig_xapian_get_newobject($this->_cPtr);
 3345+ return $this->_pData[$var];
 3346+ }
 3347+
 3348+ const STANDARD = 0;
 3349+
 3350+ const FULL = Compactor_FULL;
 3351+
 3352+ const FULLER = Compactor_FULLER;
 3353+
 3354+ function __construct($res=null) {
 3355+ if (is_resource($res) && get_resource_type($res) === '_p_Xapian__Compactor') {
 3356+ $this->_cPtr=$res;
 3357+ return;
 3358+ }
 3359+ if (get_class($this) === 'XapianCompactor') {
 3360+ $_this = null;
 3361+ } else {
 3362+ $_this = $this;
 3363+ }
 3364+ $this->_cPtr=new_Compactor($_this);
 3365+ }
 3366+
 3367+ function set_block_size($block_size) {
 3368+ Compactor_set_block_size($this->_cPtr,$block_size);
 3369+ }
 3370+
 3371+ function set_renumber($renumber) {
 3372+ Compactor_set_renumber($this->_cPtr,$renumber);
 3373+ }
 3374+
 3375+ function set_multipass($multipass) {
 3376+ Compactor_set_multipass($this->_cPtr,$multipass);
 3377+ }
 3378+
 3379+ function set_compaction_level($compaction) {
 3380+ Compactor_set_compaction_level($this->_cPtr,$compaction);
 3381+ }
 3382+
 3383+ function set_destdir($destdir) {
 3384+ return Compactor_set_destdir($this->_cPtr,$destdir);
 3385+ }
 3386+
 3387+ function add_source($srcdir) {
 3388+ return Compactor_add_source($this->_cPtr,$srcdir);
 3389+ }
 3390+
 3391+ function compact() {
 3392+ Compactor_compact($this->_cPtr);
 3393+ }
 3394+
 3395+ function set_status($table,$status) {
 3396+ return Compactor_set_status($this->_cPtr,$table,$status);
 3397+ }
 3398+
 3399+ function resolve_duplicate_metadata($key,$num_tags,$tags) {
 3400+ return Compactor_resolve_duplicate_metadata($this->_cPtr,$key,$num_tags,$tags);
 3401+ }
 3402+}
 3403+
 3404+
 3405+?>
Index: trunk/extensions/Offline/RELEASE.NOTES
@@ -0,0 +1,15 @@
 2+0.6.1 -- Dec 20, 2011
 3+
 4+ Initial commit to mediawiki repo.
 5+
 6+ Issues:
 7+ * installation and configuration still too complicated (#17), update and download manager for dump files (#6)
 8+ * recursion over templates is done badly; we could load and cache (#10)
 9+ * CACHE_ACCEL blows up if no cache can be obtained
 10+ * hybrid dump + live db mode needs review (#5)
 11+ * limited to one dump (#22)
 12+ * dump import is not transactional (#20). script to find missing or corrupt data (#23)
 13+ * only supports .xml.bz2 dump format (#13), script to generate dump index for distribution (#21)
 14+ * a way to queue download of selected media or external links (#11)
 15+ * dvd distro script (#18)
 16+ * patch bzip2recover to set split chunk filesize (#19), patch bzip2 lib to emit ftell
Index: trunk/extensions/Offline/DatabaseBz2.php
@@ -0,0 +1,564 @@
 2+<?php
 3+/**
 4+ * A rudimentary database impl which can retrieve page revision text
 5+ * from backup dumps. This can be perfectly responsive if you have
 6+ * broken the .bz2 (careful now) into chunks for indexing.
 7+ *
 8+ **
 9+ * Copyright (C) 2008, 2009 Michael Nowak
 10+ * contributions by Adam Wight, 2011
 11+ *
 12+ * This program is free software; you can redistribute it and/or modify
 13+ * it under the terms of the GNU General Public License as published by
 14+ * the Free Software Foundation; either version 2 of the License, or
 15+ * (at your option) any later version.
 16+ *
 17+ * This program is distributed in the hope that it will be useful,
 18+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 19+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 20+ * GNU General Public License for more details.
 21+ *
 22+ * You should have received a copy of the GNU General Public License along
 23+ * with this program; if not, write to the Free Software Foundation, Inc.,
 24+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 25+ * http://www.gnu.org/copyleft/gpl.html
 26+**/
 27+
 28+class DatabaseBz2 extends Database
 29+{
 30+ function select( $table, $fields, $conds='', $fname = 'Database::select', $options = array() ) {
 31+ require_once(dirname(__FILE__).'/DumpReader.php');
 32+ require_once(dirname(__FILE__).'/CachedStorage.php');
 33+ $row = null;
 34+ $title = false;
 35+ if (isset($conds['page_title'])) {
 36+ $title = $conds['page_title'];
 37+ if ($conds['page_namespace'] && MWNamespace::getCanonicalName($conds['page_namespace']))
 38+ $title = MWNamespace::getCanonicalName($conds['page_namespace']).':'.$title;
 39+ }
 40+
 41+ if ($title && ($table == 'page' || (is_array($table) && in_array('page', $table)))) {
 42+ if (preg_match('/Template:Pp-/i', $title))
 43+ return false;
 44+
 45+ $textid = CachedStorage::fetchIdByTitle($title);
 46+ if (!$textid) {
 47+ $content = DumpReader::load_article($title);
 48+ if (!$content) {
 49+ wfDebug('no content for '.$title);
 50+ return false;
 51+ }
 52+ $textid = CachedStorage::set($title, $content);
 53+ }
 54+ } elseif (isset($conds['rev_id'])) {
 55+ $textid = $conds['rev_id'];
 56+ }
 57+
 58+ if (!isset($textid))
 59+ return false;
 60+
 61+ if ($table == 'page') {
 62+ // Given a page_title, get the id of text content. For efficiency,
 63+ // we fetch the text and store it by ID to access in case 2.
 64+ $row = array_fill_keys($fields, '');
 65+ $row['page_id'] = $textid;
 66+ $row['page_title'] = $title;
 67+ $row['page_latest'] = $textid;
 68+ }
 69+ elseif ($table == array('page', 'revision')) {
 70+ // Redundantly return textid which is cache key to article wml.
 71+ $fields[] = 'rev_user';
 72+ $fields[] = 'rev_user_text';
 73+ $row = array_fill_keys($fields, '');
 74+ $row['rev_id'] = $textid;
 75+ $row['rev_text_id'] = $textid;
 76+ }
 77+ else { print_r($table); print_r($conds); }
 78+
 79+ if (!$row)
 80+ return false;
 81+ return $this->resultObject($row);
 82+ }
 83+
 84+
 85+////////////////////////////////////////////////BOILERPLATE FOLLOWS
 86+
 87+ static $instance;
 88+
 89+ static function getInstance() {
 90+ if ( !isset( self::$instance ) ) {
 91+ self::$instance = new self();
 92+ }
 93+ return self::$instance;
 94+ }
 95+
 96+#------------------------------------------------------------------------------
 97+# Accessors
 98+#------------------------------------------------------------------------------
 99+ function failFunction( $function = NULL ) {
 100+ return null;
 101+ }
 102+
 103+ function setOutputPage( $out ) {
 104+ return null;
 105+ }
 106+
 107+ function debug( $debug = NULL ) {
 108+ return null;
 109+ }
 110+
 111+ function bufferResults( $buffer = NULL ) {
 112+ return null;
 113+ }
 114+
 115+ function ignoreErrors( $ignoreErrors = NULL ) {
 116+ return true;
 117+ }
 118+
 119+ function trxLevel( $level = NULL ) {
 120+ return 0;
 121+ }
 122+
 123+ function errorCount( $count = NULL ) {
 124+ return 0;
 125+ }
 126+
 127+ function getLBInfo( $name = NULL ) {
 128+ return true;
 129+ }
 130+
 131+ function setLBInfo( $name, $value = NULL ) {
 132+ return true;
 133+ }
 134+
 135+ function cascadingDeletes() {
 136+ return false;
 137+ }
 138+
 139+ function cleanupTriggers() {
 140+ return false;
 141+ }
 142+
 143+ function strictIPs() {
 144+ return false;
 145+ }
 146+
 147+ function realTimestamps() {
 148+ return false;
 149+ }
 150+
 151+ function implicitGroupby() {
 152+ return true;
 153+ }
 154+
 155+ function implicitOrderby() {
 156+ return true;
 157+ }
 158+
 159+ function searchableIPs() {
 160+ return false;
 161+ }
 162+
 163+ function functionalIndexes() {
 164+ return false;
 165+ }
 166+
 167+ function lastQuery() {
 168+ return true;
 169+ }
 170+ function isOpen() {
 171+ return true;
 172+ }
 173+
 174+ function setFlag( $flag ) {
 175+ return true;
 176+ }
 177+
 178+ function clearFlag( $flag ) {
 179+ return true;
 180+ }
 181+
 182+ function getFlag( $flag ) {
 183+ return true;
 184+ }
 185+
 186+ function getProperty( $name ) {
 187+ return true;
 188+ }
 189+
 190+
 191+ function __construct( $server = false, $user = false, $password = false, $dbName = false,
 192+ $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) {
 193+ null;
 194+ }
 195+
 196+ static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) {
 197+ return new Database( $server, $user, $password, $dbName, $failFunction, $flags );
 198+ }
 199+
 200+ function open( $server, $user, $password, $dbName ) {
 201+//TODO test article load using TestDumpReader
 202+ return true;
 203+ }
 204+
 205+ function close() {
 206+ return true;
 207+ }
 208+
 209+ function reportConnectionError( $error = 'Unknown error' ) {
 210+ return null;
 211+ }
 212+
 213+ public function query( $sql, $fname = '', $tempIgnore = false ) {
 214+ return null;
 215+ }
 216+
 217+ function doQuery( $sql ) {
 218+ return true;
 219+ }
 220+
 221+ function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
 222+ return null;
 223+ }
 224+
 225+
 226+ function prepare( $sql, $func = 'Database::prepare' ) {
 227+ return null;
 228+ }
 229+
 230+ function freePrepared( $prepared ) {
 231+ return null;
 232+ }
 233+
 234+ function execute( $prepared, $args = null ) {
 235+ return true;
 236+ }
 237+
 238+ function safeQuery( $query, $args = null ) {
 239+ return true;
 240+ }
 241+
 242+ function fillPrepared( $preparedQuery, $args ) {
 243+ return true;
 244+ }
 245+
 246+ function fillPreparedArg( $matches ) {
 247+ return true;
 248+ }
 249+
 250+ function freeResult( $res ) {
 251+ return null;
 252+ }
 253+
 254+ function fetchObject( $res ) {
 255+ // cast to object
 256+ if (!$res)
 257+ return false;
 258+
 259+ $array = $res->result;
 260+ if(!is_array($array)) {
 261+ return $array;
 262+ }
 263+
 264+ $object = new stdClass();
 265+ if (is_array($array) && count($array) > 0) {
 266+ foreach ($array as $name=>$value) {
 267+ if (!empty($name)) {
 268+ $object->$name = $value;
 269+ }
 270+ }
 271+ return $object;
 272+ }
 273+ else {
 274+ return false;
 275+ }
 276+ }
 277+
 278+ function fetchRow( $res ) {
 279+ return null;
 280+ }
 281+
 282+ function numRows( $res ) {
 283+ return 0;
 284+ }
 285+
 286+ function numFields( $res ) {
 287+ return 0;
 288+ }
 289+
 290+ function fieldName( $res, $n ) {
 291+ return true;
 292+ }
 293+
 294+ function insertId() {
 295+ return null;
 296+ }
 297+
 298+ function dataSeek( $res, $row ) {
 299+ return true;
 300+ }
 301+
 302+ function lastErrno() {
 303+ return null;
 304+ }
 305+
 306+ function lastError() {
 307+ return null;
 308+ }
 309+
 310+ function affectedRows() {
 311+ return 0;
 312+ }
 313+
 314+ function set( $table, $var, $value, $cond, $fname = 'Database::set' ) {
 315+ return null;
 316+ }
 317+
 318+ function selectField( $table, $var, $cond='', $fname = 'Database::selectField', $options = array() ) {
 319+ return $this->fetchObject($this->select($table, array($var), $cond));
 320+ }
 321+
 322+ function makeSelectOptions( $options ) {
 323+ return null;
 324+ }
 325+
 326+ function selectRow( $table, $vars, $conds, $fname = 'Database::selectRow', $options = array() ) {
 327+ return $this->fetchObject($this->select($table, $vars, $conds));
 328+ }
 329+
 330+ function estimateRowCount( $table, $vars='*', $conds='', $fname = 'Database::estimateRowCount', $options = array() ) {
 331+ return 0;
 332+ }
 333+
 334+
 335+ static function generalizeSQL( $sql ) {
 336+ return null;
 337+ }
 338+
 339+ function fieldExists( $table, $field, $fname = 'Database::fieldExists' ) {
 340+ return null;
 341+ }
 342+
 343+ function indexExists( $table, $index, $fname = 'Database::indexExists' ) {
 344+ return null;
 345+ }
 346+
 347+
 348+ function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
 349+ return null;
 350+ }
 351+
 352+ function tableExists( $table ) {
 353+ return null;
 354+ }
 355+
 356+ function fieldInfo( $table, $field ) {
 357+ return null;
 358+ }
 359+
 360+ function fieldType( $res, $index ) {
 361+ return null;
 362+ }
 363+
 364+ function indexUnique( $table, $index ) {
 365+ return null;
 366+ }
 367+
 368+ function insert( $table, $a, $fname = 'Database::insert', $options = array() ) {
 369+ return null;
 370+ }
 371+
 372+ function makeUpdateOptions( $options ) {
 373+ return null;
 374+ }
 375+
 376+ function update( $table, $values, $conds, $fname = 'Database::update', $options = array() ) {
 377+ return null;
 378+ }
 379+
 380+ function makeList( $a, $mode = LIST_COMMA ) {
 381+ return null;
 382+ }
 383+
 384+ function selectDB( $db ) {
 385+ return null;
 386+ }
 387+
 388+ function tableName( $name ) {
 389+ return null;
 390+ }
 391+
 392+ public function tableNames() {
 393+ return null;
 394+ }
 395+
 396+ public function tableNamesN() {
 397+ return null;
 398+ }
 399+
 400+ function tableNamesWithUseIndex( $tables, $use_index ) {
 401+ return null;
 402+ }
 403+
 404+ function strencode( $s ) {
 405+ return true;
 406+ }
 407+
 408+ function addQuotes( $s ) {
 409+ return true;
 410+ }
 411+
 412+ function escapeLike( $s ) {
 413+ return true;
 414+ }
 415+
 416+ function nextSequenceValue( $seqName ) {
 417+ return null;
 418+ }
 419+
 420+ function useIndexClause( $index ) {
 421+ return true;
 422+ }
 423+
 424+ function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) {
 425+ return null;
 426+ }
 427+
 428+ function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'Database::deleteJoin' ) {
 429+ return null;
 430+ }
 431+
 432+ function textFieldSize( $table, $field ) {
 433+ return null;
 434+ }
 435+
 436+ function lowPriorityOption() {
 437+ }
 438+
 439+ function delete( $table, $conds, $fname = 'Database::delete' ) {
 440+ return true;
 441+ }
 442+
 443+ function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect',
 444+ $insertOptions = array(), $selectOptions = array() )
 445+ {
 446+ return null;
 447+ }
 448+
 449+ function limitResult($sql, $limit, $offset=false) {
 450+ return null;
 451+ }
 452+
 453+ function limitResultForUpdate($sql, $num) {
 454+ return null;
 455+ }
 456+
 457+ function conditional( $cond, $trueVal, $falseVal ) {
 458+ return null;
 459+ }
 460+
 461+ function wasDeadlock() {
 462+ return null;
 463+ }
 464+
 465+ function deadlockLoop() {
 466+ return null;
 467+ }
 468+
 469+ function masterPosWait( $file, $pos, $timeout ) {
 470+ return null;
 471+ }
 472+
 473+ function getSlavePos() {
 474+ return null;
 475+ }
 476+
 477+ function getMasterPos() {
 478+ return null;
 479+ }
 480+
 481+ function begin( $fname = 'Database::begin' ) {
 482+ }
 483+
 484+ function commit( $fname = 'Database::commit' ) {
 485+ }
 486+
 487+ function rollback( $fname = 'Database::rollback' ) {
 488+ }
 489+
 490+ function immediateBegin( $fname = 'Database::immediateBegin' ) {
 491+ }
 492+
 493+ function immediateCommit( $fname = 'Database::immediateCommit' ) {
 494+ }
 495+
 496+ function timestamp( $ts=0 ) {
 497+ }
 498+
 499+ function timestampOrNull( $ts = null ) {
 500+ }
 501+
 502+ function resultObject( $result ) {
 503+ return new ResultWrapper($this, $result);
 504+ }
 505+
 506+ function aggregateValue ($valuedata,$valuename='value') {
 507+ }
 508+
 509+ static function getSoftwareLink() {
 510+ return "[http://www.mysql.com/ MySQL]";
 511+ }
 512+
 513+ function getServerVersion() {
 514+ }
 515+
 516+ function ping() {
 517+ return true;
 518+ }
 519+
 520+ function getLag() {
 521+ return 0;
 522+ }
 523+
 524+ function getStatus($which="%") {
 525+ return true;
 526+ }
 527+
 528+ function maxListLen() {
 529+ return 0;
 530+ }
 531+
 532+ function encodeBlob($b) {
 533+ return $b;
 534+ }
 535+
 536+ function decodeBlob($b) {
 537+ return $b;
 538+ }
 539+
 540+ public function setTimeout( $timeout ) {
 541+ }
 542+
 543+ function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) {
 544+ return null;
 545+ }
 546+
 547+ function sourceStream( $fp, $lineCallback = false, $resultCallback = false ) {
 548+ return true;
 549+ }
 550+
 551+
 552+ protected function replaceVars( $ins ) {
 553+ return true;
 554+ }
 555+
 556+ protected function tableNameCallback( $matches ) {
 557+ }
 558+
 559+ /*
 560+ * Build a concatenation list to feed into a SQL query
 561+ */
 562+ function buildConcat( $stringList ) {
 563+ return true;
 564+ }
 565+}
Index: trunk/extensions/Offline/Offline.aliases.php
@@ -0,0 +1,8 @@
 2+<?php
 3+$aliases = array();
 4+
 5+/** English */
 6+$aliases['en'] = array(
 7+ 'Offline' => array( 'Offline' ),
 8+);
 9+
Index: trunk/extensions/Offline/Offline.php
@@ -0,0 +1,57 @@
 2+<?php
 3+$wgExtensionCredits['other'][] = array(
 4+ 'path' => __FILE__,
 5+ 'name' => 'Wikipedia Offline Patch',
 6+ 'author' => 'Adam Wight',
 7+ 'status' => 'beta',
 8+ 'url' => 'http://code.google.com/p/wikipedia-offline-patch',
 9+ 'version' => '0.6.1',
 10+ 'descriptionmsg' => 'offline_desc'
 11+ );
 12+
 13+$dir = dirname(__FILE__);
 14+$wgExtensionMessagesFiles['Offline'] = $dir.'/Offline.i18n.php';
 15+$wgExtensionAliasesFiles['Offline'] = $dir.'/Offline.aliases.php';
 16+
 17+$wgExtensionFunctions[] = 'wfOfflineInit';
 18+
 19+$wgSpecialPages['Offline'] = 'SpecialOffline';
 20+$wgSpecialPageGroups['Offline'] = 'wiki'; // XXX is not the key?
 21+
 22+
 23+$wgAutoloadClasses['DatabaseBz2'] = $dir.'/DatabaseBz2.php';
 24+$wgAutoloadClasses['SearchBz2'] = $dir.'/SearchBz2.php';
 25+$wgAutoloadClasses['SpecialOffline'] = $dir.'/SpecialOffline.php';
 26+
 27+
 28+function wfOfflineInit() {
 29+ global $wgDBservers, $wgOfflineWikiPath;
 30+
 31+// TODO -> mediawiki:
 32+ if ( !$wgDBservers ) {
 33+ global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, $wgDBtype, $wgDebugDumpSql;
 34+ $wgDBservers = array(array(
 35+ 'host' => $wgDBserver,
 36+ 'user' => $wgDBuser,
 37+ 'password' => $wgDBpassword,
 38+ 'dbname' => $wgDBname,
 39+ 'type' => $wgDBtype,
 40+ 'load' => 1,
 41+ 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
 42+ ));
 43+ }
 44+
 45+
 46+ // Our dump fetch is installed as the fallback to existing dbs.
 47+ // Dump reader will be called through a very single-minded sql api.
 48+ //$wgDBservers[] = array( // fixme: you can only do this if your primary db will successfully connect().
 49+ $wgDBservers[] = array(
 50+ 'dbname' => $wgOfflineWikiPath,
 51+ 'type' => 'bz2',
 52+ 'load' => 1,
 53+ 'host' => false,
 54+ 'user' => false,
 55+ 'flags' => false,
 56+ 'password' => false,
 57+ );
 58+}
Index: trunk/extensions/Offline/SearchBz2.php
@@ -0,0 +1,106 @@
 2+<?php
 3+/**
 4+ * Interface to search backup dump data using its index.
 5+ * @file
 6+ * @ingroup Search
 7+ */
 8+
 9+/**
 10+ * Search engine hook
 11+ * @ingroup Search
 12+ */
 13+class SearchBz2 extends SearchEngine {
 14+ var $strictMatching = true;
 15+ static $mMinSearchLength;
 16+
 17+ function __construct( $db ) {
 18+ $this->db = $db;
 19+ }
 20+
 21+ /**
 22+ * Parse the user's query and transform it into an SQL fragment which will
 23+ * become part of a WHERE clause
 24+ */
 25+ function parseQuery( $filteredText, $fulltext ) {
 26+ return $filteredText;
 27+ }
 28+
 29+ /**
 30+ * Perform a full text search query and return a result set.
 31+ *
 32+ * @param $term String: raw search term
 33+ * @return MySQLSearchResultSet
 34+ */
 35+ function searchText( $term ) {
 36+ return $this->searchInternal( $term, true );
 37+ }
 38+
 39+ /**
 40+ * Perform a title-only search query and return a result set.
 41+ *
 42+ * @param $term String: raw search term
 43+ * @return Bz2SearchResultSet
 44+ */
 45+ function searchTitle( $term ) {
 46+ return $this->searchInternal( $term, false );
 47+ }
 48+
 49+ protected function searchInternal( $term, $fulltext ) {
 50+ global $wgCountTotalSearchHits;
 51+
 52+ require_once(dirname(__FILE__).'/DumpReader.php');
 53+ $results = DumpReader::index_search($term);
 54+
 55+ return new Bz2SearchResultSet( $results, $term);
 56+ }
 57+// TODO
 58+// function queryNamespaces() {
 59+}
 60+
 61+/**
 62+ * @ingroup Search
 63+ */
 64+class Bz2SearchResultSet extends SearchResultSet {
 65+ function Bz2SearchResultSet($results, $terms) {
 66+ $this->mTotalHits = count($results);
 67+ $this->mResultSet = $results;
 68+ $this->mTerms = $terms;
 69+ }
 70+
 71+ function termMatches() {
 72+ return $this->mTerms;
 73+ }
 74+
 75+ function numRows() {
 76+ return $this->getTotalHits();
 77+ }
 78+
 79+ function getTotalHits() {
 80+ return $this->mTotalHits;
 81+ }
 82+
 83+ function next() {
 84+ if ($this->mResultSet === false || count($this->mResultSet) < 1)
 85+ return false;
 86+
 87+ $result = array_pop($this->mResultSet);
 88+ if ($result === false)
 89+ return false;
 90+
 91+ list ($bzfile, $title) = $result;
 92+
 93+ $matches = array();
 94+ $row = new stdClass();
 95+ if (preg_match('/([^:]*):([^:]+)$/', $title, $matches)) {
 96+//TODO lookup index
 97+ $row->page_namespace = $matches[1];
 98+ $row->page_title = $matches[2];
 99+ } else {
 100+ $row->page_namespace = NS_MAIN;
 101+ $row->page_title = $title;
 102+ }
 103+
 104+//wfDebug('GOT'.$row->page_namespace .' : '. $row->page_title .'('.$bzfile.')');
 105+ return new SearchResult($row);
 106+ }
 107+}
Index: trunk/extensions/Offline/SpecialOffline.php
@@ -0,0 +1,166 @@
 2+<?php
 3+/**
 4+ * Special:Offline
 5+ * Configuration and status reporting for standalone mode.
 6+ * Checks that dependencies are installed correctly and the database
 7+ * dumps have been prepared.
 8+ */
 9+
 10+$wgExtensionCredits['specialpage'][] = array(
 11+ 'path' => __FILE__,
 12+ 'name' => 'Wikipedia Offline Patch',
 13+ 'author' => 'Adam Wight',
 14+ 'status' => 'beta',
 15+ 'url' => 'http://code.google.com/p/wikipedia-offline-patch',
 16+ 'version' => '0.6',
 17+ 'descriptionmsg' => 'offline_special_desc'
 18+ );
 19+
 20+$dir = dirname(__FILE__);
 21+$wgExtensionMessagesFiles['SpecialOffline'] = $dir.'/SpecialOffline.i18n.php';
 22+
 23+class SpecialOffline extends SpecialPage
 24+{
 25+ function SpecialOffline() {
 26+ parent::__construct('offline' /*, 'editinterface' */);
 27+ }
 28+
 29+ function execute($param) {
 30+ global $wgOut, $wgTitle;
 31+
 32+ require_once(dirname(__FILE__).'/DumpReader.php');
 33+
 34+ $this->setHeaders();
 35+ $this->outputHeader();
 36+
 37+ $this->runTests();
 38+
 39+ //TODO report and explain wgOfflineIgnoreLiveData
 40+ }
 41+
 42+ function runTests() {
 43+ global $wgOut, $wgTitle;
 44+
 45+ $wgOut->wrapWikiMsg('<h1>$1</h1>', 'offline_heading_status');
 46+
 47+ $wgOut->addHTML('<ul>');
 48+ // lookup a real article in the index can be searched
 49+ $results = DumpReader::index_search(wfMsg('offline_test_article'));
 50+ if (count($results) > 0)
 51+ list ($bz_file, $entry_title) = $results[0];
 52+
 53+ $test_index = isset($bz_file);
 54+ $this->printTest($test_index, 'offline_index_test');
 55+ if (!$test_index) {
 56+ $this->diagnoseIndex();
 57+ return;
 58+ }
 59+
 60+ // tests that bz2 dumpfiles can be opened and read
 61+ $xml = DumpReader::load_bz($bz_file, $entry_title);
 62+ $test_bz = isset($xml);
 63+ $this->printTest($test_bz, 'offline_bzload_test');
 64+ if (!$test_bz) {
 65+ $this->diagnoseBzload($bz_file);
 66+ return;
 67+ }
 68+ //report subdirectory setting
 69+// if (substr($bz_file, 0, 1) == 'x') {
 70+// $subdir = dirname($bz_file); //TODO strip absolute components if needed
 71+// $wgOut->addWikiMsg('offline_subdir-status', $subdir);
 72+// $wgOut->addHTML(
 73+// '<label>' . wfMsg('offline_change-subdir') .
 74+// '<input type=text size=20 name="subdir" value="'.$subdir.'">
 75+// <input type=submit name="subdir" value="Change">
 76+// </label/>'
 77+// );
 78+// }
 79+
 80+ // TODO report language settings and availabilities
 81+
 82+ //test that a specific article can be loaded
 83+ $article_wml = DumpReader::load_article($entry_title);
 84+ $test_article = isset($article_wml);
 85+ $this->printTest($test_article, 'offline_article_test');
 86+ if (!$test_article) {
 87+ //TODO diagnose
 88+ return;
 89+ }
 90+ //TODO test that the wml has not been padded or truncated
 91+
 92+ //test that our handler is still hooked in
 93+ $mw_api_article = new Article(Title::newFromText($entry_title));
 94+ $mw_api_article->loadContent();
 95+ $content = $mw_api_article->getContent();
 96+//wfDebug('got '.strlen($mw_api_article->mContent).' bytes of wml from cache');
 97+ $test_hooks = $mw_api_article->mContentLoaded;
 98+ // TODO false positive
 99+ $this->printTest($test_hooks, 'offline_hooks_test');
 100+ if (!$test_hooks) {
 101+ $this->diagnoseHooks();
 102+ return;
 103+ }
 104+
 105+ //TODO test Templates
 106+
 107+ $wgOut->addHTML('</ul>');
 108+
 109+ $wgOut->wrapWikiMsg('<i>$1</i>', 'offline_all_tests_pass');
 110+ //TODO div collapse or load on demand
 111+ //$wgOut->addWikiText($content);
 112+ }
 113+
 114+ function diagnoseIndex() {
 115+ global $wgOut, $wgOfflineWikiPath;
 116+
 117+ if (!isset($wgOfflineWikiPath)) {
 118+ $this->printDiagnostic('offlinewikipath_not_configured');
 119+ }
 120+ elseif (!is_dir($wgOfflineWikiPath)) {
 121+ $this->printDiagnostic(array('offlinewikipath_not_found', $wgOfflineWikiPath));
 122+ }
 123+ elseif (!is_dir("$wgOfflineWikiPath/db") || !file_exists("$wgOfflineWikiPath/db/termlist.DB")) {
 124+ $this->printDiagnostic(array('offline_dbdir_not_found', $wgOfflineWikiPath));
 125+ } else {
 126+ $this->printDiagnostic('offline_unknown_index_error');
 127+ }
 128+ }
 129+
 130+ function diagnoseBzload($bz_file) {
 131+ global $wgOut, $wgOfflineWikiPath;
 132+
 133+ $full_path = $wgOfflineWikiPath.'/'.$bz_file;
 134+ if (!extension_loaded('bz2')) {
 135+ $this->printDiagnostic('offline_bz2_ext_needed');
 136+ }
 137+ if (!file_exists($full_path)) {
 138+ $this->printDiagnostic(array('offline_bz2_file_gone', $full_path));
 139+ }
 140+ else {
 141+ $this->printDiagnostic(array('offline_unknown_bz2_error', $full_path));
 142+ }
 143+ }
 144+
 145+ function diagnoseHooks() {
 146+ global $wgOut, $wgMemc;
 147+ $key = wfMemcKey('offline','trial');
 148+ $wgMemc->set($key, true);
 149+ if (!$wgMemc->get($key)) {
 150+ $this->printDiagnostic('offline_cache_needed');
 151+ }
 152+ // check that passing revisiontext through cache will work
 153+ }
 154+
 155+ function printTest($bool, $msg) {
 156+ global $wgOut;
 157+ if ($bool)
 158+ $wgOut->wrapWikiMsg('<div class="result-pass"><li>$1</div>', $msg.'_pass');
 159+ else
 160+ $wgOut->wrapWikiMsg('<div class="error"><li>$1</div>', $msg.'_fail');
 161+ }
 162+
 163+ function printDiagnostic($msg) {
 164+ global $wgOut;
 165+ $wgOut->wrapWikiMsg('<div class="errorbox">$1</div>', $msg);
 166+ }
 167+}
Index: trunk/extensions/Offline/README.txt
@@ -0,0 +1,42 @@
 2+This extension provides an offline viewing mode for Wikipedia dumps, or
 3+any other wiki.
 4+
 5+Be aware that you will need a Wikipedia dump and the corresponding index,
 6+see the project page if you need help:
 7+
 8+ For a recent English, compressed backup of all article text (6.3Gb
 9+ once you build an index):
 10+http://download.wikimedia.org/enwiki/20101011/enwiki-20101011-pages-articles.xml.bz2
 11+
 12+ For a small testing database (or if you speak Tagalog), try this
 13+http://wikipedia-offline-patch.googlecode.com/files/wiki-splits-tl.zip
 14+
 15+ or browse many other languages and wiki projects:
 16+http://dumps.wikimedia.org/backup-index.html
 17+
 18+
 19+
 20+The project page has binary distributions for macos, windows, and linux,
 21+which include a webserver and supporting libraries.
 22+ http://code.google.com/p/wikipedia-offline-patch
 23+
 24+There is an unusual dependency: the Xapian indexing library and its PHP
 25+bindings. Also, you will have to configure some type of revision_text
 26+caching by setting $wgRevisionCacheExpiry and $wgCacheType.
 27+
 28+
 29+= Acknowledgements =
 30+The current author is Adam Wight, who can be reached through the
 31+wikipedia-offline-patch project page or at adamw on ludd.net.
 32+
 33+Thanassis Tsiodras has a great page explaining how to build a working
 34+offline wikipedia:
 35+ http://users.softlab.ece.ntua.gr/~ttsiod/buildWikipediaOffline.html
 36+
 37+Wikipedia Offline Client was the starting point for this project.
 38+ https://projects.fslab.de/projects/wpofflineclient/
 39+
 40+MediaWiki developers contributed valuable insight.
 41+
 42+
 43+This software and its source code are licensed as GPL.
Index: trunk/extensions/Offline/DumpReader.php
@@ -0,0 +1,135 @@
 2+<?php
 3+class DumpReader
 4+{
 5+ #
 6+ # open the index files and lookup the chunk. Load article source.
 7+ #
 8+ static function load_article($title)
 9+ {
 10+ $article_wml = null;
 11+ $results = self::index_search($title);
 12+ if (count($results) > 0) {
 13+ $archive_file = $results[0][0];
 14+ $title = $results[0][1];
 15+
 16+ $article_wml = self::load_all_data($title, $archive_file);
 17+ } else {
 18+ $article_wml = ""; //TODO or null?
 19+ }
 20+ $article_wml = htmlspecialchars_decode($article_wml);
 21+ return $article_wml;
 22+ }
 23+
 24+ static function load_all_data($title, $file_name)
 25+ {
 26+ wfDebug("loading chunk [$file_name] to find article [$title]");
 27+ $article_wml = "";
 28+ $matches = array();
 29+ $all_chunk_data = self::load_bz($file_name);
 30+ if (preg_match("/<title>".preg_quote($title, '/')."<\/title>.*?<text[^>]*>(.*)/s",
 31+ $all_chunk_data, $matches))
 32+ {
 33+ $all_chunk_data = $matches[1];
 34+ while (isset($all_chunk_data)) {
 35+ $end_pos = strpos($all_chunk_data, '</text>');
 36+ if ($end_pos !== FALSE) {
 37+ $article_wml .= substr($all_chunk_data, 0, $end_pos);
 38+ break;
 39+ }
 40+ $article_wml .= $all_chunk_data;
 41+
 42+ wfDebug('continuing into next bz2 chunk');
 43+ $file_name = self::increment_file($file_name);
 44+ $all_chunk_data = self::load_bz($file_name);
 45+ }
 46+ }
 47+ return $article_wml;
 48+ }
 49+
 50+ #
 51+ # open chosen bz2 split, decompress and return
 52+ # TODO begin bzcat at chunk, let pipe load in the bg process.
 53+ #
 54+ static function load_bz($file_name)
 55+ {
 56+ global $wgOfflineWikiPath;
 57+ $path = "$wgOfflineWikiPath/$file_name";
 58+ if (strlen($file_name) < 1) return null; #strange that bzopen doesn't choke on dir.
 59+ $bz = bzopen($path, "r");
 60+ if (!$bz) return null;
 61+
 62+ $out = "";
 63+ while ($bz && !feof($bz)) {
 64+ $out .= bzread($bz, 8192);
 65+ }
 66+ bzclose($bz);
 67+ return $out;
 68+ }
 69+
 70+ #
 71+ # use the index files
 72+ #
 73+ static function index_search($title)
 74+ {
 75+ $title = strtr($title, '_', ' ');
 76+ $title = strtolower(trim($title));
 77+ #wfDebug("looking up word [$title]");
 78+
 79+ try {
 80+ require_once("xapian.php");
 81+ global $wgOfflineWikiPath;
 82+ $db = new XapianDatabase("$wgOfflineWikiPath/db");
 83+ #$qp = new XapianQueryParser();
 84+ #$qp->set_database($db);
 85+ #$stemmer = new XapianStem("english");
 86+ #$qp->set_stemmer($stemmer);
 87+ #$query = $qp->parse_query($title);
 88+ $query = new XapianQuery($title);
 89+ $enquire = new XapianEnquire($db);
 90+ $enquire->set_query($query);
 91+ $matches = $enquire->get_mset(0, 25);
 92+
 93+ if (0 /*SCORING*/) {
 94+ $scores = array();
 95+ for ($i = $matches->begin(); !$i->equals($matches->end()); $i->next())
 96+ {
 97+ $row = $i->get_document();
 98+ $str = $i->get_percent()."% [".$row->get_data()."]";
 99+ $scores[] = $str;
 100+ if (1/*DEBUG*/) wfDebug("$str\n");
 101+ }
 102+ }
 103+
 104+ $result = array();
 105+ for ($i = $matches->begin(); !$i->equals($matches->end()); $i->next())
 106+ {
 107+ $entry = $i->get_document()->get_data();
 108+ $fsep = strpos($entry, ':');
 109+ $row = array(substr($entry, 0, $fsep), substr($entry, $fsep + 1));
 110+ $result[] = $row;
 111+ }
 112+ # not in Xapian 1.0.X
 113+ #$db->close();
 114+
 115+ return $result;
 116+
 117+ } catch (Exception $e) {
 118+ wfDebug(__METHOD__.':'.$e->getMessage());
 119+ return null;
 120+ }
 121+ }
 122+
 123+ static function increment_file($fname)
 124+ {
 125+ // XXX assuming a lot
 126+ $matches = array();
 127+// TODO fails on 99 ...
 128+ if (preg_match('/(.*?)([1-9][0-9]*)(.*?)$/', $fname, $matches)) {
 129+ $i = $matches[2];
 130+ return preg_replace("/$i/", $i + 1, $fname);
 131+ } else {
 132+ wfDebug('Failed to grok your wiki-splits filename pattern');
 133+ return false;
 134+ }
 135+ }
 136+}

Comments

#Comment by Raymond (talk | contribs)   16:05, 21 December 2011

Please add message documentation for the newly added messages. Thanks.

#Comment by SPQRobin (talk | contribs)   18:54, 22 December 2011

The files need svn:eol-style native property, see Subversion/auto-props.

Status & tagging log