コード例 #1
0
ファイル: test_html5.php プロジェクト: biribogos/wikihow-src
function process($title)
{
    global $wgOut, $wgTitle;
    $rev = Revision::newFromTitle($title);
    if (!$rev) {
        continue;
    }
    #echo "Checkng {$title->getText()}\n";
    $text = $rev->getText();
    $oldtext = $text;
    wfRunHooks('ArticleBeforeOutputWikiText', array(&$article, &$text));
    $html = $wgOut->parse($text);
    $wgTitle = $title;
    $html = WikihowArticleHTML::postProcess($html, array('no-ads' => 0));
    $editor = new Html5editor();
    $newtext = $editor->convertHTML2Wikitext($html, $oldtext);
    echo "{$title->getFullURL()} - {$title->getArticleID()}\n";
}
コード例 #2
0
 private function addMethod($articleId, $altMethod, $altSteps)
 {
     global $wgParser, $wgUser;
     $title = Title::newFromID($articleId);
     $result = array();
     if ($title) {
         $dbw = wfGetDB(DB_MASTER);
         $dbw->insert('altmethodadder', array('ama_page' => $articleId, 'ama_method' => $altMethod, 'ama_steps' => $altSteps, 'ama_user' => $wgUser->getID(), 'ama_timestamp' => wfTimestampNow()));
         $result['success'] = true;
         //Parse the wikiText that they gave us.
         //Need to add in a steps header so that mungeSteps
         //actually knows that it's a steps section
         $newMethod = $wgParser->parse("== Steps ==\n=== " . $altMethod . " ===\n" . $altSteps, $title, new ParserOptions())->getText();
         $result['html'] = WikihowArticleHTML::postProcess($newMethod, array('no-ads' => true));
     } else {
         $result['success'] = false;
     }
     return $result;
 }
コード例 #3
0
ファイル: Categorizer.body.php プロジェクト: ErdemA/wikihow
 function getArticleHtml($t)
 {
     global $wgOut;
     if ($t) {
         $popts = $wgOut->parserOptions();
         $popts->setTidy(true);
         $revision = Revision::newFromTitle($t);
         $parserOutput = $wgOut->parse($revision->getText(), $t, $popts);
         return WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads', 'ns' => NS_MAIN));
     }
     return "";
 }
コード例 #4
0
 protected function getNonMobileHtml($title, $rev)
 {
     global $wgOut, $wgParser;
     $pOpts = $wgOut->parserOptions();
     $pOpts->setTidy(true);
     $pOut = $wgParser->parse($rev->getText(), $title, $pOpts, true, true, $rev->getId());
     $html = $pOut->mText;
     $pOpts->setTidy(false);
     // munge steps first
     $opts = array('no-ads' => true);
     $this->html = WikihowArticleHTML::postProcess($html, $opts);
 }
コード例 #5
0
ファイル: EditFinder.body.php プロジェクト: ErdemA/wikihow
 /**
  * cuteCUTE
  **/
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang, $wgParser, $efType, $wgTitle;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     wfLoadExtensionMessages('EditFinder');
     self::setTemplatePath();
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if ($wgUser->getID() == 0) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $this->topicMode = strtolower($par) == 'topic' || strtolower($wgRequest->getVal('edittype')) == 'topic';
     if ($wgRequest->getVal('fetchArticle')) {
         $wgOut->setArticleBodyOnly(true);
         echo json_encode($this->getNextArticle());
         return;
     } elseif ($wgRequest->getVal('show-article')) {
         $wgOut->setArticleBodyOnly(true);
         if ($wgRequest->getInt('aid') == '') {
             $catsJs = $this->topicMode ? "editFinder.getThoseInterests();" : "editFinder.getThoseCats();";
             $catsTxt = $this->topicMode ? "interests" : "categories";
             $wgOut->addHTML('<div class="article_inner">No articles found.  <a href="#" onclick="' . $catsJs . '">Select more ' . $catsTxt . '</a> and try again.</div>');
             return;
         }
         $t = Title::newFromID($wgRequest->getInt('aid'));
         $articleTitleLink = $t->getLocalURL();
         $articleTitle = $t->getText();
         //$edittype = $a['edittype'];
         //get article
         $a = new Article($t);
         $r = Revision::newFromTitle($t);
         $popts = $wgOut->parserOptions();
         $popts->setTidy(true);
         $popts->enableLimitReport();
         $parserOutput = $wgParser->parse($r->getText(), $t, $popts, true, true, $a->getRevIdFetched());
         $popts->setTidy(false);
         $popts->enableLimitReport(false);
         $html = WikihowArticleHTML::processArticleHTML($parserOutput->getText(), array('no-ads', 'ns' => NS_MAIN));
         $wgOut->addHTML($html);
         return;
     } elseif ($wgRequest->getVal('edit-article')) {
         // SHOW THE EDIT FORM
         $wgOut->setArticleBodyOnly(true);
         $t = Title::newFromID($wgRequest->getInt('aid'));
         $a = new Article($t);
         $editor = new EditPage($a);
         $editor->edit();
         return;
     } elseif ($wgRequest->getVal('action') == 'submit') {
         $wgOut->setArticleBodyOnly(true);
         $efType = strtolower($wgRequest->getVal('type'));
         $t = Title::newFromID($wgRequest->getInt('aid'));
         $a = new Article($t);
         //log it
         $params = array($efType);
         $log = new LogPage('EF_' . substr($efType, 0, 7), false);
         // false - dont show in recentchanges
         $log->addEntry('', $t, 'Repaired an article -- ' . strtoupper($efType) . '.', $params);
         $text = $wgRequest->getVal('wpTextbox1');
         $sum = $wgRequest->getVal('wpSummary');
         //save the edit
         $a->doEdit($text, $sum, EDIT_UPDATE);
         wfRunHooks("EditFinderArticleSaveComplete", array($a, $text, $sum, $wgUser, $efType));
         return;
     } elseif ($wgRequest->getVal('confirmation')) {
         $wgOut->setArticleBodyOnly(true);
         echo $this->confirmationModal($wgRequest->getVal('type'), $wgRequest->getInt('aid'));
         wfProfileOut(__METHOD__);
         return;
     } elseif ($wgRequest->getVal('cancel-confirmation')) {
         $wgOut->setArticleBodyOnly(true);
         echo $this->cancelConfirmationModal($wgRequest->getInt('aid'));
         wfProfileOut(__METHOD__);
         return;
     } else {
         //default view (same as most of the views)
         $sk = $wgUser->getSkin();
         $wgOut->setArticleBodyOnly(false);
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('mousetrap.min.js', 'jquery.cookie.js'), 'extensions/wikihow/common', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('preview.js'), 'skins/common', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('clientscript.js', 'preview.js'), 'skins/common', false));
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('editfinder.js'), 'extensions/wikihow/editfinder', false));
         $efType = strtolower($target);
         if (strpos($efType, '/') !== false) {
             $efType = substr($efType, 0, strpos($efType, '/'));
         }
         if ($efType == '') {
             //no type specified?  send 'em to format...
             $wgOut->redirect('/Special:EditFinder/Format');
         }
         $wgOut->addHTML('<script>var g_eftype = "' . $target . '";</script>');
         //add main article info
         $vars = array('pagetitle' => wfMsg('app-name') . ': ' . wfMsg($efType), 'question' => wfMsg('editfinder-question'), 'yep' => wfMsg('editfinder_yes'), 'nope' => wfMsg('editfinder_no'), 'helparticle' => wfMsg('help_' . $efType));
         $vars['uc_categories'] = $this->topicMode ? 'Interests' : 'Categories';
         $vars['lc_categories'] = $this->topicMode ? 'interests' : 'categories';
         $vars['editfinder_edit_title'] = wfMsg('editfinder_edit_title');
         $vars['editfinder_skip_title'] = wfMsg('editfinder_skip_title');
         $vars['css'] = HtmlSnips::makeUrlTags('css', array('editfinder.css'), 'extensions/wikihow/editfinder', false);
         $vars['css'] .= HtmlSnips::makeUrlTags('css', array('suggestedtopics.css'), 'extensions/wikihow', false);
         $html = EasyTemplate::html('editfinder_main', $vars);
         $wgOut->addHTML($html);
         $wgOut->setHTMLTitle(wfMsg('app-name') . ': ' . wfMsg($efType) . ' - wikiHow');
         $wgOut->setPageTitle(wfMsg('app-name') . ': ' . wfMsg($efType) . ' - wikiHow');
     }
     $stats = new EditFinderStandingsIndividual($efType);
     $stats->addStatsWidget();
     $standings = new EditFinderStandingsGroup($efType);
     $standings->addStandingsWidget();
 }
コード例 #6
0
 function execute($par)
 {
     global $wgOut, $wgRequest, $wgUser, $wgParser;
     if (!in_array('importxml', $wgUser->getRights())) {
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     // used through ajax
     if ($wgRequest->getVal('delete')) {
         $wgOut->disable();
         $dbw = wfGetDB(DB_MASTER);
         $dbw->delete('import_articles', array('ia_id' => $wgRequest->getVal('delete')));
         return;
     }
     if ($wgRequest->getVal('publishedcsv')) {
         $wgOut->disable();
         header("Content-type: text/plain;");
         $dbr = wfGetDB(DB_MASTER);
         if ($wgRequest->getVal('errs')) {
             $opts = array('ia_publish_err' => 1);
         } else {
             $opts = array('ia_published' => 1);
         }
         $res = $dbr->select('import_articles', array('ia_title', 'ia_published_timestamp'), $opts, "ImportXML::execute", array("ORDER BY" => "ia_published_timestamp"));
         while ($row = $dbr->fetchObject($res)) {
             $t = Title::newFromDBKey($row->ia_title);
             $ts = date("Y-m-d", wfTimestamp(TS_UNIX, $row->ia_published_timestamp));
             echo "{$t->getFullURL()}\t{$t->getText()}\t{$ts}\n";
         }
         return;
     }
     // used through ajax
     if ($wgRequest->getVal('view')) {
         $wgOut->disable();
         $dbr = wfGetDB(DB_MASTER);
         $text = $dbr->selectField('import_articles', array('ia_text'), array('ia_id' => $wgRequest->getVal('view')));
         echo "<textarea class='xml_edit' id='xml_input'>{$text}</textarea><br/>" . '<a onclick="save_xml(' . $wgRequest->getVal('view') . ');" class="button button136" style="float: left;" onmouseover="button_swap(this);" onmouseout="button_unswap(this);">Save</a>';
         return;
     }
     // used through ajax
     if ($wgRequest->getVal('update')) {
         $wgOut->disable();
         $dbw = wfGetDB(DB_MASTER);
         $dbw->update('import_articles', array('ia_text' => $wgRequest->getVal('text')), array('ia_id' => $wgRequest->getVal('update')));
         return;
     }
     if ($wgRequest->getVal('preview')) {
         $dbr = wfGetDB(DB_SLAVE);
         $text = $dbr->selectField('import_articles', array('ia_text'), array('ia_id' => $wgRequest->getVal('preview')));
         $title = $dbr->selectField('import_articles', array('ia_title'), array('ia_id' => $wgRequest->getVal('preview')));
         $t = Title::newFromText($title);
         # try this parse, this is for debugging only
         $popts = $wgOut->parserOptions();
         $popts->setTidy(true);
         $popts->enableLimitReport();
         $parserOutput = $wgParser->parse($text, $t, $popts);
         $popts->setTidy(false);
         $popts->enableLimitReport(false);
         $wgOut->setPageTitle(wfMsg('howto', $t->getText()));
         $html = WikihowArticleHTML::postProcess($parserOutput->getText());
         $wgOut->addHTML($html);
         return;
     }
     if ($wgRequest->wasPosted() && ($wgRequest->getVal('xml') || sizeof($_FILES) > 0)) {
         $dbw = wfGetDB(DB_MASTER);
         // input can either come from an XML file or copy+pasted input from the textarea
         // use the file if we have it.
         $input = $wgRequest->getVal('xml');
         foreach ($_FILES as $f) {
             if (trim($f['tmp_name']) == "") {
                 continue;
             }
             $input = preg_replace('@\\r@', "\n", file_get_contents($f['tmp_name']));
             break;
         }
         $articles = self::parseXML($input);
         foreach ($articles as $t => $text) {
             $title = Title::newFromText($t);
             if (!$title) {
                 $wgOut->addHTML("cant make title out of {$t}<br/>");
                 continue;
             }
             if ($dbw->selectField('import_articles', 'count(*)', array('ia_title' => $title->getDBKey())) > 0) {
                 $wgOut->addHTML("Article {$title->getText()} already exists, not adding.<br/>");
                 continue;
             }
             $dbw->insert('import_articles', array('ia_title' => $title->getDBKey(), 'ia_text' => $text, 'ia_timestamp' => wfTimestampNow()));
             $wgOut->addHTML("Article {$title->getText()} saved.<br/>");
         }
     } else {
         if ($wgRequest->wasPosted() && $wgRequest->getVal('publish_articles')) {
             self::publishArticles();
         }
     }
     $wgOut->addHTML('<style type="text/css" media="all">/*<![CDATA[*/ @import "/extensions/min/f/extensions/wikihow/import_xml.css"; /*]]>*/</style>');
     $wgOut->addScript('<script type="text/javascript" src="/extensions/min/f/extensions/wikihow/import_xml.js"></script>');
     $wgOut->addHTML("\n\t\t\t<form method='post' action='/Special:ImportXML' enctype='multipart/form-data'>\n\t\t\t<input type='hidden' name='publish_articles' value='1'/>\n\t\t\t<a href='#' id='hide_btn' style='float: right;' class='button white_button_150' onmouseover='button_swap(this);' onmouseout='button_unswap(this);' onclick='hidePublished();'>Show Published</a><br/>\n\t\t\t<table class='importxml'><tr class='toprow'><td>ID</td><td>Title</td>\n\t\t\t<td>Created</td><td>Preview</td>\n\t\t\t<td>Published?</td>\n\t\t\t<td>Edit</td><td>Delete?</td>\n\t\t\t<td>Publish</td>\n\t\t\t</tr>");
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('import_articles', array('ia_published', 'ia_title', 'ia_id', 'ia_timestamp'), array(), "ImportXML", array("ORDER BY" => "ia_id"));
     while ($row = $dbr->fetchObject($res)) {
         $t = Title::newFromText($row->ia_title);
         if ($t) {
             $class = $row->ia_published == 1 ? "pub" : "";
             $safe_title = urlencode(htmlspecialchars($row->ia_title));
             $wgOut->addHTML("<tr id='row_{$row->ia_id}' class='{$class}'><td>{$row->ia_id}</td><td>{$t->getText()}</td><td>{$row->ia_timestamp}</td>\n\t\t\t\t\t<td><a href='/Special:ImportXML?preview={$row->ia_id}' target='new'>Preview</a></td>\n\t\t\t\t\t<td>" . ($row->ia_published == 1 ? "yes" : "no") . "</td>\n\t\t\t\t\t<td><a onclick=\"edit_xml({$row->ia_id});\">Edit</a></td>\n\t\t\t\t\t<td><input style='height: 24px; width: 24px;' type='image' src='/extensions/wikihow/rcwidget/rcwDelete.png' onclick='return delete_xml({$row->ia_id}, \"{$safe_title}\");'></td>\n\t\t\t\t\t<td><input type='checkbox' name='publish_{$row->ia_id}'></a></td>\n\t\t\t\t</tr>");
         }
     }
     $wgOut->addHTML("</table>\n\t\t\t<input type='submit' value='Publish'/>\n\t\t\t</form>\n\t\t<br/>\n\t\t<a href='/Special:ImportXML?publishedcsv=1'>Published(CSV)</a> | \n\t\t<a href='/Special:ImportXML?publishedcsv=1&errs=1'>Errors (CSV) </a>\n\t\t<br/><br/>Insert new articles:\n\t\t<form action='/Special:ImportXML' method='post' accept-charset='UTF-8' enctype='multipart/form-data'>\n\n\t\t\t<textarea class='xmlinput' name='xml'></textarea><br/>\n\t\t\tOr, use an input file in XML format: <input type='file' name='uploadFile'> <br/>\n\t\t\t<input type='submit'>\n\t\t</form>\n\t\t<div id='magicbox'></div>\n\t\t");
 }
コード例 #7
0
ファイル: DifferenceEngine.php プロジェクト: ErdemA/wikihow
 /**
  * Show the new revision of the page.
  */
 function renderNewRevision()
 {
     global $wgOut;
     $fname = 'DifferenceEngine::renderNewRevision';
     wfProfileIn($fname);
     $wgOut->addHTML("<br /><h2>{$this->mPagetitle}</h2>\n");
     #add deleted rev tag if needed
     if (!$this->mNewRev->userCan(Revision::DELETED_TEXT)) {
         $wgOut->addWikiMsg('rev-deleted-text-permission');
     } else {
         if ($this->mNewRev->isDeleted(Revision::DELETED_TEXT)) {
             $wgOut->addWikiMsg('rev-deleted-text-view');
         }
     }
     if (!$this->mNewRev->isCurrent()) {
         $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false);
     }
     $this->loadNewText();
     if (is_object($this->mNewRev)) {
         $wgOut->setRevisionId($this->mNewRev->getId());
     }
     if ($this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage()) {
         // Stolen from Article::view --AG 2007-10-11
         // Give hooks a chance to customise the output
         if (wfRunHooks('ShowRawCssJs', array($this->mNewtext, $this->mTitle, $wgOut))) {
             // Wrap the whole lot in a <pre> and don't parse
             $m = array();
             preg_match('!\\.(css|js)$!u', $this->mTitle->getText(), $m);
             $wgOut->addHtml("<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n");
             $wgOut->addHtml(htmlspecialchars($this->mNewtext));
             $wgOut->addHtml("\n</pre>\n");
         }
     } else {
         //			$wgOut->addWikiTextTidy( $this->mNewtext );
         $popts = $wgOut->parserOptions();
     }
     $popts->setTidy(true);
     $html = WikihowArticleHTML::processArticleHTML($wgOut->parse($this->mNewtext, $this, $popts), array('ns' => $this->mTitle->getNamespace()));
     $wgOut->addHTML($html);
     if (!$this->mNewRev->isCurrent()) {
         $wgOut->parserOptions()->setEditSection($oldEditSectionSetting);
     }
     wfProfileOut($fname);
 }
