public function askAction() { session_start(); if (isset($_SESSION['user'])) { $loginuser = $_SESSION['user']; } else { $loginuser = array('UID' => -1); } #名字要根据login的控制器改过来 $UID = $loginuser['UID']; //$UID=2; #if($_GET['P'] != null) #$QPage=$_GET['P']; #从前端获取ask的页码 #else $QPage=1; $QPage = 1; $tag = new tag(); $this->view->url = "\\personal\\ask"; //$this->view->Tag=$tag.getAllTags(); #$MUID=$this->getRequest()->getParam('MUID',''); #从前端的获取被访问者的UID $MUID = $_GET['UID']; $user = new user(); $info = $user->getAllbyUID($MUID); $answer_tmp = 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_tmp->getAnswernumbyUID($MUID), 'likenum' => $this->getLikedNumByUID($MUID), 'likeQnum' => $likeQ->getLikenumbyUID($MUID), 'follownum' => $follownum, 'followednum' => $followednum, 'isfollow' => $isfollow); file_put_contents("E:/out.txt", $info); $question = new question(); $followq = new followQ(); $followu = new followU(); $ask_tmp = new ask(); $answer1 = new answer(); $tag = new tag(); $QIDs = $ask_tmp->getQIDsbyUID($MUID); $Qnum = count($QIDs); $QID_Time_tmp = array(); $ask = array(); $m = 0; #计数用 for ($i = 0; $i < $Qnum; $i++) { $QID_Time_tmp[$QIDs[$i]] = $ask_tmp->getAskTimebyQID($QIDs[$i]); } arsort($QID_Time_tmp); foreach ($QID_Time_tmp as $qid => $time) { $q = $question->getAllbyQID($qid); $ask[$m] = array('QID' => $qid, 'title' => $q['qtitle'], 'abstract' => $q['Qabstract'], 'follownum' => $followq->getFollownumbyQID($qid), 'answernum' => $answer1->getAnswernumbyQID($qid), 'tag' => $tag->getTagbyQID($qid), 'Atime' => $QID_Time_tmp[$qid]); $m++; } if ($Qnum % 10 == 0) { $this->view->QpageNum = $Qnum / 10; } else { $this->view->QpageNum = $Qnum / 10 + 1; } $this->view->ask = array_slice($ask, ($QPage - 1) * 10, 10); //$this->render("ask"); $this->render("homepage-ask"); }