function collectAction() { session_start(); if (isset($_SESSION['user'])) { $loginuser = $_SESSION['user']; } else { $loginuser = array('UID' => -1); } $UID = $loginuser['UID']; //$UID=2; //自己的ID $this->view->personalinfo = array('UID' => $UID, 'image' => ''); #$loginuser['image']);//上边栏信息 #if($_GET['P'] != null) #$QPage=$_GET['P']; #从前端获取ask的页码 #else $QPage=1; $QPage = 1; //得到你访问的人的UID //$MUID=$this->getRequest()->getParam('MUID',''); $user = new user(); $MUID = $_GET['UID']; $info = $user->getAllbyUID($MUID); $answer = new answer(); $likeQ = new likeQ(); $likeA = new likeA(); $followu = new followU(); $follownum = $followu->getFollownumbyUID($MUID); $followednum = $followu->getFollownumbyFUID($MUID); $farr = $followu->getFUIDsbyUID($UID); $isfollow = false; for ($i = 0; $i < count($farr); $i++) { if ($farr[$i] == $MUID) { $isfollow = true; break; } } $this->view->pinfo = array('UID' => $MUID, 'nickname' => $info['nickname'], 'sex' => $info['sex'], 'image' => $info['image'], 'institute' => $info['institute'], 'grade' => $info['grade'], 'answernum' => $answer->getAnswernumbyUID($MUID), 'likenum' => $this->getLikedNumByUID($MUID), 'follownum' => $follownum, 'followednum' => $followednum, 'isfollow' => $isfollow); $followq = new followQ(); $question = new question(); $tag = new tag(); $Quids = $followq->getQIDsbyUID($MUID); $Qnum = count($Quids); $Qinfo = array(); for ($j = 0; $j < $Qnum; $j++) { $qid = $Quids[$j]; $Qinfo[$j] = array("QID" => $qid, "title" => $question->getAllbyQID($qid)['qtitle'], "answernum" => $answer->getAnswernumbyQID($qid), 'follownum' => $followq->getFollownumbyQID($qid), 'tag' => $tag->getTagbyQID($qid)); } if ($Qnum % 10 == 0) { $this->view->QpageNum = $Qnum / 10; } else { $this->view->QpageNum = $Qnum / 10 + 1; } array_slice($Qinfo, ($QPage - 1) * 10, 10); $this->view->collection = $Qinfo; $this->render("homepage-collection"); }
public function questionAction() { //封装header $auth = Zend_Auth::getinstance(); #获取auth用户实例 $auth->getIdentity(); #取得当前用户信息 $email = $auth->getIdentity(); $quser = new user(); $qquestion = new question(); $qanswer = new answer(); $qcomment = new comment(); $qask = new ask(); $likec = new likeC(); $likea = new likeA(); $followq = new followQ(); $user = $quser->getAllbyEmail($email); $header = array("UID" => $user[0]["UID"], "image" => $user[0]["image"]); $qtag = new tag(); $QID = $this->getRequest()->getParam("QID"); $tag = $qtag->getTagbyQID($QID); $Q = $qquestion->getAllbyQID($QID); $qtitle = $Q["qtitle"]; $qtime = $qask->getAskTimebyQID($QID); $qcontent = $Q["Qcontent"]; $answernum = $qanswer->getAnswernumbyQID($QID); $AIDs = $qanswer->getAIDsbyQID($QID); $ans_val[0][0] = 0; $comment[0][0] = 0; $answer[0][0] = 0; $com_val[0][0] = 0; for ($i = 0; $i < $answernum; $i++) { //第i个回答 $AID = $AIDs[$i]; $AUID = $qanswer->getUIDbyAID($AID); $auser = $quser->getAllbyUID($AUID); $Anickname = $auser["nickname"]; $anow = $qanswer->getAllbyAID($AID); $acontent = $anow["AContent"]; //print_r($anow); //print_r($acontent); $unow = $quser->getAllbyUID($AUID); $image = $unow["image"]; $atime = $qanswer->getTimebyAID($AID); $ans_val[$i] = $atime; $commentnum = $qcomment->getCommentnumbyAID($AID); $CIDs = $qcomment->getCIDsbyAID($AID); $likeNum = $likea->getLikenumbyAID($AID); $comment = array(); $com_val = array(); for ($j = 0; $j < $commentnum; $j++) { //第j个评论 $CID = $CIDs[$j]; $CUID = $qcomment->getUIDbyCID($CID); $RUID = $qcomment->getRIDbyCID($CID); $ccontent = $qcomment->getContentbyCID($CID); $ctime = $qcomment->getTimebyCID($CID); $com_val[$j] = $ctime; $user = new user(); $tmp = $user->getAllbyUID($CUID); $comment[$j] = array("CID" => $CID, "CUID" => $CUID, "RUID" => $RUID, "nickname" => $tmp['nickname'], "content" => $ccontent, "time" => $ctime); } if ($commentnum > 0) { array_multisort($com_val, SORT_DESC, $comment); } $answer[$i] = array("AID" => $AID, "AUID" => $AUID, "content" => $acontent, "image" => $image, "time" => $atime, "comment" => $comment, "commentnum" => $commentnum, "time" => $atime, "Anickname" => $Anickname, "likeNum" => $likeNum); } array_multisort($ans_val, SORT_DESC, $answer); $iscollect = false; //session_start(); if (isset($_SESSION['user'])) { $loginuser = $_SESSION['user']; } else { $loginuser = array('UID' => -1); } $UID = $loginuser['UID']; $carr = $followq->getQIDsbyUID($UID); for ($i = 0; $i < count($carr); $i++) { if ($QID == $carr[$i]) { $iscollect = true; break; } } $question = array("QID" => $QID, "content" => $qcontent, "tag" => $tag, "answernum" => $answernum, "answer" => $answer, "title" => $qtitle, "time" => $qtime, "iscollect" => $iscollect); //HotQlist $hquestion = $qanswer->getMostAnsweredQID(1, 6); for ($i = 0; $i < count($hquestion); $i++) { $qq = $qquestion->getAllbyQID($hquestion[$i]); $HotQlist[$i]["QID"] = $qq["QID"]; $HotQlist[$i]["title"] = $qq["qtitle"]; $HotQlist[$i]["follownum"] = $followq->getFollownumbyQID($qq["QID"]); $HotQlist[$i]["answernum"] = $qanswer->getAnswernumbyQID($qq["QID"]); } //print_r($question["answer"][1]); //print_r($question["answer"][1]["comment"]); $this->view->hotQlist = $HotQlist; $this->view->question = $question; $this->view->header = $header; $this->render('qdetail'); }