コード例 #8
0
 function getNextArticle($articleName = '')
 {
     global $wgOut;
     $dbr = wfGetDB(DB_SLAVE);
     $skippedSql = "";
     $skippedIds = $this->skipTool->getSkipped();
     $expired = wfTimestamp(TS_MW, time() - Spellchecker::SPELLCHECKER_EXPIRED);
     $title = Title::newFromText($articleName);
     if ($title && $title->getArticleID() > 0) {
         $articleId = $title->getArticleID();
     } else {
         if ($skippedIds) {
             $articleId = $dbr->selectField('spellchecker', 'sc_page', array('sc_exempt' => 0, 'sc_errors' => 1, 'sc_dirty' => 0, "sc_checkout < '{$expired}'", "sc_page NOT IN ('" . implode("','", $skippedIds) . "')"), __METHOD__, array("limit" => 1, "ORDER BY" => "RAND()"));
         } else {
             $articleId = $dbr->selectField('spellchecker', 'sc_page', array('sc_exempt' => 0, 'sc_errors' => 1, 'sc_dirty' => 0, "sc_checkout < '{$expired}'"), __METHOD__, array("limit" => 1, "ORDER BY" => "RAND()"));
         }
     }
     if ($articleId) {
         $sql = "SELECT * from `spellchecker_page` JOIN `spellchecker_word` ON sp_word = sw_id WHERE sp_page = {$articleId}";
         $res = $dbr->query($sql, __METHOD__);
         $words = array();
         $corrections = array();
         while ($row = $dbr->fetchObject($res)) {
             $words[] = $row->sw_word;
             $corrections[] = $row->sw_corrections;
         }
         $caps = wikiHowDictionary::getCaps();
         $exclusions = array();
         foreach ($words as $word) {
             if (preg_match('@\\s' . $word . '\\s@', $caps)) {
                 $exclusions[] = strtoupper($word);
             }
         }
         $title = Title::newFromID($articleId);
         if ($title) {
             $revision = Revision::newFromTitle($title);
             $article = new Article($title);
             if ($revision) {
                 $text = $revision->getRawText();
                 $text = self::markBreaks($text);
                 $text = self::replaceNewlines($text);
                 $content['html'] = "<p>{$text}</p>";
                 $content['title'] = "<a href='{$title->getFullURL()}' target='new'>" . wfMsg('howto', $title->getText()) . "</a>";
                 $content['articleId'] = $title->getArticleID();
                 $content['words'] = $words;
                 $content['exclusions'] = $exclusions;
                 $popts = $wgOut->parserOptions();
                 $popts->setTidy(true);
                 $parserOutput = $wgOut->parse($revision->getText(), $title, $popts);
                 $magic = WikihowArticleHTML::grabTheMagic($revision->getText());
                 $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => NS_MAIN, 'magic-word' => $magic));
                 $content['html'] = $html;
                 $this->skipTool->useItem($articleId);
                 return $content;
             }
         }
     }
     //return error message
     $content['error'] = true;
     return $content;
 }
コード例 #9
0
ファイル: EditPage.php プロジェクト: ErdemA/wikihow
 /**
  * @todo document
  */
 function getPreviewText()
 {
     global $wgOut, $wgUser, $wgTitle, $wgParser;
     $fname = 'EditPage::getPreviewText';
     wfProfileIn($fname);
     if ($this->mTriedSave && !$this->mTokenOk) {
         if ($this->mTokenOkExceptSuffix) {
             $note = wfMsg('token_suffix_mismatch');
         } else {
             $note = wfMsg('session_fail_preview');
         }
     } else {
         $note = wfMsg('previewnote');
     }
     $parserOptions = ParserOptions::newFromUser($wgUser);
     $parserOptions->setEditSection(false);
     global $wgRawHtml;
     if ($wgRawHtml && !$this->mTokenOk) {
         // Could be an offsite preview attempt. This is very unsafe if
         // HTML is enabled, as it could be an attack.
         return $wgOut->parse("<div class='previewnote'>" . wfMsg('session_fail_preview_html') . "</div>");
     }
     # don't parse user css/js, show message about preview
     # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
     if ($this->isCssJsSubpage) {
         if (preg_match("/\\.css\$/", $this->mTitle->getText())) {
             $previewtext = wfMsg('usercsspreview');
         } else {
             if (preg_match("/\\.js\$/", $this->mTitle->getText())) {
                 $previewtext = wfMsg('userjspreview');
             }
         }
         $parserOptions->setTidy(true);
         $parserOutput = $wgParser->parse($previewtext, $this->mTitle, $parserOptions);
         $wgOut->addHTML($parserOutput->mText);
         $previewHTML = '';
     } else {
         $toparse = $this->textbox1;
         # If we're adding a comment, we need to show the
         # summary as the headline
         if ($this->section == "new" && $this->summary != "") {
             $toparse = "== {$this->summary} ==\n\n" . $toparse;
         }
         if ($this->mMetaData != "") {
             $toparse .= "\n" . $this->mMetaData;
         }
         $parserOptions->setTidy(true);
         $parserOptions->enableLimitReport();
         $parserOutput = $wgParser->parse($this->mArticle->preSaveTransform($toparse) . "\n\n", $this->mTitle, $parserOptions);
         // XXXCHANGED for redesign add a surrounding article_inner
         #$previewHTML = "<div class='article_inner'>" . WikihowArticleHTML::postProcess($parserOutput->getText()) . "</div>";
         $previewHTML = WikihowArticleHTML::processArticleHTML($parserOutput->getText(), array('ns' => $this->mTitle->getNamespace()));
         #$previewHTML = "<div class='article_inner'>{$text}</div>";
         $wgOut->addParserOutputNoText($parserOutput);
         # ParserOutput might have altered the page title, so reset it
         # Also, use the title defined by DISPLAYTITLE magic word when present
         if (($dt = $parserOutput->getDisplayTitle()) !== false) {
             $wgOut->setPageTitle(wfMsg('editing', $dt));
         } else {
             $wgOut->setPageTitle(wfMsg('editing', $wgTitle->getPrefixedText()));
         }
         foreach ($parserOutput->getTemplates() as $ns => $template) {
             foreach (array_keys($template) as $dbk) {
                 $this->mPreviewTemplates[] = Title::makeTitle($ns, $dbk);
             }
         }
         if (count($parserOutput->getWarnings())) {
             $note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings());
         }
     }
     $previewhead = '<h2>' . htmlspecialchars(wfMsg('preview')) . "</h2>\n" . "<div class='previewnote'>" . $wgOut->parse($note) . "</div>\n";
     if ($this->isConflict) {
         $previewhead .= '<h2>' . htmlspecialchars(wfMsg('previewconflict')) . "</h2>\n";
     }
     wfProfileOut($fname);
     return $previewhead . $previewHTML;
 }
コード例 #10
0
 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->showErrorPage('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) {
                                 $historyContext = clone $this->getContext();
                                 $historyContext->setTitle($t);
                                 $historyContext->setWikiPage(WikiPage::factory($t));
                                 $pageHistory = Action::factory("history", WikiPage::factory($t), $historyContext);
                                 $pageHistory->onView();
                                 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' => true, '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->addJScode('nfdgj');
     $wgOut->addJScode('csjs');
     $wgOut->addCSScode('nfdgc');
     $wgOut->addCSScode('diffc');
     //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();
 }
コード例 #11
0
ファイル: RCPatrol.body.php プロジェクト: ErdemA/wikihow
 static function postParserCallback($outputPage, &$html)
 {
     $html = WikihowArticleHTML::processArticleHTML($html, array('no-ads' => true));
     return true;
 }
コード例 #12
0
ファイル: QC.body.php プロジェクト: ErdemA/wikihow
 function getNextToPatrolHTML()
 {
     global $wgOut;
     if (!$this->mResult) {
         // nothing to patrol
         return null;
     }
     // construct the HTML to reply
     // load the page
     $t = $this->mTitle;
     // Title::newFromID($this->mResult->qc_page);
     if (!$t) {
         $this->deleteBad($this->mResult->qc_page);
         return "<!--{$this->mResult->qc_page}-->error creating title, oops, please <a href='#' onclick='window.location.reload()'>refresh</a>";
     }
     // get current revsion
     $r = Revision::newFromTitle($t);
     if (!$r) {
         return "Error creating revision";
     }
     $html = "";
     //grab all that good tip stuff
     list($tip_user, $the_tip, $tip_page) = self::getTipData($this->mResult->qc_extra);
     $addedby = $tip_user ? self::getChangedBy("Tip added by: ", "qc_addedby", $tip_user) : '';
     $approvedby = self::getChangedBy("Tip approved by: ", "qc_approvedby");
     $html = '<h3>New Tip</h3><br />' . '<div class="wh_block"><ul><li>' . $the_tip . '</li></ul></div>';
     $html = "<div id='qc_box'>" . $addedby . $approvedby . $html . "</div>";
     $wgOut->clearHTML();
     $html .= "<div id='quickeditlink'></div>";
     $popts = $wgOut->parserOptions();
     $popts->setTidy(true);
     $html .= WikihowArticleHTML::processArticleHTML($wgOut->parse($r->getText(), $t, $popts), array('no-ads' => 1, 'ns' => $t->getNamespace()));
     $html .= "<input type='hidden' name='qc_id' value='{$this->mResult->qc_id}'/>";
     $html .= "<div id='numqcusers'>{$this->mUsers}</div>";
     return $html;
 }
コード例 #13
0
 private function getNext()
 {
     $content = array();
     $guestId = $this->getRequest()->getVal('guestId');
     $content['user_voter'] = UCIPatrol::getUserAvatar($this->getUser(), $guestId);
     $content['required_upvotes'] = UCIPatrol::UCI_UPVOTES;
     $content['required_downvotes'] = UCIPatrol::UCI_DOWNVOTES;
     $content['vote_mult'] = $this->getVoteMultiplier();
     $skipped = UCIPatrol::getSkipList();
     $count = UCIPatrol::getCount() - count($skipped);
     $content['uciCount'] = $count;
     $where = array();
     $where[] = "uci_downvotes < " . self::UCI_DOWNVOTES;
     $where[] = "uci_upvotes < " . self::UCI_UPVOTES;
     $where[] = "uci_copyright_violates = 0";
     $where[] = "uci_copyright_checked = 1";
     if ($skipped) {
         $where[] = "uci_article_id NOT IN ('" . implode("','", $skipped) . "')";
     }
     $dbr = wfGetDB(DB_SLAVE);
     $row = $dbr->selectRow('user_completed_images', array('*'), $where, __METHOD__, array("LIMIT" => 1));
     $content['pageId'] = $row->uci_article_id;
     $content['upvotes'] = $row->uci_upvotes;
     $content['downvotes'] = $row->uci_downvotes;
     //$content['sql' . $i] = $dbw->lastQuery();
     //$content['row'] = $row;
     if ($row === false) {
         MWDebug::log("no more images to patrol");
         return $content;
     }
     $title = Title::newFromText($row->uci_article_name);
     // check page id vs whitelist/blacklist
     if (!UCIPatrol::isUCIAllowed($title)) {
         MWDebug::log("not allowed title: " . $title);
         $this->skipById($row->uci_article_id);
         return $this->getNext();
     }
     $content['articleTitle'] = $title->getText();
     $content['articleURL'] = $title->getPartialUrl();
     if (!$title) {
         MWDebug::log("no title: " . $title);
         $content['error'] = "notitle";
         return $content;
     }
     // get data about the completion image
     $file = UCIPatrol::fileFromRow($row);
     if (!$file) {
         MWDebug::warning("no file with image name " . $row->uci_image_name);
         $content['error'] = "filenotfound";
         return $content;
     }
     $content['uci_image_name'] = $row->uci_image_name;
     // get info about the originating page the image was added for
     $revision = Revision::newFromTitle($title);
     if ($title->isRedirect()) {
         MWDebug::log("is a redirect: " . $title);
         $wtContent = $revision->getContent();
         $title = $wtContent->getUltimateRedirectTarget();
         // edge case if there are just too many redirects, just skip this
         if ($title->isRedirect()) {
             MWDebug::log("too many redirects..skipping" . $title);
             $content['error'] = "redirect";
             return $content;
         }
         $revision = Revision::newFromTitle($title);
         $content['articleTitle'] = $title->getText();
         $content['articleURL'] = $title->getPartialUrl();
         UCIPatrol::updateArticleName($row, $title->getText());
     }
     $popts = $this->getOutput()->parserOptions();
     $popts->setTidy(true);
     $parserOutput = $this->getOutput()->parse($revision->getText(), $title, $popts);
     $magic = WikihowArticleHTML::grabTheMagic($revision->getText());
     $content['article'] = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => NS_MAIN, 'magic-word' => $magic));
     $width = $file->getWidth();
     // scale width so that the height is no greater than PATROL_THUMB_HEIGHT
     if ($file->getHeight() > self::PATROL_THUMB_HEIGHT) {
         $ratio = self::PATROL_THUMB_HEIGHT / $file->getHeight();
         $width = floor($width * $ratio);
     }
     // now that we have possibly scaled the width down to fit our max height..
     // we also will potentially scale down the width if it is still larger
     // than will fit on the patrol page
     $width = $width < self::PATROL_THUMB_WIDTH ? $width : self::PATROL_THUMB_WIDTH;
     $thumb = $file->getThumbnail($width);
     $content['thumb_url'] = $thumb->getUrl();
     $content['width'] = $thumb->getWidth();
     $content['height'] = $thumb->getHeight();
     // this is the page id of the image file itself not the same as articleTitle
     // used for skipping
     $voters = UCIPatrol::getVoters($row->uci_article_id);
     $content['voters'] = $voters;
     return $content;
 }
