/** * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ * @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package Publisher * @since 1.0 * @author trabis <*****@*****.**> * @version $Id$ */ function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "") { $publisher = Publisher::getInstance(); $ret = array(); if ($queryarray == '' || count($queryarray) == 0) { $hightlight_key = ''; } else { $keywords = implode('+', $queryarray); $hightlight_key = "&keywords=" . $keywords; } $itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra); $withCategoryPath = $publisher->getConfig('search_cat_path'); $usersIds = array(); /* @var $obj PublisherItem */ foreach ($itemsObjs as $obj) { $item['image'] = "images/item_icon.gif"; $item['link'] = $obj->getItemUrl(); $item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&') : $hightlight_key; if ($withCategoryPath) { $item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title(); } else { $item['title'] = $obj->title(); } $item['time'] = $obj->getVar('datesub'); //must go has unix timestamp $item['uid'] = $obj->getVar('uid'); //"Fulltext search/highlight $text = $obj->body(); $sanitized_text = ""; $text_i = strtolower($text); $queryarray = is_array($queryarray) ? $queryarray : array($queryarray); //@todo look into xoopslocal foreach ($queryarray as $query) { $pos = strpos($text_i, strtolower($query)); //xoops_local("strpos", $text_i, strtolower($query)); $start = max($pos - 100, 0); $length = strlen($query) + 200; //xoops_local("strlen", $query) + 200; $context = $obj->highlight(XoopsLocale::substr($text, $start, $length, " [...]"), $query); $sanitized_text .= "<p>[...] " . $context . "</p>"; } //End of highlight $item['text'] = $sanitized_text; $item['author'] = $obj->getVar('author_alias'); $item['datesub'] = $obj->datesub($publisher->getConfig('format_date')); $usersIds[$obj->getVar('uid')] = $obj->getVar('uid'); $ret[] = $item; unset($item, $sanitized_text); } $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true); foreach ($ret as $key => $item) { if ($item["author"] == '') { $ret[$key]["author"] = @$usersNames[$item["uid"]]; } } unset($usersNames, $usersIds); return $ret; }
/** * Function to a list of user names associated with their user IDs * */ function &art_getUnameFromId($uid, $usereal = 0, $linked = false) { if (!is_array($uid)) { $uid = array($uid); } xoops_load("userUtility"); $ids = XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked); return $ids; }
/** * Function to a list of user names associated with their user IDs * */ function &art_getAuthorNameFromId($userid, $usereal = 0, $linked = false) { if (!is_array($userid)) { $userid = array($userid); } xoops_load("userUtility"); $users = XoopsUserUtility::getUnameFromIds($userid, $usereal); if (!empty($linked)) { mod_loadFunctions("url", $GLOBALS["artdirname"]); foreach (array_keys($users) as $uid) { $users[$uid] = "<a href=\"" . art_buildUrl(XOOPS_URL . "/modules/" . $GLOBALS["artdirname"] . "/view.author.php", array("uid" => $uid)) . "\">" . $users[$uid] . "</a>"; } } return $users; }
public function searchAdvanced($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = "", $extra = "") { $publisher = Publisher::getInstance(); $ret = array(); if ($queryarray == '' || count($queryarray) == 0) { $hightlight_key = ''; } else { $keywords = implode('+', $queryarray); $hightlight_key = "&keywords=" . $keywords; } $itemsObjs = $publisher->getItemHandler()->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra); $withCategoryPath = $publisher->getConfig('search_cat_path'); $usersIds = array(); /* @var $obj PublisherItem */ foreach ($itemsObjs as $obj) { $item['image'] = "images/item_icon.gif"; $item['link'] = $obj->getItemUrl(); $item['link'] .= !empty($hightlight_key) && strpos($item['link'], '.php?') === false ? "?" . ltrim($hightlight_key, '&') : $hightlight_key; if ($withCategoryPath) { $item['title'] = $obj->getCategoryPath(false) . " > " . $obj->title(); } else { $item['title'] = $obj->title(); } $item['time'] = $obj->getVar('datesub'); //must go has unix timestamp $item['uid'] = $obj->getVar('uid'); $item['content'] = Metagen::getSearchSummary($obj->body(), $queryarray); $item['author'] = $obj->getVar('author_alias'); $item['datesub'] = $obj->datesub($publisher->getConfig('format_date')); $usersIds[$obj->getVar('uid')] = $obj->getVar('uid'); $ret[] = $item; unset($item, $sanitized_text); } $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true); foreach ($ret as $key => $item) { if ($item["author"] == '') { $ret[$key]["author"] = @$usersNames[$item["uid"]]; } } unset($usersNames, $usersIds); return $ret; }
/** * @param $uid * @param bool $usereal * @param bool $linked * * @return array */ function &mod_getUnameFromIds($uid, $usereal = false, $linked = false) { $GLOBALS['xoopsLogger']->addDeprecated("Deprecated function '" . __FUNCTION__ . "', use XoopsUserUtility directly."); $ids = XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked); return $ids; }
/** * Function to a list of user names associated with their user IDs * */ function &newbb_getUnameFromIds($uid, $usereal = 0, $linked = false) { xoops_load("xoopsuserutility"); $ids = XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked); return $ids; }
function &mod_getUnameFromIds($uid, $usereal = false, $linked = false) { trigger_error("Deprecated function '" . __FUNCTION__ . "', use XoopsUserUtility directly.", E_USER_NOTICE); $ids = XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked); return $ids; }
/** * @param $queryarray * @param $andor * @param $limit * @param $offset * @param $userid * @param array $categories * @param int $sortby * @param string $searchin * @param string $extra * * @return array */ function publisher_search($queryarray, $andor, $limit, $offset, $userid, $categories = array(), $sortby = 0, $searchin = '', $extra = '') { $publisher =& PublisherPublisher::getInstance(); $ret = array(); if ($queryarray == '' || count($queryarray) == 0) { $hightlightKey = ''; } else { $keywords = implode('+', $queryarray); $hightlightKey = '&keywords=' . $keywords; } $itemsObjs =& $publisher->getHandler('item')->getItemsFromSearch($queryarray, $andor, $limit, $offset, $userid, $categories, $sortby, $searchin, $extra); $withCategoryPath = $publisher->getConfig('search_cat_path'); //xoops_load("xoopslocal"); $usersIds = array(); foreach ($itemsObjs as $obj) { $item['image'] = 'assets/images/item_icon.gif'; $item['link'] = $obj->getItemUrl(); $item['link'] .= !empty($hightlightKey) && strpos($item['link'], '.php?') === false ? '?' . ltrim($hightlightKey, '&') : $hightlightKey; if ($withCategoryPath) { $item['title'] = $obj->getCategoryPath(false) . ' > ' . $obj->getTitle(); } else { $item['title'] = $obj->getTitle(); } $item['time'] = $obj->getVar('datesub'); //must go has unix timestamp $item['uid'] = $obj->uid(); //"Fulltext search/highlight $text = $obj->getBody(); $sanitizedText = ''; $textLower = strtolower($text); $queryarray = is_array($queryarray) ? $queryarray : array($queryarray); if ($queryarray[0] != '' && count($queryarray) > 0) { foreach ($queryarray as $query) { $pos = strpos($textLower, strtolower($query)); //xoops_local("strpos", $textLower, strtolower($query)); $start = max($pos - 100, 0); $length = strlen($query) + 200; //xoops_local("strlen", $query) + 200; $context = $obj->highlight(xoops_substr($text, $start, $length, ' [...]'), $query); $sanitizedText .= '<p>[...] ' . $context . '</p>'; } } //End of highlight $item['text'] = $sanitizedText; $item['author'] = $obj->author_alias(); $item['datesub'] = $obj->getDatesub($publisher->getConfig('format_date')); $usersIds[$obj->uid()] = $obj->uid(); $ret[] = $item; unset($item, $sanitizedText); } xoops_load('XoopsUserUtility'); $usersNames = XoopsUserUtility::getUnameFromIds($usersIds, $publisher->getConfig('format_realname'), true); foreach ($ret as $key => $item) { if ($item['author'] == '') { $ret[$key]['author'] = isset($usersNames[$item['uid']]) ? $usersNames[$item['uid']] : ''; } } unset($usersNames, $usersIds); return $ret; }
* uid * tags */ if (!($item = @$items_module[$items[$key]["modid"]][$items[$key]["catid"]][$items[$key]["itemid"]])) { continue; } $item["module"] = $modules_obj[$items[$key]["modid"]]->getVar("name"); $item["dirname"] = $modules_obj[$items[$key]["modid"]]->getVar("dirname", "n"); $time = empty($item["time"]) ? $items[$key]["time"] : $item["time"]; $item["time"] = formatTimestamp($time, "s"); $item["tags"] = @tagBar($item["tags"]); $items_data[] = $item; $uids[$item["uid"]] = 1; } xoops_load("UserUtility"); $users = XoopsUserUtility::getUnameFromIds(array_keys($uids)); foreach (array_keys($items_data) as $key) { $items_data[$key]["uname"] = $users[$items_data[$key]["uid"]]; } if (!empty($start) || count($items_data) >= $limit) { $count_item = $tag_handler->getItemCount($tag_id, $modid, $catid); // Tag, modid, catid include_once XOOPS_ROOT_PATH . "/class/pagenav.php"; $nav = new XoopsPageNav($count_item, $limit, $start, "start", "tag={$tag_id}&catid={$catid}"); $pagenav = $nav->renderNav(4); } else { $pagenav = ""; } $tag_addon = array(); if (!empty($GLOBALS["TAG_MD_ADDONS"])) { $tag_addon["title"] = TAG_MD_TAG_ON;