protected function getData($var) { $data = array(); $type = isset($var["new"]) ? "new" . $var["type"] : $var["type"]; switch ($type) { case "following": $pages = PageUtil::create(1000, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $list = Feed::model()->searchFeed($var["feedkey"], "following", $var["loadId"], $var["nums"], $pages->getOffset()); } else { $where = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid, "a."); if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND a.feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND a.type = '" . $var["feedtype"] . "'"; } $list = Feed::model()->getFollowingFeed($where, $var["nums"], $pages->getOffset()); } break; case "all": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $list = Feed::model()->searchFeed($var["feedkey"], "all", $var["loadId"], $var["nums"], $pages->getOffset()); } else { $where = "isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid); if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND type = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); } break; case "movement": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $list = Feed::model()->searchFeed($var["feedkey"], "movement", $var["loadId"], $var["nums"], $pages->getOffset()); } else { $where = "isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid); if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND module = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } else { $where .= " AND module != 'weibo'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); } break; case "newmovement": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 AND %s AND feedid > %d", WbfeedUtil::getViewCondition($this->uid), intval($var["maxId"]), $this->uid); $list = Feed::model()->getList($where); $data["count"] = count($list); } break; case "newfollowing": $where = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid, "a."); if (0 < $var["maxId"]) { $where .= " AND a.feedid > '" . intval($var["maxId"]) . "'"; $list = Feed::model()->getFollowingFeed($where); $data["count"] = count($list); } break; case "newall": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 AND %s AND feedid > %d AND uid <> %d", WbfeedUtil::getViewCondition($this->uid), intval($var["maxId"]), $this->uid); $list = Feed::model()->getList($where); $data["count"] = count($list); } break; default: break; } if (!isset($var["new"])) { $pages->route = "home/index"; } if (!empty($list)) { $data["firstId"] = $list[0]["feedid"]; $data["lastId"] = $list[count($list) - 1]["feedid"]; $feedids = ConvertUtil::getSubByKey($list, "feedid"); $diggArr = FeedDigg::model()->checkIsDigg($feedids, $this->uid); foreach ($list as &$v) { switch ($v["module"]) { case "mobile": break; default: $v["from"] = EnvUtil::getFromClient($v["from"], $v["module"]); break; } if (isset($v["attach_id"][0])) { $_tmp = AttachUtil::getAttachData($v["attach_id"][0]); $v["attach_url"] = FileUtil::getAttachUrl() . "/" . $_tmp[$v["attach_id"][0]]["attachment"]; } if (isset($v["api_source"]["attach"][0]["attach_url"])) { $v["api_source"]["attach_url"] = $v["api_source"]["attach"][0]["attach_url"]; unset($v["api_source"]["attach"]); unset($v["api_source"]["source_body"]); } unset($v["user_info"]); unset($v["body"]); unset($v["sourceInfo"]); unset($v["api_source"]["source_user_info"]); unset($v["api_source"]["avatar_big"]); unset($v["api_source"]["avatar_middle"]); unset($v["api_source"]["avatar_small"]); unset($v["api_source"]["source_url"]); unset($v["feeddata"]); } $data["list"] = $list; $data["diggArr"] = $diggArr; } else { $data["list"] = array(); $data["firstId"] = $data["lastId"] = 0; } return $data; }
protected function getData($var) { $data = array(); $type = isset($var["new"]) ? "new" . $var["type"] : $var["type"]; $where = "isdel = 0 AND uid = " . $this->getUid() . ($this->getIsMe() ? "" : " AND " . WbfeedUtil::getViewCondition(Ibos::app()->user->uid)); switch ($type) { case "all": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $loadId = isset($var["loadId"]) ? $var["loadId"] : 0; $list = Feed::model()->searchFeed($var["feedkey"], "all", $loadId, $var["nums"], $pages->getOffset(), "", $this->getUid()); $count = Feed::model()->countSearchAll($var["feedkey"], $loadId); } else { if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND type = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); $count = Feed::model()->count($where); } break; case "movement": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $loadId = isset($var["loadId"]) ? $var["loadId"] : 0; $list = Feed::model()->searchFeed($var["feedkey"], "movement", $loadId, $var["nums"], $pages->getOffset(), "", $this->getUid()); $count = Feed::model()->countSearchMovement($var["feedkey"], $loadId); } else { if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND module = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } else { $where .= " AND module != 'weibo'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); $count = Feed::model()->count($where); } break; case "newmovement": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 AND %s AND feedid > %d AND uid = %d", WbfeedUtil::getViewCondition(Ibos::app()->user->uid), intval($var["maxId"]), $this->uid); $list = Feed::model()->getList($where); $count = Feed::model()->count($where); $data["count"] = count($list); } break; case "newall": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 %s AND feedid > %d AND uid = %d", $this->getIsMe() ? "" : " AND " . WbfeedUtil::getViewCondition(Ibos::app()->user->uid), intval($var["maxId"]), $this->getUid()); $list = Feed::model()->getList($where); $count = Feed::model()->countFollowingFeed($where); $data["count"] = count($list); } break; default: break; } $count = isset($count) ? $count : WbConst::MAX_VIEW_FEED_NUMS; $pages = PageUtil::create($count, WbConst::DEF_LIST_FEED_NUMS); if (!isset($var["new"])) { $pages->route = "personal/index"; $currentUrl = (string) Ibos::app()->getRequest()->getUrl(); $replaceUrl = str_replace("weibo/personal/loadmore", "weibo/personal/index", $currentUrl); $data["pageData"] = $this->widget("IWPage", array("pages" => $pages, "currentUrl" => $replaceUrl), true); } if (!empty($list)) { $data["firstId"] = $list[0]["feedid"]; $data["lastId"] = $list[count($list) - 1]["feedid"]; $feedids = ConvertUtil::getSubByKey($list, "feedid"); $diggArr = FeedDigg::model()->checkIsDigg($feedids, $this->getUid()); foreach ($list as &$v) { switch ($v["module"]) { case "mobile": break; default: $v["from"] = EnvUtil::getFromClient($v["from"], $v["module"]); break; } } $data["html"] = $this->renderPartial("application.modules.message.views.feed.feedlist", array("list" => $list, "diggArr" => $diggArr), true); } else { $data["html"] = ""; $data["firstId"] = $data["lastId"] = 0; } return $data; }
private function mergeSearchMovementCondition($key, $loadId, $feedtype = "", $uid = 0) { $me = intval(Ibos::app()->user->uid); $map = array("and"); if (!$uid) { $map[] = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($me); } else { $map[] = "a.isdel = 0 AND uid = " . $uid . ($me == $uid ? "" : " AND " . WbfeedUtil::getViewCondition($me)); } !empty($loadId) && ($map[] = "a.feedid < " . intval($loadId)); $map[] = array("LIKE", "b.feedcontent", "%" . StringUtil::filterCleanHtml($key) . "%"); if ($feedtype) { $map[] = "a.module = " . $feedtype; } else { $map[] = "a.module != 'weibo'"; } return $map; }