コード例 #14
0
 function execute($par)
 {
     global $wgOut, $wgRequest, $wgUser, $wgParser;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if ($wgUser->getID() == 0) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if (class_exists('WikihowCSSDisplay')) {
         WikihowCSSDisplay::setSpecialBackground(true);
     }
     if ($wgRequest->getVal('fetchReviewersTable')) {
         $wgOut->setArticleBodyOnly(true);
         echo $this->getReviewersTable();
         return;
     }
     wfLoadExtensionMessages('Importvideo');
     wfLoadExtensionMessages("Videoadder");
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $cat = htmlspecialchars($wgRequest->getVal('cat'));
     // get just the HTML for the Ajax call for the next video
     // used even on the initial page load
     if ($target == 'getnext') {
         $wgOut->setArticleBodyOnly(true);
         // process any skipped videos
         if ($wgRequest->getVal('va_page_id') && !preg_match("@[^0-9]@", $wgRequest->getVal('va_page_id'))) {
             $dbw = wfGetDB(DB_MASTER);
             $vals = array('va_vid_id' => $wgRequest->getVal('va_vid_id'), 'va_user' => $wgUser->getID(), 'va_user_text' => $wgUser->getName(), 'va_timestamp' => wfTimestampNow(), 'va_inuse' => null, 'va_src' => 'youtube');
             $va_skip = $wgRequest->getVal('va_skip');
             if ($va_skip < 2) {
                 $vals['va_skipped_accepted'] = $va_skip;
             }
             $dbw->update('videoadder', $vals, array('va_page' => $wgRequest->getVal('va_page_id')));
             if ($wgRequest->getVal('va_skip') == 0) {
                 // import the video
                 $tx = Title::newFromID($wgRequest->getVal('va_page_id'));
                 $ipv = new ImportvideoYoutube();
                 $text = $ipv->loadVideoText($wgRequest->getVal('va_vid_id'));
                 $vid = Title::makeTitle(NS_VIDEO, $tx->getText());
                 Importvideo::updateVideoArticle($vid, $text, wfMessage('va_addingvideo')->text());
                 Importvideo::updateMainArticle($tx, wfMessage('va_addingvideo')->text());
                 wfRunHooks("VAdone", array());
                 $wgOut->redirect('');
             } else {
                 if ($wgRequest->getVal('va_skip') == 2) {
                     // the user has skipped it and not rejected this one, don't show it to them again
                     self::skipArticle($wgRequest->getVal('va_page_id'));
                     wfRunHooks("VAskipped", array());
                 }
             }
         }
         $results = self::getNext();
         if (empty($results)) {
             $wgOut->addHTML("Something went wrong. Refresh.");
             return;
         }
         $title = $results[0];
         $vid = $results[1];
         $id = str_replace("http://gdata.youtube.com/feeds/api/videos/", "", $vid['ID']);
         if (!$title) {
             $wgOut->addHTML("Something went wrong. Refresh.");
             return;
         }
         $revision = Revision::newFromTitle($title);
         $popts = $wgOut->parserOptions();
         $popts->setTidy(true);
         $parserOutput = $wgOut->parse($revision->getText(), $title, $popts);
         $magic = WikihowArticleHTML::grabTheMagic($revision->getText());
         $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => NS_MAIN, 'magic-word' => $magic));
         $result['guts'] = "<div id='va_buttons'><a href='#' onclick='va_skip(); return false;' class='button secondary ' style='float:left;'>Skip</a>\n<a id='va_yes' href='#' class='button primary disabled buttonright'>Yes, it does</a>\n<a id='va_no' href='#' class='button secondary buttonright'>No, it doesn't</a><div class='clearall'></div></div>\n<div id='va_title'><a href='{$title->getFullURL()}' target='new'>" . wfMsg("howto", $title->getText()) . "</a></div>\n\t\t\t\t\t<div id='va_video' class='section_text'>\n\t<p id='va_notice'>" . wfMsg('va_notice') . "</p>\n<object width='480' height='385'><param name='movie' value='http://www.youtube.com/v/{$id}&amp;hl=en_US&amp;fs=1'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/{$id}&amp;hl=en_US&amp;fs=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='480' height='385'></embed></object>\n\t\t\t\t\t<input type='hidden' id='va_vid_id' value='{$id}'/>\n\t\t\t\t\t<input type='hidden' id='va_page_id' value='{$title->getArticleID()}'/>\n\t\t\t\t\t<input type='hidden' id='va_page_title' value='" . htmlspecialchars($title->getText()) . "'/>\n\t\t\t\t\t<input type='hidden' id='va_page_url' value='" . htmlspecialchars($title->getFullURL()) . "'/>\n\t\t\t\t\t<input type='hidden' id='va_skip' value='0'/>\n\t\t\t\t\t<input type='hidden' id='va_src' value='youtube'/>\n\t\t\t\t\t</div>\n\n\t\t\t</div>\n\t\t\t";
         $result['article'] = $html;
         $dropdown = wfMsg('va_browsemsg') . " " . self::getCategoryDropDown();
         $result['options'] = "<div id='va_browsecat'>" . $dropdown . "</div>";
         $result['cat'] = $cat;
         print_r(json_encode($result));
         return;
     }
     // add the layer of the page
     $this->setHeaders();
     $this->setSideWidgets();
     $wgOut->addJScode('vcooj');
     $wgOut->addJScode('vaddj');
     $wgOut->addCSScode('vaddc');
     $wgOut->addHTML("<div class='tool_header tool'><h1>" . wfMessage('va_question') . "<span id='va_instructions'>" . wfMessage('va_instructions') . "</span></h1>");
     $wgOut->addHTML("<div id='va_guts'>\n\t\t\t\t\t<center><img src='/extensions/wikihow/rotate.gif'/></center>\n\t\t\t\t</div>");
     $wgOut->addHTML("</div>");
     $wgOut->addHTML("<input type='hidden' id='va_cat' value='{$cat}' />");
     $wgOut->addHTML("<div id='va_article'></div>");
     $langKeys = array('va_congrats', 'va_check');
     $js = Wikihow_i18n::genJSMsgs($langKeys);
     $wgOut->addHTML($js);
     return;
 }
コード例 #15
0
 private function getDBTip($content)
 {
     global $wgUser, $wgOut;
     $dbw = wfGetDB(DB_MASTER);
     //$dbw->query( 'SET NAMES latin1', __METHOD__ );
     $expired = wfTimestamp(TS_MW, time() - TipsPatrol::TIP_EXPIRED);
     $i = 0;
     $content['error'] = true;
     $goodRevision = false;
     do {
         $skippedIds = $this->skipTool->getSkipped();
         $where = array();
         $where[] = "tw_checkout < '{$expired}'";
         $where[] = "NOT EXISTS (SELECT rc_id from recentchanges where rc_cur_id = tw_page and rc_patrolled = 0 LIMIT 1)";
         if ($skippedIds) {
             $where[] = "tw_id NOT IN ('" . implode("','", $skippedIds) . "')";
         }
         $row = $dbw->selectRow('tipsandwarnings', array('*'), $where, __METHOD__, array("LIMIT" => 1));
         //$content['sql' . $i] = $dbw->lastQuery();
         //$content['row'] = $row;
         if ($row !== false) {
             $title = Title::newFromID($row->tw_page);
             $isRedirect = false;
             if ($title) {
                 $dbr = wfGetDB(DB_SLAVE);
                 $isRedirect = intval($dbr->selectField('page', 'page_is_redirect', array('page_id' => $row->tw_page), __METHOD__, array("LIMIT" => 1)));
             }
             if ($title && !$isRedirect) {
                 $this->skipTool->useItem($row->tw_id);
                 $revision = Revision::newFromTitle($title);
                 $popts = $wgOut->parserOptions();
                 $popts->setTidy(true);
                 $parserOutput = $wgOut->parse($revision->getText(), $title, $popts);
                 $magic = WikihowArticleHTML::grabTheMagic($revision->getText());
                 $content['article'] = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads', 'ns' => NS_MAIN, 'magic-word' => $magic));
                 $content['tip'] = $row->tw_tip;
                 $content['tipId'] = $row->tw_id;
                 $content['articleId'] = $row->tw_page;
                 $content['articleTitle'] = $title->getText();
                 $content['articleUrl'] = $title->getPartialUrl();
                 $content['error'] = false;
             } else {
                 //article must no longer exist or be a redirect, so delete the tips associated with that article
                 $dbw = wfGetDB(DB_MASTER);
                 $dbw->delete('tipsandwarnings', array('tw_page' => $row->tw_page));
             }
         }
         $i++;
         // Check up to 5 titles.
         // If no good title then return an error message
     } while ($i <= 5 && !$title && $row !== false);
     $content['i'] = $i;
     $content['tipCount'] = self::getCount();
     return $content;
 }
コード例 #16
0
 function getArticleHtml($t)
 {
     global $wgOut;
     if ($t) {
         $popts = $wgOut->parserOptions();
         $popts->setTidy(true);
         $revision = Revision::newFromTitle($t);
         if ($revision) {
             $parserOutput = $wgOut->parse($revision->getText(), $t, $popts);
             $magic = WikihowArticleHTML::grabTheMagic($revision->getText());
             return WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => NS_MAIN, 'magic-word' => $magic));
         } else {
             return '';
         }
     }
     return "";
 }
コード例 #17
0
 function execute($par)
 {
     global $wgRequest, $wgOut;
     $wgOut->disable();
     $whow = WikihowArticleEditor::newFromRequest($wgRequest);
     if ($wgRequest->getVal('parse') == '1') {
         $body = $wgOut->parse($whow->formatWikiText());
         $magic = WikihowArticleHTML::grabTheMagic($whow->formatWikiText());
         echo WikihowArticleHTML::processArticleHTML($body, array('magic-word' => $magic));
     } else {
         echo $whow->formatWikiText();
     }
     return;
 }
コード例 #18
0
function onDifferenceEngineRenderRevisionAddParserOutput($differenceEngine, &$out, $parserOutput, $wikiPage)
{
    $magic = WikihowArticleHTML::grabTheMagic($differenceEngine->mNewRev->getText());
    $html = WikihowArticleHTML::processArticleHTML($parserOutput->getText(), array('ns' => $wikiPage->mTitle->getNamespace(), 'magic-word' => $magic));
    $out->addHTML($html);
    return true;
}
コード例 #19
0
 function parse($t, $a, $text)
 {
     global $wgOut, $wgParser;
     # try this parse, this is for debugging only
     $popts = $wgOut->parserOptions();
     $popts->setTidy(true);
     $popts->enableLimitReport();
     #Html5WrapTemplates($a, &$newtext);
     $parserOutput = $wgParser->parse($text, $t, $popts, true, true, $a->getRevIdFetched());
     $popts->setTidy(false);
     $popts->enableLimitReport(false);
     $html = WikihowArticleHTML::postProcess($parserOutput->getText(), array('no-ads'));
     $this->debug("output.html", $wtext . "\n\n-----------\n" . $html);
     return $html;
 }
コード例 #20
0
    /**
     * Parse and transform the document from the old HTML for NS_MAIN articles to the new mobile
     * style. This should probably be pulled out and added to a subclass that can then be extended for
     * builders that focus on building NS_MAIN articles
     */
    protected function parseNonMobileArticle(&$article)
    {
        global $IP, $wgContLang, $wgLanguageCode;
        $sectionMap = array(wfMsg('Intro') => 'intro', wfMsg('Ingredients') => 'ingredients', wfMsg('Steps') => 'steps', wfMsg('Video') => 'video', wfMsg('Tips') => 'tips', wfMsg('Warnings') => 'warnings', wfMsg('relatedwikihows') => 'relatedwikihows', wfMsg('sourcescitations') => 'sources', wfMsg('thingsyoullneed') => 'thingsyoullneed', wfMsg('article_info') => 'article_info');
        $lang = MobileWikihow::getSiteLanguage();
        $imageNsText = $wgContLang->getNsText(NS_IMAGE);
        $device = $this->getDevice();
        // munge steps first
        $opts = array('no-ads' => true);
        $article = WikihowArticleHTML::postProcess($article, $opts);
        // Make doc correctly formed
        $articleText = <<<DONE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang}" lang="{$lang}">
