function wp_xoops_search($queryarray, $andor, $limit, $offset, $userid, $wp_num = "") { global $xoopsDB, $siteurl; global $month, $wpdb, $wp_id, $wp_inblock; if ($wp_num == "") { $wp_id = $wp_num; $wp_inblock = 1; require XOOPS_ROOT_PATH . "/modules/wordpress/wp-config.php"; $wp_inblock = 0; } $time_difference = get_settings('time_difference'); $now = date('Y-m-d H:i:s', time() + $time_difference * 3600); $where = "(post_status = 'publish') AND (post_date <= '" . $now . "')"; if (is_array($queryarray) && ($count = count($queryarray))) { $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $where .= " {$andor} "; $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')"; } $where .= ") "; } if ($userid) { $userid = intval($userid); $where .= " AND (post_author=" . $userid . ")"; } $request = "SELECT * FROM " . $xoopsDB->prefix("wp" . $wp_num . "_posts") . " WHERE " . $where; $request .= " ORDER BY post_date DESC"; $result = $xoopsDB->query($request, $limit, $offset); $ret = array(); $i = 0; while ($myrow = $xoopsDB->fetchArray($result)) { $ret[$i]['link'] = str_replace($siteurl . "/", "", get_permalink($myrow['ID'])); $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES); $ret[$i]['image'] = "wp-images/search.png"; $date_str = $myrow['post_date']; $yyyy = substr($date_str, 0, 4); $mm = substr($date_str, 5, 2); $dd = substr($date_str, 8, 2); $hh = substr($date_str, 11, 2); $nn = substr($date_str, 15, 2); $ss = substr($date_str, 17, 2); $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy); $ret[$i]['uid'] = $myrow['post_author']; $ret[$i]['page'] = $myrow['post_title']; if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) { $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray); } $i++; } return $ret; }
function _wp_xoops_search($queryarray, $andor, $limit, $offset, $userid) { $now = current_time('mysql'); $where = '(post_status = \'publish\') AND (post_date <= \'' . $now . '\')'; if (is_array($queryarray) && ($count = count($queryarray))) { $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $where .= " {$andor} "; $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')"; } $where .= ') '; } if ($userid) { $userid = intval($userid); $where .= ' AND (post_author=' . $userid . ')'; } $request = 'SELECT * FROM ' . wp_table('posts') . ' WHERE ' . $where; $request .= ' ORDER BY post_date DESC'; $result = $GLOBALS['xoopsDB']->query($request, $limit, $offset); $ret = array(); $i = 0; while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { $ret[$i]['link'] = str_replace(wp_siteurl() . '/', '', get_permalink($myrow['ID'])); $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES); $ret[$i]['image'] = 'wp-images/search.png'; $date_str = $myrow['post_date']; $yyyy = substr($date_str, 0, 4); $mm = substr($date_str, 5, 2); $dd = substr($date_str, 8, 2); $hh = substr($date_str, 11, 2); $nn = substr($date_str, 15, 2); $ss = substr($date_str, 17, 2); $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy); $ret[$i]['uid'] = $myrow['post_author']; $ret[$i]['page'] = $myrow['post_title']; if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) { $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray); } if (!empty($myrow['post_content']) && function_exists('search_make_context')) { if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) { $ret[$i]['context'] = search_make_context(strip_tags($myrow['post_content']), $queryarray); } } $i++; } return $ret; }
function search(&$environment, $queryarray, $andor, $limit, $offset, $userid) { $ret = array(); $markerHandler =& NBFrame::getHandler('MyGmapMarker', $environment); if (is_array($queryarray) && ($count = count($queryarray))) { $criteria0 = new CriteriaCompo(new Criteria('mygmap_marker_title', '%' . $queryarray[0] . '%', 'LIKE')); $criteria0->add(new Criteria('mygmap_marker_desc', '%' . $queryarray[0] . '%', 'LIKE'), 'OR'); $criteria =& new CriteriaCompo($criteria0); for ($i = 1; $i < $count; $i++) { $criteria0 = new CriteriaCompo(new Criteria('mygmap_marker_title', '%' . $queryarray[$i] . '%', 'LIKE')); $criteria0->add(new Criteria('mygmap_marker_desc', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); $criteria->add($criteria0, $andor); } } else { $criteria =& new CriteriaCompo(new CriteriaElement()); } if ($userid) { $criteria->add(new Criteria('_NBsys_create_user', $userid)); } $criteria->setLimit($limit); $criteria->setStart($offset); $markerObjects = $markerHandler->getObjects($criteria); foreach ($markerObjects as $markerObject) { $desc = $markerObject->getVar('mygmap_marker_desc'); if (!empty($desc) && function_exists('xoops_make_context')) { $context = xoops_make_context(strip_tags($desc), $queryarray); } else { if (!empty($desc) && function_exists('search_make_context')) { if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) { $context = search_make_context(strip_tags($desc), $queryarray); } } else { $context = ''; } } $ret[] = array('title' => $markerObject->getVar('mygmap_marker_title'), 'uid' => $markerObject->getVar('_NBsys_create_user'), 'time' => $markerObject->getVar('_NBsys_update_time'), 'page' => $markerObject->getVar('mygmap_marker_title'), 'link' => $environment->getActionUrl('MyGmapMain', array('cat' => $markerObject->getVar('mygmap_marker_category_id'), 'id' => $markerObject->getVar('mygmap_marker_id')), 'html', true), 'context' => $context); } return $ret; }