parser hook with the Parser. * * @param $parser Parser: instance of Parser (not necessarily $wgParser) * @return Boolean: true */ function wfCommentsListAll( &$parser ) { $parser->setHook( 'commentsAll', 'getcommentsAll' ); return true; } /** * Get comments all -- * * @return String: HTML */ function getcommentsAll( $input, $args, $parser ) { global $wgMemc, $wgUploadPath; $oneDay = 60 * 60 * 24 * 50000; // Try memcached first $key = wfMemcKey( 'comments-all', 'standalone-hook' ); $data = $wgMemc->get( $key ); if( $data ) { // success, got it from memcached! $commentsAll = $data; //$dbr = wfGetDB( DB_SLAVE ); } elseif ( !$data || $args['nocache'] ) { // just query the DB $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( array( 'Comments', 'page' ), array( 'Comment_Username', 'comment_ip', 'comment_text', 'comment_date', 'Comment_user_id', 'CommentID', 'IFNULL(Comment_Plus_Count - Comment_Minus_Count,0) AS Comment_Score', 'Comment_Plus_Count AS CommentVotePlus', 'Comment_Minus_Count AS CommentVoteMinus', 'Comment_Parent_ID', 'page_title', 'page_namespace' ), array( 'comment_page_id = page_id', 'UNIX_TIMESTAMP(comment_date) > ' . ( time() - ( $oneDay ) ) ), __METHOD__, array( 'ORDER BY' => '(comment_date) DESC') ); $commentsAll = array(); foreach ( $res as $row ) { $commentsAll[] = array( 'username' => $row->Comment_Username, 'userid' => $row->Comment_user_id, 'score' => $row->CommentVotePlus, 'text' => $row->comment_text, 'id' => $row->CommentID, 'pagens' => $row->page_namespace, 'pagetitle' => $row->page_title, 'date' => $row->comment_date ); } $wgMemc->set( $key, $commentsAll, $oneDay ); } $comments = ''; foreach ( $commentsAll as $commentsAllTemp ) { $title2 = Title::makeTitle( $commentsAllTemp['pagens'], $commentsAllTemp['pagetitle'] ); if( $commentsAllTemp['userid'] != 0 ) { $title = Title::makeTitle( NS_USER, $commentsAllTemp['username'] ); $commentPoster_Display = $commentsAllTemp['username']; $commentPoster = '' . $commentsAllTemp['username'] . ''; //avatar = new wAvatar( $commentsAllTemp['userid'], 's' ); $commentIcon = 'extensions/Comments/images/default_s.gif'; } else { $title = Title::makeTitle( NS_USER, $commentsAllTemp['username'] ); $commentPoster_Display = $commentsAllTemp['username']; $commentPoster = '' . $commentsAllTemp['username'] . ''; //avatar = new wAvatar( $commentsAllTemp['userid'], 's' ); $commentIcon = 'extensions/Comments/images/default_s.gif'; /* $commentPoster_Display = wfMsg( 'comment-anon-name' ); $commentPoster = wfMsg( 'comment-anon-name' ); $commentIcon = '{$IP}/extensions/Comments/images/default_s.gif'; */ } // $comment_text = substr( $commentsAllTemp['text'], 0, 550 - strlen( $commentPoster_Display ) ); $comment_text = $commentsAllTemp['text']; if( $comment_text != $commentsAllTemp['text'] ) { $comment_text .= wfMsg( 'ellipsis' ); } $comments .= '
'; $comments .= '
'; $comments .= '
'; $comments .= '
' . $commentsAllTemp['date'] . ' -
'; $comments .= '
' . $commentPoster . ':
'; $comments .= '
'; $comments .= '
' . '' . $comment_text . '
'; $comments .= '

'; // $comments .= '
'; // $sign = ''; // /*if ( $commentsAllTemp['score'] > 0 ) { // $sign = '+'; // } elseif ( $commentsAllTemp['score'] < 0 ) { // $sign = '-'; // this *really* shouldn't be happening... // }*/ // $comments .= '
' . $sign . // ' // ' . $commentsAllTemp['date'] . ' - ' . $commentPoster . ': '; // $comments .= '' . '' . $comment_text . '
' . // ''; // $comments .= '
'; } $output = ''; if ( !empty( $comments ) ) { $output .= $comments; } else { $output .= wfMsg( 'comments-no-comments-of-day' ); } return $output; }