<head>
\t<meta http-equiv="Content-Type" content="text/html; charset='utf-8'" />
</head>
<body>
{$article}
</body>
</html>
DONE;
        require_once "{$IP}/extensions/wikihow/mobile/JSLikeHTMLElement.php";
        $doc = new DOMDocument('1.0', 'utf-8');
        $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
        $doc->strictErrorChecking = false;
        $doc->recover = true;
        //$doc->preserveWhiteSpace = false;
        //$wgOut->setarticlebodyonly(true);
        @$doc->loadHTML($articleText);
        $doc->normalizeDocument();
        //echo $doc->saveHtml();exit;
        $xpath = new DOMXPath($doc);
        // Delete #featurestar node
        $node = $doc->getElementById('featurestar');
        if (!empty($node)) {
            $node->parentNode->removeChild($node);
        }
        $node = $doc->getElementById('newaltmethod');
        if (!empty($node)) {
            $node->parentNode->removeChild($node);
        }
        // Remove all "Edit" links
        $nodes = $xpath->query('//a[@id = "gatEditSection"]');
        foreach ($nodes as $node) {
            $node->parentNode->removeChild($node);
        }
        // Resize youtube video
        $nodes = $xpath->query('//embed');
        foreach ($nodes as $node) {
            $url = '';
            $src = $node->attributes->getNamedItem('src')->nodeValue;
            if (!$device['show-youtube'] || stripos($src, 'youtube.com') === false) {
                $parent = $node->parentNode;
                $grandParent = $parent->parentNode;
                if ($grandParent && $parent) {
                    $grandParent->removeChild($parent);
                }
            } else {
                foreach (array(&$node, &$node->parentNode) as $node) {
                    $widthAttr = $node->attributes->getNamedItem('width');
                    $oldWidth = (int) $widthAttr->nodeValue;
                    $newWidth = $device['max-video-width'];
                    if ($newWidth < $oldWidth) {
                        $widthAttr->nodeValue = (string) $newWidth;
                        $heightAttr = $node->attributes->getNamedItem('height');
                        $oldHeight = (int) $heightAttr->nodeValue;
                        $newHeight = (int) round($newWidth * $oldHeight / $oldWidth);
                        $heightAttr->nodeValue = (string) $newHeight;
                    }
                }
            }
        }
        // Remove templates from intro so that they don't muck up
        // the text and images we extract
        $nodes = $xpath->query('//div[@class = "template_top"]');
        foreach ($nodes as $node) {
            $node->parentNode->removeChild($node);
        }
        // Grab intro text
        $intro = '';
        $nodes = $xpath->query('//body/div/p');
        foreach ($nodes as $i => $node) {
            $text = $node->textContent;
            if (!empty($text) && $i == 0) {
                $introNode = $node;
                $intro = Wikitext::removeRefsFromFlattened($text);
                break;
            }
        }
        if ($introNode) {
            // Grab first image from article
            $imgs = $xpath->query('.//img', $introNode->parentNode);
            $firstImage = '';
            foreach ($imgs as $img) {
                // parent is an <a> tag
                $parent = $img->parentNode;
                if ($parent->nodeName == 'a') {
                    $href = $parent->attributes->getNamedItem('href')->nodeValue;
                    if (preg_match('@(Image|' . $imageNsText . '):@', $href)) {
                        $firstImage = preg_replace('@^.*(Image|' . $imageNsText . '):([^:]*)([#].*)?$@', '$2', $href);
                        $firstImage = urldecode($firstImage);
                        break;
                    }
                }
            }
            // Remove intro node
            $parent = $introNode->parentNode;
            $parent->removeChild($introNode);
        }
        // Get rid of the <span> element to standardize the html for the
        // next dom query
        $nodes = $xpath->query('//div/span/a[@class = "image"]');
        foreach ($nodes as $a) {
            $parent = $a->parentNode;
            $grandParent = $parent->parentNode;
            $grandParent->replaceChild($a, $parent);
        }
        // Resize all resize-able images
        $nodes = $xpath->query('//div/a[@class = "image"]/img');
        $imgNum = 1;
        foreach ($nodes as $img) {
            $srcNode = $img->attributes->getNamedItem('src');
            $widthNode = $img->attributes->getNamedItem('width');
            $width = (int) $widthNode->nodeValue;
            $heightNode = $img->attributes->getNamedItem('height');
            $height = (int) $heightNode->nodeValue;
            $imageClasses = $img->parentNode->parentNode->attributes->getNamedItem('class')->nodeValue;
            /*
            if (!stristr($imageClasses, "tcenter")) {
            	$img->parentNode->parentNode->parentNode->attributes->getNamedItem('class')->nodeValue = '';
            	$img->parentNode->parentNode->parentNode->attributes->getNamedItem('style')->nodeValue = '';
            }
            */
            if (stristr($imageClasses, "tcenter") !== false) {
                $newWidth = $device['full-image-width'];
                $newHeight = (int) round($device['full-image-width'] * $height / $width);
            } else {
                $newWidth = $device['max-image-width'];
                $newHeight = (int) round($device['max-image-width'] * $height / $width);
            }
            $a = $img->parentNode;
            $href = $a->attributes->getNamedItem('href')->nodeValue;
            if (!$href) {
                $onclick = $a->attributes->getNamedItem('onclick')->nodeValue;
                $onclick = preg_replace('@.*",[ ]*"@', '', $onclick);
                $onclick = preg_replace('@".*@', '', $onclick);
                $imgName = preg_replace('@.*(Image|' . $imageNsText . '|' . urlencode($imageNsText) . '):@', '', $onclick);
            } else {
                $imgName = preg_replace('@^/(Image|' . $imageNsText . '|' . urlencode($imageNsText) . '):@', '', $href);
            }
            $title = Title::newFromURL($imgName, NS_IMAGE);
            if (!$title) {
                $imgName = urldecode($imgName);
                $title = Title::newFromURL($imgName, NS_IMAGE);
            }
            if ($title) {
                $image = RepoGroup::singleton()->findFile($title);
                if ($image) {
                    list($thumb, $newWidth, $newHeight) = self::makeThumbDPI($image, $newWidth, $newHeight, $device['enlarge-thumb-high-dpi']);
                    $url = wfGetPad($thumb->getUrl());
                    $srcNode->nodeValue = $url;
                    $widthNode->nodeValue = $newWidth;
                    $heightNode->nodeValue = $newHeight;
                    // change surrounding div width and height
                    $div = $a->parentNode;
                    $styleNode = $div->attributes->getNamedItem('style');
                    //removing the set width/height
                    $styleNode->nodeValue = '';
                    //$div->attributes->getNamedItem('class')->nodeValue = '';
                    /*					if (preg_match('@^(.*width:)[0-9]+(px;\s*height:)[0-9]+(.*)$@', $styleNode->nodeValue, $m)) {
                    						$styleNode->nodeValue = $m[1] . $newWidth . $m[2] . $newHeight . $m[3];
                    					}
                    */
                    //default width/height for the srcset
                    $bigWidth = 600;
                    $bigHeight = 800;
                    // change grandparent div width too
                    $grandparent = $div;
                    if ($grandparent && $grandparent->nodeName == 'div') {
                        $class = $grandparent->attributes->getNamedItem('class');
                        if ($class) {
                            $isThumb = stristr($class->nodeValue, 'mthumb') !== false;
                            $isRight = stristr($class->nodeValue, 'tright') !== false;
                            $isLeft = stristr($class->nodeValue, 'tleft') !== false;
                            $isCenter = stristr($class->nodeValue, 'tcenter') !== false;
                            if ($isThumb) {
                                if ($isRight) {
                                    $style = $grandparent->attributes->getNamedItem('style');
                                    $style->nodeValue = 'width:' . $newWidth . 'px;height:' . $newHeight . 'px;';
                                    $bigWidth = 300;
                                    $bigHeight = 500;
                                } elseif ($isCenter) {
                                    $style = $grandparent->attributes->getNamedItem('style');
                                    $style->nodeValue = 'width:' . $newWidth . 'px;height:' . $newHeight . 'px;';
                                    $bigWidth = 600;
                                    $bigHeight = 800;
                                } elseif ($isLeft) {
                                    //if its centered or on the left, give it double the width if too big
                                    $style = $grandparent->attributes->getNamedItem('style');
                                    $oldStyle = $style->nodeValue;
                                    $matches = array();
                                    preg_match('@(width:\\s*)[0-9]+@', $oldStyle, $matches);
                                    if ($matches[0]) {
                                        $curSize = intval(substr($matches[0], 6));
                                        //width: = 6
                                        if ($newWidth * 2 < $curSize) {
                                            $existingCSS = preg_replace('@(width:\\s*)[0-9]+@', 'width:' . $newWidth * 2, $oldStyle);
                                            $style->nodeValue = $existingCSS;
                                        }
                                    }
                                    $bigWidth = 300;
                                    $bigHeight = 500;
                                }
                            }
                        }
                    }
                    list($thumb, $newWidth, $newHeight) = self::makeThumbDPI($image, $bigWidth, $bigHeight, $device['enlarge-thumb-high-dpi']);
                    $url = wfGetPad($thumb->getUrl());
                    $img->setAttribute('srcset', $url . ' ' . $newWidth . 'w');
                    //if we couldn't make it big enough, let's add a class
                    if ($newWidth < $bigWidth) {
                        $imgclass = $img->getAttribute('class');
                        $img->setAttribute('class', $imgclass . ' not_huge');
                    }
                    //add the hidden info
                    /*
                    $newDiv = new DOMElement( 'div', htmlentities('test') );
                    $a->appendChild($newDiv);
                    $newDiv->setAttribute('style', 'display:none;');
                    */
                    $a->setAttribute('id', 'image-zoom-' . $imgNum);
                    $a->setAttribute('class', 'image-zoom');
                    $a->setAttribute('href', '#');
                    global $wgServerName;
                    $href = $wgServerName . $href;
                    if (!preg_match("/^http:\\/\\//", $href)) {
                        $href = "http://" . $serverName . $href;
                    }
                    $href = preg_replace("/\\m\\./", "", $href);
                    $href = preg_replace("/^http:\\/\\/wikihow\\.com/", "http://www.wikihow.com", $href);
                    $details = array('url' => $url, 'width' => $newWidth, 'height' => $newHeight, 'credits_page' => $href);
                    $newDiv = new DOMElement('div', htmlentities(json_encode($details)));
                    $a->appendChild($newDiv);
                    $newDiv->setAttribute('style', 'display:none;');
                    $newDiv->setAttribute('id', 'image-details-' . $imgNum);
                    $imgNum++;
                } else {
                    //huh? can't find it? well, then let's not display it
                    $img->parentNode->parentNode->parentNode->parentNode->setAttribute('style', 'display:none;');
                }
            } else {
                //huh? can't find it? well, then let's not display it
                $img->parentNode->parentNode->parentNode->parentNode->setAttribute('style', 'display:none;');
            }
        }
        // Remove template from images, add new zoom one
        $nodes = $xpath->query('//img');
        foreach ($nodes as $node) {
            $src = $node->attributes ? $node->attributes->getNamedItem('src') : null;
            $src = $src ? $src->nodeValue : '';
            if (stripos($src, 'magnify-clip.png') !== false) {
                $parent = $node->parentNode;
                $parent->parentNode->removeChild($parent);
            }
        }
        //get rid of the corners and watermarks
        $nodes = $xpath->query('//div[@class = "corner top_left" 
								or @class = "corner bottom_left"
								or @class = "corner top_right"
								or @class = "corner bottom_right"
								or @class = "wikihow_watermark"]');
        foreach ($nodes as $node) {
            $parent = $node->parentNode;
            $parent->removeChild($node);
        }
        //gotta swap in larger images if the client's width is big enough
        //(i.e. tablet et al)
        $nodes = $xpath->query('//img[@class = "mwimage101" 
								or @class = "mwimage101 not_huge"]');
        foreach ($nodes as $node) {
            //make a quick unique id for this
            $id = md5($node->attributes->getNamedItem('src')->nodeValue) . rand();
            $node->setAttribute('id', $id);
            //pass it to our custom function for swapping in larger images
            $swap_it = 'if (isBig) WH.mobile.swapEm("' . $id . '");';
            $scripttag = new DOMElement('script', htmlentities($swap_it));
            $node->appendChild($scripttag);
        }
        // Change the width attribute from any tables with a width set.
        // This often happen around video elements.
        $nodes = $xpath->query('//table/@width');
        foreach ($nodes as $node) {
            $width = preg_replace('@px\\s*$@', '', $node->nodeValue);
            if ($width > $device['screen-width'] - 20) {
                $node->nodeValue = $device['screen-width'] - 20;
            }
        }
        // Surround step content in its own div. We do this to support other features like checkmarks
        $nodes = $xpath->query('//div[@id="steps"]/ol/li');
        foreach ($nodes as $node) {
            $node->innerHTML = '<div class="step_content">' . $node->innerHTML . '</div>';
        }
        //remove quiz
        $nodes = $xpath->query('//div[@class = "quiz_cta"]');
        foreach ($nodes as $node) {
            $node->parentNode->removeChild($node);
        }
        //remove quiz header
        $nodes = $xpath->query('//h3/span[text()="Quiz"]');
        foreach ($nodes as $node) {
            $parentNode = $node->parentNode;
            $parentNode->parentNode->removeChild($parentNode);
        }
        //pull out the first 6 related wikihows and format them
        $nodes = $xpath->query('//div[@id="relatedwikihows"]/ul/li');
        $count = 0;
        $related_boxes = array();
        foreach ($nodes as $node) {
            if ($count > 6) {
                break;
            }
            //grab the title
            preg_match('@href=\\"\\/(.*?)?\\"@', $node->innerHTML, $m);
            $title = Title::newFromText($m[1]);
            if (!$title) {
                continue;
            }
            $temp_box = $this->makeRelatedBox($title);
            if ($temp_box) {
                $related_boxes[] = $temp_box;
                $last_node = $node;
                $parent = $node->parentNode;
                $last_parent = $parent;
                $parent->removeChild($node);
                $count++;
            }
        }
        //only 1? not enough. throw it back
        if ($count == 1) {
            $related_boxes = array();
            $last_parent->appendChild($last_node);
        }
        // Inject html into the DOM tree for specific features (ie thumb ratings, ads, etc)
        $this->mobileParserBeforeHtmlSave($xpath);
        //self::walkTree($doc->documentElement, 1);
        $html = $doc->saveXML();
        $sections = array();
        $sectionsHtml = explode('<h2>', $html);
        unset($sectionsHtml[0]);
        // remove leftovers from intro section
        foreach ($sectionsHtml as $i => &$section) {
            $section = '<h2>' . $section;
            if (preg_match('@^<h2[^>]*>\\s*<span[^>]*>\\s*([^<]+)@i', $section, $m)) {
                $heading = trim($m[1]);
                $section = preg_replace('@^<h2[^>]*>\\s*<span[^>]*>\\s*([^<]+)</span>(\\s|\\n)*</h2>@i', '', $section);
                if (isset($sectionMap[$heading])) {
                    $key = $sectionMap[$heading];
                    $sections[$key] = array('name' => $heading, 'html' => $section);
                }
            }
        }
        // Remove Video section if there is no longer a youtube video
        if (isset($sections['video'])) {
            if (!preg_match('@<object@i', $sections['video']['html'])) {
                unset($sections['video']);
            }
        }
        // Add the related boxes
        if (isset($sections['relatedwikihows']) && !empty($related_boxes)) {
            $sections['relatedwikihows']['boxes'] = $related_boxes;
        }
        // Add article info
        $sections['article_info']['name'] = wfMsg('article_info');
        $sections['article_info']['html'] = $this->getArticleInfo($title);
        // Remove </body></html> from html
        if (count($sections) > 0) {
            $keys = array_keys($sections);
            $last =& $sections[$keys[count($sections) - 2]]['html'];
            $last = preg_replace('@</body>(\\s|\\n)*</html>(\\s|\\n)*$@', '', $last);
        }
        // Add a simple form for uploading images of completed items to the article
        if ($wgLanguageCode == 'en' && isset($sections['steps']) && isset($device['show-upload-images']) && $device['show-upload-images']) {
            require_once "{$IP}/extensions/wikihow/mobile/MobileUciHtmlBuilder.class.php";
            $userCompletedImages = new MobileUciHtmlBuilder();
            $sections['steps']['html'] .= $userCompletedImages->createByHtml($this->t);
        }
        return array($sections, $intro, $firstImage);
    }
コード例 #21
0
 function view($u = null)
 {
     global $wgOut, $wgTitle, $wgUser, $wgRequest;
     $diff = $wgRequest->getVal('diff');
     $rcid = $wgRequest->getVal('rcid');
     $this->user = $u ? $u : User::newFromName($wgTitle->getDBKey());
     if (!$u && $this->mTitle->getNamespace() != NS_USER || !$this->user || isset($diff) || isset($rcid)) {
         return Article::view();
     }
     if ($this->user->getID() == 0) {
         header('HTTP/1.1 404 Not Found');
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchuser', 'Noarticletext_user');
         return;
     }
     $this->isPageOwner = $wgUser->getID() == $this->user->getID();
     if ($this->user->isBlocked() && $this->isPageOwner) {
         $wgOut->blockedPage();
         return;
     }
     $wgOut->setRobotpolicy('index,follow');
     $skin = $wgUser->getSkin();
     //user settings
     $checkStats = $this->user->getOption('profilebox_stats') == 1;
     $checkStartedEdited = $this->user->getOption('profilebox_startedEdited') == 1;
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('profilebox.js'), '/extensions/wikihow/profilebox/', false));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('profilebox.css'), '/extensions/wikihow/profilebox/', false));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('rcwidget.css'), '/extensions/wikihow/rcwidget/', false));
     $profileStats = new ProfileStats($this->user);
     $badgeData = $profileStats->getBadges();
     $wgOut->addHTML(ProfileBox::getDisplayBadge($badgeData));
     if (!$u) {
         $skin->addWidget($this->getRCUserWidget());
     }
     if ($checkStats || $checkStartedEdited) {
         $createdData = $profileStats->getArticlesCreated(0);
     }
     //stats
     if ($checkStats) {
         $stats = ProfileBox::fetchStats("User:"******"<div class='clearall'></div>");
     }
 }
コード例 #22
0
    private function displayNABConsole(&$dbw, &$dbr, $target)
    {
        global $wgOut, $wgRequest, $wgUser, $wgParser;
        $not_found = false;
        $title = Title::newFromURL($target);
        if (!$title || !$title->exists()) {
            $articleName = $title ? $title->getFullText() : $target;
            $wgOut->addHTML("<p>Error: Article &ldquo;{$articleName}&rdquo; 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 &ldquo;{$title->getFullText()}&rdquo;. 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">&#9660;</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("'", "&#39;", $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()}\" 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);
        $output = $wgParser->parse($rev->getText(), $title, $popts);
        $parserOutput = $output->getText();
        $magic = WikihowArticleHTML::grabTheMagic($rev->getText());
        $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => $title->getNamespace(), 'magic-word' => $magic));
        $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;";
                }
                $output = $wgParser->parse($rp->getText(), $user_talk, $popts);
                $parserOutput = $output->getText();
                $wgOut->addHTML("<div style='border: 1px solid #eee; {$xtra}'>" . $parserOutput . "</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('&#9658;');
\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('&#9660;');
\t\t\t\tfooter.show();
\t\t\t\tbody.css('overflow', 'visible');
\t\t\t});
\t}
\treturn false;
});
})(jQuery);

</script>

END
);
    }
コード例 #23
0
 private function getNextMethod()
 {
     global $wgUser, $wgOut, $wgParser;
     $dbw = wfGetDB(DB_MASTER);
     $expired = wfTimestamp(TS_MW, time() - MethodGuardian::METHOD_EXPIRED);
     $i = 0;
     $content['error'] = true;
     $goodRevision = false;
     do {
         $skippedIds = $this->skipTool->getSkipped();
         $where = array();
         $where[] = "ama_checkout < '{$expired}'";
         $where[] = "ama_patrolled = 0";
         if ($skippedIds) {
             $where[] = "ama_id NOT IN ('" . implode("','", $skippedIds) . "')";
         }
         $row = $dbw->selectRow(MethodGuardian::TABLE_NAME, array('*'), $where, __METHOD__, array("LIMIT" => 1));
         $content['sql' . $i] = $dbw->lastQuery();
         $content['row'] = $row;
         if ($row !== false) {
             $title = Title::newFromID($row->ama_page);
             $isRedirect = false;
             if ($title) {
                 $dbr = wfGetDB(DB_SLAVE);
                 $isRedirect = intval($dbr->selectField('page', 'page_is_redirect', array('page_id' => $row->ama_page), __METHOD__, array("LIMIT" => 1)));
             }
             if ($title && !$isRedirect) {
                 $this->skipTool->useItem($row->ama_id);
                 $revision = Revision::newFromTitle($title);
                 $popts = $wgOut->parserOptions();
                 $popts->setTidy(true);
                 $parserOutput = $wgOut->parse($revision->getText(), $title, $popts);
                 $content['article'] = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads', 'ns' => NS_MAIN));
                 $content['method'] = $row->ama_method;
                 $content['methodId'] = $row->ama_id;
                 $content['articleId'] = $row->ama_page;
                 $newMethod = $wgParser->parse("== Steps ==\n=== " . $row->ama_method . " ===\n" . $row->ama_steps, $title, new ParserOptions())->getText();
                 $content['steps'] = WikihowArticleHTML::postProcess($newMethod, array('no-ads' => true));
                 //$content['steps'] = $row->ama_steps;
                 $content['articleTitle'] = "<a href='{$title->getLocalURL()}'>{$title->getText()}</a>";
                 $content['error'] = false;
             } else {
                 //article must no longer exist or be a redirect, so delete the tips associated with that article
                 $dbw = wfGetDB(DB_MASTER);
                 $dbw->delete(MethodGuardian::TABLE_NAME, array('ama_page' => $row->ama_page));
             }
         }
         $i++;
         // Check up to 5 titles.
         // If no good title then return an error message
     } while ($i <= 5 && !$title && $row !== false);
     $content['i'] = $i;
     $content['methodCount'] = self::getCount();
     return $content;
 }
