本文整理汇总了PHP中tag::getTagbyQID方法的典型用法代码示例。如果您正苦于以下问题:PHP tag::getTagbyQID方法的具体用法?PHP tag::getTagbyQID怎么用?PHP tag::getTagbyQID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tag
的用法示例。
在下文中一共展示了tag::getTagbyQID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: questionAction
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');
}
示例2: tagAction
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');
}
示例3: 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');
//
}
示例4: answerAction
public function answerAction()
{
session_start();
if (isset($_SESSION['user'])) {
$loginuser = $_SESSION['user'];
} else {
$loginuser = array('UID' => -1);
}
#名字要根据login的控制器改过来
$UID = $loginuser['UID'];
//if($_GET['P'] != null)
//$APage=$_GET['P']; #从前端获取ask的页码
//else $APage=1;
$APage = 1;
//$UID=2;
$this->view->PersonalInfo = array('UID' => $UID, 'image' => '');
#$loginuser['image']);
#$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), 'follownum' => $follownum, 'followednum' => $followednum, 'isfollow' => $isfollow);
$question = new question();
$answer_tmp1 = new answer();
$answer = array();
$tag = new tag();
$followq = new followQ();
$AIDs = $answer_tmp1->getAIDsbyUID($MUID);
$Anum = count($AIDs);
$AID_Time_tmp = array();
$m = 0;
#为answer数组计数用
for ($i = 0; $i < $Anum; $i++) {
$AID_Time_tmp[$AIDs[$i]] = $answer_tmp1->getTimebyAID($AIDs[$i]);
}
arsort($AID_Time_tmp);
foreach ($AID_Time_tmp as $aid => $time) {
$a = $answer_tmp1->getAllbyAID($aid);
$qid = $a['QID'];
$answer[$m] = array('QID' => $qid, 'title' => $question->getAllbyQID($qid)['qtitle'], 'abstract' => $question->getAllbyQID($qid)['Qabstract'], 'Aabstract' => $a['AAbstract'], 'Atime' => $a['time'], 'follownum' => $followq->getFollownumbyQID($qid), 'answernum' => $answer_tmp->getAnswernumbyQID($qid), 'tag' => $tag->getTagbyQID($qid));
$m++;
}
if ($Anum % 10 == 0) {
$this->view->Pnum = $Anum / 10;
} else {
$this->view->Pnum = $Anum / 10 + 1;
}
$this->view->answer = array_slice($answer, ($APage - 1) * 10, 10);
$this->view->url = "/personal/answer?UID={$MUID}&";
$this->render("homepage-answer");
}