function updatePageContent($article, $rev, $baseID, $user) { global $wgHuijiPrefix, $wgSitename; $title = $article->getId() == 1 ? $wgSitename : $article->getTitle()->getText(); $post_data = array('timestamp' => $rev->getTimestamp(), 'content' => ContentHandler::getContentText($rev->getContent(Revision::RAW)), 'sitePrefix' => $wgHuijiPrefix, 'siteName' => $wgSitename, 'id' => $article->getId(), 'title' => $title); $post_data_string = json_encode($post_data); curl_post_json('upsert', $post_data_string); }
static function newFromTitle($title) { // see if we already have this as our main instance... if (self::$instance && self::$instance->mTitle == $title) { return self::$instance; } $wikiPage = new WikiPage($title); if (!$wikiPage) { return null; } $whow = new WikihowArticleEditor(); $whow->mTitleObj = $wikiPage->getTitle(); $whow->mWikiPage = $wikiPage; $whow->mTitle = $wikiPage->getTitle()->getText(); $text = ContentHandler::getContentText($wikiPage->getContent(Revision::RAW)); $whow->loadFromText($text); return $whow; }
/** * Parser hook * * @param string $text * @param array $args * @param Parser $parser * @return string */ public static function parserHook($input, array $args, Parser $wgParser) { global $wgIncMarkupTranscludeContent, $wgIncMarkupEscapeContent; $text = $input; $pageTitle = Title::newFromText(substr($input, 2, -2), NS_TEMPLATE); if (isset($pageTitle) && $pageTitle->exists()) { $page = WikiPage::factory($pageTitle); if ($wgIncMarkupTranscludeContent) { $parser = $wgParser->getFreshParser(); $parserOptions = is_null($parser->getOptions()) ? new ParserOptions() : $parser->getOptions(); $text = $parser->getPreloadText($page->getContent()->getWikitextForTransclusion(), $pageTitle, $parserOptions); } else { // $content = $page->getContent(Revision::RAW); $content = $page->getContent(Revision::FOR_THIS_USER); $text = ContentHandler::getContentText($content); } } if ($wgIncMarkupEscapeContent) { $text = htmlentities($text); } return "<pre>\n" . $text . "\n</pre>"; }
/** * Hook into Content::getParserOutput to provide syntax highlighting for * script content. * * @return bool * @since MW 1.21 */ public static function onContentGetParserOutput(Content $content, Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) { global $wgParser, $wgTextModelsToParse; if (!$generateHtml) { // Nothing special for us to do, let MediaWiki handle this. return true; } // Determine the language $extension = ExtensionRegistry::getInstance(); $models = $extension->getAttribute('SyntaxHighlightModels'); $model = $content->getModel(); if (!isset($models[$model])) { // We don't care about this model, carry on. return true; } $lexer = $models[$model]; // Hope that $wgSyntaxHighlightModels does not contain silly types. $text = ContentHandler::getContentText($content); if (!$text) { // Oops! Non-text content? Let MediaWiki handle this. return true; } // Parse using the standard parser to get links etc. into the database, HTML is replaced below. // We could do this using $content->fillParserOutput(), but alas it is 'protected'. if ($content instanceof TextContent && in_array($model, $wgTextModelsToParse)) { $output = $wgParser->parse($text, $title, $options, true, true, $revId); } $status = self::highlight($text, $lexer); if (!$status->isOK()) { return true; } $out = $status->getValue(); $output->addModuleStyles('ext.pygments'); $output->setText('<div dir="ltr">' . $out . '</div>'); // Inform MediaWiki that we have parsed this page and it shouldn't mess with it. return false; }
protected function populateBodyContent() { if ($this->dirtyFlags['content'] !== null) { return; } $bodyPage = $this->getTitle(); $curRev = Revision::newFromTitle($bodyPage); if (!$curRev) { throw new AdContentException("No content for ad: {$this->name}"); } $this->bodyContent = ContentHandler::getContentText($curRev->getContent()); $this->markBodyContentDirty(false); }
/** * Fetch revision text if it's available to the specified audience. * If the specified audience does not have the ability to view this * revision, an empty string will be returned. * * @param $audience Integer: one of: * Revision::FOR_PUBLIC to be displayed to all users * Revision::FOR_THIS_USER to be displayed to the given user * Revision::RAW get the text regardless of permissions * @param $user User object to check for, only if FOR_THIS_USER is passed * to the $audience parameter * * @deprecated in 1.21, use getContent() instead * @todo Replace usage in core * @return String */ public function getText($audience = self::FOR_PUBLIC, User $user = null) { ContentHandler::deprecated(__METHOD__, '1.21'); $content = $this->getContent($audience, $user); return ContentHandler::getContentText($content); # returns the raw content text, if applicable }
/** * Attempt submission (no UI) * * @param array $result Array to add statuses to, currently with the * possible keys: * - spam (string): Spam string from content if any spam is detected by * matchSpamRegex. * - sectionanchor (string): Section anchor for a section save. * - nullEdit (boolean): Set if doEditContent is OK. True if null edit, * false otherwise. * - redirect (bool): Set if doEditContent is OK. True if resulting * revision is a redirect. * @param bool $bot True if edit is being made under the bot right. * * @return Status Status object, possibly with a message, but always with * one of the AS_* constants in $status->value, * * @todo FIXME: This interface is TERRIBLE, but hard to get rid of due to * various error display idiosyncrasies. There are also lots of cases * where error metadata is set in the object and retrieved later instead * of being returned, e.g. AS_CONTENT_TOO_BIG and * AS_BLOCKED_PAGE_FOR_USER. All that stuff needs to be cleaned up some * time. */ function internalAttemptSave(&$result, $bot = false) { global $wgUser, $wgRequest, $wgParser, $wgMaxArticleSize; $status = Status::newGood(); wfProfileIn(__METHOD__); wfProfileIn(__METHOD__ . '-checks'); if (!wfRunHooks('EditPage::attemptSave', array($this))) { wfDebug("Hook 'EditPage::attemptSave' aborted article saving\n"); $status->fatal('hookaborted'); $status->value = self::AS_HOOK_ERROR; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } $spam = $wgRequest->getText('wpAntispam'); if ($spam !== '') { wfDebugLog('SimpleAntiSpam', $wgUser->getName() . ' editing "' . $this->mTitle->getPrefixedText() . '" submitted bogus field "' . $spam . '"'); $status->fatal('spamprotectionmatch', false); $status->value = self::AS_SPAM_ERROR; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } try { # Construct Content object $textbox_content = $this->toEditContent($this->textbox1); } catch (MWContentSerializationException $ex) { $status->fatal('content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage()); $status->value = self::AS_PARSE_ERROR; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } # Check image redirect if ($this->mTitle->getNamespace() == NS_FILE && $textbox_content->isRedirect() && !$wgUser->isAllowed('upload')) { $code = $wgUser->isAnon() ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED; $status->setResult(false, $code); wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } # Check for spam $match = self::matchSummarySpamRegex($this->summary); if ($match === false && $this->section == 'new') { # $wgSpamRegex is enforced on this new heading/summary because, unlike # regular summaries, it is added to the actual wikitext. if ($this->sectiontitle !== '') { # This branch is taken when the API is used with the 'sectiontitle' parameter. $match = self::matchSpamRegex($this->sectiontitle); } else { # This branch is taken when the "Add Topic" user interface is used, or the API # is used with the 'summary' parameter. $match = self::matchSpamRegex($this->summary); } } if ($match === false) { $match = self::matchSpamRegex($this->textbox1); } if ($match !== false) { $result['spam'] = $match; $ip = $wgRequest->getIP(); $pdbk = $this->mTitle->getPrefixedDBkey(); $match = str_replace("\n", '', $match); wfDebugLog('SpamRegex', "{$ip} spam regex hit [[{$pdbk}]]: \"{$match}\""); $status->fatal('spamprotectionmatch', $match); $status->value = self::AS_SPAM_ERROR; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } if (!wfRunHooks('EditFilter', array($this, $this->textbox1, $this->section, &$this->hookError, $this->summary))) { # Error messages etc. could be handled within the hook... $status->fatal('hookaborted'); $status->value = self::AS_HOOK_ERROR; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } elseif ($this->hookError != '') { # ...or the hook could be expecting us to produce an error $status->fatal('hookaborted'); $status->value = self::AS_HOOK_ERROR_EXPECTED; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } if ($wgUser->isBlockedFrom($this->mTitle, false)) { // Auto-block user's IP if the account was "hard" blocked $wgUser->spreadAnyEditBlock(); # Check block state against master, thus 'false'. $status->setResult(false, self::AS_BLOCKED_PAGE_FOR_USER); wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } $this->kblength = (int) (strlen($this->textbox1) / 1024); if ($this->kblength > $wgMaxArticleSize) { // Error will be displayed by showEditForm() $this->tooBig = true; $status->setResult(false, self::AS_CONTENT_TOO_BIG); wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } if (!$wgUser->isAllowed('edit')) { if ($wgUser->isAnon()) { $status->setResult(false, self::AS_READ_ONLY_PAGE_ANON); wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } else { $status->fatal('readonlytext'); $status->value = self::AS_READ_ONLY_PAGE_LOGGED; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } } if ($this->contentModel !== $this->mTitle->getContentModel() && !$wgUser->isAllowed('editcontentmodel')) { $status->setResult(false, self::AS_NO_CHANGE_CONTENT_MODEL); wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } if (wfReadOnly()) { $status->fatal('readonlytext'); $status->value = self::AS_READ_ONLY_PAGE; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } if ($wgUser->pingLimiter() || $wgUser->pingLimiter('linkpurge', 0)) { $status->fatal('actionthrottledtext'); $status->value = self::AS_RATE_LIMITED; wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } # If the article has been deleted while editing, don't save it without # confirmation if ($this->wasDeletedSinceLastEdit() && !$this->recreate) { $status->setResult(false, self::AS_ARTICLE_WAS_DELETED); wfProfileOut(__METHOD__ . '-checks'); wfProfileOut(__METHOD__); return $status; } wfProfileOut(__METHOD__ . '-checks'); # Load the page data from the master. If anything changes in the meantime, # we detect it by using page_latest like a token in a 1 try compare-and-swap. $this->mArticle->loadPageData('fromdbmaster'); $new = !$this->mArticle->exists(); if ($new) { // Late check for create permission, just in case *PARANOIA* if (!$this->mTitle->userCan('create', $wgUser)) { $status->fatal('nocreatetext'); $status->value = self::AS_NO_CREATE_PERMISSION; wfDebug(__METHOD__ . ": no create permission\n"); wfProfileOut(__METHOD__); return $status; } // Don't save a new page if it's blank or if it's a MediaWiki: // message with content equivalent to default (allow empty pages // in this case to disable messages, see bug 50124) $defaultMessageText = $this->mTitle->getDefaultMessageText(); if ($this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false) { $defaultText = $defaultMessageText; } else { $defaultText = ''; } if (!$this->allowBlankArticle && $this->textbox1 === $defaultText) { $this->blankArticle = true; $status->fatal('blankarticle'); $status->setResult(false, self::AS_BLANK_ARTICLE); wfProfileOut(__METHOD__); return $status; } if (!$this->runPostMergeFilters($textbox_content, $status, $wgUser)) { wfProfileOut(__METHOD__); return $status; } $content = $textbox_content; $result['sectionanchor'] = ''; if ($this->section == 'new') { if ($this->sectiontitle !== '') { // Insert the section title above the content. $content = $content->addSectionHeader($this->sectiontitle); } elseif ($this->summary !== '') { // Insert the section title above the content. $content = $content->addSectionHeader($this->summary); } $this->summary = $this->newSectionSummary($result['sectionanchor']); } $status->value = self::AS_SUCCESS_NEW_ARTICLE; } else { # not $new # Article exists. Check for edit conflict. $this->mArticle->clear(); # Force reload of dates, etc. $timestamp = $this->mArticle->getTimestamp(); wfDebug("timestamp: {$timestamp}, edittime: {$this->edittime}\n"); if ($timestamp != $this->edittime) { $this->isConflict = true; if ($this->section == 'new') { if ($this->mArticle->getUserText() == $wgUser->getName() && $this->mArticle->getComment() == $this->newSectionSummary()) { // Probably a duplicate submission of a new comment. // This can happen when squid resends a request after // a timeout but the first one actually went through. wfDebug(__METHOD__ . ": duplicate new section submission; trigger edit conflict!\n"); } else { // New comment; suppress conflict. $this->isConflict = false; wfDebug(__METHOD__ . ": conflict suppressed; new section\n"); } } elseif ($this->section == '' && Revision::userWasLastToEdit(DB_MASTER, $this->mTitle->getArticleID(), $wgUser->getId(), $this->edittime)) { # Suppress edit conflict with self, except for section edits where merging is required. wfDebug(__METHOD__ . ": Suppressing edit conflict, same user.\n"); $this->isConflict = false; } } // If sectiontitle is set, use it, otherwise use the summary as the section title. if ($this->sectiontitle !== '') { $sectionTitle = $this->sectiontitle; } else { $sectionTitle = $this->summary; } $content = null; if ($this->isConflict) { wfDebug(__METHOD__ . ": conflict! getting section '{$this->section}' for time '{$this->edittime}'" . " (article time '{$timestamp}')\n"); $content = $this->mArticle->replaceSectionContent($this->section, $textbox_content, $sectionTitle, $this->edittime); } else { wfDebug(__METHOD__ . ": getting section '{$this->section}'\n"); $content = $this->mArticle->replaceSectionContent($this->section, $textbox_content, $sectionTitle); } if (is_null($content)) { wfDebug(__METHOD__ . ": activating conflict; section replace failed.\n"); $this->isConflict = true; $content = $textbox_content; // do not try to merge here! } elseif ($this->isConflict) { # Attempt merge if ($this->mergeChangesIntoContent($content)) { // Successful merge! Maybe we should tell the user the good news? $this->isConflict = false; wfDebug(__METHOD__ . ": Suppressing edit conflict, successful merge.\n"); } else { $this->section = ''; $this->textbox1 = ContentHandler::getContentText($content); wfDebug(__METHOD__ . ": Keeping edit conflict, failed merge.\n"); } } if ($this->isConflict) { $status->setResult(false, self::AS_CONFLICT_DETECTED); wfProfileOut(__METHOD__); return $status; } if (!$this->runPostMergeFilters($content, $status, $wgUser)) { wfProfileOut(__METHOD__); return $status; } if ($this->section == 'new') { // Handle the user preference to force summaries here if (!$this->allowBlankSummary && trim($this->summary) == '') { $this->missingSummary = true; $status->fatal('missingsummary'); // or 'missingcommentheader' if $section == 'new'. Blegh $status->value = self::AS_SUMMARY_NEEDED; wfProfileOut(__METHOD__); return $status; } // Do not allow the user to post an empty comment if ($this->textbox1 == '') { $this->missingComment = true; $status->fatal('missingcommenttext'); $status->value = self::AS_TEXTBOX_EMPTY; wfProfileOut(__METHOD__); return $status; } } elseif (!$this->allowBlankSummary && !$content->equals($this->getOriginalContent($wgUser)) && !$content->isRedirect() && md5($this->summary) == $this->autoSumm) { $this->missingSummary = true; $status->fatal('missingsummary'); $status->value = self::AS_SUMMARY_NEEDED; wfProfileOut(__METHOD__); return $status; } # All's well wfProfileIn(__METHOD__ . '-sectionanchor'); $sectionanchor = ''; if ($this->section == 'new') { $this->summary = $this->newSectionSummary($sectionanchor); } elseif ($this->section != '') { # Try to get a section anchor from the section source, redirect # to edited section if header found. # XXX: Might be better to integrate this into Article::replaceSection # for duplicate heading checking and maybe parsing. $hasmatch = preg_match("/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches); # We can't deal with anchors, includes, html etc in the header for now, # headline would need to be parsed to improve this. if ($hasmatch && strlen($matches[2]) > 0) { $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText($matches[2]); } } $result['sectionanchor'] = $sectionanchor; wfProfileOut(__METHOD__ . '-sectionanchor'); // Save errors may fall down to the edit form, but we've now // merged the section into full text. Clear the section field // so that later submission of conflict forms won't try to // replace that into a duplicated mess. $this->textbox1 = $this->toEditText($content); $this->section = ''; $status->value = self::AS_SUCCESS_UPDATE; } // Check for length errors again now that the section is merged in $this->kblength = (int) (strlen($this->toEditText($content)) / 1024); if ($this->kblength > $wgMaxArticleSize) { $this->tooBig = true; $status->setResult(false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED); wfProfileOut(__METHOD__); return $status; } $flags = EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | ($new ? EDIT_NEW : EDIT_UPDATE) | ($this->minoredit && !$this->isNew ? EDIT_MINOR : 0) | ($bot ? EDIT_FORCE_BOT : 0); $doEditStatus = $this->mArticle->doEditContent($content, $this->summary, $flags, false, null, $content->getDefaultFormat()); if (!$doEditStatus->isOK()) { // Failure from doEdit() // Show the edit conflict page for certain recognized errors from doEdit(), // but don't show it for errors from extension hooks $errors = $doEditStatus->getErrorsArray(); if (in_array($errors[0][0], array('edit-gone-missing', 'edit-conflict', 'edit-already-exists'))) { $this->isConflict = true; // Destroys data doEdit() put in $status->value but who cares $doEditStatus->value = self::AS_END; } wfProfileOut(__METHOD__); return $doEditStatus; } $result['nullEdit'] = $doEditStatus->hasMessage('edit-no-change'); if ($result['nullEdit']) { // We don't know if it was a null edit until now, so increment here $wgUser->pingLimiter('linkpurge'); } $result['redirect'] = $content->isRedirect(); $this->updateWatchlist(); wfProfileOut(__METHOD__); return $status; }
/** * Returns of stored translation of message specified by the $key in language * code $code. * * @param string $key Message key * @param string $code Language code * @return string|null Stored translation or null. */ public function getMessage($key, $code) { if ($this->isSourceLanguage($code)) { $stuff = $this->load($code); $title = Title::newFromText($key); if ($title) { $key = $title->getPrefixedDBKey(); } return isset($stuff[$key]) ? $stuff[$key] : null; } $title = Title::makeTitleSafe($this->getNamespace(), "{$key}/{$code}"); $rev = Revision::newFromTitle($title, false, Revision::READ_LATEST); if (!$rev) { return null; } return ContentHandler::getContentText($rev->getContent()); }
/** * Get text of an article from database * Does *NOT* follow redirects. * * @protected * @note This is really internal functionality that should really NOT be * used by other functions. For accessing article content, use the WikiPage * class, especially WikiBase::getContent(). However, a lot of legacy code * uses this method to retrieve page text from the database, so the function * has to remain public for now. * * @return string|bool String containing article contents, or false if null * @deprecated since 1.21, use WikiPage::getContent() instead */ function fetchContent() { // BC cruft! ContentHandler::deprecated(__METHOD__, '1.21'); if ($this->mContentLoaded && $this->mContent) { return $this->mContent; } $content = $this->fetchContentObject(); if (!$content) { return false; } // @todo Get rid of mContent everywhere! $this->mContent = ContentHandler::getContentText($content); ContentHandler::runLegacyHooks('ArticleAfterFetchContent', array(&$this, &$this->mContent)); return $this->mContent; }
public function testGetContentText_NonTextContent_ignore() { $this->setMwGlobals('wgContentHandlerTextFallback', 'ignore'); $content = new DummyContentForTesting("hello world"); $text = ContentHandler::getContentText($content); $this->assertNull($text); }
/** * Returns the text for this translatable page. * @throws MWException * @return string */ public function getText() { if ($this->init === false) { switch ($this->source) { case 'text': break; case 'title': $this->revision = $this->getMarkedTag(); // There is no break statement here on purpose // There is no break statement here on purpose case 'revision': $rev = Revision::newFromTitle($this->getTitle(), $this->revision); $this->text = ContentHandler::getContentText($rev->getContent()); break; } } if (!is_string($this->text)) { throw new MWException('We have no text'); } $this->init = true; return $this->text; }
/** * Returns the blacklist, which is a non-associative array of user NSIDs and path_aliases * (the name name which can be seen in the pretty URL). For a given user, usually only one * of the NSID and the path_alias will be present; it is the responsibility of the consumers * of the blacklist to check it against both. * @return array */ public function getBlacklist() { if (!isset(self::$blacklist)) { self::$blacklist = array(); if ($this->flickrBlacklistPage) { $title = Title::newFromText($this->flickrBlacklistPage); $page = WikiPage::factory($title); $text = ContentHandler::getContentText($page->getContent()); $text = preg_replace('/^\\s*#.*$/m', '', $text); preg_match_all('/\\S+/', $text, $match); self::$blacklist = $match[0]; } } return self::$blacklist; }
/** * 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'])) . ' <span><a href="' . htmlspecialchars($langlink['href']) . '">' . $linkText . "</a><span>"; } echo implode(", ", $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 }
/** * @param MessageGroup $group * @param string $code * @param string $type * @param array $params * @param int $limit * @return string HTML */ protected function formatChange(MessageGroup $group, $code, $type, $params, &$limit) { $key = $params['key']; $title = Title::makeTitleSafe($group->getNamespace(), "{$key}/{$code}"); $id = self::changeId($group->getId(), $code, $type, $key); if ($title && $title->exists() && $type === 'addition') { // The message has for some reason dropped out from cache // or perhaps it is being reused. In any case treat it // as a change for display, so the admin can see if // action is needed and let the message be processed. // Otherwise it will end up in the postponed category // forever and will prevent rebuilding the cache, which // leads to many other annoying problems. $type = 'change'; } elseif ($title && !$title->exists() && ($type === 'deletion' || $type === 'change')) { return ''; } $text = ''; if ($type === 'deletion') { $wiki = ContentHandler::getContentText(Revision::newFromTitle($title)->getContent()); $oldContent = ContentHandler::makeContent($wiki, $title); $newContent = ContentHandler::makeContent('', $title); $this->diff->setContent($oldContent, $newContent); $text = $this->diff->getDiff(Linker::link($title), ''); } elseif ($type === 'addition') { $oldContent = ContentHandler::makeContent('', $title); $newContent = ContentHandler::makeContent($params['content'], $title); $this->diff->setContent($oldContent, $newContent); $text = $this->diff->getDiff('', Linker::link($title)); } elseif ($type === 'change') { $wiki = ContentHandler::getContentText(Revision::newFromTitle($title)->getContent()); $handle = new MessageHandle($title); if ($handle->isFuzzy()) { $wiki = '!!FUZZY!!' . str_replace(TRANSLATE_FUZZY, '', $wiki); } $label = $this->msg('translate-manage-action-ignore')->text(); $actions = Xml::checkLabel($label, "i/{$id}", "i/{$id}"); $limit--; if ($group->getSourceLanguage() === $code) { $label = $this->msg('translate-manage-action-fuzzy')->text(); $actions .= ' ' . Xml::checkLabel($label, "f/{$id}", "f/{$id}", true); $limit--; } $oldContent = ContentHandler::makeContent($wiki, $title); $newContent = ContentHandler::makeContent($params['content'], $title); $this->diff->setContent($oldContent, $newContent); $text .= $this->diff->getDiff(Linker::link($title), $actions); } $hidden = Html::hidden($id, 1); $limit--; $text .= $hidden; $classes = "mw-translate-smg-change smg-change-{$type}"; if ($limit < 0) { // Don't add if one of the fields might get dropped of at submission return ''; } return Html::rawElement('div', array('class' => $classes), $text); }
protected function getPageDiff() { $this->mustBeKnownMessage(); $title = $this->handle->getTitle(); $key = $this->handle->getKey(); if (!$title->exists()) { return null; } $definitionTitle = Title::makeTitleSafe($title->getNamespace(), "{$key}/en"); if (!$definitionTitle || !$definitionTitle->exists()) { return null; } $db = wfGetDB(DB_MASTER); $conds = array('rt_page' => $title->getArticleID(), 'rt_type' => RevTag::getType('tp:transver')); $options = array('ORDER BY' => 'rt_revision DESC'); $latestRevision = $definitionTitle->getLatestRevID(); $translationRevision = $db->selectField('revtag', 'rt_value', $conds, __METHOD__, $options); if ($translationRevision === false) { return null; } // Using newFromId instead of newFromTitle, because the page might have been renamed $oldrev = Revision::newFromId($translationRevision); if (!$oldrev) { // And someone might still have deleted it return null; } $oldtext = ContentHandler::getContentText($oldrev->getContent()); $newContent = Revision::newFromTitle($definitionTitle, $latestRevision)->getContent(); $newtext = ContentHandler::getContentText($newContent); if ($oldtext === $newtext) { return null; } $diff = new DifferenceEngine(); if (method_exists('DifferenceEngine', 'setTextLanguage')) { $diff->setTextLanguage($this->group->getSourceLanguage()); } $oldContent = ContentHandler::makeContent($oldtext, $diff->getTitle()); $newContent = ContentHandler::makeContent($newtext, $diff->getTitle()); $diff->setContent($oldContent, $newContent); $diff->setReducedLineNumbers(); $diff->showDiffStyle(); return $diff->getDiff(wfMessage('tpt-diff-old')->escaped(), wfMessage('tpt-diff-new')->escaped()); }
/** * Get text of an article from database * Does *NOT* follow redirects. * * @protected * @note this is really internal functionality that should really NOT be used by other functions. For accessing * article content, use the WikiPage class, especially WikiBase::getContent(). However, a lot of legacy code * uses this method to retrieve page text from the database, so the function has to remain public for now. * * @return mixed string containing article contents, or false if null * @deprecated in 1.21, use WikiPage::getContent() instead */ function fetchContent() { #BC cruft! ContentHandler::deprecated(__METHOD__, '1.21'); if ($this->mContentLoaded && $this->mContent) { return $this->mContent; } wfProfileIn(__METHOD__); $content = $this->fetchContentObject(); $this->mContent = ContentHandler::getContentText($content); #@todo: get rid of mContent everywhere! ContentHandler::runLegacyHooks('ArticleAfterFetchContent', array(&$this, &$this->mContent)); wfProfileOut(__METHOD__); return $this->mContent; }
/** * Performs an edit and checks the result. * * @param string|Title $title The title of the page to edit * @param string|null $baseText Some text to create the page with before attempting the edit. * @param User|string|null $user The user to perform the edit as. * @param array $edit An array of request parameters used to define the edit to perform. * Some well known fields are: * * wpTextbox1: the text to submit * * wpSummary: the edit summary * * wpEditToken: the edit token (will be inserted if not provided) * * wpEdittime: timestamp of the edit's base revision (will be inserted * if not provided) * * wpStarttime: timestamp when the edit started (will be inserted if not provided) * * wpSectionTitle: the section to edit * * wpMinorEdit: mark as minor edit * * wpWatchthis: whether to watch the page * @param int|null $expectedCode The expected result code (EditPage::AS_XXX constants). * Set to null to skip the check. * @param string|null $expectedText The text expected to be on the page after the edit. * Set to null to skip the check. * @param string|null $message An optional message to show along with any error message. * * @return WikiPage The page that was just edited, useful for getting the edit's rev_id, etc. */ protected function assertEdit($title, $baseText, $user = null, array $edit, $expectedCode = null, $expectedText = null, $message = null) { if (is_string($title)) { $ns = $this->getDefaultWikitextNS(); $title = Title::newFromText($title, $ns); } $this->assertNotNull($title); if (is_string($user)) { $user = User::newFromName($user); if ($user->getId() === 0) { $user->addToDatabase(); } } $page = WikiPage::factory($title); if ($baseText !== null) { $content = ContentHandler::makeContent($baseText, $title); $page->doEditContent($content, "base text for test"); $this->forceRevisionDate($page, '20120101000000'); // sanity check $page->clear(); $currentText = ContentHandler::getContentText($page->getContent()); # EditPage rtrim() the user input, so we alter our expected text # to reflect that. $this->assertEditedTextEquals($baseText, $currentText); } if ($user == null) { $user = $GLOBALS['wgUser']; } else { $this->setMwGlobals('wgUser', $user); } if (!isset($edit['wpEditToken'])) { $edit['wpEditToken'] = $user->getEditToken(); } if (!isset($edit['wpEdittime'])) { $edit['wpEdittime'] = $page->exists() ? $page->getTimestamp() : ''; } if (!isset($edit['wpStarttime'])) { $edit['wpStarttime'] = wfTimestampNow(); } $req = new FauxRequest($edit, true); // session ?? $article = new Article($title); $article->getContext()->setTitle($title); $ep = new EditPage($article); $ep->setContextTitle($title); $ep->importFormData($req); $bot = isset($edit['bot']) ? (bool) $edit['bot'] : false; // this is where the edit happens! // Note: don't want to use EditPage::AttemptSave, because it messes with $wgOut // and throws exceptions like PermissionsError $status = $ep->internalAttemptSave($result, $bot); if ($expectedCode !== null) { // check edit code $this->assertEquals($expectedCode, $status->value, "Expected result code mismatch. {$message}"); } $page = WikiPage::factory($title); if ($expectedText !== null) { // check resulting page text $content = $page->getContent(); $text = ContentHandler::getContentText($content); # EditPage rtrim() the user input, so we alter our expected text # to reflect that. $this->assertEditedTextEquals($expectedText, $text, "Expected article text mismatch. {$message}"); } return $page; }
/** * Retrieve the text of a WikiPage * @param Title $title The title object of the WikiPage * @return string The text of the page */ protected function getWikiPageText(Title $title) { $text = ''; $wikiPage = WikiPage::newFromID($title->getArticleID()); if ($wikiPage) { $content = $wikiPage->getContent(); if ($content) { $text = ContentHandler::getContentText($content); } } return $text; }
/** * Prepare content which is about to be saved. * Returns a stdClass with source, pst and output members * * @param Content $content * @param Revision|int|null $revision Revision object. For backwards compatibility, a * revision ID is also accepted, but this is deprecated. * @param User|null $user * @param string|null $serialFormat * @param bool $useCache Check shared prepared edit cache * * @return object * * @since 1.21 */ public function prepareContentForEdit(Content $content, $revision = null, User $user = null, $serialFormat = null, $useCache = true) { global $wgContLang, $wgUser, $wgAjaxEditStash; if (is_object($revision)) { $revid = $revision->getId(); } else { $revid = $revision; // This code path is deprecated, and nothing is known to // use it, so performance here shouldn't be a worry. if ($revid !== null) { $revision = Revision::newFromId($revid, Revision::READ_LATEST); } else { $revision = null; } } $user = is_null($user) ? $wgUser : $user; // XXX: check $user->getId() here??? // Use a sane default for $serialFormat, see bug 57026 if ($serialFormat === null) { $serialFormat = $content->getContentHandler()->getDefaultFormat(); } if ($this->mPreparedEdit && isset($this->mPreparedEdit->newContent) && $this->mPreparedEdit->newContent->equals($content) && $this->mPreparedEdit->revid == $revid && $this->mPreparedEdit->format == $serialFormat) { // Already prepared return $this->mPreparedEdit; } // The edit may have already been prepared via api.php?action=stashedit $cachedEdit = $useCache && $wgAjaxEditStash ? ApiStashEdit::checkCache($this->getTitle(), $content, $user) : false; $popts = ParserOptions::newFromUserAndLang($user, $wgContLang); Hooks::run('ArticlePrepareTextForEdit', [$this, $popts]); $edit = (object) []; if ($cachedEdit) { $edit->timestamp = $cachedEdit->timestamp; } else { $edit->timestamp = wfTimestampNow(); } // @note: $cachedEdit is safely not used if the rev ID was referenced in the text $edit->revid = $revid; if ($cachedEdit) { $edit->pstContent = $cachedEdit->pstContent; } else { $edit->pstContent = $content ? $content->preSaveTransform($this->mTitle, $user, $popts) : null; } $edit->format = $serialFormat; $edit->popts = $this->makeParserOptions('canonical'); if ($cachedEdit) { $edit->output = $cachedEdit->output; } else { if ($revision) { // We get here if vary-revision is set. This means that this page references // itself (such as via self-transclusion). In this case, we need to make sure // that any such self-references refer to the newly-saved revision, and not // to the previous one, which could otherwise happen due to replica DB lag. $oldCallback = $edit->popts->getCurrentRevisionCallback(); $edit->popts->setCurrentRevisionCallback(function (Title $title, $parser = false) use($revision, &$oldCallback) { if ($title->equals($revision->getTitle())) { return $revision; } else { return call_user_func($oldCallback, $title, $parser); } }); } else { // Try to avoid a second parse if {{REVISIONID}} is used $edit->popts->setSpeculativeRevIdCallback(function () { return 1 + (int) wfGetDB(DB_MASTER)->selectField('revision', 'MAX(rev_id)', [], __METHOD__); }); } $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput($this->mTitle, $revid, $edit->popts) : null; } $edit->newContent = $content; $edit->oldContent = $this->getContent(Revision::RAW); // NOTE: B/C for hooks! don't use these fields! $edit->newText = $edit->newContent ? ContentHandler::getContentText($edit->newContent) : ''; $edit->oldText = $edit->oldContent ? ContentHandler::getContentText($edit->oldContent) : ''; $edit->pst = $edit->pstContent ? $edit->pstContent->serialize($serialFormat) : ''; if ($edit->output) { $edit->output->setCacheTime(wfTimestampNow()); } // Process cache the result $this->mPreparedEdit = $edit; return $edit; }
/** * Hook into Content::getParserOutput to provide syntax highlighting for * script content. * * @return bool * @since MW 1.21 */ public static function renderHook(Content $content, Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output) { global $wgSyntaxHighlightModels, $wgUseSiteCss, $wgParser, $wgTextModelsToParse; // Determine the language $model = $content->getModel(); if (!isset($wgSyntaxHighlightModels[$model])) { // We don't care about this model, carry on. return true; } if (!$generateHtml) { // Nothing special for us to do, let MediaWiki handle this. return true; } // Hope that $wgSyntaxHighlightModels does not contain silly types. $text = ContentHandler::getContentText($content); if ($text === null || $text === false) { // Oops! Non-text content? Let MediaWiki handle this. return true; } // Parse using the standard parser to get links etc. into the database, HTML is replaced below. // We could do this using $content->fillParserOutput(), but alas it is 'protected'. if ($content instanceof TextContent && in_array($model, $wgTextModelsToParse)) { $output = $wgParser->parse($text, $title, $options, true, true, $revId); } $lang = $wgSyntaxHighlightModels[$model]; // Attempt to format $geshi = self::prepare($text, $lang); if ($geshi instanceof GeSHi) { $out = $geshi->parse_code(); if (!$geshi->error()) { // Done $output->addModuleStyles("ext.geshi.language.{$lang}"); $output->setText("<div dir=\"ltr\">{$out}</div>"); if ($wgUseSiteCss) { $output->addModuleStyles('ext.geshi.local'); } // Inform MediaWiki that we have parsed this page and it shouldn't mess with it. return false; } } // Bottle out return true; }
/** * Prepare content which is about to be saved. * Returns a stdclass with source, pst and output members * * @param Content $content * @param int|null $revid * @param User|null $user * @param string|null $serialization_format * * @return bool|object * * @since 1.21 */ public function prepareContentForEdit( Content $content, $revid = null, User $user = null, $serialization_format = null ) { global $wgContLang, $wgUser; $user = is_null( $user ) ? $wgUser : $user; //XXX: check $user->getId() here??? if ( $this->mPreparedEdit && $this->mPreparedEdit->newContent && $this->mPreparedEdit->newContent->equals( $content ) && $this->mPreparedEdit->revid == $revid && $this->mPreparedEdit->format == $serialization_format // XXX: also check $user here? ) { // Already prepared return $this->mPreparedEdit; } $popts = ParserOptions::newFromUserAndLang( $user, $wgContLang ); wfRunHooks( 'ArticlePrepareTextForEdit', array( $this, $popts ) ); $edit = (object)array(); $edit->revid = $revid; $edit->pstContent = $content ? $content->preSaveTransform( $this->mTitle, $user, $popts ) : null; $edit->format = $serialization_format; $edit->popts = $this->makeParserOptions( 'canonical' ); $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) : null; $edit->newContent = $content; $edit->oldContent = $this->getContent( Revision::RAW ); // NOTE: B/C for hooks! don't use these fields! $edit->newText = $edit->newContent ? ContentHandler::getContentText( $edit->newContent ) : ''; $edit->oldText = $edit->oldContent ? ContentHandler::getContentText( $edit->oldContent ) : ''; $edit->pst = $edit->pstContent ? $edit->pstContent->serialize( $serialization_format ) : ''; $this->mPreparedEdit = $edit; return $edit; }
public function testGetContentText_NonTextContent() { global $wgContentHandlerTextFallback; $content = new DummyContentForTesting("hello world"); $wgContentHandlerTextFallback = 'fail'; try { $text = ContentHandler::getContentText($content); $this->fail("ContentHandler::getContentText should have thrown an exception for non-text Content object"); } catch (MWException $ex) { // as expected } $wgContentHandlerTextFallback = 'serialize'; $text = ContentHandler::getContentText($content); $this->assertEquals($content->serialize(), $text); $wgContentHandlerTextFallback = 'ignore'; $text = ContentHandler::getContentText($content); $this->assertNull($text); }