コード例 #24
0
 public static function getXPath(&$bodyHtml, &$r)
 {
     global $wgWikiHowSections, $IP, $wgTitle;
     $lang = MobileWikihow::getSiteLanguage();
     // munge steps first
     $opts = array('no-ads' => true);
     require_once "{$IP}/skins/WikiHowSkin.php";
     $oldTitle = $wgTitle;
     $wgTitle = $r->getTitle();
     $vars['bodyHtml'] = WikihowArticleHTML::postProcess($bodyHtml, $opts);
     $vars['lang'] = $lang;
     EasyTemplate::set_path(dirname(__FILE__) . '/');
     $html = EasyTemplate::html('thumb_html.tmpl.php', $vars);
     require_once "{$IP}/extensions/wikihow/mobile/JSLikeHTMLElement.php";
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
     $doc->strictErrorChecking = false;
     $doc->recover = true;
     @$doc->loadHTML($html);
     $doc->normalizeDocument();
     $xpath = new DOMXPath($doc);
     $wgTitle = $oldTitle;
     return $xpath;
 }
コード例 #25
0
ファイル: WikiHowSkin.php プロジェクト: biribogos/wikihow-src
    /**
     * Template filter callback for wikiHow skin.
     * Takes an associative array of data set from a SkinTemplate-based
     * class, and a wrapper for MediaWiki's localization database, and
     * outputs a formatted page.
     *
     * @access private
     */
    public function execute()
    {
        global $wgUser, $wgLang, $wgTitle, $wgRequest, $wgParser, $wgGoogleSiteVerification;
        global $wgOut, $wgScript, $wgStylePath, $wgLanguageCode, $wgForumLink;
        global $wgContLang, $wgXhtmlDefaultNamespace, $wgContLanguageCode;
        global $wgWikiHowSections, $IP, $wgServer, $wgServerName, $wgIsDomainTest;
        global $wgSSLsite, $wgSpecialPages;
        $prefix = "";
        if (class_exists('MobileWikihow')) {
            $mobileWikihow = new MobileWikihow();
            $result = $mobileWikihow->controller();
            // false means we stop processing template
            if (!$result) {
                return;
            }
        }
        $action = $wgRequest->getVal('action', 'view');
        if (count($wgRequest->getVal('diff')) > 0) {
            $action = 'diff';
        }
        $isMainPage = $wgTitle && $wgTitle->getNamespace() == NS_MAIN && $wgTitle->getText() == wfMessage('mainpage')->inContentLanguage()->text() && $action == 'view';
        $isArticlePage = $wgTitle && !$isMainPage && $wgTitle->getNamespace() == NS_MAIN && $action == 'view';
        $isDocViewer = $wgTitle->getText() == "DocViewer";
        $isBehindHttpAuth = !empty($_SERVER['HTTP_AUTHORIZATION']);
        // determine whether or not the user is logged in
        $isLoggedIn = $wgUser->getID() > 0;
        $isTool = false;
        wfRunHooks('getToolStatus', array(&$isTool));
        $sk = $this->getSkin();
        wikihowAds::setCategories();
        if (!$isLoggedIn && $action == "view") {
            wikihowAds::getGlobalChannels();
        }
        $showAds = wikihowAds::isEligibleForAds();
        $isIndexed = RobotPolicy::isIndexable($wgTitle);
        $pageTitle = SkinWikihowSkin::getHTMLTitle($wgOut->getHTMLTitle(), $this->data['title'], $isMainPage);
        // set the title and what not
        $avatar = '';
        $namespace = $wgTitle->getNamespace();
        if ($namespace == NS_USER || $namespace == NS_USER_TALK) {
            $username = $wgTitle->getText();
            $usernameKey = $wgTitle->getDBKey();
            $avatar = $wgLanguageCode == 'en' ? Avatar::getPicture($usernameKey) : "";
            $h1 = $username;
            if ($wgTitle->getNamespace() == NS_USER_TALK) {
                $h1 = $wgLang->getNsText(NS_USER_TALK) . ": {$username}";
            } elseif ($username == $wgUser->getName()) {
                //user's own page
                $profileBoxName = wfMessage('profilebox-name')->text();
                $h1 .= "<div id='gatEditRemoveButtons'>\n\t\t\t\t\t\t\t\t<a href='/Special:Profilebox' id='gatProfileEditButton'>Edit</a>\n\t\t\t\t\t\t\t\t | <a href='#' onclick='removeUserPage(\"{$profileBoxName}\");'>Remove {$profileBoxName}</a>\n\t\t\t\t\t\t\t\t </div>";
            }
            $this->set("title", $h1);
        }
        $logoutPage = $wgLang->specialPage("Userlogout");
        $returnTarget = $wgTitle->getPrefixedURL();
        $returnto = strcasecmp(urlencode($logoutPage), $returnTarget) ? "returnto={$returnTarget}" : "";
        $login = "";
        if (!$wgUser->isAnon()) {
            $uname = $wgUser->getName();
            if (strlen($uname) > 16) {
                $uname = substr($uname, 0, 16) . "...";
            }
            $login = wfMessage('welcome_back', $wgUser->getUserPage()->getFullURL(), $uname)->text();
            if ($wgLanguageCode == 'en' && $wgUser->isFacebookUser()) {
                $login = wfMessage('welcome_back_fb', $wgUser->getUserPage()->getFullURL(), $wgUser->getName())->text();
            } elseif ($wgLanguageCode == 'en' && $wgUser->isGPlusUser()) {
                $gname = $wgUser->getName();
                if (substr($gname, 0, 3) == 'GP_') {
                    $gname = substr($gname, 0, 12) . '...';
                }
                $login = wfMessage('welcome_back_gp', $wgUser->getUserPage()->getFullURL(), $gname)->text();
            }
        } else {
            if ($wgLanguageCode == "en") {
                $login = wfMessage('signup_or_login', $returnto)->text() . " " . wfMessage('social_connect_header')->text();
            } else {
                $login = wfMessage('signup_or_login', $returnto)->text();
            }
        }
        //XX PROFILE EDIT/CREAT/DEL BOX DATE - need to check for pb flag in order to display this.
        $pbDate = "";
        $pbDateFlag = 0;
        $profilebox_name = wfMessage('profilebox-name')->text();
        if ($wgTitle->getNamespace() == NS_USER) {
            if ($u = User::newFromName($wgTitle->getDBKey())) {
                if (UserPagePolicy::isGoodUserPage($wgTitle->getDBKey())) {
                    $pbDate = ProfileBox::getPageTop($u);
                    $pbDateFlag = true;
                }
            }
        }
        $heading = '';
        if (!$sk->suppressH1Tag()) {
            if ($wgTitle->getNamespace() == NS_MAIN && $wgTitle->exists() && $action == "view") {
                if (Microdata::showRecipeTags() && Microdata::showhRecipeTags()) {
                    $itemprop_name1 = " fn'";
                    $itemprop_name2 = "";
                } else {
                    $itemprop_name1 = "' itemprop='name'";
                    $itemprop_name2 = " itemprop='url'";
                }
                $heading = "<h1 class='firstHeading" . $itemprop_name1 . "><a href=\"" . $wgTitle->getFullURL() . "\"" . $itemprop_name2 . ">" . wfMessage('howto', $this->data['title'])->text() . "</a></h1>";
            } else {
                if ($wgTitle->getNamespace() == NS_USER && UserPagePolicy::isGoodUserPage($wgTitle->getDBKey()) || $wgTitle->getNamespace() == NS_USER_TALK) {
                    $heading = "<h1 class=\"firstHeading\" >" . $this->data['title'] . "</h1>  " . $pbDate;
                    if ($avatar) {
                        $heading = $avatar . "<div id='avatarNameWrap'>" . $heading . "</div><div style='clear: both;'> </div>";
                    }
                } else {
                    if ($this->data['title'] && strtolower(substr($wgTitle->getText(), 0, 9)) != 'userlogin') {
                        $heading = "<h1 class='firstHeading'>" . $this->data['title'] . "</h1>";
                    }
                }
            }
        }
        // get the breadcrumbs / category links at the top of the page
        $catLinksTop = $sk->getCategoryLinks(true);
        wfRunHooks('getBreadCrumbs', array(&$catLinksTop));
        $mainPageObj = Title::newMainPage();
        $isPrintable = false;
        if (MWNamespace::isTalk($wgTitle->getNamespace()) && $action == "view") {
            $isPrintable = $wgRequest->getVal("printable") == "yes";
        }
        // QWER links for everyone on all pages
        //$helplink = Linker::link(Title::makeTitle(NS_PROJECT_TALK, 'Help-Team'), wfMessage('help')->text());
        $logoutlink = Linker::link(Title::makeTitle(NS_SPECIAL, 'Userlogout'), wfMessage('logout')->text());
        $rsslink = "<a href='" . $wgServer . "/feed.rss'>" . wfMessage('rss')->text() . "</a>";
        $rplink = Linker::link(Title::makeTitle(NS_SPECIAL, "Randompage"), wfMessage('randompage')->text());
        if ($wgTitle->getNamespace() == NS_MAIN && !$isMainPage && $wgTitle->userCan('edit')) {
            $links[] = array(Title::makeTitle(NS_SPECIAL, "Recentchangeslinked")->getFullURL() . "/" . $wgTitle->getPrefixedURL(), wfMessage('recentchangeslinked')->text());
        }
        //Editing Tools
        $uploadlink = "";
        $freephotoslink = "";
        $uploadlink = Linker::link(Title::makeTitle(NS_SPECIAL, "Upload"), wfMessage('upload')->text());
        $freephotoslink = Linker::link(Title::makeTitle(NS_SPECIAL, "ImportFreeImages"), wfMessage('imageimport')->text());
        $relatedchangeslink = "";
        if ($isArticlePage) {
            $relatedchangeslink = "<li> <a href='" . Title::makeTitle(NS_SPECIAL, "Recentchangeslinked")->getFullURL() . "/" . $wgTitle->getPrefixedURL() . "'>" . wfMessage('recentchangeslinked')->text() . "</a></li>";
        }
        //search
        $searchTitle = Title::makeTitle(NS_SPECIAL, "LSearch");
        $otherLanguageLinks = array();
        $translationData = array();
        if ($this->data['language_urls']) {
            foreach ($this->data['language_urls'] as $lang) {
                if ($lang['code'] == $wgLanguageCode) {
                    continue;
                }
                $otherLanguageLinks[$lang['code']] = $lang['href'];
                $langMsg = $sk->getInterWikiCTA($lang['code'], $lang['text'], $lang['href']);
                if (!$langMsg) {
                    continue;
                }
                $encLangMsg = json_encode($langMsg);
                $translationData[] = "'{$lang['code']}': {'msg':{$encLangMsg}}";
            }
        }
        if (!$isMainPage && !$isDocViewer && (!isset($_COOKIE['sitenoticebox']) || !$_COOKIE['sitenoticebox'])) {
            $siteNotice = $sk->getSiteNotice();
        } else {
            $siteNotice = '';
        }
        // Right-to-left languages
        $dir = $wgContLang->isRTL() ? "rtl" : "ltr";
        $head_element = "<html xmlns:fb=\"https://www.facebook.com/2008/fbml\" xmlns=\"{$wgXhtmlDefaultNamespace}\" xml:lang=\"{$wgContLanguageCode}\" lang=\"{$wgContLanguageCode}\" dir='{$dir}'>\n";
        $rtl_css = "";
        if ($wgContLang->isRTL()) {
            $rtl_css = "<style type=\"text/css\" media=\"all\">/*<![CDATA[*/ @import \\a" . wfGetPad("/extensions/min/f/skins/WikiHow/rtl.css") . "\"; /*]]>*/</style>";
            $rtl_css .= "\n   <!--[if IE]>\n   <style type=\"text/css\">\n   BODY { margin: 25px; }\n   </style>\n   <![endif]-->";
        }
        $printable_media = "print";
        if ($wgRequest->getVal('printable') == 'yes') {
            $printable_media = "all";
        }
        $top_search = "";
        $footer_search = "";
        if ($wgLanguageCode == 'en') {
            //INTL: Search options for the english site are a bit more complex
            if (!$isLoggedIn) {
                $top_search = GoogSearch::getSearchBox("cse-search-box");
            } else {
                $top_search = '
				   <form id="bubble_search" name="search_site" action="' . $searchTitle->getFullURL() . '" method="get">
				   <input type="text" class="search_box" name="search" x-webkit-speech />
				   <input type="submit" value="Search" id="search_site_bubble" class="search_button" />
				   </form>';
            }
        } else {
            //INTL: International search just uses Google custom search
            $top_search = GoogSearch::getSearchBox("cse-search-box");
        }
        $text = $this->data['bodytext'];
        // Remove stray table under video section. Probably should eventually do it at
        // the source, but then have to go through all articles.
        if (strpos($text, '<a name="Video">') !== false) {
            $vidpattern = "<p><br /></p>\n<center>\n<table width=\"375px\">\n<tr>\n<td><br /></td>\n<td align=\"left\"></td>\n</tr>\n</table>\n</center>\n<p><br /></p>";
            $text = str_replace($vidpattern, "", $text);
        }
        $this->data['bodytext'] = $text;
        // hack to get the FA template working, remove after we go live
        $fa = '';
        if ($wgLanguageCode != "nl" && strpos($this->data['bodytext'], 'featurestar') !== false) {
            $fa = '<p id="feature_star">' . wfMessage('featured_article')->text() . '</p>';
            //$this->data['bodytext'] = preg_replace("@<div id=\"featurestar\">(.|\n)*<div style=\"clear:both\"></div>@mU", '', $this->data['bodytext']);
        }
        $body = '';
        if ($wgTitle->userCan('edit') && $action != 'edit' && $action != 'diff' && $action != 'history' && ($isLoggedIn && !in_array($wgTitle->getNamespace(), array(NS_USER, NS_USER_TALK, NS_IMAGE, NS_CATEGORY)) || !in_array($wgTitle->getNamespace(), array(NS_USER, NS_USER_TALK, NS_IMAGE, NS_CATEGORY)))) {
            //INTL: Need bigger buttons for non-english sites
            $editlink_text = $wgTitle->getNamespace() == NS_MAIN ? wfMessage('editarticle')->text() : wfMessage('edit')->text();
            $heading = '<a href="' . $wgTitle->getLocalURL($sk->editUrlOptions()) . '" class="editsection">' . $editlink_text . '</a>' . $heading;
        }
        if ($isArticlePage || $wgTitle->getNamespace() == NS_PROJECT && $action == 'view' || $wgTitle->getNamespace() == NS_CATEGORY && !$wgTitle->exists()) {
            if ($wgTitle->getNamespace() == NS_PROJECT && ($wgTitle->getDbKey() == 'RSS-feed' || $wgTitle->getDbKey() == 'Rising-star-feed')) {
                $list_page = true;
                $sticky = false;
            } else {
                $list_page = false;
                $sticky = true;
            }
            $body .= $heading . ArticleAuthors::getAuthorHeader() . $this->data['bodytext'];
            $body = '<div id="bodycontents">' . $body . '</div>';
            $wikitext = ContentHandler::getContentText($this->getSkin()->getContext()->getWikiPage()->getContent(Revision::RAW));
            $magic = WikihowArticleHTML::grabTheMagic($wikitext);
            $this->data['bodytext'] = WikihowArticleHTML::processArticleHTML($body, array('sticky-headers' => $sticky, 'ns' => $wgTitle->getNamespace(), 'list-page' => $list_page, 'magic-word' => $magic));
        } else {
            if ($action == 'edit') {
                $heading .= WikihowArticleEditor::grabArticleEditLinks($wgRequest->getVal("guidededitor"));
            }
            $this->data['bodyheading'] = $heading;
            $body = '<div id="bodycontents">' . $this->data['bodytext'] . '</div>';
            if (!$isTool) {
                $this->data['bodytext'] = WikihowArticleHTML::processHTML($body, $action, array('show-gray-container' => $sk->showGrayContainer()));
            } else {
                // a little hack to style the no such special page messages for special pages that actually
                // exist
                if (false !== strpos($body, 'You have arrived at a "special page"')) {
                    $body = "<div class='minor_section'>{$body}</div>";
                }
                $this->data['bodytext'] = $body;
            }
        }
        // post-process the Steps section HTML to get the numbers working
        if ($wgTitle->getNamespace() == NS_MAIN && !$isMainPage && ($action == 'view' || $action == 'purge')) {
            // for preview article after edit, you have to munge the
            // steps of the previewHTML manually
            $body = $this->data['bodytext'];
            $opts = array();
            if (!$showAds) {
                $opts['no-ads'] = true;
            }
            //$this->data['bodytext'] = WikihowArticleHTML::postProcess($body, $opts);
        }
        // insert avatars into discussion, talk, and kudos pages
        if (MWNamespace::isTalk($wgTitle->getNamespace()) || $wgTitle->getNamespace() == NS_USER_KUDOS) {
            $this->data['bodytext'] = Avatar::insertAvatarIntoDiscussion($this->data['bodytext']);
        }
        //$navMenu = $sk->genNavigationMenu();
        $navTabs = $sk->genNavigationTabs();
        // set up the main page
        $mpActions = "";
        $mpWorldwide = '

		';
        $profileBoxIsUser = false;
        if ($isLoggedIn && $wgTitle && $wgTitle->getNamespace() == NS_USER) {
            $name = $wgTitle->getDBKey();
            $profileBoxUser = User::newFromName($name);
            if ($profileBoxUser && $wgUser->getID() == $profileBoxUser->getID()) {
                $profileBoxIsUser = true;
            }
        }
        // Reuben (11/2013): Micro-customization as a test for BR
        //$slowSpeedUsers = array('BR');
        $slowSpeedUsers = array();
        $isSlowSpeedUser = $wgUser && in_array($wgUser->getName(), $slowSpeedUsers);
        $optimizelyJS = false;
        if (class_exists('OptimizelyPageSelector') && $wgTitle) {
            if (OptimizelyPageSelector::isArticleEnabled($wgTitle) && OptimizelyPageSelector::isUserEnabled($wgUser)) {
                $optimizelyJS = OptimizelyPageSelector::getOptimizelyTag();
            }
        }
        $showSpotlightRotate = $isMainPage && $wgLanguageCode == 'en';
        $showBreadCrumbs = $sk->showBreadCrumbs();
        $showSideBar = $sk->showSideBar();
        $showHeadSection = $sk->showHeadSection();
        $showArticleTabs = $wgTitle->getNamespace() != NS_SPECIAL && !$isMainPage;
        if (in_array($wgTitle->getNamespace(), array(NS_IMAGE)) && (empty($action) || $action == 'view') && !$isLoggedIn) {
            $showArticleTabs = false;
        }
        $showWikiTextWidget = false;
        if (class_exists('WikitextDownloader')) {
            $showWikiTextWidget = WikitextDownloader::isAuthorized() && !$isDocViewer;
        }
        $showRCWidget = class_exists('RCWidget') && $wgTitle->getNamespace() != NS_USER && (!$isLoggedIn || $wgUser->getOption('recent_changes_widget_show', true) == 1) && ($isLoggedIn || $isMainPage) && !in_array($wgTitle->getPrefixedText(), array('Special:Avatar', 'Special:ProfileBox', 'Special:IntroImageAdder')) && strpos($wgTitle->getPrefixedText(), 'Special:Userlog') === false && !$isDocViewer && $action != 'edit';
        $showFollowWidget = class_exists('FollowWidget') && !$isDocViewer && in_array($wgLanguageCode, array('en', 'de', 'es', 'pt'));
        $showSocialSharing = $wgTitle && $wgTitle->exists() && $wgTitle->getNamespace() == NS_MAIN && !$isSlowSpeedUser && $action == 'view' && class_exists('WikihowShare');
        $showSliderWidget = class_exists('Slider') && $wgTitle->exists() && $wgTitle->getNamespace() == NS_MAIN && !$wgTitle->isProtected() && !$isPrintable && !$isMainPage && $isIndexed && $wgLanguageCode == 'en' && $wgRequest->getVal('oldid') == '' && ($wgRequest->getVal('action') == '' || $wgRequest->getVal('action') == 'view');
        $showTopTenTips = $wgTitle->exists() && $wgTitle->getNamespace() == NS_MAIN && $wgLanguageCode == 'en' && !$isPrintable && !$isMainPage && $wgRequest->getVal('oldid') == '' && ($wgRequest->getVal('action') == '' || $wgRequest->getVal('action') == 'view');
        $showAltMethod = false;
        if (class_exists('AltMethodAdder')) {
            $showAltMethod = true;
        }
        $showExitTimer = $wgLanguageCode == 'en' && class_exists('BounceTimeLogger') && !$isSlowSpeedUser;
        $showRUM = false;
        //($isArticlePage || $isMainPage) && !$isBehindHttpAuth && !$isSlowSpeedUser;
        $showGoSquared = ($isArticlePage || $isMainPage) && !$isLoggedIn && !$isBehindHttpAuth && mt_rand(1, 100) <= 30;
        // 30% chance
        $showClickIgniter = !$isLoggedIn && !$isBehindHttpAuth && !$wgSSLsite;
        $showGA = !$isSlowSpeedUser;
        $showGAevents = $wgLanguageCode == 'en' && $isMainPage && !$isSlowSpeedUser;
        $isLiquid = false;
        //!$isMainPage && ( $wgTitle->getNameSpace() == NS_CATEGORY );
        $showFeaturedArticlesSidebar = $action == 'view' && !$isMainPage && !$isDocViewer && !$wgSSLsite && $wgTitle->getNamespace() != NS_USER;
        $isSpecialPage = $wgTitle->getNamespace() == NS_SPECIAL || $wgTitle->getNamespace() == NS_MAIN && $wgRequest->getVal('action') == 'protect' || $wgTitle->getNamespace() == NS_MAIN && $wgRequest->getVal('action') == 'delete';
        $showTextScroller = class_exists('TextScroller') && $wgTitle->exists() && $wgTitle->getNamespace() == NS_MAIN && !$isPrintable && !$isMainPage && strpos($this->data['bodytext'], 'textscroller_outer') !== false;
        $showUserCompletedImages = class_exists('UCIPatrol') && $wgTitle->exists() && $wgTitle->getNamespace() == NS_MAIN && !$isMainPage && UCIPatrol::showUCI($this->getSkin()->getContext()->getTitle());
        $showImageFeedback = class_exists('ImageFeedback') && ImageFeedback::isValidPage();
        $showWikivideo = class_exists('WHVid') && ($wgTitle->exists() && $wgTitle->getNamespace() == NS_MAIN && strpos($this->data['bodytext'], 'whvid_cont') !== false || $wgTitle->getNamespace() == NS_SPECIAL) && !$isPrintable && !$isMainPage;
        $showStaffStats = !$isMainPage && $isLoggedIn && (in_array('staff', $wgUser->getGroups()) || in_array('staff_widget', $wgUser->getGroups())) && $wgTitle->getNamespace() == NS_MAIN && class_exists('Pagestats');
        $showThumbsUp = class_exists('ThumbsNotifications');
        $postLoadJS = $isArticlePage;
        // add present JS files to extensions/min/groupsConfig.php
        $fullJSuri = '/extensions/min/g/whjs' . (!$isArticlePage ? ',jqui' : '') . ($showExitTimer ? ',stu' : '') . ($showRCWidget ? ',rcw' : '') . ($showSpotlightRotate ? ',sp' : '') . ($showFollowWidget ? ',fl' : '') . ($showSliderWidget ? ',slj' : '') . ($showThumbsUp ? ',thm' : '') . ($showWikiTextWidget ? ',wkt' : '') . ($showAltMethod ? ',altj' : '') . ($showTopTenTips ? ',tpt' : '') . ($isMainPage ? ',hp' : '') . ($showWikivideo ? ',whv' : '') . ($showImageFeedback ? ',ii' : '') . ($showUserCompletedImages ? ',uci' : '') . ($showTextScroller ? ',ts' : '');
        if ($wgOut->mJSminCodes) {
            $fullJSuri .= ',' . join(',', $wgOut->mJSminCodes);
        }
        $cachedParam = $wgRequest && $wgRequest->getVal('c') == 't' ? '&c=t' : '';
        $fullJSuri .= '&r=' . WH_SITEREV . $cachedParam . '&e=.js';
        $fullCSSuri = '/extensions/min/g/whcss' . (!$isArticlePage ? ',jquic,nona' : '') . ($isLoggedIn ? ',li' : '') . ($showSliderWidget ? ',slc' : '') . ($showAltMethod ? ',altc' : '') . ($showTopTenTips ? ',tptc' : '') . ($showWikivideo ? ',whvc' : '') . ($showTextScroller ? ',tsc' : '') . ($isMainPage ? ',hpc' : '') . ($showImageFeedback ? ',iic' : '') . ($showUserCompletedImages ? ',ucic' : '') . ($isSpecialPage ? ',spc' : '');
        if ($wgOut->mCSSminCodes) {
            $fullCSSuri .= ',' . join(',', $wgOut->mCSSminCodes);
        }
        $fullCSSuri .= '&r=' . WH_SITEREV . $cachedParam . '&e=.css';
        $tabsArray = $sk->getTabsArray($showArticleTabs);
        wfRunHooks('JustBeforeOutputHTML', array(&$this));
        ?>
<!DOCTYPE html>
<?php 
        echo $head_element;
        ?>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#">
	<title><?php 
        echo $pageTitle;
        ?>
</title>
	<?php 
        /*Hack to add variable WH as a global variable before loading script. This is need because load.php creates a closure when loading wikibits.js 
        		Add by Gershon Bialer on 12/2/2013*/
        ?>
<script>
<!--
var WH = WH || {};
//-->
</script>

	<?php 
        if ($showRUM) {
            ?>
<script>
<!--
window.UVPERF = {};
UVPERF.authtoken = 'b473c3f9-a845-4dc3-9432-7ad0441e00c3';
UVPERF.start = new Date().getTime();
//-->
</script>
	<?php 
        }
        ?>
	<?php 
        if ($wgIsDomainTest) {
            ?>
	<base href="http://www.wikihow.com/" />
	<?php 
        }
        ?>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<meta name="verify-v1" content="/Ur0RE4/QGQIq9F46KZyKIyL0ZnS96N5x1DwQJa7bR8=" />
	<meta name="google-site-verification" content="Jb3uMWyKPQ3B9lzp5hZvJjITDKG8xI8mnEpWifGXUb0" />
	<meta name="msvalidate.01" content="CFD80128CAD3E726220D4C2420D539BE" />
	<meta name="y_key" content="1b3ab4fc6fba3ab3" />
	<meta name="p:domain_verify" content="bb366527fa38aa5bc27356b728a2ec6f" />
	<?php 
        if ($isArticlePage || $isMainPage) {
            ?>
	<link rel="alternate" media="only screen and (max-width: 640px)" href="http://<?php 
            if ($wgLanguageCode != 'en') {
                echo $wgLanguageCode . ".";
            }
            ?>
m.wikihow.com/<?php 
            echo $wgTitle->getPartialUrl();
            ?>
">
	<?php 
        }
        ?>
	<?php 
        // add CSS files to extensions/min/groupsConfig.php
        ?>
	<style type="text/css" media="all">/*<![CDATA[*/ @import "<?php 
        echo $fullCSSuri;
        ?>
"; /*]]>*/</style>
	<?php 
        // below is the minified http://www.wikihow.com/extensions/min/f/skins/owl/printable.css
        ?>
	<style type="text/css" media="<?php 
        echo $printable_media;
        ?>
">/*<![CDATA[*/ body{background-color:#FFF;font-size:1.2em}#header_outer{background:0 0;position:relative}#header{text-align:center;height:63px!important;width:242px!important;background:url(/skins/owl/images/logo_lightbg_242.jpg) no-repeat center center;margin-top:15px}#article_shell{margin:0 auto;float:none;padding-bottom:2em}.sticking{position:absolute!important;top:0!important}#actions,#article_rating,#article_tabs,#breadcrumb,#bubble_search,#cse-search-box,#end_options,#footer_outer,#header_space,#logo_link,#notification_count,#originators,#sidebar,#sliderbox,.edit,.editsection,.mwimg,.section.relatedwikihows,.section.video,.whvid_cont,.altadder_section{display:none!important} /*]]>*/</style>	
		<?php 
        // Bootstapping certain javascript functions:
        // A function to merge one object with another; stub funcs
        // for button swapping (this should be done in CSS anyway);
        // initialize the timer for bounce stats tracking.
        ?>
		<script>
			<!--
			var WH = WH || {};
			WH.lang = WH.lang || {};
			button_swap = button_unswap = function(){};
			WH.exitTimerStartTime = (new Date()).getTime();
			WH.mergeLang = function(A){for(i in A){v=A[i];if(typeof v==='string'){WH.lang[i]=v;}}};
			//-->
		</script>
		<?php 
        if (!$postLoadJS) {
            ?>
			<?php 
            echo $this->html('headscripts');
            ?>
			<script type="text/javascript" src="<?php 
            echo $fullJSuri;
            ?>
"></script>
		<?php 
        }
        ?>

		<?php 
        $this->html('headlinks');
        ?>
		
	<?php 
        if (!$wgIsDomainTest) {
            ?>
			<link rel='canonical' href='<?php 
            echo $wgTitle->getFullURL();
            ?>
'/>
			<link href="https://plus.google.com/102818024478962731382" rel="publisher" />
		<?php 
        }
        ?>
	<?php 
        if ($sk->isUserAgentMobile()) {
            ?>
			<link media="only screen and (max-device-width: 480px)" href="<?php 
            echo wfGetPad('/extensions/min/f/skins/WikiHow/iphone.css');
            ?>
" type="text/css" rel="stylesheet" />
		<?php 
        } else {
            ?>
			<!-- not mobile -->
		<?php 
        }
        ?>
	<!--<![endif]-->
	<?php 
        echo $rtl_css;
        ?>
	<link rel="alternate" type="application/rss+xml" title="wikiHow: How-to of the Day" href="http://www.wikihow.com/feed.rss"/>
	<link rel="apple-touch-icon" href="<?php 
        echo wfGetPad('/skins/WikiHow/safari-large-icon.png');
        ?>
" />
	<?php 
        //= wfMessage('Test_setup')->text()
        ?>
	<?php 
        if (class_exists('CTALinks') && trim(wfMessage('cta_feature')->inContentLanguage()->text()) == "on") {
            echo CTALinks::getGoogleControlScript();
        }
        ?>
	<?php 
        echo $wgOut->getHeadItems();
        ?>
			
	<?php 
        if ($wgTitle && $wgTitle->getText() == "Get Caramel off Pots and Pans") {
            echo wfMessage('Adunit_test_top')->text();
        }
        ?>

	<?php 
        $userdir = $wgLang->getDir();
        $sitedir = $wgContLang->getDir();
        ?>
	<?php 
        foreach ($otherLanguageLinks as $lang => $url) {
            ?>
			<link rel="alternate" hreflang="<?php 
            echo $lang;
            ?>
" href="<?php 
            echo htmlspecialchars($url);
            ?>
" />
		<?php 
        }
        ?>
		</head>
		<body <?php 
        if (isset($this->data['body_ondblclick']) && $this->data['body_ondblclick']) {
            ?>
ondblclick="<?php 
            $this->text('body_ondblclick');
            ?>
"<?php 
        }
        ?>
			  <?php 
        if (isset($this->data['body_onload']) && $this->data['body_onload']) {
            ?>
onload="<?php 
            $this->text('body_onload');
            ?>
"<?php 
        }
        ?>
 
			  class="mediawiki <?php 
        echo $userdir;
        ?>
  sitedir-<?php 
        echo $sitedir;
        ?>
"
			>
		<?php 
        wfRunHooks('PageHeaderDisplay', array($sk->isUserAgentMobile()));
        ?>

		<?php 
        if (!$isLoggedIn) {
            echo wikihowAds::getSetup();
        }
        ?>
		<div id="header_outer"><div id="header">
			<ul id="actions">
				<?php 
        foreach ($navTabs as $tabid => $tab) {
            ?>
					<li id="<?php 
            echo $tabid;
            ?>
_li">
						<div class="nav_icon"></div>
						<a id='<?php 
            echo $tabid;
            ?>
' class='nav' href='<?php 
            echo $tab['link'];
            ?>
'><?php 
            echo $tab['text'];
            ?>
</a>
						<?php 
            echo $tab['menu'];
            ?>
					</li>
				<?php 
        }
        ?>
			</ul><!--end actions-->
			<?php 
        if (isset($sk->notifications_count) && (int) $sk->notifications_count > 0) {
            ?>
				<div id="notification_count" class="notice"><?php 
            echo $sk->notifications_count;
            ?>
</div>
			<?php 
        }
        ?>
			<?php 
        $holidayLogo = SkinWikihowskin::getHolidayLogo();
        $logoPath = $holidayLogo ? $holidayLogo : '/skins/owl/images/wikihow_logo.png';
        if ($wgLanguageCode != "en") {
            $logoPath = "/skins/owl/images/wikihow_logo_intl.png";
        }
        ?>
			<a href='<?php 
        echo $mainPageObj->getLocalURL();
        ?>
' id='logo_link'><img src="<?php 
        echo wfGetPad($logoPath);
        ?>
" class="logo" /></a>
			<?php 
        echo $top_search;
        ?>
			<?php 
        wfRunHooks('EndOfHeader', array(&$wgOut));
        ?>
		</div></div><!--end header-->
		<?php 
        wfRunHooks('AfterHeader', array(&$wgOut));
        ?>
		<div id="main_container" class="<?php 
        echo $isMainPage ? 'mainpage' : '';
        ?>
">
			<div id="header_space"></div>
		
		<div id="main">
		<?php 
        wfRunHooks('BeforeActionbar', array(&$wgOut));
        ?>
		<div id="actionbar" class="<?php 
        echo $isTool ? 'isTool' : '';
        ?>
">
			<?php 
        if ($showBreadCrumbs) {
            ?>
				<div id="gatBreadCrumb">
					<ul id="breadcrumb" class="Breadcrumbs">
						<?php 
            echo $catLinksTop;
            ?>
					</ul>
				</div>
			<?php 
        }
        ?>
			<?php 
        if (count($tabsArray) > 0) {
            echo $sk->getTabsHtml($tabsArray);
        }
        ?>

		</div><!--end actionbar-->
		<script>
		<!--
		WH.translationData = {<?php 
        echo join(',', $translationData);
        ?>
};
		//-->
		</script>
		<?php 
        echo $mpActions;
        ?>
		<?php 
        $sidebar = !$showSideBar ? 'no_sidebar' : '';
        // INTL: load mediawiki messages for sidebar expand and collapse for later use in sidebar boxes
        $langKeys = array('navlist_collapse', 'navlist_expand', 'usernameoremail', 'password');
        print Wikihow_i18n::genJSMsgs($langKeys);
        ?>
		<div id="container" class="<?php 
        echo $sidebar;
        ?>
">
		<div id="article_shell">
		<div id="article"<?php 
        echo Microdata::genSchemaHeader();
        ?>
>

			<?php 
        wfRunHooks('BeforeTabsLine', array(&$wgOut));
        ?>
			<?php 
        if (!$isArticlePage && !$isMainPage && $this->data['bodyheading']) {
            echo '<div class="wh_block">' . $this->data['bodyheading'] . '</div>';
        }
        echo $this->html('bodytext');
        $showingArticleInfo = 0;
        if (in_array($wgTitle->getNamespace(), array(NS_MAIN, NS_PROJECT)) && $action == 'view' && !$isMainPage) {
            $catLinks = $sk->getCategoryLinks(false);
            $authors = ArticleAuthors::getAuthorFooter();
            if ($authors || is_array($this->data['language_urls']) || $catLinks) {
                $showingArticleInfo = 1;
            }
            ?>

				<div class="section">
					<?php 
            if ($showingArticleInfo) {
                ?>
						<h2 class="section_head" id="article_info_header"><span><?php 
                echo wfMessage('article_info')->text();
                ?>
</span></h2>
						<div id="article_info" class="section_text">
					<?php 
            } else {
                ?>
						<h2 class="section_head" id="article_tools_header"><span><?php 
                echo wfMessage('article_tools')->text();
                ?>
</span></h2>
						<div id="article_tools" class="section_text">
					<?php 
            }
            ?>
						<?php 
            echo $fa;
            ?>
						<?php 
            if ($catLinks) {
                ?>
							<p class="info"> <?php 
                echo wfMessage('categories')->text();
                ?>
: <?php 
                echo $catLinks;
                ?>
</p>
						<?php 
            }
            ?>
						<p><?php 
            echo $authors;
            ?>
</p>
						<?php 
            if (is_array($this->data['language_urls'])) {
                ?>
							<p class="info"><?php 
                $this->msg('otherlanguages');
                ?>
:</p>
							<p class="info"><?php 
                $links = array();
                $sk = $this->getSkin();
                foreach ($this->data['language_urls'] as $langlink) {
                    $linkText = $langlink['text'];
                    preg_match("@interwiki-(..)@", $langlink['class'], $langCode);
                    if (!empty($langCode[1])) {
                        $linkText = $sk->getInterWikiLinkText($linkText, $langCode[1]);
                    }
                    $links[] = htmlspecialchars(trim($langlink['language'])) . '&nbsp;<span><a href="' . htmlspecialchars($langlink['href']) . '">' . $linkText . "</a><span>";
                }
                echo implode("&#44;&nbsp;", $links);
                ?>
							</p>
						<?php 
            }
            //talk link
            if ($action == 'view' && MWNamespace::isTalk($wgTitle->getNamespace())) {
                $talk_link = '#postcomment';
            } else {
                $talk_link = $wgTitle->getTalkPage()->getLocalURL();
            }
            ?>
						<ul id="end_options">
							<li class="endop_discuss"><span></span><a href="<?php 
            echo $talk_link;
            ?>
" id="gatDiscussionFooter"><?php 
            echo wfMessage('at_discuss')->text();
            ?>
</a></li>
							<li class="endop_print"><span></span><a href="<?php 
            echo $wgTitle->getLocalUrl('printable=yes');
            ?>
" id="gatPrintView"><?php 
            echo wfMessage('print')->text();
            ?>
</a></li>
							<li class="endop_email"><span></span><a href="#" onclick="return emailLink();" id="gatSharingEmail"><?php 
            echo wfMessage('at_email')->text();
            ?>
</a></li>
							<?php 
            if ($isLoggedIn) {
                ?>
								<?php 
                if ($wgTitle->userIsWatching()) {
                    ?>
									<li class="endop_watch"><span></span><a href="<?php 
                    echo $wgTitle->getLocalURL('action=unwatch');
                    ?>
"><?php 
                    echo wfMessage('at_remove_watch')->text();
                    ?>
</a></li>
								<?php 
                } else {
                    ?>
									<li class="endop_watch"><span></span><a href="<?php 
                    echo $wgTitle->getLocalURL('action=watch');
                    ?>
"><?php 
                    echo wfMessage('at_watch')->text();
                    ?>
</a></li>
								<?php 
                }
                ?>
							<?php 
            }
            ?>
							<li class="endop_edit"><span></span><a href="<?php 
            echo $wgTitle->getEditUrl();
            ?>
" id="gatEditFooter"><?php 
            echo wfMessage('edit')->text();
            ?>
</a></li>
							<?php 
            if ($wgTitle->getNamespace() == NS_MAIN) {
                ?>
								<li class="endop_fanmail"><span></span><a href="/Special:ThankAuthors?target=<?php 
                echo $wgTitle->getPrefixedURL();
                ?>
" id="gatThankAuthors"><?php 
                echo wfMessage('at_fanmail')->text();
                ?>
</a></li>
							<?php 
            }
            ?>
						</ul> <!--end end_options -->
							<?php 
            if (!in_array($wgTitle->getNamespace(), array(NS_USER, NS_CATEGORY))) {
                ?>

							<?php 
            }
            ?>
							<?php 
            if ($showAds && $wgTitle->getNamespace() == NS_MAIN) {
                //only show this ad on article pages
                echo wikihowAds::getAdUnitPlaceholder(7);
            }
            ?>
						<div class="clearall"></div>
					</div><!--end article_info section_text-->
						<p class='page_stats'><?php 
            echo $sk->pageStats();
            ?>
</p>

						<div id='article_rating'>
							<?php 
            echo RateItem::showForm('article');
            ?>
						</div>
				</div><!--end section-->

			<?php 
        }
        if ($showUserCompletedImages) {
            ?>
				<div class="section">
					<h2 class="section_head" id="uci_header"><span><?php 
            echo wfMessage('user_completed_images')->text();
            ?>
</span></h2>
					<div id="uci_images" class="section_text">
						<?php 
            echo UCIPatrol::getHTMLForArticle($this->getSkin()->getContext());
            ?>
					</div> <!-- end section_text-->
				</div><!--end section-->
			<?php 
        }
        if (in_array($wgTitle->getNamespace(), array(NS_USER, NS_MAIN, NS_PROJECT)) && $action == 'view' && !$isMainPage) {
            ?>

		</div> <!-- article -->
		<div id="">

			<?php 
        }
        ?>
		</div>  <!--end last_question-->
		<div class="clearall"></div>

		</div>  <!--end article_shell-->


		<?php 
        if ($showSideBar) {
            $loggedOutClass = "";
            if ($showAds && $wgTitle->getText() != 'Userlogin' && $wgTitle->getNamespace() == NS_MAIN) {
                $loggedOutClass = ' logged_out';
            }
            ?>
			<div id="sidebar">		
				<?php 
            echo $siteNotice;
            ?>

				<!-- Sidebar Top Widgets -->
				<?php 
            foreach ($sk->mSidebarTopWidgets as $sbWidget) {
                ?>
					<?php 
                echo $sbWidget;
                ?>
				<?php 
            }
            ?>
				<!-- END Sidebar Top Widgets -->

				<?php 
            if (!$isDocViewer) {
                ?>
				<div id="top_links" class="sidebox<?php 
                echo $loggedOutClass;
                ?>
" <?php 
                echo is_numeric(wfMessage('top_links_padding')->text()) ? ' style="padding-left:' . wfMessage('top_links_padding')->text() . 'px;padding-right:' . wfMessage('top_links_padding')->text() . 'px;"' : '';
                ?>
>
					<a href="/Special:Randomizer" id="gatRandom" accesskey='x' class="button secondary"><?php 
                echo wfMessage('randompage')->text();
                ?>
</a>
					<a href="/Special:Createpage" id="gatWriteAnArticle" class="button secondary"><?php 
                echo wfMessage('writearticle')->text();
                ?>
</a>
					<?php 
                if (class_exists('Randomizer') && Randomizer::DEBUG && $wgTitle && $wgTitle->getNamespace() == NS_MAIN && $wgTitle->getArticleId()) {
                    ?>
						<?php 
                    echo Randomizer::getReason($wgTitle);
                    ?>
					<?php 
                }
                ?>
				</div><!--end top_links-->
				<?php 
            }
            ?>
				<?php 
            if ($showStaffStats) {
                ?>
					<div class="sidebox" style="padding-top:10px" id="staff_stats_box"></div>
				<?php 
            }
            ?>

				<?php 
            if ($showWikiTextWidget) {
                ?>
					<div class="sidebox" id="side_rc_widget">
						<a id='wikitext_downloader' href='#'>Download WikiText</a>
					</div><!--end sidebox-->
				<?php 
            }
            ?>


				<?php 
            if ($showAds && $wgTitle->getText() != 'Userlogin' && $wgTitle->getNamespace() == NS_MAIN) {
                // temporary ad code for amazon ad loading, added by Reuben 3/13, disabled 4/23, and re-enabled 5/28
                if ($wgLanguageCode == 'en') {
                    ?>
					<script>
						<!--
						var aax_src='3003';
						var amzn_targs = '';
						var url = encodeURIComponent(document.location);
						try { url = encodeURIComponent("" + window.top.location); } catch(e) {}
						document.write("<scr"+"ipt src='//aax-us-east.amazon-Adsystem.com/e/dtb/bid?src=" + aax_src + "&u="+url+"&cb=" + Math.round(Math.random()*10000000) + "'></scr"+"ipt>");
						document.close();
						//-->
					</script>
						<?php 
                }
                ?>
					<?php 
                //only show this ad on article pages
                //comment out next line to turn off HHM ad
                if (wikihowAds::isHHM() && $wgLanguageCode == 'en') {
                    echo wikihowAds::getHhmAd();
                } else {
                    echo wikihowAds::getCategoryAd();
                }
                //Temporairily taking down Jane
                /*if (class_exists('StarterTool')) {
                			//spellchecker test "ad"
                			echo "<a href='/Special:StarterTool?ref=1' style='display:none' id='starter_ad'><img src='" . wfGetPad('/skins/WikiHow/images/sidebar_spelling3.png') . "' nopin='nopin' /></a>";
                		}*/
            }
            //<!-- <a href="#"><img src="/skins/WikiHow/images/imgad.jpg" /></a> -->
            ?>

				<?php 
            $userLinks = $sk->getUserLinks();
            ?>
				<?php 
            if ($userLinks) {
                ?>
				<div class='sidebox'>
					<?php 
                echo $userLinks;
                ?>
				</div>
				<?php 
            }
            ?>

				<?php 
            $related_articles = $sk->getRelatedArticlesBox($this);
            //disable custom link units
            //  if (!$isLoggedIn && $wgTitle->getNamespace() == NS_MAIN && !$isMainPage)
            //if ($related_articles != "")
            //$related_articles .= WikiHowTemplate::getAdUnitPlaceholder(2, true);
            if ($action == 'view' && $related_articles != "") {
                $related_articles = '<div id="side_related_articles" class="sidebox">' . $related_articles . '</div><!--end side_related_articles-->';
                echo $related_articles;
            }
            ?>

				<?php 
            if ($showSocialSharing) {
                ?>
					<div class="sidebox<?php 
                echo $loggedOutClass;
                ?>
" id="sidebar_share">
						<h3><?php 
                echo wfMessage('social_share')->text();
                ?>
</h3>
						<?php 
                if ($isMainPage) {
                    echo WikihowShare::getMainPageShareButtons();
                } else {
                    echo WikihowShare::getTopShareButtons($isIndexed);
                }
                ?>
						<div style="clear:both; float:none;"></div>
					</div>
				<?php 
            }
            ?>

				<?php 
            if ($mpWorldwide !== "") {
                ?>
					<?php 
                echo $mpWorldwide;
                ?>
				<?php 
            }
            ?>

				<?php 
            /*
            <!--
            <div class="sidebox_shell">
            	<div class='sidebar_top'></div>
            	<div id="side_fb_timeline" class="sidebox">
            	</div>
            	<div class='sidebar_bottom_fold'></div>
            </div>
            -->
            <!--end sidebox_shell-->
            */
            ?>

				<!-- Sidebar Widgets -->
				<?php 
            foreach ($sk->mSidebarWidgets as $sbWidget) {
                ?>
					<?php 
                echo $sbWidget;
                ?>
				<?php 
            }
            ?>
				<!-- END Sidebar Widgets -->

				<?php 
            //if ($isLoggedIn) echo $navMenu;
            ?>


				<?php 
            if ($showFeaturedArticlesSidebar) {
                ?>
					<div id="side_featured_articles" class="sidebox">
						<?php 
                echo $sk->getFeaturedArticlesBox(4, 4);
                ?>
					</div>
				<?php 
            }
            ?>

				<?php 
            if ($showRCWidget) {
                ?>
					<div class="sidebox" id="side_rc_widget">
						<?php 
                RCWidget::showWidget();
                ?>
						<p class="bottom_link">
							<?php 
                if ($isLoggedIn) {
                    ?>
								<?php 
                    echo wfMessage('welcome', $wgUser->getName(), $wgUser->getUserPage()->getLocalURL())->text();
                    ?>
							<?php 
                } else {
                    ?>
								<a href="/Special:Userlogin" id="gatWidgetBottom"><?php 
                    echo wfMessage('rcwidget_join_in')->text();
                    ?>
</a>
							<?php 
                }
                ?>
							<a href="" id="play_pause_button" onclick="rcTransport(this); return false;" ></a>
						</p>
					</div><!--end side_recent_changes-->
				<?php 
            }
            ?>

				<?php 
            if (class_exists('FeaturedContributor') && ($wgTitle->getNamespace() == NS_MAIN || $wgTitle->getNamespace() == NS_USER) && !$isMainPage && !$isDocViewer) {
                ?>
					<div id="side_featured_contributor" class="sidebox">
						<?php 
                FeaturedContributor::showWidget();
                ?>
						<?php 
                if (!$isLoggedIn) {
                    ?>
							<p class="bottom_button">
								<a href="/Special:Userlogin" class="button secondary" id="gatFCWidgetBottom" onclick='gatTrack("Browsing","Feat_contrib_cta","Feat_contrib_wgt");'><?php 
                    echo wfMessage('fc_action')->text();
                    ?>
</a>
							</p>
						<?php 
                }
                ?>
					</div><!--end side_featured_contributor-->
				<?php 
            }
            ?>

				<?php 
            //if (!$isLoggedIn) echo $navMenu;
            ?>

				<?php 
            if ($showFollowWidget) {
                ?>
					<div class="sidebox">
						<?php 
                FollowWidget::showWidget();
                ?>
					</div>
				<?php 
            }
            ?>
			</div><!--end sidebar-->
		<?php 
        }
        // end if $showSideBar
        ?>
		<div class="clearall" ></div>
		</div> <!--end container -->
		</div><!--end main-->
			<div id="clear_footer"></div>
		</div><!--end main_container-->
		<div id="footer_outer">
			<div id="footer">
				<div id="footer_side">
					<?php 
        if ($isLoggedIn) {
            ?>
						<?php 
            echo wfMessage('site_footer_owl')->parse();
            ?>
					<?php 
        } else {
            ?>
						<?php 
            echo wfMessage('site_footer_owl_anon')->parse();
            ?>
					<?php 
        }
        ?>
				</div><!--end footer_side-->

				<div id="footer_main">

					<div id="sub_footer">
						<?php 
        if ($isLoggedIn || $isMainPage) {
            ?>
							<?php 
            echo wfMessage('sub_footer_new', wfGetPad(), wfGetPad())->text();
            ?>
						<?php 
        } else {
            ?>
							<?php 
            echo wfMessage('sub_footer_new_anon', wfGetPad(), wfGetPad())->text();
            ?>
						<?php 
        }
        ?>
					</div>
				</div><!--end footer_main-->
			</div>
				<br class="clearall" />
		</div><!--end footer-->
		<div id="dialog-box" title=""></div>

		<?php 
        // Quick note/edit popup
        if ($action == 'diff' && $wgLanguageCode == 'en') {
            echo QuickNoteEdit::displayQuicknote();
            echo QuickNoteEdit::displayQuickedit();
        }
        // Slider box -- for non-logged in users on articles only
        if ($showSliderWidget) {
            echo Slider::getBox();
            echo '<div id="slideshowdetect"></div>';
        }
        ?>

		<div id="fb-root" ></div>

		<?php 
        if ($postLoadJS) {
            ?>
			<?php 
            echo $this->html('headscripts');
            ?>
			<script type="text/javascript" src="<?php 
            echo $fullJSuri;
            ?>
"></script>
		<?php 
        }
        ?>
		<?php 
        if ($optimizelyJS) {
            print $optimizelyJS;
        }
        ?>

		<?php 
        if ($showExitTimer) {
            ?>
			<script>
				<!--
				if (WH.ExitTimer) {
					WH.ExitTimer.start();
				}
				//-->
			</script>
		<?php 
        }
        ?>

		<?php 
        if ($showRCWidget) {
            ?>
			<?php 
            RCWidget::showWidgetJS();
            ?>
		<?php 
        }
        ?>

		<script type="text/javascript">
			<!--
			var _gaq = _gaq || [];
	<?php 
        if ($showGA) {
            ?>
			_gaq.push(['_setAccount', 'UA-2375655-1']);
			_gaq.push(['_setDomainName', '.wikihow.com']);
			_gaq.push(['_trackPageview']);
			(function() {
				var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
				ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
				var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
			})();
	<?php 
        }
        ?>
			//-->
		</script>

	<?php 
        if ($showGA) {
            ?>
		<?php 
            // Google Analytics Event Track
            ?>
		<script type="text/javascript">
			<!--
			if (typeof Event =='undefined' || typeof Event.observe == 'undefined') {
				jQuery(window).load(gatStartObservers);
			} else {
				Event.observe(window, 'load', gatStartObservers);
			}
			//-->
		</script>
		<?php 
            // END Google Analytics Event Track
            ?>
		<?php 
            if (class_exists('CTALinks') && trim(wfMessage('cta_feature')->inContentLanguage()->text()) == "on") {
                echo CTALinks::getGoogleControlTrackingScript();
                echo CTALinks::getGoogleConversionScript();
            }
            ?>
		<?php 
            // Load event listeners
            ?>
		<?php 
            if ($showGAevents) {
                ?>
			<script type="text/javascript">
				<!--
				if (typeof Event =='undefined' || typeof Event.observe == 'undefined') {
					jQuery(window).load(initSA);
				} else {
					Event.observe(window, 'load', initSA);
				}
				//-->
			</script>
		<?php 
            }
            ?>
	<?php 
        }
        // $showGA
        ?>

		<?php 
        // Load event listeners all pages
        ?>
		<?php 
        if (class_exists('CTALinks') && trim(wfMessage('cta_feature')->inContentLanguage()->text()) == "on") {
            echo CTALinks::getBlankCTA();
        }
        ?>

		<?php 
        if ($showClickIgniter) {
            ?>
			<script type="text/javascript">
			(function() {
				var ci = document.createElement('script'); ci.type = 'text/javascript'; ci.async = true;
				ci.src = 'http://cdn.clickigniter.io/ci.js';
				var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ci, s);
			})();
			</script>
		<?php 
        }
        ?>
		<?php 
        if ($showGoSquared) {
            ?>
			<script type="text/javascript">
				var GoSquared = {};
				GoSquared.acct = "GSN-491441-Y";
				(function(w){
					function gs(){
						w._gstc_lt = +new Date;
						var d = document, g = d.createElement("script");
						g.type = "text/javascript";
						g.src = "//d1l6p2sc9645hc.cloudfront.net/tracker.js";
						g.async = true;
						var s = d.getElementsByTagName("script")[0];
						s.parentNode.insertBefore(g, s);
					}
					w.addEventListener ?
						w.addEventListener("load", gs, false) :
						w.attachEvent("onload", gs);
				})(window);
			</script>
		<?php 
        }
        ?>
		<?php 
        if ($showRUM) {
            ?>
		<script>
			(function(){
				var a=document.createElement('script'); a.type='text/javascript'; a.async=true;
				a.src='//yxjj4c.rumanalytics.com/sampler/basic2';
				var b=document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a,b);
			})();
		</script>
		<?php 
        }
        ?>
		<?php 
        wfRunHooks('ArticleJustBeforeBodyClose', array());
        ?>
		<?php 
        if (($wgRequest->getVal("action") == "edit" || $wgRequest->getVal("action") == "submit2") && $wgRequest->getVal('advanced', null) != 'true') {
            ?>
			<script type="text/javascript">
				if (document.getElementById('steps') && document.getElementById('wpTextbox1') == null) {
					InstallAC(document.editform,document.editform.q,document.editform.btnG,"./<?php 
            echo $wgLang->getNsText(NS_SPECIAL) . ":TitleSearch";
            ?>
","en");
				}
			</script>
		<?php 
        }
        ?>

		<?php 
        if ($wgLanguageCode == 'en' && !$isLoggedIn && class_exists('GoogSearch')) {
            ?>
			<?php 
            echo GoogSearch::getSearchBoxJS();
            ?>
		<?php 
        }
        ?>

<script type="text/javascript">
	(function ($) {
		$(document).ready(function() {
			WH.addScrollEffectToTOC();
		});

		$(window).load(function() {
			if ($('.twitter-share-button').length && (!$.browser.msie || $.browser.version > 7)) {

				$.getScript("https://platform.twitter.com/widgets.js", function() {
					twttr.events.bind('tweet', function(event) {
						if (event) {
							var targetUrl;
							if (event.target && event.target.nodeName == 'IFRAME') {
								targetUrl = extractParamFromUri(event.target.src, 'url');
							}
							_gaq.push(['_trackSocial', 'twitter', 'tweet', targetUrl]);
						}
					});

				});
			}

			if (isiPhone < 0 && isiPad < 0 && $('.gplus1_button').length) {
				WH.setGooglePlusOneLangCode();
				var node2 = document.createElement('script');
				node2.type = 'text/javascript';
				node2.async = true;
				node2.src = 'http://apis.google.com/js/plusone.js';
				$('body').append(node2);
			}
			if (typeof WH.FB != 'undefined') WH.FB.init('new');
			if (typeof WH.GP != 'undefined') WH.GP.init();

			if ($('#pinterest').length) {
				var node3 = document.createElement('script');
				node3.type = 'text/javascript';
				node3.async = true;
				node3.src = 'http://assets.pinterest.com/js/pinit.js';
				$('body').append(node3);
			}

			if (typeof WH.imageFeedback != 'undefined') {
				WH.imageFeedback();
			}
			if (typeof WH.uciFeedback != 'undefined') {
				WH.uciFeedback();
			}
		});
	})(jQuery);
</script>
<?php 
        //Temporarily taking down Jane
        /*
        			var r = Math.random();
        			if(r <= .05) {
        				$('#starter_ad').show();
        			}*/
        if ($showStaffStats) {
            ?>
	<?php 
            echo Pagestats::getJSsnippet("article");
        }
        echo $wgOut->getBottomScripts();
        ?>

<?php 
        if (class_exists('GoodRevision')) {
            ?>
	<?php 
            $grevid = $wgTitle ? GoodRevision::getUsedRev($wgTitle->getArticleID()) : '';
            $title = $this->getSkin()->getContext()->getTitle();
            $latestRev = $title->getNamespace() == NS_MAIN ? $title->getLatestRevID() : '';
            ?>
	<!-- shown patrolled revid=<?php 
            echo $grevid;
            ?>
, latest=<?php 
            echo $latestRev;
            ?>
 -->
<?php 
        }
        echo wfReportTime();
        $this->printTrail();
        ?>
</body>
</html>
<?php 
    }
