forked from anhyeuviolet/module-videos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
52 lines (42 loc) · 1.81 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @Project VIDEOS 4.x
* @Author KENNYNGUYEN (nguyentiendat713@gmail.com)
* @Website tradacongnghe.com
* @License GNU/GPL version 2 or any later version
* @Createdate Oct 08, 2015 10:47:41 AM
*/
if( ! defined( 'NV_IS_MOD_SEARCH' ) ) die( 'Stop!!!' );
$db->sqlreset()
->select( 'COUNT(*)' )
->from( NV_PREFIXLANG . '_' . $m_values['module_data'] . '_rows r')
->join( 'INNER JOIN ' . NV_PREFIXLANG . '_' . $m_values['module_data'] . '_bodytext c ON (r.id=c.id)' )
->where('(' . nv_like_logic( 'r.title', $dbkeywordhtml, $logic ) . ' OR ' . nv_like_logic( 'r.hometext', $dbkeyword, $logic ) . ' OR ' . nv_like_logic( 'c.bodytext', $dbkeyword, $logic ) . ') AND r.status= 1' );
$num_items = $db->query( $db->sql() )->fetchColumn();
if( $num_items )
{
$array_cat_alias = array();
$array_cat_alias[0] = 'other';
$sql_cat = 'SELECT catid, alias FROM ' . NV_PREFIXLANG . '_' . $m_values['module_data'] . '_cat';
$re_cat = $db->query( $sql_cat );
while( list( $catid, $alias ) = $re_cat->fetch( 3 ) )
{
$array_cat_alias[$catid] = $alias;
}
$link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=';
$db->select( 'r.id, r.title, r.alias, r.catid, r.hometext, c.bodytext' )
->order( 'publtime DESC' )
->limit( $limit )
->offset( ( $page - 1 ) * $limit );
$result = $db->query( $db->sql() );
while( list( $id, $tilterow, $alias, $catid, $hometext, $bodytext ) = $result->fetch( 3 ) )
{
$content = $hometext . $bodytext;
$url = $link . $array_cat_alias[$catid] . '/' . $alias . '-' . $id . $global_config['rewrite_exturl'];
$result_array[] = array(
'link' => $url,
'title' => BoldKeywordInStr( $tilterow, $key, $logic ),
'content' => BoldKeywordInStr( $content, $key, $logic )
);
}
}