Esempio n. 1
0
    function display()
    {
        global $wgUser;
        global $wgLang;
        global $wgContLang;
        global $wgTitle;
        global $wgOut;
        global $wgParser;
        global $wgAnonName;
        $sk =& $wgUser->getSkin();
        $dbr =& wfGetDB(DB_MASTER);
        $output = "";
        $sql = "SELECT Comment_Username,comment_ip, comment_text,comment_date,Comment_user_id,\n\t\t\t\tCommentID,IFNULL(Comment_Plus_Count - Comment_Minus_Count,0) as Comment_Score,\n\t\t\t\tComment_Plus_Count as CommentVotePlus, \n\t\t\t\tComment_Minus_Count as CommentVoteMinus,\n\t\t\t\t(select count(*) FROM Comments_Vote WHERE Comment_Vote_ID = CommentID AND Comment_Vote_user_id=" . $wgUser->mId . ") as AlreadyVoted,\n\t\t\t\tComment_Parent_ID, CommentID,\n\t\t\t\tCASE Comment_Parent_ID WHEN 0 THEN  CAST(replace(Comment_Parent_ID,0,CommentID) as UNSIGNED) else  CAST(Comment_Parent_ID as UNSIGNED) end as thread";
        if ($this->ShowUserRating == 1) {
            $sql .= ",vote_value";
        }
        $sql .= " FROM Comments ";
        if ($this->ShowUserRating == 1) {
            $sql .= " LEFT JOIN Vote ON Comment_username=username and vote_page_id=" . $this->PageID;
        }
        $sql .= " WHERE comment_page_id = " . $this->PageID;
        if ($this->OrderBy == 0) {
            $sql .= " ORDER BY thread,Comment_Date";
        } else {
            $sql .= " ORDER BY Comment_Score DESC";
        }
        $res = $dbr->query($sql);
        $AFCounter = 1;
        $AFBucket = array();
        while ($row = $dbr->fetchObject($res)) {
            $CommentScore = $row->Comment_Score;
            $this->Scorecard[$row->Comment_Username] += $CommentScore;
            if ($row->Comment_user_id != 0) {
                $title = Title::makeTitle(2, $row->Comment_Username);
                $CommentPoster = $sk->makeKnownLinkObj($title, $wgContLang->convertHtml($title->getText()));
                $CommentReplyTo = $row->Comment_Username;
            } else {
                if (!array_key_exists($row->Comment_Username, $AFBucket)) {
                    $AFBucket[$row->Comment_Username] = $AFCounter;
                    $AFCounter++;
                }
                $CommentPoster = $wgAnonName . " #" . $AFBucket[$row->Comment_Username];
                $CommentReplyTo = $wgAnonName;
            }
            if ($row->Comment_user_id != 0) {
                $avatar = new wAvatar($row->Comment_user_id, "m");
                $CommentIcon = $avatar->getAvatarImage();
            } else {
                $CommentIcon = "af_m.gif";
            }
            if ($row->Comment_Parent_ID == 0) {
                $Width1 = 629;
                $Width2 = 385;
                $class = "comment";
                $moveleft = "";
            } else {
                $Width1 = 520;
                $Width2 = 286;
                $class = "reply";
                $moveleft = 'style="padding-left:109px"';
            }
            $timeArray = $this->dateDiff(time(), $row->comment_date);
            $timeStr = "";
            $timeStrD = $this->getTimeOffset($timeArray, "d", "day");
            $timeStrH = $this->getTimeOffset($timeArray, "h", "hour");
            $timeStrM = $this->getTimeOffset($timeArray, "m", "minute");
            $timeStrS = $this->getTimeOffset($timeArray, "s", "second");
            $timeStr = $timeStrD;
            if ($timeStr < 2) {
                $timeStr .= $timeStrH;
                $timeStr .= $timeStrM;
                if (!$timeStr) {
                    $timeStr .= $timeStrS;
                }
            }
            $UserRating = "";
            if ($this->ShowUserRating == 1) {
                $Vote = new VoteStars($this->PageID);
                $UserRating = ' ' . $Vote->displayRating($row->vote_value);
            }
            $output .= '<div ' . $moveleft . ' id="comment-' . $row->CommentID . '" ><table border="0" cellspacing="0" cellpadding="0" width="' . $Width1 . '" style="padding-bottom:15px;">
  <tr>
   <td class="' . $class . 'top"><table border="0" cellpadding="0" cellspacing="0" width="' . $Width1 . '">
  <tr>
    <td width="100" class="commenticon"><img src="images/avatars/' . $CommentIcon . '" alt="" border="0"/></td>
    <td width="' . $Width2 . '">
	<table border="0" cellpadding="0" cellspacing="0" width="' . $Width2 . '">
	  <tr>
	  <td class="username">' . $CommentPoster . $UserRating . '</td>
	  </tr>
	  <tr>
	    <td class="commenttime">posted <b>' . $timeStr . '</b> ago</td>
	  </tr>
	</table>
	</td>
    <td width="134">
    <table border="0" cellpadding="0" cellspacing="0" width="134">
      <tr> 
	   <td class="commentscore" nowrap="nowrap" height="35" valign="bottom">';
            if ($this->AllowMinus == true || $this->AllowPlus == true) {
                $output .= "Score: <span id=\"Comment" . $row->CommentID . "\">" . $CommentScore . "</span>";
            }
            $output .= "</td>";
            $output .= "<td valign=\"bottom\">";
            $output .= "<span class=\"CommentVote\">";
            $output .= "<span id=\"CommentBtn" . $row->CommentID . "\">";
            if ($row->AlreadyVoted == 0) {
                if ($wgUser->mName != $row->Comment_Username) {
                    if ($this->AllowPlus == true) {
                        $output .= $this->getVoteLink($row->CommentID, 1);
                        //'<a href=javascript:cv(' . $row['CommentID'] . ',1,"' . $VoteKey . '","' . $this->Voting . '")>';
                    }
                    if ($this->AllowMinus == true) {
                        $output .= $this->getVoteLink($row->CommentID, -1);
                        //'<a href=javascript:cv(' . $row['CommentID'] . ',1,"' . $VoteKey . '","' . $this->Voting . '")>';
                    }
                } else {
                    $output .= '<span class="commentscore"><b>You</b></span>';
                }
            } else {
                $output .= '<img src="images/myfeed.gif" align="bottom" hspace="2" alt="v" /><span class="commentscore">voted</span>';
            }
            $output .= "</span>";
            $output .= "</span>";
            $output .= "</td>";
            $output .= '</tr>
    </table>
    </td>
  </tr>
  </table>
  </td>
</tr>
<tr>
  <td class="commentmiddle" width="' . $Width1 . '" height="40">' . $this->getCommentText($row->comment_text) . '</td>
</tr>
<tr>
  <td class="' . $class . 'bottom"></td>
</tr>';
            $dlt = "";
            if (in_array('staff', $wgUser->getGroups()) || $wgUser->mName == "Pean") {
                $dlt = ' <span ><a href="javascript:document.commentform.commentid.value=' . $row->CommentID . ';document.commentform.submit();" style="color:red">x</a></span>&nbsp;';
            }
            $replyRow = "";
            if ($row->Comment_Parent_ID == 0) {
                if ($replyRow) {
                    $replyRow .= " | ";
                }
                $replyRow .= "<a href=\"#end\" class=\"reply\" onclick=\"javascript:Reply(" . $row->CommentID . ",'" . urlencode($CommentReplyTo) . "')\">reply</a>";
            }
            if ($replyRow || $dlt) {
                $output .= "<tr><td  align=\"right\">" . $dlt . " " . $replyRow . "</td></tr>";
            }
            $output .= '</table></div>';
        }
        $output .= '<a id="end" name="end"></a>';
        return $output;
    }