コード例 #26
0
ファイル: MethodEditor.body.php プロジェクト: ErdemA/wikihow
 private function getNextMethod()
 {
     global $wgUser, $wgOut;
     $dbw = wfGetDB(DB_MASTER);
     $expired = wfTimestamp(TS_MW, time() - MethodEditor::METHOD_EXPIRED);
     $i = 0;
     $content['error'] = true;
     $goodRevision = false;
     do {
         $skippedIds = $this->skipTool->getSkipped();
         $where = array();
         $where[] = "ama_checkout < '{$expired}'";
         $where[] = "ama_patrolled = 1";
         $where[] = "NOT EXISTS (SELECT rc_id from recentchanges where rc_cur_id = ama_page and rc_patrolled = 0 LIMIT 1)";
         if ($skippedIds) {
             $where[] = "ama_id NOT IN ('" . implode("','", $skippedIds) . "')";
         }
         $row = $dbw->selectRow(MethodEditor::TABLE_NAME, array('*'), $where, __METHOD__, array("LIMIT" => 1));
         $content['sql' . $i] = $dbw->lastQuery();
         $content['row'] = $row;
         if ($row !== false) {
             $title = Title::newFromID($row->ama_page);
             $isRedirect = false;
             if ($title) {
                 $dbr = wfGetDB(DB_SLAVE);
                 $isRedirect = intval($dbr->selectField('page', 'page_is_redirect', array('page_id' => $row->ama_page), __METHOD__, array("LIMIT" => 1)));
             }
             if ($title && !$isRedirect) {
                 $this->skipTool->useItem($row->ama_id);
                 $revision = Revision::newFromTitle($title);
                 $popts = $wgOut->parserOptions();
                 $popts->setTidy(true);
                 $parserOutput = $wgOut->parse($revision->getText(), $title, $popts);
                 $content['article'] = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads', 'ns' => NS_MAIN));
                 $content['method'] = $row->ama_method;
                 $content['methodId'] = $row->ama_id;
                 $content['articleId'] = $row->ama_page;
                 $content['steps'] = $row->ama_steps;
                 $content['articleTitle'] = "<a href='{$title->getLocalURL()}'>{$title->getText()}</a>";
                 $editURL = Title::makeTitle(NS_SPECIAL, "QuickEdit")->getFullURL() . '?type=editform&target=' . urlencode($title->getFullText());
                 $class = "class='button secondary buttonleft'";
                 $link = "<a id='qe_button' title='" . wfMsg("rcpatrol_quick_edit_title") . "' accesskey='e' href='' {$class} onclick=\"return loadQuickEdit('" . $editURL . "') ;\">" . htmlspecialchars('Quick edit') . "</a> ";
                 $content['quickEditUrl'] = $link;
                 $content['error'] = false;
             } else {
                 //article must no longer exist or be a redirect, so delete the tips associated with that article
                 $dbw = wfGetDB(DB_MASTER);
                 $dbw->delete(MethodEditor::TABLE_NAME, array('ama_page' => $row->ama_page));
             }
         }
         $i++;
         // Check up to 5 titles.
         // If no good title then return an error message
     } while ($i <= 5 && !$title && $row !== false);
     $content['i'] = $i;
     $content['methodCount'] = self::getCount();
     return $content;
 }
