Esempio n. 1
0
 public function logoutAction()
 {
     $auth = Zend_Auth::getinstance();
     $auth->getIdentity();
     if ($auth->hasIdentity() == true) {
         $this->view->code = $auth->getIdentity();
     } else {
         $this->view->code = 'NO';
     }
     $this->forward('login', 'index');
 }
Esempio n. 2
0
 public function tagAction()
 {
     //封装header
     $tuser = new user();
     $auth = Zend_Auth::getinstance();
     #获取auth用户实例
     $auth->getIdentity();
     #取得当前用户信息
     $email = $auth->getIdentity();
     $tuser = new user();
     $user = $tuser->getAllbyEmail($email);
     $header = array("UID" => $user[0]["UID"], "image" => $user[0]["image"]);
     //封装tag
     $ttag = new tag();
     $tans = new answer();
     $task = new ask();
     $tquestion = new question();
     $tfollowq = new followQ();
     $tags = $ttag->getAllTags();
     $tagnum = count($tags);
     $this->view->tags = $tags;
     //print_r($tags);
     for ($i = 0; $i < count($tags); $i++) {
         //第i个tag
         $QIDs = $ttag->getQIDsbyTag($tags[$i]);
         $questionnum = count($QIDs);
         $tag[$i]["tag"] = $tags[$i];
         $questiontmp[0] = 0;
         $answernum[0] = 0;
         for ($j = 0; $j < $questionnum; $j++) {
             //第j个question
             $question = $tquestion->getAllbyQID($QIDs[$j]);
             $QID = $QIDs[$j];
             $title = $question["qtitle"];
             if (strlen($title) > 75) {
                 $title = substr($title, 0, 72);
                 $title = $title . "...";
             }
             $follownum = $tfollowq->getFollownumbyQID($QID);
             $answernum[$j] = $tans->getAnswernumbyQID($QID);
             $questiontmp[$j] = array("QID" => $QID, "title" => $title, "follownum" => $follownum, "answernum" => $answernum[$j]);
         }
         array_multisort($answernum, SORT_DESC, $questiontmp);
         for ($j = 0; $j < min(3, count($questiontmp)); $j++) {
             $Qresult[$i][$j] = $questiontmp[$j];
         }
     }
     $this->view->tag = $tags;
     $this->view->Qresult = $Qresult;
     $this->view->header = $header;
     $this->render('tag');
 }
Esempio n. 3
0
 public function tagAction()
 {
     //封装header
     $auth = Zend_Auth::getinstance();
     #获取当前用户实例
     $UID = $auth->getIdentity();
     #取得当前用户信息
     if ($auth->hasIdentity() == false) {
         $this->render('index');
     }
     $tuser = new user();
     $user = $tuser->getAllbyUID($UID);
     $header = array("UID" => $user["UID"], "image" => $user["image"]);
     //封装tag
     $ttag = new tag();
     $tans = new answer();
     $task = new ask();
     $tquestion = new question();
     $tfollowq = new followQ();
     $tagnum = $ttag->gerRequest()->getParam("tagnum");
     $tags = $ttag->getAllTags();
     for ($i = 0; $i < $tagnum; $i++) {
         //第i个tag
         $QIDs = $ttag->getQIDsbyTags($tags[$i]);
         for ($j = 0; $j < tagnum; $j++) {
             //第j个question
             $mUID = $task->getUIDbyQID($QIDs[$j]);
             $person = $tuser->getAllbyUID($mUID);
             $image1[$j] = $person['image'];
             $question = $tquestion->getAllbyQID($QIDs[$j]);
             $QID1[$j] = $QIDs[$i];
             $title1[$j] = $question["title"];
             $abstract1[$j] = $question["Qabstract"];
             $follownum[$j] = $tfollowq->getFollownumbyQID($QID1[$j]);
             $answernum[$j] = $tans->getAnswernumbyQID($QID1[$j]);
             $tag1[$j] = $ttag->getTagbyQID($QID1[$j]);
             $time1[$j] = $task->getAskTimebyQID($QIDs[$j]);
             $tag[$i][$j] = array("image" => $image1[$j], "QID" => $QIDs[$j], "title" => $title1[$j], "abstract" => $abstract1[$j], "follownum" => $follownum[$j], "answernum" => $answernum[$j], "tag" => $tag1[$j], "time" => $time1[$j]);
         }
     }
     //传递变量,render
     $this->view->tag = $tag;
     $this->view->header = $header;
     $this->render('tag');
 }