当前位置: 首页>>代码示例>>PHP>>正文


PHP tag::getQIDsbyTag方法代码示例

本文整理汇总了PHP中tag::getQIDsbyTag方法的典型用法代码示例。如果您正苦于以下问题:PHP tag::getQIDsbyTag方法的具体用法?PHP tag::getQIDsbyTag怎么用?PHP tag::getQIDsbyTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tag的用法示例。


在下文中一共展示了tag::getQIDsbyTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tagAction

 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');
 }
开发者ID:Zziwei,项目名称:Microknow,代码行数:52,代码来源:IndexController.php

示例2: tagAction

 public function tagAction()
 {
     if ($_GET) {
         $key = $this->getRequest()->getParam('tag', '');
         $P = $this->getRequest()->getParam('P', '1');
     }
     $perpage = 10;
     //question number per page
     $answer = new answer();
     $followQ = new followQ();
     $question = new question();
     $tag = new tag();
     $ask = new ask();
     $QID = $tag->getQIDsbyTag($key);
     $result = array();
     for ($i = 0; $i < count($QID); $i++) {
         $result[$i] = $question->getAllbyQID($QID[$i]);
         $result[$i]['time'] = $ask->getAskTimebyQID($result[$i]['QID']);
         $result[$i]['answernum'] = $answer->getAnswernumbyQID($result[$i]['QID']);
         $result[$i]['follownum'] = $followQ->getFollownumbyQID($result[$i]['QID']);
         $result[$i]['tag'] = $tag->getTagbyQID($result[$i]['QID']);
     }
     $answer = new answer();
     $likeA = new likeA();
     $user = new user();
     for ($i = 0; $i < count($result); $i++) {
         $maxansid = -1;
         $maxsum = -1;
         //the id of most liked answer, the like number of the answer
         $AID = $answer->getAIDsbyQID($QID[$i]);
         for ($j = 0; $j < count($AID); $j++) {
             $likenum = $likeA->getLikenumbyAID($AID[$j]);
             if ($likenum > $maxsum) {
                 $maxansid = $AID[$j];
                 $maxsum = $likenum;
             }
         }
         if ($maxansid != -1) {
             $result[$i]['AAbstract'] = $answer->getAbstractbyAID($maxansid);
             $tmp = $user->getAllbyUID($answer->getUIDbyAID($maxansid));
             $result[$i]['image'] = $tmp['image'];
         }
     }
     $sum = count($result);
     //divide into several pages
     $Pnum = floor($sum / $perpage);
     if ($sum % $perpage > 0) {
         $Pnum++;
     }
     $presult = array();
     $length = min($P * $perpage, $sum);
     for ($i = ($P - 1) * $perpage; $i < $length; $i++) {
         $presult[$i] = $result[$i];
     }
     $this->view->P = $P;
     $this->view->Pnum = $Pnum;
     $this->view->Qresult = $presult;
     $tmp = $tag->getAllTags();
     //warning: bad situation:$tmp[1] is empty,but $tmp[0] && $tmp[2] is exist
     $i = 0;
     foreach ($tmp as $a) {
         $result[$i++] = $a;
     }
     $this->view->tag = $result;
     //HotQlist
     $mans = new answer();
     $mquestion = new question();
     $mfollowq = new followQ();
     $hquestion = $mans->getMostAnsweredQID(1, 6);
     for ($i = 0; $i < count($hquestion); $i++) {
         $qq = $mquestion->getAllbyQID($hquestion[$i]);
         $HotQlist[$i]["QID"] = $qq["QID"];
         $HotQlist[$i]["title"] = $qq["qtitle"];
         $HotQlist[$i]["follownum"] = $mfollowq->getFollownumbyQID($qq["QID"]);
         $HotQlist[$i]["answernum"] = $mans->getAnswernumbyQID($qq["QID"]);
     }
     $lefter = array("hotQlist" => $HotQlist);
     $this->view->lefter = $lefter;
     $this->view->url = "/search/tag";
     $this->render('tagresult');
     //
 }
开发者ID:Zziwei,项目名称:Microknow,代码行数:82,代码来源:searchController.php


注:本文中的tag::getQIDsbyTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。