コード例 #27
0
ファイル: EditPage.php プロジェクト: biribogos/wikihow-src
 /**
  * Get the rendered text for previewing.
  * @throws MWException
  * @return string
  */
 function getPreviewText()
 {
     global $wgOut, $wgUser, $wgRawHtml, $wgLang;
     wfProfileIn(__METHOD__);
     if ($wgRawHtml && !$this->mTokenOk) {
         // Could be an offsite preview attempt. This is very unsafe if
         // HTML is enabled, as it could be an attack.
         $parsedNote = '';
         if ($this->textbox1 !== '') {
             // Do not put big scary notice, if previewing the empty
             // string, which happens when you initially edit
             // a category page, due to automatic preview-on-open.
             $parsedNote = $wgOut->parse("<div class='previewnote'>" . wfMessage('session_fail_preview_html')->text() . "</div>", true, true);
         }
         wfProfileOut(__METHOD__);
         return $parsedNote;
     }
     $note = '';
     try {
         $content = $this->toEditContent($this->textbox1);
         $previewHTML = '';
         if (!wfRunHooks('AlternateEditPreview', array($this, &$content, &$previewHTML, &$this->mParserOutput))) {
             wfProfileOut(__METHOD__);
             return $previewHTML;
         }
         # provide a anchor link to the editform
         $continueEditing = '<span class="mw-continue-editing">' . '[[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage('continue-editing')->text() . ']]</span>';
         if ($this->mTriedSave && !$this->mTokenOk) {
             if ($this->mTokenOkExceptSuffix) {
                 $note = wfMessage('token_suffix_mismatch')->plain();
             } else {
                 $note = wfMessage('session_fail_preview')->plain();
             }
         } elseif ($this->incompleteForm) {
             $note = wfMessage('edit_form_incomplete')->plain();
         } else {
             $note = wfMessage('previewnote')->plain() . ' ' . $continueEditing;
         }
         $parserOptions = $this->mArticle->makeParserOptions($this->mArticle->getContext());
         $parserOptions->setEditSection(false);
         $parserOptions->setIsPreview(true);
         $parserOptions->setIsSectionPreview(!is_null($this->section) && $this->section !== '');
         # don't parse non-wikitext pages, show message about preview
         if ($this->mTitle->isCssJsSubpage() || $this->mTitle->isCssOrJsPage()) {
             if ($this->mTitle->isCssJsSubpage()) {
                 $level = 'user';
             } elseif ($this->mTitle->isCssOrJsPage()) {
                 $level = 'site';
             } else {
                 $level = false;
             }
             if ($content->getModel() == CONTENT_MODEL_CSS) {
                 $format = 'css';
             } elseif ($content->getModel() == CONTENT_MODEL_JAVASCRIPT) {
                 $format = 'js';
             } else {
                 $format = false;
             }
             # Used messages to make sure grep find them:
             # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
             if ($level && $format) {
                 $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage("{$level}{$format}preview")->text() . ' ' . $continueEditing . "</div>";
             }
         }
         # If we're adding a comment, we need to show the
         # summary as the headline
         if ($this->section === "new" && $this->summary !== "") {
             $content = $content->addSectionHeader($this->summary);
         }
         $hook_args = array($this, &$content);
         ContentHandler::runLegacyHooks('EditPageGetPreviewText', $hook_args);
         wfRunHooks('EditPageGetPreviewContent', $hook_args);
         $parserOptions->enableLimitReport();
         # For CSS/JS pages, we should have called the ShowRawCssJs hook here.
         # But it's now deprecated, so never mind
         $content = $content->preSaveTransform($this->mTitle, $wgUser, $parserOptions);
         $parserOutput = $content->getParserOutput($this->getArticle()->getTitle(), null, $parserOptions);
         $previewHTML = $parserOutput->getText();
         //XXCHANGEDXX Scott: need to tag magic words for processArticleHTML()
         $magic = WikihowArticleHTML::grabTheMagic($this->textbox1);
         // Bebeth, upgrade 1.21: need to post process the html
         $previewHTML = WikihowArticleHTML::processArticleHTML($previewHTML, array('no-ads' => true, 'ns' => $this->mTitle->getNamespace(), 'magic-word' => $magic));
         $this->mParserOutput = $parserOutput;
         $wgOut->addParserOutputNoText($parserOutput);
         if (count($parserOutput->getWarnings())) {
             $note .= "\n\n" . implode("\n\n", $parserOutput->getWarnings());
         }
     } catch (MWContentSerializationException $ex) {
         $m = wfMessage('content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage());
         $note .= "\n\n" . $m->parse();
         $previewHTML = '';
     }
     if ($this->isConflict) {
         $conflict = '<h2 id="mw-previewconflict">' . wfMessage('previewconflict')->escaped() . "</h2>\n";
     } else {
         $conflict = '<hr />';
     }
     $previewhead = "<div class='previewnote'>\n" . '<h2 id="mw-previewheader">' . wfMessage('preview')->escaped() . "</h2>" . $wgOut->parse($note, true, true) . $conflict . "</div>\n";
     $pageViewLang = $this->mTitle->getPageViewLanguage();
     $attribs = array('lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(), 'class' => 'mw-content-' . $pageViewLang->getDir());
     $previewHTML = Html::rawElement('div', $attribs, $previewHTML);
     wfProfileOut(__METHOD__);
     return $previewhead . $previewHTML . $this->previewTextAfterContent;
 }