/** * This is the method previously used to load block info in CheckUser etc * passing an empty value (empty string, null, etc) as the ip parameter bypasses IP lookup checks. * * This stopped working with r84475 and friends: regression being fixed for bug 29116. * * @dataProvider dataBug29116 */ function testBug29116LoadWithEmptyIp($vagueTarget) { $uid = User::idFromName('UTBlockee'); $this->assertTrue($uid > 0, 'Must be able to look up the target user during tests'); $block = new Block(); $ok = $block->load($vagueTarget, $uid); $this->assertTrue($ok, "Block->load() with empty IP and user ID '{$uid}' should return a block"); $this->assertTrue($this->block->equals($block), "Block->load() returns the same block as the one that was made when given empty ip param " . var_export($vagueTarget, true)); }
static function newFromDB($address, $user = 0, $killExpired = true) { $block = new Block(); $block->load($address, $user, $killExpired); if ($block->isValid()) { return $block; } else { return null; } }
/** * Get blocking information * @private * @param bool $bFromSlave Specify whether to check slave or master. To improve performance, * non-critical checks are done against slaves. Check when actually saving should be done against * master. */ function getBlockedStatus($bFromSlave = true) { global $wgEnableSorbs, $wgProxyWhitelist; if (-1 != $this->mBlockedby) { wfDebug("User::getBlockedStatus: already loaded.\n"); return; } $fname = 'User::getBlockedStatus'; wfProfileIn($fname); wfDebug("{$fname}: checking...\n"); $this->mBlockedby = 0; $ip = wfGetIP(); # User/IP blocking $block = new Block(); $block->fromMaster(!$bFromSlave); if ($block->load($ip, $this->mId)) { wfDebug("{$fname}: Found block.\n"); $this->mBlockedby = $block->mBy; $this->mBlockreason = $block->mReason; if ($this->isLoggedIn()) { $this->spreadBlock(); } } else { wfDebug("{$fname}: No block.\n"); } # Proxy blocking # FIXME ? proxyunbannable is to deprecate the old isSysop() if (!$this->isAllowed('proxyunbannable') && !in_array($ip, $wgProxyWhitelist)) { # Local list if (wfIsLocallyBlockedProxy($ip)) { $this->mBlockedby = wfMsg('proxyblocker'); $this->mBlockreason = wfMsg('proxyblockreason'); } # DNSBL if (!$this->mBlockedby && $wgEnableSorbs && !$this->getID()) { if ($this->inSorbsBlacklist($ip)) { $this->mBlockedby = wfMsg('sorbs'); $this->mBlockreason = wfMsg('sorbsreason'); } } } # Extensions wfRunHooks('GetBlockedStatus', array(&$this)); wfProfileOut($fname); }
/** * Get blocking information * @access private * @param bool $bFromSlave Specify whether to check slave or master. To improve performance, * non-critical checks are done against slaves. Check when actually saving should be done against * master. * * Note that even if $bFromSlave is false, the check is done first against slave, then master. * The logic is that if blocked on slave, we'll assume it's either blocked on master or * just slightly outta sync and soon corrected - safer to block slightly more that less. * And it's cheaper to check slave first, then master if needed, than master always. */ function getBlockedStatus($bFromSlave = true) { global $wgIP, $wgBlockCache, $wgProxyList, $wgEnableSorbs, $wgProxyWhitelist; if (-1 != $this->mBlockedby) { return; } $this->mBlockedby = 0; # User blocking if ($this->mId) { $block = new Block(); $block->forUpdate($bFromSlave); if ($block->load($wgIP, $this->mId)) { $this->mBlockedby = $block->mBy; $this->mBlockreason = $block->mReason; $this->spreadBlock(); } } # IP/range blocking if (!$this->mBlockedby) { # Check first against slave, and optionally from master. $block = $wgBlockCache->get($wgIP, true); if (!$block && !$bFromSlave) { # Not blocked: check against master, to make sure. $wgBlockCache->clearLocal(); $block = $wgBlockCache->get($wgIP, false); } if ($block !== false) { $this->mBlockedby = $block->mBy; $this->mBlockreason = $block->mReason; } } # Proxy blocking if (!$this->isSysop() && !in_array($wgIP, $wgProxyWhitelist)) { # Local list if (array_key_exists($wgIP, $wgProxyList)) { $this->mBlockedby = wfMsg('proxyblocker'); $this->mBlockreason = wfMsg('proxyblockreason'); } # DNSBL if (!$this->mBlockedby && $wgEnableSorbs && !$this->getID()) { if ($this->inSorbsBlacklist($wgIP)) { $this->mBlockedby = wfMsg('sorbs'); $this->mBlockreason = wfMsg('sorbsreason'); } } } }
/** * Get the robot policy to be used for the current view * @param $action String the action= GET parameter * @return Array the policy that should be set * TODO: actions other than 'view' */ public function getRobotPolicy($action) { global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies; global $wgDefaultRobotPolicy, $wgRequest; $ns = $this->mTitle->getNamespace(); if ($ns == NS_USER || $ns == NS_USER_TALK) { # Don't index user and user talk pages for blocked users (bug 11443) if (!$this->mTitle->isSubpage()) { $block = new Block(); if ($block->load($this->mTitle->getText())) { return array('index' => 'noindex', 'follow' => 'nofollow'); } } } if ($this->getID() === 0 || $this->getOldID()) { # Non-articles (special pages etc), and old revisions return array('index' => 'noindex', 'follow' => 'nofollow'); } elseif ($wgOut->isPrintable()) { # Discourage indexing of printable versions, but encourage following return array('index' => 'noindex', 'follow' => 'follow'); } elseif ($wgRequest->getInt('curid')) { # For ?curid=x urls, disallow indexing return array('index' => 'noindex', 'follow' => 'follow'); } # Otherwise, construct the policy based on the various config variables. $policy = self::formatRobotPolicy($wgDefaultRobotPolicy); if (isset($wgNamespaceRobotPolicies[$ns])) { # Honour customised robot policies for this namespace $policy = array_merge($policy, self::formatRobotPolicy($wgNamespaceRobotPolicies[$ns])); } if ($this->mTitle->canUseNoindex() && is_object($this->mParserOutput) && $this->mParserOutput->getIndexPolicy()) { # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates # a final sanity check that we have really got the parser output. $policy = array_merge($policy, array('index' => $this->mParserOutput->getIndexPolicy())); } if (isset($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])) { # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__ $policy = array_merge($policy, self::formatRobotPolicy($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])); } return $policy; }
function add_block($parent, $type) { $page_path = $_POST['page_path']; PC::page_paths($page_path); $this->BuilderEngine->set_page_path($page_path); //$this->blocks->set_page_path($this->blocks->get_page_path_of($parent)); $max_id = $this->blocks->get_max_block_id(); $new_id = $max_id + 1; $new_block_name = "custom-block-" . $new_id; $block = new Block($parent); $block->load(); $new_block = new Block($new_block_name); $new_block->set_type($type); if (isset($_POST['data_class']) && $_POST['data_class'] != "") { $new_block->add_css_class($_POST['data_class']); } if ($block->is_global()) { $new_block->set_global(true); } $block->add_block_first($new_block); $block->save(); $new_block->set_content("Your new block."); $new_block->show(); }
function _integrate_builderengine_styles() { ?> <script src="<?php echo home_url("/builderengine/public/js/jquery.js"); ?> "></script> <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" /> <link href="http://vitalets.github.io/angular-xeditable/dist/css/xeditable.css" rel="stylesheet" /> <link rel='stylesheet' id='font-awesome-4-css' href="<?php echo base_url('/builderengine/public/css/font-awesome.css?ver=4.0.3'); ?> " type='text/css' media='all' /> <?php if (is_installed()) { ?> <?php $block = new Block('be_body_styler_' . $this->BuilderEngine->get_option('active_frontend_theme')); $block->set_global(true); if (!$block->load()) { $block->save(); } ?> <style> body { <?php echo $block->build_style(true); ?> } <?php } ?> #virtual-block-holder{ position: absolute; z-index:999; } .area { position: relative; display: inline-block; min-width: 50px; min-height: 25px; } #admin-window { z-index: 999999 !important; } .block-children { /*min-height: 20px;*/ position:relative; /*display: inline-block;*/ /*float: left;*/ } .block { position: relative; /*float: left;*/ /*display: inline-block;*/ } .placeholder { border: 1px dotted #888; -webkit-box-shadow: 0px 0px 10px #888; -moz-box-shadow: 0px 0px 10px #888; box-shadow: 0px 0px 10px #888; } .ui-sortable-placeholder { border: 2px dotted #333; -webkit-box-shadow: 0px 0px 10px #888; -moz-box-shadow: 0px 0px 10px #888; box-shadow: 0px 0px 10px #888; visibility: visible !important; } </style> <?php }
public function initialize($db_result) { //print_r($db_result); //echo debug_print_backtrace(); $this->id = $db_result->id; $this->data = json_decode($db_result->data, true); $this->global = $db_result->global == 'yes'; $this->type = $db_result->type; $this->html = $this->data('html'); $this->blocks = array(); foreach ($db_result->children as $child_name) { $child = new Block($child_name); $child->load(); $this->add_block($child); } }
function newFromDB($address, $user = 0, $killExpired = true) { $ban = new Block(); $ban->load($address, $user, $killExpired); return $ban; }
/** * @param string $ip * @param bool $xfor * @param string $reason * Get all IPs used by a user * Shows first and last date and number of edits */ function doUserIPsRequest($user, $reason = '') { global $wgOut, $wgTitle, $wgLang, $wgUser, $wgDBname; $fname = 'CheckUser::doUserIPsRequest'; $userTitle = Title::newFromText($user, NS_USER); if (!is_null($userTitle)) { // normalize the username $user = $userTitle->getText(); } #IPs are passed in as a blank string if (!$user) { $s = wfMsgHtml('nouserspecified'); $wgOut->addHTML($s); return; } #get ID, works better than text as user may have been renamed $user_id = User::idFromName($user); #if user is not IP or nonexistant if (!$user_id) { $s = wfMsgExt('nosuchusershort', array('parseinline'), $user); $wgOut->addHTML($s); return; } if (!$this->addLogEntry('userips', 'user', $user, $reason, $user_id)) { $wgOut->addHTML('<p>' . wfMsgHtml('checkuser-log-fail') . '</p>'); } $dbr = wfGetDB(DB_SLAVE); # Ordering by the latest timestamp makes a small filesort on the IP list $cu_changes = $dbr->tableName('cu_changes'); $use_index = $dbr->useIndexClause('cuc_user_ip_time'); $sql = "SELECT cuc_ip,cuc_ip_hex, COUNT(*) AS count, \n\t\t\tMIN(cuc_timestamp) AS first, MAX(cuc_timestamp) AS last \n\t\t\tFROM {$cu_changes} {$use_index} WHERE cuc_user = {$user_id} \n\t\t\tGROUP BY cuc_ip ORDER BY last DESC"; $ret = $dbr->query($sql, __METHOD__); if (!$dbr->numRows($ret)) { $s = wfMsgHtml("checkuser-nomatch") . "\n"; } else { $blockip = SpecialPage::getTitleFor('blockip'); $ips_edits = array(); while ($row = $dbr->fetchObject($ret)) { $ips_edits[$row->cuc_ip] = $row->count; $ips_first[$row->cuc_ip] = $row->first; $ips_last[$row->cuc_ip] = $row->last; $ips_hex[$row->cuc_ip] = $row->cuc_ip_hex; } $logs = SpecialPage::getTitleFor('Log'); $blocklist = SpecialPage::getTitleFor('Ipblocklist'); $s = '<ul>'; foreach ($ips_edits as $ip => $edits) { $s .= '<li>'; $s .= '<a href="' . $wgTitle->escapeLocalURL('user='******'&reason=' . urlencode($reason)) . '">' . htmlspecialchars($ip) . '</a>'; $s .= ' (<a href="' . $blockip->escapeLocalURL('ip=' . urlencode($ip)) . '">' . wfMsgHtml('blocklink') . '</a>)'; if ($ips_first[$ip] == $ips_last[$ip]) { $s .= ' (' . $wgLang->timeanddate($ips_first[$ip], true) . ') '; } else { $s .= ' (' . $wgLang->timeanddate($ips_first[$ip], true) . ' -- ' . $wgLang->timeanddate($ips_last[$ip], true) . ') '; } $s .= ' <strong>[' . $edits . ']</strong>'; # If we get some results, it helps to know if the IP in general # has a lot more edits, e.g. "tip of the iceberg"... global $wgMiserMode; if ($wgMiserMode) { $ipedits = $dbr->estimateRowCount('cu_changes', '*', array('cuc_ip_hex' => $ips_hex[$ip]), __METHOD__); } else { $ipedits = $dbr->selectField('cu_changes', 'COUNT(*)', array('cuc_ip_hex' => $ips_hex[$ip]), __METHOD__); } # Kludge a little for estimates... if (!$wgMiserMode || $ipedits > 1.5 * $ips_edits[$ip]) { $s .= ' <i>(' . wfMsgHtml('checkuser-ipeditcount', $ipedits) . ')</i>'; } # If this IP is blocked, give a link to the block log $block = new Block(); $block->fromMaster(false); // use slaves if ($block->load($ip, 0)) { if (IP::isIPAddress($block->mAddress) && strpos($block->mAddress, '/')) { $userpage = Title::makeTitle(NS_USER, $block->mAddress); $blocklog = $this->sk->makeKnownLinkObj($logs, wfMsgHtml('checkuser-blocked'), 'type=block&page=' . urlencode($userpage->getPrefixedText())); $s .= ' <strong>(' . $blocklog . ' - ' . $block->mAddress . ')</strong>'; } else { if ($block->mAuto) { $blocklog = $this->sk->makeKnownLinkObj($blocklist, wfMsgHtml('checkuser-blocked'), 'ip=' . urlencode("#{$block->mId}")); $s .= ' <strong>(' . $blocklog . ')</strong>'; } else { $userpage = Title::makeTitle(NS_USER, $ip); $blocklog = $this->sk->makeKnownLinkObj($logs, wfMsgHtml('checkuser-blocked'), 'type=block&page=' . urlencode($userpage->getPrefixedText())); $s .= ' <strong>(' . $blocklog . ')</strong>'; } } } $s .= "</li>\n"; } $s .= '</ul>'; } $wgOut->addHTML($s); $dbr->freeResult($ret); }
/** * Find out if a given IP address is blocked * * @param String $ip IP address * @param bool $bFromSlave True means to load check against slave, else check against master. */ function get($ip, $bFromSlave) { $this->load($bFromSlave); $ipint = ip2long($ip); $blocked = false; foreach ($this->mData as $networkBits => $blockInts) { if (array_key_exists($ipint >> 32 - $networkBits, $blockInts)) { $blocked = true; break; } } if ($blocked) { # Clear low order bits if ($networkBits != 32) { $ip .= '/' . $networkBits; $ip = Block::normaliseRange($ip); } $block = new Block(); $block->forUpdate($bFromSlave); $block->load($ip); } else { $block = false; } return $block; }
public function loadBlocks() { // Load the grid $this->grid = new Grid($this); $this->setPredefinedTags($this->grid); if (!is_array($this->instanceBlocks)) { $this->instanceBlocks = array(); } // Merge the blocks lists $blocks = array_merge($this->blocks, $this->userBlocks, $this->instanceBlocks); // Load the parsed blocks foreach ($blocks as $blockDef) { $block = Block::load($this->context, $this, $this->grid, $blockDef['module'], $blockDef['name'], $blockDef['counter'], $blockDef['row'], $blockDef['column'], $blockDef['position'], $blockDef['params']); if (!is_null($block)) { $this->setPredefinedTags($block); $block->set('block_module', $blockDef['module']); $block->set('block_name', $blockDef['name']); $block->set('block_row', $blockDef['row']); $block->set('block_column', $blockDef['column']); $block->set('block_position', $blockDef['position']); $block->set('block_counter', $blockDef['counter']); $this->grid->addBlock($block, $blockDef['row'], $blockDef['column'], $blockDef['position']); } } // Blocks must be properly sorted for the grid loop $this->grid->sortBlocks(); }
function add_block($parent, $type) { $page_path = $_POST['page_path']; PC::page_paths($page_path); $this->BuilderEngine->set_page_path($page_path); //$this->blocks->set_page_path($this->blocks->get_page_path_of($parent)); $max_id = $this->blocks->get_max_block_id(); $new_id = $max_id + 1; $new_block_name = "custom-block-" . $new_id; $block = new Block($parent); $block->load(); $new_block = new Block($new_block_name); $new_block->set_type($type); $block->add_block($new_block); $block->save(); $new_block->set_content("Your new block."); $new_block->show(); }
/** * This is the default action of the script: just view the page of * the given title. */ public function view() { global $wgUser, $wgOut, $wgRequest, $wgContLang; global $wgEnableParserCache, $wgStylePath, $wgParser; global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies; global $wgDefaultRobotPolicy; # Let the parser know if this is the printable version if ($wgOut->isPrintable()) { $wgOut->parserOptions()->setIsPrintable(true); } wfProfileIn(__METHOD__); # Get variables from query string $oldid = $this->getOldID(); # Try client and file cache if ($oldid === 0 && $this->checkTouched()) { global $wgUseETag; if ($wgUseETag) { $parserCache = ParserCache::singleton(); $wgOut->setETag($parserCache->getETag($this, $wgOut->parserOptions())); } # Is is client cached? if ($wgOut->checkLastModified($this->getTouched())) { wfProfileOut(__METHOD__); return; # Try file cache } else { if ($this->tryFileCache()) { # tell wgOut that output is taken care of $wgOut->disable(); $this->viewUpdates(); wfProfileOut(__METHOD__); return; } } } $ns = $this->mTitle->getNamespace(); # shortcut $sk = $wgUser->getSkin(); # getOldID may want us to redirect somewhere else if ($this->mRedirectUrl) { $wgOut->redirect($this->mRedirectUrl); wfProfileOut(__METHOD__); return; } $diff = $wgRequest->getVal('diff'); $rcid = $wgRequest->getVal('rcid'); $rdfrom = $wgRequest->getVal('rdfrom'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly')); $purge = $wgRequest->getVal('action') == 'purge'; $return404 = false; $wgOut->setArticleFlag(true); # Discourage indexing of printable versions, but encourage following if ($wgOut->isPrintable()) { $policy = 'noindex,follow'; } elseif (isset($wgArticleRobotPolicies[$this->mTitle->getPrefixedText()])) { $policy = $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()]; } elseif (isset($wgNamespaceRobotPolicies[$ns])) { # Honour customised robot policies for this namespace $policy = $wgNamespaceRobotPolicies[$ns]; } else { $policy = $wgDefaultRobotPolicy; } $wgOut->setRobotPolicy($policy); # Allow admins to see deleted content if explicitly requested $delId = $diff ? $diff : $oldid; $unhide = $wgRequest->getInt('unhide') == 1 && $wgUser->matchEditToken($wgRequest->getVal('token'), $delId); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. if (!is_null($diff)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $htmldiff = $wgRequest->getVal('htmldiff', false); $de = new DifferenceEngine($this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff, $unhide); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage($diffOnly); // Needed to get the page's current revision $this->loadPageData(); if ($diff == 0 || $diff == $this->mLatest) { # Run view updates for current revision only $this->viewUpdates(); } wfProfileOut(__METHOD__); return; } if ($ns == NS_USER || $ns == NS_USER_TALK) { # User/User_talk subpages are not modified. (bug 11443) if (!$this->mTitle->isSubpage()) { $block = new Block(); if ($block->load($this->mTitle->getBaseText())) { $wgOut->setRobotpolicy('noindex,nofollow'); } } } # Should the parser cache be used? $pcache = $this->useParserCache($oldid); wfDebug('Article::view using parser cache: ' . ($pcache ? 'yes' : 'no') . "\n"); if ($wgUser->getOption('stubthreshold')) { wfIncrStats('pcache_miss_stub'); } $wasRedirected = false; if (isset($this->mRedirectedFrom)) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. if (wfRunHooks('ArticleViewRedirect', array(&$this))) { $redir = $sk->makeKnownLinkObj($this->mRedirectedFrom, '', 'redirect=no'); $s = wfMsgExt('redirectedfrom', array('parseinline', 'replaceafter'), $redir); $wgOut->setSubtitle($s); // Set the fragment if one was specified in the redirect if (strval($this->mTitle->getFragment()) != '') { $fragment = Xml::escapeJsString($this->mTitle->getFragmentForURL()); $wgOut->addInlineScript("redirectToFragment(\"{$fragment}\");"); } // Add a <link rel="canonical"> tag $wgOut->addLink(array('rel' => 'canonical', 'href' => $this->mTitle->getLocalURL())); $wasRedirected = true; } } elseif (!empty($rdfrom)) { // This is an externally redirected view, from some other wiki. // If it was reported from a trusted site, supply a backlink. global $wgRedirectSources; if ($wgRedirectSources && preg_match($wgRedirectSources, $rdfrom)) { $redir = $sk->makeExternalLink($rdfrom, $rdfrom); $s = wfMsgExt('redirectedfrom', array('parseinline', 'replaceafter'), $redir); $wgOut->setSubtitle($s); $wasRedirected = true; } } $outputDone = false; wfRunHooks('ArticleViewHeader', array(&$this, &$outputDone, &$pcache)); if ($pcache && $wgOut->tryParserCache($this)) { // Ensure that UI elements requiring revision ID have // the correct version information. $wgOut->setRevisionId($this->mLatest); $outputDone = true; } # Fetch content and check for errors if (!$outputDone) { # If the article does not exist and was deleted, show the log if ($this->getID() == 0) { $this->showDeletionLog(); } $text = $this->getContent(); // For now, check also for ID until getContent actually returns // false for pages that do not exists if ($text === false || $this->getID() === 0) { # Failed to load, replace text with error message $t = $this->mTitle->getPrefixedText(); if ($oldid) { $d = wfMsgExt('missingarticle-rev', 'escape', $oldid); $text = wfMsgExt('missing-article', 'parsemag', $t, $d); // Always use page content for pages in the MediaWiki namespace // since it contains the default message } elseif ($this->mTitle->getNamespace() != NS_MEDIAWIKI) { $text = wfMsgExt('noarticletext', 'parsemag'); } } # Non-existent pages if ($this->getID() === 0) { $wgOut->setRobotPolicy('noindex,nofollow'); $text = "<div class='noarticletext'>\n{$text}\n</div>"; if (!$this->hasViewableContent()) { // If there's no backing content, send a 404 Not Found // for better machine handling of broken links. $return404 = true; } } if ($return404) { $wgRequest->response()->header("HTTP/1.x 404 Not Found"); } # Another whitelist check in case oldid is altering the title if (!$this->mTitle->userCanRead()) { $wgOut->loginToUse(); $wgOut->output(); $wgOut->disable(); wfProfileOut(__METHOD__); return; } # For ?curid=x urls, disallow indexing if ($wgRequest->getInt('curid')) { $wgOut->setRobotPolicy('noindex,follow'); } # We're looking at an old revision if (!empty($oldid)) { $wgOut->setRobotPolicy('noindex,nofollow'); if (is_null($this->mRevision)) { // FIXME: This would be a nice place to load the 'no such page' text. } else { $this->setOldSubtitle(isset($this->mOldId) ? $this->mOldId : $oldid); # Allow admins to see deleted content if explicitly requested if ($this->mRevision->isDeleted(Revision::DELETED_TEXT)) { if (!$unhide || !$this->mRevision->userCan(Revision::DELETED_TEXT)) { $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission'); $wgOut->setPageTitle($this->mTitle->getPrefixedText()); wfProfileOut(__METHOD__); return; } else { $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view'); // and we are allowed to see... } } // Is this the current revision and otherwise cacheable? Try the parser cache... if ($oldid === $this->getLatest() && $this->useParserCache(false) && $wgOut->tryParserCache($this)) { $outputDone = true; } } } // Ensure that UI elements requiring revision ID have // the correct version information. $wgOut->setRevisionId($this->getRevIdFetched()); if ($outputDone) { // do nothing... // Pages containing custom CSS or JavaScript get special treatment } else { if ($this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage()) { $wgOut->addHTML(wfMsgExt('clearyourcache', 'parse')); // Give hooks a chance to customise the output if (wfRunHooks('ShowRawCssJs', array($this->mContent, $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->mContent)); $wgOut->addHTML("\n</pre>\n"); } } else { if ($rt = Title::newFromRedirectArray($text)) { # get an array of redirect targets # Don't append the subtitle if this was an old revision $wgOut->addHTML($this->viewRedirect($rt, !$wasRedirected && $this->isCurrent())); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText($parseout); } else { if ($pcache) { # Display content and save to parser cache $this->outputWikiText($text); } else { # Display content, don't attempt to save to parser cache # Don't show section-edit links on old revisions... this way lies madness. if (!$this->isCurrent()) { $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection(false); } # Display content and don't save to parser cache # With timing hack -- TS 2006-07-26 $time = -wfTime(); $this->outputWikiText($text, false); $time += wfTime(); # Timing hack if ($time > 3) { wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->mTitle->getPrefixedDBkey())); } if (!$this->isCurrent()) { $wgOut->parserOptions()->setEditSection($oldEditSectionSetting); } } } } } } /* title may have been set from the cache */ $t = $wgOut->getPageTitle(); if (empty($t)) { $wgOut->setPageTitle($this->mTitle->getPrefixedText()); # For the main page, overwrite the <title> element with the con- # tents of 'pagetitle-view-mainpage' instead of the default (if # that's not empty). if ($this->mTitle->equals(Title::newMainPage()) && wfMsgForContent('pagetitle-view-mainpage') !== '') { $wgOut->setHTMLTitle(wfMsgForContent('pagetitle-view-mainpage')); } } # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if ($ns == NS_USER_TALK && IP::isValid($this->mTitle->getText())) { $wgOut->addWikiMsg('anontalkpagetext'); } # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if (!empty($rcid) && $this->mTitle->exists() && $this->mTitle->quickUserCan('patrol')) { $wgOut->addHTML("<div class='patrollink'>" . wfMsgHtml('markaspatrolledlink', $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('markaspatrolledtext'), "action=markpatrolled&rcid={$rcid}")) . '</div>'); } # Trackbacks if ($wgUseTrackbacks) { $this->addTrackbacks(); } $this->viewUpdates(); wfProfileOut(__METHOD__); }