diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mnogosearch/README | 4 | ||||
-rw-r--r-- | ext/mnogosearch/php_mnogo.c | 74 | ||||
-rw-r--r-- | ext/mnogosearch/php_mnogo.h | 1 | ||||
-rw-r--r-- | ext/mnogosearch/test.php | 14 |
4 files changed, 86 insertions, 7 deletions
diff --git a/ext/mnogosearch/README b/ext/mnogosearch/README index 3f547838d1..bb9e329ca8 100644 --- a/ext/mnogosearch/README +++ b/ext/mnogosearch/README @@ -2,7 +2,7 @@ $Source$ $Id$ mnoGoSearch extension module for PHP4. -Basic mnoGoSearch function implementation. +mnoGoSearch function implementation. If used with mysql you should not use bundled mysql library in the php distribution. You should use native mysql @@ -12,7 +12,7 @@ library. To do this you should compile php with specefying mysql-dir TODO ---- -1. Implement more mnoGoSearch functions. +1. Implement all mnoGoSearch functions. 2. Fix config.m4 to detect whether mnoGoSearch is actually installed. Currently there is no any checking. ./configure just trust that mnoGoSearch diff --git a/ext/mnogosearch/php_mnogo.c b/ext/mnogosearch/php_mnogo.c index 6001a0a535..97b2dabeae 100644 --- a/ext/mnogosearch/php_mnogo.c +++ b/ext/mnogosearch/php_mnogo.c @@ -51,6 +51,12 @@ #define UDM_PARAM_STOPTABLE 7 #define UDM_PARAM_STOPFILE 8 +/* udm_add_search_limit constants */ +#define UDM_LIMIT_URL 1 +#define UDM_LIMIT_TAG 2 +#define UDM_LIMIT_LANG 3 +#define UDM_LIMIT_CAT 4 + #define UDM_TRACK_ENABLED 1 #define UDM_TRACK_DISABLED 0 @@ -66,6 +72,7 @@ static int le_link,le_res; function_entry mnogosearch_functions[] = { PHP_FE(udm_alloc_agent, NULL) PHP_FE(udm_set_agent_param, NULL) + PHP_FE(udm_add_search_limit, NULL) PHP_FE(udm_free_agent, NULL) PHP_FE(udm_errno, NULL) @@ -133,6 +140,12 @@ DLEXPORT PHP_MINIT_FUNCTION(mnogosearch) REGISTER_LONG_CONSTANT("UDM_PARAM_STOPTABLE",UDM_PARAM_STOPTABLE,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("UDM_PARAM_STOPFILE",UDM_PARAM_STOPFILE,CONST_CS | CONST_PERSISTENT); + /* udm_add_search_limit constants */ + REGISTER_LONG_CONSTANT("UDM_LIMIT_CAT",UDM_LIMIT_CAT,CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("UDM_LIMIT_URL",UDM_LIMIT_URL,CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("UDM_LIMIT_TAG",UDM_LIMIT_TAG,CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("UDM_LIMIT_LANG",UDM_LIMIT_LANG,CONST_CS | CONST_PERSISTENT); + /* udm_get_res_param constants */ REGISTER_LONG_CONSTANT("UDM_PARAM_FOUND",UDM_PARAM_FOUND,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("UDM_PARAM_NUM_ROWS",UDM_PARAM_NUM_ROWS,CONST_CS | CONST_PERSISTENT); @@ -354,7 +367,66 @@ DLEXPORT PHP_FUNCTION(udm_set_agent_param) break; default: - php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown agent parameter"); + php_error(E_WARNING,"Udm_Set_Agent_Param: Unknown agent session parameter"); + RETURN_FALSE; + break; + } + RETURN_TRUE; +} +/* }}} */ + + +/* {{{ proto int udm_add_search_limit(int agent, int var, string val) + Add mnoGoSearch search restrictions */ +DLEXPORT PHP_FUNCTION(udm_add_search_limit) +{ + pval **yyagent, **yyvar, **yyval; + char *val; + int var; + UDM_AGENT * Agent; + + switch(ZEND_NUM_ARGS()){ + + case 3: + if(zend_get_parameters_ex(3,&yyagent,&yyvar,&yyval)==FAILURE){ + RETURN_FALSE; + } + convert_to_long_ex(yyvar); + convert_to_string_ex(yyval); + ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, -1, "mnoGoSearch-agent", le_link); + var = (*yyvar)->value.lval; + val = (*yyval)->value.str.val; + + break; + + default: + WRONG_PARAM_COUNT; + break; + } + + switch(var){ + case UDM_LIMIT_URL: + UdmAddURLLimit(Agent->Conf,val); + + break; + + case UDM_LIMIT_TAG: + UdmAddTagLimit(Agent->Conf,val); + + break; + + case UDM_LIMIT_LANG: + UdmAddLangLimit(Agent->Conf,val); + + break; + + case UDM_LIMIT_CAT: + UdmAddCatLimit(Agent->Conf,val); + + break; + + default: + php_error(E_WARNING,"Udm_Add_Search_Limit: Unknown search limit parameter"); RETURN_FALSE; break; } diff --git a/ext/mnogosearch/php_mnogo.h b/ext/mnogosearch/php_mnogo.h index 897b564169..4603d8fc27 100644 --- a/ext/mnogosearch/php_mnogo.h +++ b/ext/mnogosearch/php_mnogo.h @@ -48,6 +48,7 @@ DLEXPORT PHP_MINFO_FUNCTION(mnogosearch); DLEXPORT PHP_FUNCTION(udm_alloc_agent); DLEXPORT PHP_FUNCTION(udm_set_agent_param); +DLEXPORT PHP_FUNCTION(udm_add_search_limit); DLEXPORT PHP_FUNCTION(udm_free_agent); DLEXPORT PHP_FUNCTION(udm_error); diff --git a/ext/mnogosearch/test.php b/ext/mnogosearch/test.php index 0f99703fb0..2dd86c2a1e 100644 --- a/ext/mnogosearch/test.php +++ b/ext/mnogosearch/test.php @@ -35,14 +35,20 @@ Udm_Set_Agent_Param($udm,UDM_PARAM_CACHE_MODE,UDM_CACHE_DISABLED); Udm_Set_Agent_Param($udm,UDM_PARAM_TRACK_MODE,UDM_TRACK_DISABLED); Udm_Set_Agent_Param($udm,UDM_PARAM_CHARSET,"koi8-r"); - Udm_Set_Agent_Param($udm,UDM_PARAM_STOPTABLE,"stopwords"); +// Udm_Set_Agent_Param($udm,UDM_PARAM_STOPTABLE,"stopword"); // Udm_Set_Agent_Param($udm,UDM_PARAM_STOPFILE,"stop.txt"); + +// Stage 3: add search limits +// Udm_Add_Search_Limit($udm,UDM_LIMIT_URL,"http://www.mydomain.com/%"); +// Udm_Add_Search_Limit($udm,UDM_LIMIT_TAG,"01"); +// Udm_Add_Search_Limit($udm,UDM_LIMIT_CAT,"01"); +// Udm_Add_Search_Limit($udm,UDM_LIMIT_LANG,"en"); -// Stage 3: perform search +// Stage 4: perform search $res=Udm_Find($udm,$q); -// Stage 4: display results +// Stage 5: display results // Check error code if(($errno=Udm_Errno($udm))>0){ @@ -77,7 +83,7 @@ Udm_Free_Res($res); } -//Stage 5: free UdmSearch agent +//Stage 6: free UdmSearch agent Udm_Free_Agent($udm); ?> |