mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
- An Udm_Make_Excerpt function has been added to mnogosearch extension
to support excerpts while using with mnogosearch-3.2.5 or later.
This commit is contained in:
parent
c90764d753
commit
37e58c21b2
@ -970,6 +970,10 @@ if(($errno=Udm_Errno($udm_agent))>0){
|
|||||||
}
|
}
|
||||||
|
|
||||||
for($i=0;$i<$rows;$i++){
|
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);
|
$ndoc=Udm_Get_Res_Field($res,$i,UDM_FIELD_ORDER);
|
||||||
$rating=Udm_Get_Res_Field($res,$i,UDM_FIELD_RATING);
|
$rating=Udm_Get_Res_Field($res,$i,UDM_FIELD_RATING);
|
||||||
$url=Udm_Get_Res_Field($res,$i,UDM_FIELD_URL);
|
$url=Udm_Get_Res_Field($res,$i,UDM_FIELD_URL);
|
||||||
|
@ -149,7 +149,8 @@ function_entry mnogosearch_functions[] = {
|
|||||||
PHP_FE(udm_crc32, NULL)
|
PHP_FE(udm_crc32, NULL)
|
||||||
#endif
|
#endif
|
||||||
#if UDM_VERSION_ID >= 30204
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1502,6 +1503,58 @@ DLEXPORT PHP_FUNCTION(udm_parse_query_string)
|
|||||||
RETURN_TRUE;
|
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;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* {{{ proto int udm_find(int agent, string query)
|
/* {{{ proto int udm_find(int agent, string query)
|
||||||
|
@ -67,6 +67,7 @@ DLEXPORT PHP_FUNCTION(udm_crc32);
|
|||||||
#endif
|
#endif
|
||||||
#if UDM_VERSION_ID >= 30204
|
#if UDM_VERSION_ID >= 30204
|
||||||
DLEXPORT PHP_FUNCTION(udm_parse_query_string);
|
DLEXPORT PHP_FUNCTION(udm_parse_query_string);
|
||||||
|
DLEXPORT PHP_FUNCTION(udm_make_excerpt);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user