From 7ef5e08f70859a17c62f7ddf01667f19cb1d7e76 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 29 Jan 2010 15:47:02 +0100 Subject: [PATCH] PHP extension by Wenqiang Song : make ready for external use. - added minimal doc - fixed build script to work around php/libtool issue - have the module default to Query Language (instead of AND) --- src/php/00README.txt | 20 ++++++++++++++++++++ src/php/recoll/make.sh | 11 +++++++++-- src/php/recoll/recoll.cpp | 18 ++++-------------- 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 src/php/00README.txt diff --git a/src/php/00README.txt b/src/php/00README.txt new file mode 100644 index 00000000..727da573 --- /dev/null +++ b/src/php/00README.txt @@ -0,0 +1,20 @@ +Recoll PHP extension: + + Author: Wenqiang Song (wsong.cn, google mail) + +This has minimum features for now. + +The sample/ subdirectory has a minimal script which demonstrates the +interface. + +Building the extension needs the librcl.a library (recoll-xxx/lib/librcl.a) +to have been built with PIC objects. This will be handled by the Recoll +build system in the future, but, for now, if using gcc, just add -fPIC +-DPIC to LOCALCXXFLAGS inside mk/localdefs, and run "make clean;make" inside +lib/ . For other compilers, adjust to taste :) + +The recoll/ subdirectory has the C++ code and the build script +(make.sh). You'll need to "make install" after building. + +If you want to clean up the recoll/ directory, you can run phpize --clean +in there. diff --git a/src/php/recoll/make.sh b/src/php/recoll/make.sh index efbf237f..e40e5720 100755 --- a/src/php/recoll/make.sh +++ b/src/php/recoll/make.sh @@ -1,7 +1,14 @@ #!/bin/sh phpize --clean phpize -rm aclocal.m4 -rf -autoreconf + +# The version of libtool shipped with php at this time (2010-01-29) +# is buggy (ECHO/echo typo...) +# autoreconf -i should replace them with the system versions +# Another approach would be to ship an autoconf'd version to avoid +# needing autotools on the target compile system. What a mess. +rm -f ltmain.sh libtool +rm -f aclocal.m4 +autoreconf -i ./configure --enable-recoll make -j3 diff --git a/src/php/recoll/recoll.cpp b/src/php/recoll/recoll.cpp index 3d8fddaa..143c2aff 100644 --- a/src/php/recoll/recoll.cpp +++ b/src/php/recoll/recoll.cpp @@ -122,20 +122,10 @@ PHP_METHOD(Query, query) pRclDb->setAbstractParams(-1, maxchars, ctxwords); Rcl::SearchData *sd = 0; - sd = new Rcl::SearchData(Rcl::SCLT_AND); - Rcl::SearchDataClause *clp = 0; - - // If there is no white space inside the query, then the user - // certainly means it as a phrase. - bool isreallyaphrase = false; - if (!TextSplit::hasVisibleWhite(qs)) - isreallyaphrase = true; - clp = isreallyaphrase ? - new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, qs, 0) : - new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND, qs); - - if (sd) - sd->addClause(clp); + // jf: the original implementation built an AND clause. It would + // be nice to offer an option, but the next best thing is to + // default to the query language + sd = wasaStringToRcl(qs, reason); if (!sd) { cerr << "Query string interpretation failed: " << reason << endl;