Esempio n. 2
0
 function displayListDB()
 {
     global $wgUser;
     global $wgLang;
     global $wgContLang;
     global $wgTitle;
     global $wgOut;
     $sk =& $wgUser->getSkin();
     $dbr =& wfGetDB(DB_SLAVE);
     //echo $this->buildSQL();
     $res = $dbr->query($this->buildSQL());
     if ($dbr->numRows($res) == 0) {
         return htmlspecialchars("No pages found.");
     }
     $output = "";
     $output .= "<div id=\"ListPages" . $this->listid . "\">";
     $output .= "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td>" . "\n";
     $ListCount = 0;
     $ListCountShow = 0;
     while ($row = $dbr->fetchObject($res)) {
         if ($ListCountShow < $this->ShowCount - 1) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $output .= "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"listpageItem\">";
             // ** MAIN ROW
             // Picture (optional) + Title
             $output .= "<tr>";
             if ($this->ShowPic == 1) {
                 $PageImage = $this->getPageImage($row->page_id);
                 if ($PageImage) {
                     $output .= "<td class=\"listpage\" rowspan=\"5\" valign=\"top\" style='padding-right:20px'>";
                     $img = Image::newFromName($PageImage);
                     $img_tag = '<img src="' . $img->getURL() . '" alt="' . $PageImage . '" width="65"/>';
                     $output .= $img_tag;
                     //str_replace("</p>","",str_replace("<p>","",$img->getText()));
                     $output .= "</td>";
                 }
             }
             if ($this->ShowVoteBox == 1) {
                 $output .= "<td width=\"30\">" . $this->getVoteBox($row->vote_count) . "</td><td width=\"8\"></td>";
             }
             if ($this->ShowCommentBox == 1) {
                 $output .= "<td width=\"30\">" . $this->getCommentBox($row->comment_count) . "</td><td width=\"8\"></td>";
             }
             if ($this->ShowDetails == 1) {
                 $output .= '<td class="showdetails" ' . ($this->ShowVoteBox == 1 || $this->ShowCommentBox == 1 ? 'valign="top"' : '') . '>';
             } else {
                 $output .= '<td class="hidedetails" ' . ($this->ShowVoteBox == 1 || $this->ShowCommentBox == 1 ? 'valign="top"' : '') . '>';
             }
             // ** Display Link
             if ($row->page_namespace != 6) {
                 //$output .= $sk->makeKnownLinkObj($title, $wgContLang->convertHtml($title->getText()));
                 $output .= '<a href="' . $title->getFullURL() . '" title="' . $title->getText() . '">' . $title->getText() . '</a>';
             } else {
                 $CommentParser = new Parser();
                 $img = $CommentParser->parse("[[Image:" . $row->page_title . "|75px]]", $wgTitle, $wgOut->mParserOptions, true);
                 $output .= $img->getText();
             }
             $output .= "</td>";
             $output .= "</tr>";
             // ** END Main Row
             // ** Display Create Date
             if ($this->ShowDate == 1) {
                 $output .= "<tr>";
                 $output .= '<td class="listdate">';
                 $output .= "(created " . $this->getTimeStr($row->page_id) . " ago)";
                 //date("D m/d/y, g:i a T",$this->getCreateDate($row->page_id) - (60 * 60 * 1));
                 $output .= '</td>';
                 $output .= "</tr>";
             }
             // ** Display Average Score + Stars Graphics
             if ($this->ShowRating == 1) {
                 $Vote = new VoteStars($row->page_id);
                 $output .= "<tr>";
                 $output .= '<td class="listrating">';
                 $output .= "<table cellpadding=\"0\" cellspacing=\"0\"><tr><td><span class=\"listrating-score-title\">Score:</span> <span class=\"listrating-score\">" . number_format($row->vote_avg, 2) . "</span></td><td>" . $Vote->displayRating($row->vote_avg) . "</td></tr></table>";
                 $output .= "</td>";
                 $output .= "</tr>";
             }
             // ** Display Blurb of N Characters (stored in ShowBlurb)
             if ($this->ShowBlurb > 0) {
                 $output .= "<tr>";
                 $output .= "<td class=\"listblurb\">";
                 $output .= $this->getBlurb($row->page_title);
                 $output .= '</td>';
                 $output .= "</tr>";
             }
             // ** Show most popular categories for current page
             if ($this->ShowCtg == 1) {
                 $output .= "<tr>";
                 $output .= "<td class=\"categorylinks\">";
                 $output .= $this->getCategoryLinks($row->page_id, 3);
                 $output .= '</td>';
                 $output .= "</tr>";
             }
             // ** Show Stats for page
             if ($this->ShowStats == 1) {
                 $output .= "<tr>";
                 $output .= '<td class="liststats"><span class="liststatstitle">stats</span>: ';
                 if ($this->Order != 'VOTES') {
                     $output .= '<img src="images/voteIcon.gif" alt="v" /> ' . $row->vote_count . ' votes';
                 }
                 if ($this->Order == 'PAGEVIEWS') {
                     $output .= ' [' . $row->page_counter . ' Views]';
                 }
                 if ($this->Order == 'VOTES') {
                     $output .= '<img src="images/voteIcon.gif" alt="v" /> ' . $row->vote_count . ' votes';
                 }
                 if ($this->Order == 'EDITS') {
                     $output .= ' [' . $row->Num_Edits . ' Edits]';
                 }
                 if ($this->Order == 'LATEST') {
                     $output .= ' [Updated ' . wfTimestamp(TS_RFC2822, $row->page_touched) . ']';
                 }
                 if ($this->ShowRating == 1) {
                     $CommentLabel = "reviews";
                 } else {
                     $CommentLabel = "comments";
                 }
                 $output .= ' <img src="images/commentIcon.gif" alt="c" /> ' . $row->comment_count . ' ' . $CommentLabel . '</td>';
                 $output .= "</tr>";
             }
             $ListCountShow++;
             $output .= "</table>";
         }
         $ListCount++;
     }
     if ($this->ShowNav == 1) {
         $output .= "<div id=\"listpagesnav\">";
         if ($this->PageNo == 1) {
             $output .= $this->getNavLink("Prev", 0);
         } else {
             $output .= $this->getNavLink("Prev", -1);
         }
         $output .= "&nbsp;";
         if ($ListCount > $ListCountShow) {
             $output .= $this->getNavLink("Next", 1);
         } else {
             $output .= $this->getNavLink("Next", 0);
         }
         $output .= "</div>";
     }
     $output .= "</td></tr></table>";
     $output .= "</div>";
     return $output;
 }