示例#1
0
    function nv_sdown_cats($_mod_table)
    {
        global $db;
        $sql = 'SELECT id, title, alias, groups_view FROM ' . $_mod_table . '_categories WHERE status=1';
        $result = $db->query($sql);
        $list = array();
        while ($row = $result->fetch()) {
            if (nv_user_in_groups($row['groups_view'])) {
                $list[$row['id']] = array('id' => $row['id'], 'title' => $row['title'], 'alias' => $row['alias']);
            }
        }
        return $list;
    }
}
$_mod_table = defined('SYS_DOWNLOAD_TABLE') ? SYS_DOWNLOAD_TABLE : NV_PREFIXLANG . '_' . $m_values['module_data'];
$list_cats = nv_sdown_cats($_mod_table);
if (!empty($list_cats)) {
    $_where = 'catid IN (' . implode(',', array_keys($list_cats)) . ')
    AND (' . nv_like_logic('title', $dbkeyword, $logic) . '
    OR ' . nv_like_logic('introtext', $dbkeyword, $logic) . ')';
    $db->sqlreset()->select('COUNT(*)')->from($_mod_table)->where($_where);
    $num_items = $db->query($db->sql())->fetchColumn();
    if ($num_items) {
        $link = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=';
        $db->select('alias, title, introtext, catid')->limit($limit)->offset(($page - 1) * $limit);
        $tmp_re = $db->query($db->sql());
        while (list($alias, $tilterow, $introtext, $catid) = $tmp_re->fetch(3)) {
            $result_array[] = array('link' => $link . $list_cats[$catid]['alias'] . '/' . $alias . $global_config['rewrite_exturl'], 'title' => BoldKeywordInStr($tilterow, $key, $logic), 'content' => BoldKeywordInStr($introtext, $key, $logic));
        }
    }
}
示例#2
0
     * 
     * @param mixed $module_data
     * @return
     */
    function nv_sdown_cats($module_data)
    {
        global $db;
        $sql = "SELECT `id`, `title`, `alias`, `who_view`, `groups_view` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_categories` WHERE `status`=1";
        $result = $db->sql_query($sql);
        $list = array();
        while ($row = $db->sql_fetchrow($result)) {
            if (nv_set_allow($row['who_view'], $row['groups_view'])) {
                $list[$row['id']] = array('id' => (int) $row['id'], 'title' => $row['title'], 'alias' => $row['alias']);
            }
        }
        return $list;
    }
}
$list_cats = nv_sdown_cats($m_values['module_data']);
$in = implode(",", array_keys($list_cats));
$sql = "SELECT SQL_CALC_FOUND_ROWS `alias`,`title`,`description`, `introtext`, `catid` \nFROM `" . NV_PREFIXLANG . "_" . $m_values['module_data'] . "` \nWHERE `catid` IN (" . $in . ") \nAND (" . nv_like_logic('title', $dbkeyword, $logic) . " \nOR " . nv_like_logic('description', $dbkeyword, $logic) . " \nOR " . nv_like_logic('introtext', $dbkeyword, $logic) . ") \nLIMIT " . $pages . "," . $limit;
$tmp_re = $db->sql_query($sql);
$result = $db->sql_query("SELECT FOUND_ROWS()");
list($all_page) = $db->sql_fetchrow($result);
if ($all_page) {
    $link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $m_values['module_name'] . '&' . NV_OP_VARIABLE . '=';
    while (list($alias, $tilterow, $content, $introtext, $catid) = $db->sql_fetchrow($tmp_re)) {
        $content = $content . ' ' . $introtext;
        $result_array[] = array('link' => $link . $list_cats[$catid]['alias'] . '/' . $alias, 'title' => BoldKeywordInStr($tilterow, $key, $logic), 'content' => BoldKeywordInStr($content, $key, $logic));
    }
}