cvs: php4 /ext/mnogosearch index.php php_mnogo.c php_mnogo.h
| From: | Sergey Kartashoff | Date: | Sat, 03 Aug 2002 08:53:26 +0000 |
| Subject: | cvs: php4 /ext/mnogosearch index.php php_mnogo.c php_mnogo.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-13095@lists.php.net to get a copy of this message | ||
gluke Sat Aug 3 04:53:26 2002 EDT
Modified files:
/php4/ext/mnogosearch index.php php_mnogo.c php_mnogo.h
Log:
- An Udm_Make_Excerpt function has been added to mnogosearch extension
to support excerpts while using with mnogosearch-3.2.5 or later.
Index: php4/ext/mnogosearch/index.php
diff -u php4/ext/mnogosearch/index.php:1.12 php4/ext/mnogosearch/index.php:1.13
--- php4/ext/mnogosearch/index.php:1.12 Sat Jun 29 06:42:52 2002
+++ php4/ext/mnogosearch/index.php Sat Aug 3 04:53:25 2002
@@ -2,7 +2,7 @@
/*
$Source: /usr/repository/php4/ext/mnogosearch/index.php,v $
- $Id: index.php,v 1.12 2002/06/29 10:42:52 gluke Exp $
+ $Id: index.php,v 1.13 2002/08/03 08:53:25 gluke Exp $
*/
/* mnoGoSearch-php-lite v.1.3
@@ -970,6 +970,10 @@
}
for($i=0;$i<$rows;$i++){
+ if (Udm_Api_Version() >= 30204) {
+ $excerpt_flag=Udm_Make_Excerpt($udm_agent, $res, $i);
+ }
+
$ndoc=Udm_Get_Res_Field($res,$i,UDM_FIELD_ORDER);
$rating=Udm_Get_Res_Field($res,$i,UDM_FIELD_RATING);
$url=Udm_Get_Res_Field($res,$i,UDM_FIELD_URL);
Index: php4/ext/mnogosearch/php_mnogo.c
diff -u php4/ext/mnogosearch/php_mnogo.c:1.60 php4/ext/mnogosearch/php_mnogo.c:1.61
--- php4/ext/mnogosearch/php_mnogo.c:1.60 Fri Aug 2 03:22:18 2002
+++ php4/ext/mnogosearch/php_mnogo.c Sat Aug 3 04:53:25 2002
@@ -1,5 +1,5 @@
/* $Source: /usr/repository/php4/ext/mnogosearch/php_mnogo.c,v $ */
-/* $Id: php_mnogo.c,v 1.60 2002/08/02 07:22:18 gluke Exp $ */
+/* $Id: php_mnogo.c,v 1.61 2002/08/03 08:53:25 gluke Exp $ */
/*
+----------------------------------------------------------------------+
@@ -149,7 +149,8 @@
PHP_FE(udm_crc32, NULL)
#endif
#if UDM_VERSION_ID >= 30204
- PHP_FE(udm_parse_query_string,NULL)
+ PHP_FE(udm_parse_query_string, NULL)
+ PHP_FE(udm_make_excerpt, NULL)
#endif
#endif
@@ -1499,6 +1500,58 @@
str = Z_STRVAL_PP(yystr);
UdmParseQueryString(Agent,&Agent->Conf->Vars,str);
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int udm_make_excerpt(int agent, int res, int row)
+ Perform search */
+DLEXPORT PHP_FUNCTION(udm_make_excerpt)
+{
+ pval ** yyagent, **yyres, **yyrow_num;
+ UDM_RESULT * Res;
+ UDM_AGENT * Agent;
+ int id=-1, row;
+
+ switch(ZEND_NUM_ARGS()){
+ case 3: {
+ if (zend_get_parameters_ex(3, &yyagent, &yyres, &yyrow_num)==FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string_ex(yyrow_num);
+ row=atoi(Z_STRVAL_PP(yyrow_num));
+ }
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+ ZEND_FETCH_RESOURCE(Agent, UDM_AGENT *, yyagent, id, "mnoGoSearch-Agent", le_link);
+ ZEND_FETCH_RESOURCE(Res, UDM_RESULT *, yyres, -1, "mnoGoSearch-Result", le_res);
+
+ if(row<Res->num_rows){
+ const char *al;
+ char *Excerpt;
+
+ al = UdmVarListFindStr(&(Res->Doc[row].Sections), "URL", "");
+ UdmVarListReplaceInt(&(Res->Doc[row].Sections), "STORED_ID", UdmCRC32(al,
strlen(al)));
+ Excerpt = UdmExcerptDoc(Agent, Res, &(Res->Doc[row]), 256);
+
+ if (Excerpt != NULL) {
+ char *HlExcerpt = UdmHlConvert(&Res->WWList, Excerpt, Agent->Conf->lcs,
Agent->Conf->bcs);
+ UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",1);
+ UdmVarListReplaceStr(&(Res->Doc[row].Sections),"body",HlExcerpt);
+ UDM_FREE(HlExcerpt);
+ UDM_FREE(Excerpt);
+ } else {
+ UdmVarListReplaceInt(&(Res->Doc[row].Sections),"ST",0);
+ RETURN_FALSE;
+ }
+ }else{
+ php_error(E_WARNING,"%s(): row number too large", get_active_function_name(TSRMLS_C));
+ RETURN_FALSE;
+ }
+
RETURN_TRUE;
}
/* }}} */
Index: php4/ext/mnogosearch/php_mnogo.h
diff -u php4/ext/mnogosearch/php_mnogo.h:1.18 php4/ext/mnogosearch/php_mnogo.h:1.19
--- php4/ext/mnogosearch/php_mnogo.h:1.18 Thu Jun 6 01:45:45 2002
+++ php4/ext/mnogosearch/php_mnogo.h Sat Aug 3 04:53:26 2002
@@ -1,5 +1,5 @@
/* $Source: /usr/repository/php4/ext/mnogosearch/php_mnogo.h,v $ */
-/* $Id: php_mnogo.h,v 1.18 2002/06/06 05:45:45 gluke Exp $ */
+/* $Id: php_mnogo.h,v 1.19 2002/08/03 08:53:26 gluke Exp $ */
/*
+----------------------------------------------------------------------+
@@ -67,6 +67,7 @@
#endif
#if UDM_VERSION_ID >= 30204
DLEXPORT PHP_FUNCTION(udm_parse_query_string);
+DLEXPORT PHP_FUNCTION(udm_make_excerpt);
#endif
#endif