/** * 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 ''; } }
function showEditor( $id, $type ) { global $wgRequest, $wgLang; $text_prev = ''; $dbr = wfGetDB( DB_SLAVE ); if ( $this->result == false ) { $text_prev = $wgRequest->getVal( 'frmText' ); $title_prev = $wgRequest->getVal( 'frmTitle' ); } else { $title_prev = wfMsg( 'wikiforum-thread-title' ); } if ( $type == 'addthread' || $type == 'editthread' ) { $mod_editthread = $wgRequest->getInt( 'editthread' ); $mod_preview = $wgRequest->getBool( 'butPreview' ); if ( $mod_editthread && $mod_editthread > 0 ) { if ( !$text_prev || !$title_prev || $mod_preview == true ) { $data_thread = $dbr->fetchObject( $dbr->select( 'wikiforum_threads', array( 'wft_thread', 'wft_thread_name', 'wft_text' ), array( 'wft_deleted' => 0, 'wft_thread' => intval( $mod_editthread ) ), __METHOD__ ) ); $action = array( 'editthread' => $data_thread->wft_thread ); if ( !$text_prev ) { $text_prev = $data_thread->wft_text; } if ( $title_prev == wfMsg( 'wikiforum-thread-title' ) ) { $title_prev = $data_thread->wft_thread_name; } } } else { $action = array( 'addthread' => $id ); } $height = '25em'; $save_button = wfMsg( 'wikiforum-save-thread' ); $input = WikiForumGui::getInput( $title_prev ); } else { // add reply $mod_comment = $wgRequest->getInt( 'editcomment' ); $mod_form = $wgRequest->getBool( 'form' ); $mod_preview = $wgRequest->getBool( 'butPreview' ); $mod_quotec = $wgRequest->getInt( 'quotecomment' ); $mod_quotet = $wgRequest->getInt( 'quotethread' ); // quote if ( isset( $mod_quotec ) && $mod_quotec > 0 ) { $reply = $dbr->fetchObject( $dbr->select( array( 'wikiforum_replies', 'user' ), array( 'wfr_reply_text', 'wfr_posted_timestamp', 'user_name' ), array( 'wfr_deleted' => 0, 'wfr_reply_id' => $mod_quotec ), __METHOD__, array(), array( 'user' => array( 'LEFT JOIN', 'user_id = wfr_user' ) ) ) ); if ( $reply ) { $posted = wfMsg( 'wikiforum-posted', $wgLang->timeanddate( $reply->wfr_posted_timestamp ), // Jack: removed this here to make quoting work // if this is present, then pressing the quote button // will generate shit like [quote=Posted on foo by Bar // <a href="/wiki/User:Bar" title="Bar">Bar</a> ( // <a href="/wiki/Project:Administrators">administrator</a>) // which is *not* what we want /*$this->getUserLink(*/ $reply->user_name /*)*/ ); $text_prev = '[quote=' . $posted . ']' . $reply->wfr_reply_text . '[/quote]'; } } elseif ( isset( $mod_quotet ) && $mod_quotet > 0 ) { $thread = $dbr->selectRow( array( 'wikiforum_threads', 'user' ), array( 'wft_text', 'wft_posted_timestamp', 'user_name' ), array( 'wft_deleted' => 0, 'wft_thread' => $mod_quotet ), __METHOD__, array(), array( 'user' => array( 'LEFT JOIN', 'user_id = wft_user' ) ) ); if ( $thread ) { $posted = wfMsg( 'wikiforum-posted', $wgLang->timeanddate( $thread->wft_posted_timestamp ), // see the explanation above /*$this->getUserLink(*/ $thread->user_name /*)*/ ); $text_prev = '[quote=' . $posted . ']' . $thread->wft_text . '[/quote]'; } } // end quote if ( isset( $mod_comment ) && $mod_comment > 0 && ( $mod_form != true || $mod_preview == true ) ) { if ( $mod_preview == true ) { $id = $wgRequest->getInt( 'thread' ); } $dbr = wfGetDB( DB_SLAVE ); $reply = $dbr->fetchObject( $dbr->select( 'wikiforum_replies', array( 'wfr_reply_id', 'wfr_reply_text' ), array( 'wfr_deleted' => 0, 'wfr_reply_id' => $mod_comment ), __METHOD__ ) ); $action = array( 'thread' => $id, 'form' => true, 'editcomment' => $reply->wfr_reply_id ); if ( $mod_preview != true ) { $text_prev = $reply->wfr_reply_text; } } else { $action = array( 'addcomment' => $id, 'thread' => $id ); } $height = '10em'; $input = ''; $save_button = wfMsg( 'wikiforum-save-reply' ); } return WikiForumGui::getWriteForm( $type, $action, $input, $height, $text_prev, $save_button ); }