/** * Callback for the <WikiForumThread> hook. * Takes the following arguments: id (ID number of the thread, used in SQL * query), replies (whether to display replies) */ public static function renderWikiForumThread( $input, $args, $parser, $frame ) { global $wgOut, $wgLang; if ( isset( $args['id'] ) && $args['id'] > 0 ) { $dbr = wfGetDB( DB_SLAVE ); $sqlThreads = $dbr->select( array( 'wikiforum_forums', 'wikiforum_category', 'wikiforum_threads', 'user' ), array( 'wft_thread', 'wft_thread_name', 'wft_text', 'wff_forum', 'wff_forum_name', 'wfc_category', 'wfc_category_name', 'user_name', 'user_id', 'wft_edit_timestamp', 'wft_edit_user', 'wft_posted_timestamp', 'wft_user', 'wft_closed', 'wft_closed_user' ), array( 'wff_deleted' => 0, 'wfc_deleted' => 0, 'wft_deleted' => 0, 'wff_category = wfc_category', 'wff_forum = wft_forum', 'wft_thread' => intval( $args['id'] ) ), __METHOD__, array(), array( 'user' => array( 'LEFT JOIN', 'user_id = wft_user' ) ) ); $overview = $dbr->fetchObject( $sqlThreads ); if ( $overview ) { $posted = wfMsg( 'wikiforum-posted', $wgLang->timeanddate( $overview->wft_posted_timestamp ), WikiForumClass::getUserLink( $overview->user_name ) ); if ( $overview->wft_edit_timestamp > 0 ) { $posted .= '<br /><i>' . wfMsg( 'wikiforum-edited', $wgLang->timeanddate( $overview->wft_edit_timestamp ), WikiForumClass::getUserLinkById( $overview->wft_edit_user ) ) . '</i>'; } $output = WikiForumGui::getHeaderRow( $overview->wfc_category, $overview->wfc_category_name, $overview->wff_forum, $overview->wff_forum_name, false ); $specialPageObj = SpecialPage::getTitleFor( 'WikiForum' ); $link = $specialPageObj->escapeFullURL( 'thread=' . $overview->wft_thread ); $output .= WikiForumGui::getThreadHeader( '<a href="' . $link . '">' . $overview->wft_thread_name . '</a>', $parser->recursiveTagParse( $overview->wft_text, $frame ), $posted, '', $overview->wft_thread, $overview->user_id ); if ( isset( $args['replies'] ) && $args['replies'] ) { $replies = $dbr->select( array( 'wikiforum_replies', 'user' ), array( '*', 'user_name' ), array( 'wfr_deleted' => 0, 'wfr_thread' => $overview->pkThread ), __METHOD__, array( 'ORDER BY' => 'wfr_posted_timestamp ASC' ), array( 'user' => array( 'LEFT JOIN', 'user_id = wfr_user' ) ) ); foreach ( $replies as $reply ) { $posted = wfMsg( 'wikiforum-posted', $wgLang->timeanddate( $reply->wfr_posted_timestamp ), WikiForumClass::getUserLink( $reply->user_name ) ); if ( $reply->wfr_edit > 0 ) { $posted .= '<br /><i>' . wfMsg( 'wikiforum-edited', $wgLang->timeanddate( $reply->wfr_edit ), WikiForumClass::getUserLinkById( $reply->wfr_edit_user ) ) . '</i>'; } $output .= WikiForumGui::getReply( $wgOut->parse( WikiForum::deleteTags( $reply->wfr_reply_text ) ), $posted, '', $reply->wfr_reply_id ); } } $output .= WikiForumGui::getThreadFooter(); return $output; } } else { return ''; } }
/** * Preview a reply. */ function previewIssue( $type, $id, $previewTitle, $previewText ) { global $wgUser, $wgLang; $output = $this->showFailure(); $title = wfMsg( 'wikiforum-preview' ); if ( $previewTitle ) { $title = wfMsg( 'wikiforum-preview-with-title', $previewTitle ); } $posted = wfMsg( 'wikiforum-posted', $wgLang->timeanddate( wfTimestampNow() ), $this->getUserLinkById( $wgUser->getId() ) ); if ( $type == 'addcomment' || $type == 'editcomment' ) { $output .= WikiForumGui::getReplyHeader( $title ); $output .= WikiForumGui::getReply( $this->parseIt( $previewText ), $posted, false, 0, $wgUser->getId() ); } else { $output .= WikiForumGui::getThreadHeader( $title, $this->parseIt( $previewText ), $posted, false, false, $wgUser->getId() ); } $output .= WikiForumGui::getThreadFooter(); $this->result = false; $output .= $this->showEditor( $id, $type ); // Jack this adds an useless "Overview" link to the bottom of the page // (below the save reply/cancel buttons) so I took the liberty of // removing it # $output .= WikiForumGui::getHeaderRow( 0, '', 0, '', '' ); $output .= $this->showFailure(); return $output; }