echo "<div id='lower_ads'>{$bottom_ads}</div>"; } if ($show_ad_section) { echo $ad_section; } ?> <?php echo $bottom_site_notice; ?> <?php if ($wgTitle->isTalkPage()) { if ($wgTitle->getFullURL() != $wgUser->getUserPage()->getTalkPage()->getFullURL()) { ?> <div class="article_inner"> <?php Postcomment::getForm(); ?> </div> <?php } else { ?> <a name='postcomment'></a> <a name='post'></a> <?php } } ?> <?php $catlinks = $sk->getCategoryLinks(false);
static function processHTML($body, $action = '', $opts = array()) { global $wgUser, $wgTitle; $processHTML = true; wfRunHooks('PreWikihowProcessHTML', array($title, &$processHTML)); if (!$processHTML) { return $body; } $skin = $wgUser->getSkin(); $doc = PHPQuery::newDocument($body); //run ShowGrayContainer hook for this if (@$opts['show-gray-container']) { pq("#bodycontents")->addClass("minor_section"); } //let's mark each bodycontents section so we can target it with CSS if ($action) { pq("#bodycontents")->addClass("bc_" . $action); } //DISCUSSION/USER TALK////////////////////// //move some pieces above the main part pq("#bodycontents")->before(pq(".template_top")->addClass("wh_block")); pq("#bodycontents")->before(pq(".archive_table")->addClass("wh_block")); //remove those useless paragraph line breaks $bc = preg_replace('/<p><br><\\/p>/', '', pq("#bodycontents")->html()); pq("#bodycontents")->html($bc); //insert postcomment form $pcf = Postcomment::getForm(false, null, true); if ($pcf && $wgTitle->getFullURL() != $wgUser->getUserPage()->getTalkPage()->getFullURL()) { $pc_form = $pcf; } else { $pc_form = '<a name="postcomment"></a><a name="post"></a>'; } pq("#bodycontents")->append($pc_form); //HISTORY////////////////////// //move top nav down a smidge pq("#history_form")->before(pq(".navigation:first")); //EDIT PREVIEW////////////////////// if (substr($action, 0, 6) == 'submit') { $name = $action == 'submit2' ? "#editpage" : "#editform"; $preview = pq("#wikiPreview"); $changes = pq("#wikiDiff")->addClass("wh_block"); pq("#wikiPreview")->remove(); pq("#wikiDiff")->remove(); //preview before or after based on user preference if ($wgUser->getOption('previewontop')) { pq($name)->before($preview); pq($name)->before($changes); } else { pq($name)->after($preview); pq($name)->after($changes); } } return $doc->htmlOuter(); }
private function displayNABConsole(&$dbw, &$dbr, $target) { global $wgOut, $wgRequest, $wgUser; $not_found = false; $title = Title::newFromURL($target); if (!$title || !$title->exists()) { $articleName = $title ? $title->getFullText() : $target; $wgOut->addHTML("<p>Error: Article “{$articleName}” not found. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>"); $not_found = true; } if (!$not_found) { $rev = Revision::newFromTitle($title); if (!$rev) { $wgOut->addHTML("<p>Error: No revision for “{$title->getFullText()}”. Return to <a href='/Special:Newarticleboost'>New Article Boost</a> instead.</p>"); $not_found = true; } } if (!$not_found) { $in_nab = $dbr->selectField('newarticlepatrol', 'count(*)', array('nap_page' => $title->getArticleID()), __METHOD__) > 0; if (!$in_nab) { $wgOut->addHTML("<p>Error: This article is not in the NAB list.</p>"); $not_found = true; } } if ($not_found) { $pageid = $wgRequest->getVal('page'); if (strpos($target, ':') !== false && $pageid) { $wgOut->addHTML('<p>We can to try to <a href="/Special:NABClean/' . $pageid . '">delete this title</a> if you know this title exists in NAB yet is likely bad data.</p>'); } return; } $locked = false; $min_timestamp = $dbr->selectField("revision", "min(rev_timestamp)", "rev_page=" . $title->getArticleId(), __METHOD__); $first_user = $dbr->selectField("revision", "rev_user_text", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__); $first_user_id = $dbr->selectField("revision", "rev_user", array("rev_page=" . $title->getArticleId(), 'rev_timestamp' => $min_timestamp), __METHOD__); $user = new User(); if ($first_user_id) { $user->setId($first_user_id); $user->loadFromDatabase(); } else { $user->setName($first_user); } $user_talk = $user->getTalkPage(); $ut_id = $user_talk->getArticleID(); $display_name = $user->getRealName() ? $user->getRealName() : $user->getName(); $wgOut->setPageTitle(wfMsg('nap_title', $title->getFullText())); $count = $dbr->selectField('suggested_titles', array('count(*)'), array('st_title' => $title->getDBKey()), __METHOD__); $extra = $count > 0 ? ' - from Suggested Titles database' : ''; $wgOut->addWikiText(wfMsg('nap_writtenby', $user->getName(), $display_name, $extra)); $wgOut->addHTML(wfMsgExt('nap_quicklinks', 'parseinline', $this->me->getFullText() . "/" . $title->getFullText())); /// CHECK TO SEE IF ARTICLE IS LOCKED OR ALREADY PATROLLED $aid = $title->getArticleID(); $half_hour_ago = wfTimestamp(TS_MW, time() - 30 * 60); $patrolled = $dbr->selectField('newarticlepatrol', 'nap_patrolled', array("nap_page={$aid}"), __METHOD__); if ($patrolled) { $locked = true; $wgOut->addHTML(wfMsgExt("nap_patrolled", 'parse')); } else { $user_co = $dbr->selectField('newarticlepatrol', 'nap_user_co', array("nap_page={$aid}", "nap_timestamp_co > '{$half_hour_ago}'"), __METHOD__); if ($user_co != '' && $user_co != 0 && $user_co != $wgUser->getId()) { $x = User::newFromId($user_co); $wgOut->addHTML(wfMsgExt("nap_usercheckedout", 'parse', $x->getName())); $locked = true; } else { // CHECK OUT THE ARTICLE TO THIS USER $ts = wfTimestampNow(); $dbw->update('newarticlepatrol', array('nap_timestamp_co' => $ts, 'nap_user_co' => $wgUser->getId()), array("nap_page = {$aid}"), __METHOD__); } } $expandSpan = '<span class="nap_expand">▼</span>'; $externalLinkImg = '<img src="' . wfGetPad('/skins/common/images/external.png') . '"/>'; /// SIMILAR RESULT $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_similarresults') . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $count = 0; $l = new LSearch(); $hits = $l->googleSearchResultTitles($title->getFullText(), 0, 5); if (sizeof($hits) > 0) { $html = ""; foreach ($hits as $hit) { $t1 = $hit; $id = rand(0, 500); if ($t1 == null || $t1->getFullURL() == $title->getFullURL() || $t1->getNamespace() != NS_MAIN || !$t1->exists()) { continue; } $safe_title = htmlspecialchars(str_replace("'", "'", $t1->getText())); $html .= "<tr><td>" . $this->skin->makeLinkObj($t1, wfMsg('howto', $t1->getText())) . "</td><td style='text-align:right; width: 200px;'>[<a href='#action' onclick='nap_Merge(\"{$safe_title}\");'>" . wfMsg('nap_merge') . "</a>] " . " [<a href='#action' onclick='javascript:nap_Dupe(\"{$safe_title}\");'>" . wfMsg('nap_duplicate') . "</a>] " . " <span id='mr_{$id}'>[<a onclick='javascript:nap_MarkRelated({$id}, {$t1->getArticleID()}, {$title->getArticleID()});'>" . wfMsg('nap_related') . "</a>]</span> " . "</td></tr>"; $count++; } } if ($count == 0) { $wgOut->addHTML(wfMsg('nap_no-related-topics')); } else { $wgOut->addHTML(wfMsg('nap_already-related-topics') . "<table style='width:100%;'>{$html}</table>"); } $wgOut->addHTML(wfMsg('nap_othersearches', urlencode($title->getFullText()))); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// COPYRIGHT CHECKER $cc_check = SpecialPage::getTitleFor('Copyrightchecker', $title->getText()); $wgOut->addHTML("<script type='text/javascript'>window.onload = nap_cCheck; var nap_cc_url = \"{$cc_check->getFullURL()}\";</script>"); $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_copyrightchecker') . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<div id='nap_copyrightresults'><center><img src='/extensions/wikihow/rotate.gif' alt='loading...'/></center></div>"); $wgOut->addHTML("<center><input type='button' class='button primary' onclick='nap_cCheck();' value='Check'/></center>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// ARTICLE PREVIEW $editUrl = Title::makeTitle(NS_SPECIAL, "QuickEdit")->getFullURL() . "?type=editform&target=" . urlencode($title->getFullText()) . "&fromnab=1"; $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='article' id='anchor-article'></a>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_articlepreview') . " - <a href=\"{$title->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getEditURL()}\" target=\"new\">" . wfMsg('edit') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getFullURL()}?action=history\" target=\"new\">" . wfMsg('history') . "</a> {$externalLinkImg}" . " - <a href=\"{$title->getTalkPage()->getFullURL()}?action=history\" target=\"new\">" . wfMsg('discuss') . "</a> {$externalLinkImg}" . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<div id='article_contents' ondblclick='nap_editClick(\"{$editUrl}\");'>"); $popts = $wgOut->parserOptions(); $popts->setTidy(true); $parserOutput = $wgOut->parse($rev->getText(), $title, $popts); $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads', 'ns' => $title->getNamespace())); $wgOut->addHTML($html); $wgOut->addHTML("</div>"); $wgOut->addHTML("<center><input id='editButton' type='button' class='button primary' name='wpEdit' value='" . wfMsg('edit') . "' onclick='nap_editClick(\"{$editUrl}\");'/></center>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); $wgOut->addHTML('<div style="clear: both;"></div>'); /// DISCUSSION PREVIEW $talkPage = $title->getTalkPage(); $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='talk' id='anchor-talk'></a>"); $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_discussion') . " - <a href=\"{$talkPage->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<div id='disc_page'>"); if ($talkPage->getArticleID() > 0) { $rp = Revision::newFromTitle($talkPage); $wgOut->addHTML($wgOut->parse($rp->getText())); } else { $wgOut->addHTML(wfMsg('nap_discussionnocontent')); } $wgOut->addHTML(Postcomment::getForm(true, $talkPage, true)); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// USER INFORMATION $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='user' id='anchor-user'></a>"); $used_templates = array(); if ($ut_id > 0) { $res = $dbr->select('templatelinks', array('tl_title'), array('tl_from=' . $ut_id), __METHOD__); while ($row = $dbr->fetchObject($res)) { $used_templates[] = strtolower($row->tl_title); } $dbr->freeResult($res); } $wgOut->addHTML("<h2 class='nap_header'>{$expandSpan} " . wfMsg('nap_userinfo') . " - <a href=\"{$user_talk->getFullURL()}\" target=\"new\">" . wfMsg('nap_articlelinktext') . "</a> {$externalLinkImg}" . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $contribs = SpecialPage::getTitleFor('Contributions', $user->getName()); $regDateTxt = ""; if ($user->getRegistration() > 0) { preg_match('/^(\\d{4})(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)$/D', $user->getRegistration(), $da); $uts = gmmktime((int) $da[4], (int) $da[5], (int) $da[6], (int) $da[2], (int) $da[3], (int) $da[1]); $regdate = gmdate('F j, Y', $uts); $regDateTxt = wfMsg('nap_regdatetext', $regdate) . ' '; } $key = 'nap_userinfodetails_anon'; if ($user->getID() != 0) { $key = 'nap_userinfodetails'; } $wgOut->addWikiText(wfMsg($key, $user->getName(), number_format(WikihowUser::getAuthorStats($first_user), 0, "", ","), $title->getFullText(), $regDateTxt)); if (WikihowUser::getAuthorStats($first_user) < 50) { if ($user_talk->getArticleId() == 0) { $wgOut->addHTML(wfMsg('nap_newwithouttalkpage')); } else { $rp = Revision::newFromTitle($user_talk); $xtra = ""; if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE 8.0") === false) { $xtra = "max-height: 300px; overflow: scroll;"; } $wgOut->addHTML("<div style='border: 1px solid #eee; {$xtra}'>" . $wgOut->parse($rp->getText()) . "</div>"); } } if ($user_talk->getArticleId() != 0 && sizeof($used_templates) > 0) { $wgOut->addHTML('<br />' . wfMsg('nap_usertalktemplates', implode($used_templates, ", "))); } $wgOut->addHTML(Postcomment::getForm(true, $user_talk, true)); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); /// ACTION INFORMATION $maxrcid = $dbr->selectField('recentchanges', 'max(rc_id)', array('rc_cur_id=' . $aid), __METHOD__); $wgOut->addHTML("<div class='nap_section minor_section'>"); $wgOut->addHTML("<a name='action' id='anchor-action'></a>"); $wgOut->addHTML("<h2 class='nap_header'> " . wfMsg('nap_action') . "</h2>"); $wgOut->addHTML("<div class='nap_body section_text'>"); $wgOut->addHTML("<form action='{$this->me->getFullURL()}' name='nap_form' method='post' onsubmit='return checkNap();'>"); $wgOut->addHTML("<input type='hidden' name='target' value='" . htmlspecialchars($title->getText()) . "'/>"); $wgOut->addHTML("<input type='hidden' name='page' value='{$aid}'/>"); $wgOut->addHTML("<input type='hidden' name='newbie' value='" . $wgRequest->getVal('newbie', 0) . "'/>"); $wgOut->addHTML("<input type='hidden' name='prevuser' value='" . $user->getName() . "'/>"); $wgOut->addHTML("<input type='hidden' name='maxrcid' value='{$maxrcid}'/>"); $wgOut->addHTML("<table>"); $suggested = $dbr->selectField('suggested_titles', 'count(*)', array('st_title' => $title->getDBKey()), __METHOD__); if ($suggested > 0) { $wgOut->addHTML("<tr><td valign='top'>" . wfMsg('nap_suggested_warning') . "</td></tr>"); } $wgOut->addHTML("</table>"); $wgOut->addHTML(wfMsg('nap_actiontemplates')); if ($wgUser->isAllowed('delete') || $wgUser->isAllowed('move')) { $wgOut->addHTML(wfMsg('nap_actionmovedeleteheader')); if ($wgUser->isAllowed('move')) { $wgOut->addHTML(wfMsg('nap_actionmove', htmlspecialchars($title->getText()))); } if ($wgUser->isAllowed('delete')) { $wgOut->addHTML(wfMsg('nap_actiondelete')); } } // BUTTONS $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_skip') . "' id='nap_skip' name='nap_skip' class='button secondary' />"); if (!$locked) { $wgOut->addHTML("<input type='submit' value='" . wfMsg('nap_markaspatrolled') . "' id='nap_submit' name='nap_submit' class='button primary' />"); } $wgOut->addHTML("</form>"); $wgOut->addHTML("</div>"); $wgOut->addHTML("</div>"); $wgOut->addHTML(<<<END <script type='text/javascript'> var tabindex = 1; for(i = 0; i < document.forms.length; i++) { \tfor (j = 0; j < document.forms[i].elements.length; j++) { \t\tswitch (document.forms[i].elements[j].type) { \t\t\tcase 'submit': \t\t\tcase 'text': \t\t\tcase 'textarea': \t\t\tcase 'checkbox': \t\t\tcase 'button': \t\t\t\tdocument.forms[i].elements[j].tabIndex = tabindex++; \t\t\t\tbreak; \t\t\tdefault: \t\t\t\tbreak; \t\t} \t} } // Handlers for expand/contract arrows (function (\$) { \$('.nap_expand').click(function() { \tvar thisSpan = \$(this); \tvar body = thisSpan.parent().next(); \tvar footer = body.next(); \tif (body.css('display') != 'none') { \t\tfooter.hide(); \t\tbody.css('overflow', 'hidden'); \t\tvar oldHeight = body.height(); \t\tbody.animate( \t\t\t{ height: 0 }, \t\t\t200, \t\t\t'swing', \t\t\tfunction () { \t\t\t\tthisSpan.html('►'); \t\t\t\tbody \t\t\t\t\t.hide() \t\t\t\t\t.height(oldHeight); \t\t\t}); \t} else { \t\tvar oldHeight = body.height(); \t\tbody.height(0); \t\tbody.animate( \t\t\t{ height: oldHeight }, \t\t\t200, \t\t\t'swing', \t\t\tfunction () { \t\t\t\tthisSpan.html('▼'); \t\t\t\tfooter.show(); \t\t\t\tbody.css('overflow', 'visible'); \t\t\t}); \t} \treturn false; }); })(jQuery); </script> END ); }
function execute($par) { global $wgUser, $wgOut, $wgRequest, $wgTitle; if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if (!($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()))) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext'); return; } wfLoadExtensionMessages("NFDGuardian"); if ($wgRequest->getVal('fetchInnards')) { //get next article to vote on $wgOut->disable(); $result = self::getNextInnards($wgRequest->getVal('nfd_type')); print_r(json_encode($result)); return; } else { if ($wgRequest->getVal('getVoteBlock')) { //get all the votes for the right rail module $wgOut->setArticleBodyOnly(true); $wgOut->addHTML(self::getVoteBlock($wgRequest->getVal('nfd_id'))); return; } else { if ($wgRequest->getVal('edit')) { //get the html that goes into the page when a user clicks the edit tab $wgOut->setArticleBodyOnly(true); $t = Title::newFromID($wgRequest->getVal('articleId')); if ($t) { $a = new Article($t); $editor = new EditPage($a); $editor->edit(); //Old code for when we wanted to remove //the nfd template from the edit window /*$content = $wgOut->getHTML(); $wgOut->clearHTML(); //grab the edit form $data = array(); $data['form'] = $content; //then take out the template $c = new NFDProcessor(); $template = $c->getFullTemplate($wgRequest->getVal('nfd_id')); $articleContent = $a->getContent(); $articleContent = str_replace($template, "", $articleContent); $data['newContent'] = $articleContent; print_r(json_encode($data));*/ } return; } else { if ($wgRequest->getVal('discussion')) { //get the html that goes into the page when a user clicks the discussion tab $wgOut->setArticleBodyOnly(true); $t = Title::newFromID($wgRequest->getVal('articleId')); if ($t) { $tDiscussion = $t->getTalkPage(); if ($tDiscussion) { $a = new Article($tDiscussion); $content = $a->getContent(); $wgOldTitle = $wgTitle; $wgTitle = $tDiscussion; $wgOut->addHTML($wgOut->parse($content)); $wgOut->addHTML(Postcomment::getForm(true, $tDiscussion, true)); $wgTitle = $wgOldTitle; } } return; } else { if ($wgRequest->getVal('confirmation')) { //get confirmation dialog after user has edited the article $wgOut->setArticleBodyOnly(true); echo $this->confirmationModal($wgRequest->getVal('articleId')); return; } else { if ($wgRequest->getVal('history')) { //get the html that goes into the page when a user clicks the history tab $wgOut->setArticleBodyOnly(true); $t = Title::newFromID($wgRequest->getVal('articleId')); if ($t) { $a = new Article($t); $pageHistory = new PageHistory($a); $pageHistory->history(); return; } } else { if ($wgRequest->getVal('diff')) { //get the html that goes into the page when a user asks for a diffs $wgOut->setArticleBodyOnly(true); $t = Title::newFromID($wgRequest->getVal('articleId')); if ($t) { $a = new Article($t); $wgOut->addHtml('<div class="article_inner">'); $a->view(); $wgOut->addHtml('</div>'); } return; } else { if ($wgRequest->getVal('article')) { //get the html that goes into the page when a user clicks the article tab $wgOut->setArticleBodyOnly(true); $t = Title::newFromId($wgRequest->getVal('articleId')); if ($t) { $r = Revision::newFromTitle($t); if ($r) { $popts = $wgOut->parserOptions(); $popts->setTidy(true); echo WikihowArticleHTML::processArticleHTML($wgOut->parse($r->getText(), $t, $popts), array('no-ads' => 1, 'ns' => $t->getNamespace())); } } return; } else { if ($wgRequest->wasPosted()) { $wgOut->setArticleBodyOnly(true); if ($wgRequest->getVal('submitEditForm')) { //user has edited the article from within the NFD Guardian tool $wgOut->disable(); $this->submitEdit(); $result = self::getNextInnards($wgRequest->getVal('nfd_type')); print_r(json_encode($result)); return; } else { //user has voted if ($wgRequest->getVal('nfd_skip', 0) == 1) { NFDProcessor::skip($wgRequest->getVal('nfd_id')); } else { NFDProcessor::vote($wgRequest->getVal('nfd_id'), $wgRequest->getVal('nfd_vote')); } $wgOut->disable(); $result = self::getNextInnards($wgRequest->getVal('nfd_type')); print_r(json_encode($result)); return; } } } } } } } } } } /** * This is the shell of the page, has the buttons, etc. */ $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('nfdGuardian.js'), 'extensions/wikihow/nfd', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('clientscript.js'), 'skins/common', false)); $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('nfdGuardian.css'), 'extensions/wikihow/nfd', false)); //add delete confirmation to bottom of page $wgOut->addHtml("<div class='waiting'><img src='" . wfGetPad('/extensions/wikihow/rotate.gif') . "' alt='' /></div>"); $tmpl = new EasyTemplate(dirname(__FILE__)); $wgOut->addHTML($tmpl->execute('NFDdelete.tmpl.php')); $wgOut->setHTMLTitle(wfMsg('nfd')); $wgOut->setPageTitle(wfMsg('nfd')); // add standings widget $group = new NFDStandingsGroup(); $indi = new NFDStandingsIndividual(); $indi->addStatsWidget(); $group->addStandingsWidget(); }