public static function getIconType($item) { wfProfileIn(__METHOD__); $type = false; if (MWNamespace::isTalk($item['namespace'])) { wfProfileOut(__METHOD__); return self::FEED_TALK_ICON; } if (defined('NS_BLOG_ARTICLE_TALK') && $item['namespace'] == NS_BLOG_ARTICLE_TALK) { wfProfileOut(__METHOD__); return self::FEED_COMMENT_ICON; } //video namespace if ($item['namespace'] == 400) { wfProfileOut(__METHOD__); return self::FEED_FILM_ICON; } switch ($item['type']) { case 'upload': $type = self::FEED_PHOTO_ICON; break; default: $type = $item['new'] == '1' ? self::FEED_SUN_ICON : self::FEED_PENCIL_ICON; } wfProfileOut(__METHOD__); return $type; }
public function get($limit = 10, User $user = null) { wfProfileIn(__METHOD__); global $wgUser; if (!$user instanceof User) { $user = $wgUser; } $result = array(); $params = array(); $params['action'] = 'query'; $params['list'] = 'usercontribs'; $params['ucuser'] = $user->getName(); $params['ucprop'] = 'ids|title|timestamp|flags|comment|wikiamode'; $params['uclimit'] = $limit; $api = new ApiMain(new FauxRequest($params)); $api->execute(); $res =& $api->GetResultData(); $i = -1; foreach ($res['query']['usercontribs'] as &$entry) { $titleObj = Title::newFromText($entry['title']); $result[++$i] = array('url' => $titleObj->getLocalURL(), 'title' => $titleObj->getText(), 'timestamp' => $entry['timestamp'], 'namespace' => $entry['ns'], 'type' => 'edit', 'new' => $entry['rev_parent_id'] == 0 ? '1' : '0', 'diff' => empty($entry['rev_parent_id']) ? '' : $titleObj->getLocalURL('diff=' . $entry['revid'] . '&oldid=' . $entry['rev_parent_id'])); if (MWNamespace::isTalk($entry['ns']) || in_array($entry['ns'], array(400, NS_USER, NS_TEMPLATE, NS_MEDIAWIKI))) { $title = $titleObj->getPrefixedText(); if (defined('ARTICLECOMMENT_PREFIX') && strpos($title, '/') !== false && strpos(end(explode('/', $title)), ARTICLECOMMENT_PREFIX) === 0) { $result[$i]['title'] = end(explode(':', reset(explode('/', $title, 2)), 2)); } else { $result[$i]['title'] = $title; } } if (defined('NS_BLOG_ARTICLE_TALK') && $entry['ns'] == NS_BLOG_ARTICLE_TALK) { $result[$i]['title'] = wfMsg('myhome-namespace-blog') . ':' . $result[$i]['title']; } if ($entry['ns'] == NS_FILE) { list(, $title) = explode(':', $entry['title'], 2); $title = str_replace(' ', '_', $title); $tsUnix = wfTimestamp(TS_UNIX, $entry['timestamp']); $tsMin = wfTimestamp(TS_MW, $tsUnix - 5); $tsMax = wfTimestamp(TS_MW, $tsUnix + 5); //get type of file operations $dbr = wfGetDB(DB_SLAVE); $type = $dbr->selectField(array('logging'), array('log_type'), array('log_type' => 'upload', 'log_namespace' => $entry['ns'], 'log_title' => $title, "log_timestamp BETWEEN {$tsMin} AND {$tsMax}"), __METHOD__); if ($type !== false) { $result[$i]['type'] = 'upload'; $result[$i]['diff'] = ''; } } } wfProfileOut(__METHOD__); return $result; }
/** * Reverse of testIsMain(). * Please update testIsMain() if you change assertions below */ public function testIsTalk() { // Special namespaces $this->assertFalse(MWNamespace::isTalk(NS_MEDIA)); $this->assertFalse(MWNamespace::isTalk(NS_SPECIAL)); // Subject pages $this->assertFalse(MWNamespace::isTalk(NS_MAIN)); $this->assertFalse(MWNamespace::isTalk(NS_USER)); $this->assertFalse(MWNamespace::isTalk(100)); # user defined // Talk pages $this->assertTrue(MWNamespace::isTalk(NS_TALK)); $this->assertTrue(MWNamespace::isTalk(NS_USER_TALK)); $this->assertTrue(MWNamespace::isTalk(101)); # user defined }
function wfPolyglotInitializeArticleMaybeRedirect(&$title, &$request, &$ignoreRedirect, &$target, &$article) { global $wgPolyglotExcemptNamespaces, $wgPolyglotExcemptTalkPages, $wgPolyglotFollowRedirects; global $wgLang, $wgContLang; $ns = $title->getNamespace(); if ($ns < 0 || in_array($ns, $wgPolyglotExcemptNamespaces) || $wgPolyglotExcemptTalkPages && MWNamespace::isTalk($ns)) { return true; } $dbkey = $title->getDBkey(); $force = false; //TODO: when user-defined language links start working (see below), // we need to look at the langlinks table here. if (!$title->exists() && strlen($dbkey) > 1) { $escContLang = preg_quote($wgContLang->getCode(), '!'); if (preg_match('!/$!', $dbkey)) { $force = true; $remove = 1; } elseif (preg_match("!/{$escContLang}\$!", $dbkey)) { $force = true; $remove = strlen($wgContLang->getCode()) + 1; } } if ($force) { $t = Title::makeTitle($ns, substr($dbkey, 0, strlen($dbkey) - $remove)); } else { $lang = $wgLang->getCode(); $t = Title::makeTitle($ns, $dbkey . '/' . $lang); } if (!$t->exists()) { return true; } if ($wgPolyglotFollowRedirects && !$force) { $page = WikiPage::factory($t); if ($page->isRedirect()) { $rt = $page->getRedirectTarget(); if ($rt && $rt->exists()) { //TODO: make "redirected from" show $source, not $title, if we followed a redirect internally. // there seems to be no clean way to do that, though. //$source = $t; $t = $rt; } } } $target = $t; return true; }
function register() { global $wgContLang, $wgNamespaceAliases, $wgNonincludableNamespaces; $lib = array('loadSiteStats' => array($this, 'loadSiteStats'), 'getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup')); $info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion()); if (!self::$namespacesCache) { $namespaces = array(); $namespacesByName = array(); foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) { $canonical = MWNamespace::getCanonicalName($ns); $namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !($wgNonincludableNamespaces && in_array($ns, $wgNonincludableNamespaces)), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'aliases' => array()); if ($ns >= NS_MAIN) { $namespaces[$ns]['subject'] = MWNamespace::getSubject($ns); $namespaces[$ns]['talk'] = MWNamespace::getTalk($ns); $namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns); } else { $namespaces[$ns]['subject'] = $ns; } $namespacesByName[strtr($title, ' ', '_')] = $ns; if ($canonical) { $namespacesByName[$canonical] = $ns; } } $aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases()); foreach ($aliases as $title => $ns) { if (!isset($namespacesByName[$title])) { $ct = count($namespaces[$ns]['aliases']); $namespaces[$ns]['aliases'][$ct + 1] = $title; $namespacesByName[$title] = $ns; } } $namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->text(); self::$namespacesCache = $namespaces; } $info['namespaces'] = self::$namespacesCache; if (self::$siteStatsLoaded) { $stats = $this->loadSiteStats(); $info['stats'] = $stats[0]; } $this->getEngine()->registerInterface('mw.site.lua', $lib, $info); }
public function build() { global $wgSitename, $wgContLanguageCode; $article = $this->Agent->getArticle(); $model = MwRdf::Model(); $rdf = MwRdf::Vocabulary('rdf'); $dc = MwRdf::Vocabulary('dc'); $dctype = MwRdf::Vocabulary('dctype'); $artres = $this->Agent->titleResource(); $model->addStatement(MwRdf::Statement($artres, $dc->title, MwRdf::LiteralNode($this->Agent->getTitle()->getText()))); $model->addStatement(MwRdf::Statement($artres, $dc->publisher, MwRdf::PageOrString(wfMsg('aboutpage'), $wgSitename))); $model->addStatement(MwRdf::Statement($artres, $dc->language, MwRdf::Language($wgContLanguageCode))); $model->addStatement(MwRdf::Statement($artres, $dc->type, $dctype->Text)); $model->addStatement(MwRdf::Statement($artres, $dc->format, MwRdf::MediaType('text/html'))); if ($this->Agent->getTimestampResource()) { $model->addStatement(MwRdf::Statement($artres, $dc->date, $this->Agent->getTimestampResource())); } if (MWNamespace::isTalk($this->Agent->getTitle()->getNamespace())) { $model->addStatement(MwRdf::Statement($artres, $dc->subject, $this->Agent->subjectResource())); } else { $talk = MwRdf::ModelingAgent($this->Agent->getTitle()->getTalkPage()); $model->addStatement(MwRdf::Statement($talk->titleResource(), $dc->subject, $artres)); } # 'Creator' is responsible for this version $creator = MwRdf::PersonToResource($article->getUser()); $model->addStatement(MwRdf::Statement($artres, $dc->creator, $creator)); # 'Contributors' are all other version authors $contributors = $article->getContributors(); foreach ($contributors as $user_parts) { $contributor = MwRdf::PersonToResource($user_parts[0], $user_parts[1], $user_parts[2]); $model->addStatement(MwRdf::Statement($artres, $dc->contributor, $contributor)); } # Rights notification global $wgRightsPage, $wgRightsUrl, $wgRightsText; $rights = MwRdf::RightsResource(); if ($rights) { $model->addStatement(MwRdf::Statement($artres, $dc->rights, $rights)); } return $model; }
function register() { global $wgContLang, $wgNamespaceAliases, $wgDisableCounters; $lib = array('getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'), 'interwikiMap' => array($this, 'interwikiMap')); $info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion()); if (!self::$namespacesCache || self::$namespacesCacheLang !== $wgContLang->getCode()) { $namespaces = array(); $namespacesByName = array(); foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) { $canonical = MWNamespace::getCanonicalName($ns); $namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !MWNamespace::isNonincludable($ns), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'defaultContentModel' => MWNamespace::getNamespaceContentModel($ns), 'aliases' => array()); if ($ns >= NS_MAIN) { $namespaces[$ns]['subject'] = MWNamespace::getSubject($ns); $namespaces[$ns]['talk'] = MWNamespace::getTalk($ns); $namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns); } else { $namespaces[$ns]['subject'] = $ns; } $namespacesByName[strtr($title, ' ', '_')] = $ns; if ($canonical) { $namespacesByName[$canonical] = $ns; } } $aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases()); foreach ($aliases as $title => $ns) { if (!isset($namespacesByName[$title]) && isset($namespaces[$ns])) { $ct = count($namespaces[$ns]['aliases']); $namespaces[$ns]['aliases'][$ct + 1] = $title; $namespacesByName[$title] = $ns; } } $namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->inContentLanguage()->text(); self::$namespacesCache = $namespaces; self::$namespacesCacheLang = $wgContLang->getCode(); } $info['namespaces'] = self::$namespacesCache; $info['stats'] = array('pages' => (int) SiteStats::pages(), 'articles' => (int) SiteStats::articles(), 'files' => (int) SiteStats::images(), 'edits' => (int) SiteStats::edits(), 'views' => $wgDisableCounters ? null : (int) SiteStats::views(), 'users' => (int) SiteStats::users(), 'activeUsers' => (int) SiteStats::activeUsers(), 'admins' => (int) SiteStats::numberingroup('sysop')); return $this->getEngine()->registerInterface('mw.site.lua', $lib, $info); }
public static function getIconType($row) { if (!isset($row['type'])) { return false; } wfProfileIn(__METHOD__); $type = false; switch ($row['type']) { case 'new': switch ($row['ns']) { // blog post case 500: $type = self::FEED_SUN_ICON; break; // blog comment // blog comment case 501: // wall comment // wall comment case 1001: $type = self::FEED_COMMENT_ICON; break; // content NS // content NS default: if (empty($row['articleComment'])) { $type = MWNamespace::isTalk($row['ns']) ? self::FEED_TALK_ICON : self::FEED_SUN_ICON; } else { $type = self::FEED_COMMENT_ICON; } } break; case 'edit': // edit done from editor if (empty($row['viewMode'])) { // talk pages if (isset($row['ns']) && MWNamespace::isTalk($row['ns'])) { if (empty($row['articleComment'])) { $type = self::FEED_TALK_ICON; } else { $type = self::FEED_COMMENT_ICON; } } else { $type = self::FEED_PENCIL_ICON; } } else { // category added if (!empty($row['CategorySelect'])) { $type = self::FEED_CATEGORY_ICON; } elseif (!empty($row['new_categories'])) { $type = self::FEED_PENCIL_ICON; } elseif (!empty($row['new_images'])) { $type = self::FEED_PHOTO_ICON; } else { $type = self::FEED_FILM_ICON; } } break; case 'delete': $type = self::FEED_DELETE_ICON; break; case 'move': case 'redirect': $type = self::FEED_MOVE_ICON; break; case 'upload': $type = self::FEED_PHOTO_ICON; break; } wfProfileOut(__METHOD__); return $type; }
protected function findEpisode($seriesName, $episodeName, $lang, $quality = self::DEFAULT_QUALITY) { // TODO: this is a workaround to not alter schema of main index too much // once the next gen search is implemented such workarounds would not be needed hopefully // this replaces american right apostrophe with normal one $episodeName = str_replace("’", "'", $episodeName); $seriesService = $this->getWikiSeriesService(); $seriesService->setLang($lang); $wikis = $seriesService->query($seriesName); if (!empty($wikis)) { $episodeService = $this->getEpisodeService(); $episodeService->setLang($lang)->setSeries($seriesName)->setQuality($quality); $result = null; foreach ($wikis as $wiki) { $episodeService->setWikiId($wiki['id']); $namespaces = WikiFactory::getVarValueByName(self::WG_CONTENT_NAMESPACES_KEY, $wiki['id']); $episodeService->setNamespace($namespaces); $result = $episodeService->query($episodeName); if ($result === null) { $result = $this->getTitle($episodeName, $wiki['id']); } if ($result === null) { $namespaceNames = WikiFactory::getVarValueByName(self::WG_EXTRA_LOCAL_NAMESPACES_KEY, $wiki['id']); if (is_array($namespaces)) { foreach ($namespaces as $ns) { if (!MWNamespace::isTalk($ns) && isset($namespaceNames[$ns])) { $result = $episodeService->query($namespaceNames[$ns] . ":" . $episodeName); if ($result !== null) { break; } } } } } if ($result !== null) { if ($quality == null || $result['quality'] !== null && $result['quality'] >= $quality) { return $result; } } } } return false; }
/** * Sets parameters for more complex options in preferences * @param string $sAdapterName Name of the adapter, e.g. MW * @param BsConfig $oVariable Instance of variable * @return array Preferences options */ public function runPreferencePlugin($sAdapterName, $oVariable) { wfProfileIn('BS::' . __METHOD__); $aPrefs = array(); switch ($oVariable->getName()) { case 'disableNS': global $wgContLang; $aExcludeNmsps = BsConfig::get('MW::VisualEditor::defaultNoContextNS'); foreach ($wgContLang->getNamespaces() as $sNamespace) { $iNsIndex = $wgContLang->getNsIndex($sNamespace); if (!MWNamespace::isTalk($iNsIndex)) { continue; } $aExcludeNmsps[] = $iNsIndex; } $aPrefs['type'] = 'multiselectex'; $aPrefs['options'] = BsNamespaceHelper::getNamespacesForSelectOptions($aExcludeNmsps); break; default: } wfProfileOut('BS::' . __METHOD__); return $aPrefs; }
/** * Get a list of titles on a user's watchlist, excluding talk pages, * and return as a two-dimensional array with namespace and title. * * @return array */ protected function getWatchlistInfo() { $titles = []; $watchedItems = MediaWikiServices::getInstance()->getWatchedItemStore()->getWatchedItemsForUser($this->getUser(), ['sort' => WatchedItemStore::SORT_ASC]); $lb = new LinkBatch(); foreach ($watchedItems as $watchedItem) { $namespace = $watchedItem->getLinkTarget()->getNamespace(); $dbKey = $watchedItem->getLinkTarget()->getDBkey(); $lb->add($namespace, $dbKey); if (!MWNamespace::isTalk($namespace)) { $titles[$namespace][$dbKey] = 1; } } $lb->execute(); return $titles; }
function wfPolyglotParserAfterTidy(&$parser, &$text) { global $wgPolyglotLanguages, $wfPolyglotExcemptNamespaces, $wfPolyglotExcemptTalkPages; global $wgContLang; if (!$wgPolyglotLanguages) { return true; } if (!$parser->mOptions->getInterwikiMagic()) { return true; } $n = $parser->mTitle->getDBkey(); $ns = $parser->mTitle->getNamespace(); $contln = $wgContLang->getCode(); $userlinks = $parser->mOutput->getLanguageLinks(); $links = array(); $pagelang = null; //TODO: if we followed a redirect, analyze the redirect's title too. // at least if wgPolyglotFollowRedirects is true if ($ns >= 0 && !in_array($ns, $wfPolyglotExcemptNamespaces) && (!$wfPolyglotExcemptTalkPages || !MWNamespace::isTalk($ns))) { $ll = wfPolyglotGetLanguages($parser->mTitle); if ($ll) { $links = array_merge($links, $ll); } if (preg_match('!(.+)/(\\w[-\\w]*\\w)$!', $n, $m)) { $pagelang = $m[2]; $t = Title::makeTitle($ns, $m[1]); if (!isset($links[$contln]) && $t->exists()) { $links[$contln] = $t->getFullText() . '/'; } $ll = wfPolyglotGetLanguages($t); if ($ll) { unset($ll[$pagelang]); $links = array_merge($links, $ll); } } } //TODO: would be nice to handle "normal" interwiki-links here. // but we would have to hack into Title::getInterwikiLink, otherwise // the links are not recognized. /* foreach ($userlinks as $link) { $m = explode(':', $link, 2); if (sizeof($m)<2) continue; $links[$m[0]] = $m[1]; } */ if ($pagelang) { unset($links[$pagelang]); } //print_r($links); $fakelinks = array(); foreach ($links as $lang => $t) { $fakelinks[] = $lang . ':' . $t; } $parser->mOutput->setLanguageLinks($fakelinks); return true; }
/** * @param object $page * @return bool */ function pass($page) { return !MWNamespace::isTalk($page->page_namespace); }
/** * 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 }
/** * Returns the ID of a namespace that defaults to Wikitext. * * @throws MWException If there is none. * @return int The ID of the wikitext Namespace * @since 1.21 */ protected function getDefaultWikitextNS() { global $wgNamespaceContentModels; static $wikitextNS = null; // this is not going to change if ($wikitextNS !== null) { return $wikitextNS; } // quickly short out on most common case: if (!isset($wgNamespaceContentModels[NS_MAIN])) { return NS_MAIN; } // NOTE: prefer content namespaces $namespaces = array_unique(array_merge(MWNamespace::getContentNamespaces(), array(NS_MAIN, NS_HELP, NS_PROJECT), MWNamespace::getValidNamespaces())); $namespaces = array_diff($namespaces, array(NS_FILE, NS_CATEGORY, NS_MEDIAWIKI, NS_USER)); $talk = array_filter($namespaces, function ($ns) { return MWNamespace::isTalk($ns); }); // prefer non-talk pages $namespaces = array_diff($namespaces, $talk); $namespaces = array_merge($namespaces, $talk); // check default content model of each namespace foreach ($namespaces as $ns) { if (!isset($wgNamespaceContentModels[$ns]) || $wgNamespaceContentModels[$ns] === CONTENT_MODEL_WIKITEXT) { $wikitextNS = $ns; return $wikitextNS; } } // give up // @todo Inside a test, we could skip the test as incomplete. // But frequently, this is used in fixture setup. throw new MWException("No namespace defaults to wikitext!"); }
/** * Constructor. * @param $title Title object. */ function __construct( $title ) { $origns = $title->getNamespace(); $this->mIsTalk = MWNamespace::isTalk( $origns ); $ns = MWNamespace::getSubject( $origns ); $tns = MWNamespace::getTalk( $origns ); if ( strpos( $title->getText(), '/' ) !== false ) { # If title contains a '/', treat as a wikilog article title. list( $this->mWikilogName, $this->mItemName ) = explode( '/', $title->getText(), 2 ); if ( strpos( $this->mItemName, '/' ) !== false ) { list( $this->mItemName, $this->mTrailing ) = explode( '/', $this->mItemName, 2 ); } $rawtitle = "{$this->mWikilogName}/{$this->mItemName}"; $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); $this->mItemTitle = Title::makeTitle( $ns, $rawtitle ); $this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle ); } else { # Title doesn't contain a '/', treat as a wikilog name. $this->mWikilogName = $title->getText(); $this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName ); $this->mItemName = null; $this->mItemTitle = null; $this->mItemTalkTitle = null; } }
function MwRdfDcmes($article) { global $wgContLanguageCode, $wgSitename, $DCMES, $DCMITYPE; $model = ModelFactory::getDefaultModel(); $nt = $article->mTitle; $artres = MwRdfArticleResource($article); $model->add(new Statement($artres, $DCMES['title'], MwRdfLiteral($article->mTitle->getText(), null, $wgContLanguageCode))); $model->add(new Statement($artres, $DCMES['publisher'], MwRdfPageOrString(wfMsg('aboutpage'), $wgSitename))); $model->add(new Statement($artres, $DCMES['language'], MwRdfLanguage($wgContLanguageCode))); $model->add(new Statement($artres, $DCMES['type'], $DCMITYPE['Text'])); $model->add(new Statement($artres, $DCMES['format'], MwRdfMediaType('text/html'))); $model->add(new Statement($artres, $DCMES['date'], MwRdfTimestamp($article->getTimestamp()))); if (MWNamespace::isTalk($nt->getNamespace())) { $model->add(new Statement($artres, $DCMES['subject'], MwRdfTitleResource($nt->getSubjectPage()))); } else { $model->add(new Statement(MwRdfTitleResource($nt->getTalkPage()), $DCMES['subject'], $artres)); } # 'Creator' is responsible for this version $last_editor = $article->getUser(); $creator = $last_editor == 0 ? MwRdfPersonResource(0) : MwRdfPersonResource($last_editor, $article->getUserText(), User::whoIsReal($last_editor)); $model->add(new Statement($artres, $DCMES['creator'], $creator)); # 'Contributors' are all other version authors $contributors = $article->getContributors(); foreach ($contributors as $user_parts) { $contributor = MwRdfPersonResource($user_parts[0], $user_parts[1], $user_parts[2]); $model->add(new Statement($artres, $DCMES['contributor'], $contributor)); } # Rights notification global $wgRightsPage, $wgRightsUrl, $wgRightsText; $rights = isset($wgRightsPage) && ($nt = Title::newFromText($wgRightsPage)) && $nt->getArticleID() != 0 ? MwRdfTitleResource($nt) : isset($wgRightsUrl) ? MwRdfGetResource($wgRightsUrl) : isset($wgRightsText) ? new Literal($wgRightsText) : null; if ($rights != null) { $model->add(new Statement($artres, $DCMES['rights'], $rights)); } return $model; }
public static function onArticleViewFooter( $article ) { global $wgOut, $wgRequest, $wgUser, $wgJsMimeType, $wgUseAjax, $wgTalkHereNamespaces; $action = $wgRequest->getVal( 'action', 'view' ); if ( $action != 'view' && $action != 'purge' ) { return true; } if ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'diff' ) ) { return true; } $title = $article->getTitle(); $ns = $title->getNamespace(); if ( MWNamespace::isTalk($ns) || !MWNamespace::canTalk($ns) || !$title->exists() || ( $wgTalkHereNamespaces && !in_array( $ns, $wgTalkHereNamespaces ) ) ) { return true; } $talk = $title->getTalkPage(); if ( !$talk || !$talk->userCanRead() ) { return true; } $hastalk = $talk->exists(); $cantalk = $talk->userCan('edit'); if ( !$hastalk && !$cantalk ) { return true; } $skin = $wgUser->getSkin(); $talkArticle = Article::newFromTitle( $talk, RequestContext::getMain() ); $wgOut->addHTML('<div class="talkhere" id="talkhere">'); if ($hastalk) { //Bah, would have to call a skin-snippet here :( $wgOut->addHTML('<div class="talkhere-head">'); $wgOut->addHTML('<h1>'); if ($talk->userCan('edit')) { $wgOut->addHTML('<span class="editsection">'); $wgOut->addHTML( '[' . $skin->makeKnownLinkObj( $talk, wfMsg('talkhere-talkpage' ) ) . ']' ); $wgOut->addHTML('</span>'); } $wgOut->addWikiText( wfMsg('talkhere-title', $talk->getPrefixedText() ), false ); $wgOut->addHTML('</h1>'); $headtext = wfMsg('talkhere-headtext', $title->getPrefixedText(), $talk->getPrefixedText() ); if ( $headtext ) { $wgOut->addWikiText( $headtext ); $wgOut->addHTML('<hr/>'); } $wgOut->addHTML('</div>'); //talkhere-head $wgOut->addHTML('<div class="talkhere-comments">'); $talkArticle->view(); $wgOut->addHTML('</div>'); // talkhere-comments } $wgOut->addHTML('<div class="talkhere-foot">'); if ( $cantalk ) { if ($hastalk) { $wgOut->addHTML('<hr/>'); } else { $wgOut->addHTML('<div class="talkhere-comments talkhere-notalk">'); $wgOut->addWikiText( wfMsg('talkhere-notalk') ); $wgOut->addHTML('</div>'); // talkhere-comments } if ( $wgUseAjax ) $wgOut->addScript( " <script type=\"{$wgJsMimeType}\"> var talkHereLoadingMsg = \"" . Xml::escapeJsString(wfMsg('talkhere-loading')) . "\"; var talkHereCollapseMsg = \"" . Xml::escapeJsString(wfMsg('talkhere-collapse')) . "\"; var talkHereExpandMsg = \"" . Xml::escapeJsString(wfMsg('talkhere-addcomment')) . "\"; </script>\n" ); $returnto = $title->getPrefixedDBKey(); $talktitle = $talk->getPrefixedDBKey(); $q = 'action=edit§ion=new&wpTalkHere=1&wpReturnTo=' . urlencode($returnto); $js = $wgUseAjax ? 'this.href="javascript:void(0);"; talkHereLoadEditor("talkhere_talklink", "talkhere_talkform", "'.Xml::escapeJsString($talktitle).'", "new", "'.Xml::escapeJsString($returnto).'"); ' : ''; $a = 'onclick="'.htmlspecialchars($js).'" id="talkhere_talklink"'; $wgOut->addHTML('<div class="talkhere-talklink">'); $wgOut->addHTML( $skin->makeKnownLinkObj( $talk, wfMsg('talkhere-addcomment' ), $q, '', '', $a ) ); $wgOut->addHTML('</div>'); $wgOut->addHTML('<div id="talkhere_talkform" style="display:none;"> </div>'); //self::showCommentForm( $title, $talk, 'new' ); } if ($hastalk) { $foottext = wfMsg('talkhere-foottext', $title->getPrefixedText(), $talk->getPrefixedText() ); if ( $foottext ) { $wgOut->addHTML('<hr/>'); $wgOut->addWikiText( $foottext ); } } $wgOut->addHTML('</div>'); // talkhere-foot $wgOut->addHTML('</div>'); // talkhere return true; }
public function execute() { global $wgUser; $params = $this->extractRequestParams(); $fld_protection = $fld_talkid = $fld_subjectid = $fld_url = $fld_readable = false; if (!is_null($params['prop'])) { $prop = array_flip($params['prop']); $fld_protection = isset($prop['protection']); $fld_talkid = isset($prop['talkid']); $fld_subjectid = isset($prop['subjectid']); $fld_url = isset($prop['url']); $fld_readable = isset($prop['readable']); } $pageSet = $this->getPageSet(); $titles = $pageSet->getGoodTitles(); $missing = $pageSet->getMissingTitles(); $result = $this->getResult(); $pageRestrictions = $pageSet->getCustomField('page_restrictions'); $pageIsRedir = $pageSet->getCustomField('page_is_redirect'); $pageIsNew = $pageSet->getCustomField('page_is_new'); $pageCounter = $pageSet->getCustomField('page_counter'); $pageTouched = $pageSet->getCustomField('page_touched'); $pageLatest = $pageSet->getCustomField('page_latest'); $pageLength = $pageSet->getCustomField('page_len'); $db = $this->getDB(); if ($fld_protection && count($titles)) { $this->addTables('page_restrictions'); $this->addFields(array('pr_page', 'pr_type', 'pr_level', 'pr_expiry', 'pr_cascade')); $this->addWhereFld('pr_page', array_keys($titles)); $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { $a = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601)); if ($row->pr_cascade) { $a['cascade'] = ''; } $protections[$row->pr_page][] = $a; # Also check old restrictions if ($pageRestrictions[$row->pr_page]) { foreach (explode(':', trim($pageRestrictions[$pageid])) as $restrict) { $temp = explode('=', trim($restrict)); if (count($temp) == 1) { // old old format should be treated as edit/move restriction $restriction = trim($temp[0]); if ($restriction == '') { continue; } $protections[$row->pr_page][] = array('type' => 'edit', 'level' => $restriction, 'expiry' => 'infinity'); $protections[$row->pr_page][] = array('type' => 'move', 'level' => $restriction, 'expiry' => 'infinity'); } else { $restriction = trim($temp[1]); if ($restriction == '') { continue; } $protections[$row->pr_page][] = array('type' => $temp[0], 'level' => $restriction, 'expiry' => 'infinity'); } } } } $db->freeResult($res); $imageIds = array(); foreach ($titles as $id => $title) { if ($title->getNamespace() == NS_FILE) { $imageIds[] = $id; } } // To avoid code duplication $cascadeTypes = array(array('prefix' => 'tl', 'table' => 'templatelinks', 'ns' => 'tl_namespace', 'title' => 'tl_title', 'ids' => array_diff(array_keys($titles), $imageIds)), array('prefix' => 'il', 'table' => 'imagelinks', 'ns' => NS_FILE, 'title' => 'il_to', 'ids' => $imageIds)); foreach ($cascadeTypes as $type) { if (count($type['ids']) != 0) { $this->resetQueryParams(); $this->addTables(array('page_restrictions', $type['table'])); $this->addTables('page', 'page_source'); $this->addTables('page', 'page_target'); $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', 'page_target.page_id AS page_target_id', 'page_source.page_namespace AS page_source_namespace', 'page_source.page_title AS page_source_title')); $this->addWhere(array("{$type['prefix']}_from = pr_page", 'page_target.page_namespace = ' . $type['ns'], 'page_target.page_title = ' . $type['title'], 'page_source.page_id = pr_page')); $this->addWhereFld('pr_cascade', 1); $this->addWhereFld('page_target.page_id', $type['ids']); $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { $source = Title::makeTitle($row->page_source_namespace, $row->page_source_title); $a = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601), 'source' => $source->getPrefixedText()); $protections[$row->page_target_id][] = $a; } $db->freeResult($res); } } } // We don't need to check for pt stuff if there are no nonexistent titles if ($fld_protection && count($missing)) { $this->resetQueryParams(); // Construct a custom WHERE clause that matches all titles in $missing $lb = new LinkBatch($missing); $this->addTables('protected_titles'); $this->addFields(array('pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry')); $this->addWhere($lb->constructSet('pt', $db)); $res = $this->select(__METHOD__); $prottitles = array(); while ($row = $db->fetchObject($res)) { $prottitles[$row->pt_namespace][$row->pt_title][] = array('type' => 'create', 'level' => $row->pt_create_perm, 'expiry' => Block::decodeExpiry($row->pt_expiry, TS_ISO_8601)); } $db->freeResult($res); $images = array(); $others = array(); foreach ($missing as $title) { if ($title->getNamespace() == NS_FILE) { $images[] = $title->getDBKey(); } else { $others[] = $title; } } if (count($others) != 0) { $lb = new LinkBatch($others); $this->resetQueryParams(); $this->addTables(array('page_restrictions', 'page', 'templatelinks')); $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', 'page_title', 'page_namespace', 'tl_title', 'tl_namespace')); $this->addWhere($lb->constructSet('tl', $db)); $this->addWhere('pr_page = page_id'); $this->addWhere('pr_page = tl_from'); $this->addWhereFld('pr_cascade', 1); $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { $source = Title::makeTitle($row->page_namespace, $row->page_title); $a = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601), 'source' => $source->getPrefixedText()); $prottitles[$row->tl_namespace][$row->tl_title][] = $a; } $db->freeResult($res); } if (count($images) != 0) { $this->resetQueryParams(); $this->addTables(array('page_restrictions', 'page', 'imagelinks')); $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', 'page_title', 'page_namespace', 'il_to')); $this->addWhere('pr_page = page_id'); $this->addWhere('pr_page = il_from'); $this->addWhereFld('pr_cascade', 1); $this->addWhereFld('il_to', $images); $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { $source = Title::makeTitle($row->page_namespace, $row->page_title); $a = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601), 'source' => $source->getPrefixedText()); $prottitles[NS_FILE][$row->il_to][] = $a; } $db->freeResult($res); } } // Run the talkid/subjectid query if ($fld_talkid || $fld_subjectid) { $talktitles = $subjecttitles = $talkids = $subjectids = array(); $everything = array_merge($titles, $missing); foreach ($everything as $t) { if (MWNamespace::isTalk($t->getNamespace())) { if ($fld_subjectid) { $subjecttitles[] = $t->getSubjectPage(); } } else { if ($fld_talkid) { $talktitles[] = $t->getTalkPage(); } } } if (count($talktitles) || count($subjecttitles)) { // Construct a custom WHERE clause that matches // all titles in $talktitles and $subjecttitles $lb = new LinkBatch(array_merge($talktitles, $subjecttitles)); $this->resetQueryParams(); $this->addTables('page'); $this->addFields(array('page_title', 'page_namespace', 'page_id')); $this->addWhere($lb->constructSet('page', $db)); $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { if (MWNamespace::isTalk($row->page_namespace)) { $talkids[MWNamespace::getSubject($row->page_namespace)][$row->page_title] = $row->page_id; } else { $subjectids[MWNamespace::getTalk($row->page_namespace)][$row->page_title] = $row->page_id; } } } } foreach ($titles as $pageid => $title) { $pageInfo = array('touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]), 'lastrevid' => intval($pageLatest[$pageid]), 'counter' => intval($pageCounter[$pageid]), 'length' => intval($pageLength[$pageid])); if ($pageIsRedir[$pageid]) { $pageInfo['redirect'] = ''; } if ($pageIsNew[$pageid]) { $pageInfo['new'] = ''; } if (!is_null($params['token'])) { $tokenFunctions = $this->getTokenFunctions(); $pageInfo['starttimestamp'] = wfTimestamp(TS_ISO_8601, time()); foreach ($params['token'] as $t) { $val = call_user_func($tokenFunctions[$t], $pageid, $title); if ($val === false) { $this->setWarning("Action '{$t}' is not allowed for the current user"); } else { $pageInfo[$t . 'token'] = $val; } } } if ($fld_protection) { $pageInfo['protection'] = array(); if (isset($protections[$pageid])) { $pageInfo['protection'] = $protections[$pageid]; $result->setIndexedTagName($pageInfo['protection'], 'pr'); } } if ($fld_talkid && isset($talkids[$title->getNamespace()][$title->getDBKey()])) { $pageInfo['talkid'] = $talkids[$title->getNamespace()][$title->getDBKey()]; } if ($fld_subjectid && isset($subjectids[$title->getNamespace()][$title->getDBKey()])) { $pageInfo['subjectid'] = $subjectids[$title->getNamespace()][$title->getDBKey()]; } if ($fld_url) { $pageInfo['fullurl'] = $title->getFullURL(); $pageInfo['editurl'] = $title->getFullURL('action=edit'); } if ($fld_readable) { if ($title->userCanRead()) { $pageInfo['readable'] = ''; } } $result->addValue(array('query', 'pages'), $pageid, $pageInfo); } // Get properties for missing titles if requested if (!is_null($params['token']) || $fld_protection || $fld_talkid || $fld_subjectid || $fld_url || $fld_readable) { $res =& $result->getData(); foreach ($missing as $pageid => $title) { if (!is_null($params['token'])) { $tokenFunctions = $this->getTokenFunctions(); $res['query']['pages'][$pageid]['starttimestamp'] = wfTimestamp(TS_ISO_8601, time()); foreach ($params['token'] as $t) { $val = call_user_func($tokenFunctions[$t], $pageid, $title); if ($val === false) { $this->setWarning("Action '{$t}' is not allowed for the current user"); } else { $res['query']['pages'][$pageid][$t . 'token'] = $val; } } } if ($fld_protection) { // Apparently the XML formatting code doesn't like array(null) // This is painful to fix, so we'll just work around it if (isset($prottitles[$title->getNamespace()][$title->getDBkey()])) { $res['query']['pages'][$pageid]['protection'] = $prottitles[$title->getNamespace()][$title->getDBkey()]; } else { $res['query']['pages'][$pageid]['protection'] = array(); } $result->setIndexedTagName($res['query']['pages'][$pageid]['protection'], 'pr'); } if ($fld_talkid && isset($talkids[$title->getNamespace()][$title->getDBKey()])) { $res['query']['pages'][$pageid]['talkid'] = $talkids[$title->getNamespace()][$title->getDBKey()]; } if ($fld_subjectid && isset($subjectids[$title->getNamespace()][$title->getDBKey()])) { $res['query']['pages'][$pageid]['subjectid'] = $subjectids[$title->getNamespace()][$title->getDBKey()]; } if ($fld_url) { $res['query']['pages'][$pageid]['fullurl'] = $title->getFullURL(); $res['query']['pages'][$pageid]['editurl'] = $title->getFullURL('action=edit'); } if ($fld_readable) { if ($title->userCanRead()) { $res['query']['pages'][$pageid]['readable'] = ''; } } } } }
/** * Handle confirmations when page is deleted * * @param WikiPage $article */ public static function addPageDeletedConfirmation(&$article, &$user, $reason, $articleId) { wfProfileIn(__METHOD__); global $wgOut; if ( F::app()->checkSkin( 'oasis' ) ) { $title = $article->getTitle(); // special handling of ArticleComments if (class_exists('ArticleComment') && MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title) && $title->getNamespace() != NS_USER_WALL ) { self::addConfirmation(wfMsg('oasis-confirmation-comment-deleted')); wfProfileOut(__METHOD__); return true; } $pageName = $title->getPrefixedText(); self::addConfirmation(wfMsgExt('oasis-confirmation-page-deleted', array('parseinline'), $pageName)); // redirect to main page $wgOut->redirect(Title::newMainPage()->getFullUrl( array( 'cb' => rand( 1, 1000 ) ) )); } wfProfileOut(__METHOD__); return true; }
public function onRecentChangeSave($recentChange) { wfProfileIn(__METHOD__); // notifications $app = F::app(); if (MWNamespace::isTalk($recentChange->getAttribute('rc_namespace')) && in_array(MWNamespace::getSubject($recentChange->getAttribute('rc_namespace')), $app->wg->WallNS)) { $rcType = $recentChange->getAttribute('rc_type'); //FIXME: WallMessage::remove() creates a new RC but somehow there is no rc_this_oldid $revOldId = $recentChange->getAttribute('rc_this_oldid'); if ($rcType == RC_EDIT && !empty($revOldId)) { $helper = F::build('WallHelper', array()); $helper->sendNotification($revOldId, $rcType); } } wfProfileOut(__METHOD__); return true; }
/** * Show the error text for a missing article. For articles in the MediaWiki * namespace, show the default message text. To be called from Article::view(). */ public function showMissingArticle() { global $wgSend404Code; $outputPage = $this->getContext()->getOutput(); // Whether the page is a root user page of an existing user (but not a subpage) $validUserPage = false; # Show info in user (talk) namespace. Does the user exist? Is he blocked? if ($this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK) { $parts = explode('/', $this->getTitle()->getText()); $rootPart = $parts[0]; $user = User::newFromName($rootPart, false); $ip = User::isIP($rootPart); if (!($user && $user->isLoggedIn()) && !$ip) { # User does not exist $outputPage->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", array('userpage-userdoesnotexist-view', wfEscapeWikiText($rootPart))); } elseif ($user->isBlocked()) { # Show log extract if the user is currently blocked LogEventsList::showLogExtract($outputPage, 'block', $user->getUserPage(), '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('blocked-notice-logextract', $user->getName()))); $validUserPage = !$this->getTitle()->isSubpage(); } else { $validUserPage = !$this->getTitle()->isSubpage(); } } wfRunHooks('ShowMissingArticle', array($this)); // Give extensions a chance to hide their (unrelated) log entries $logTypes = array('delete', 'move'); $conds = array("log_action != 'revision'"); wfRunHooks('Article::MissingArticleConditions', array(&$conds, $logTypes)); # Show delete and move logs LogEventsList::showLogExtract($outputPage, $logTypes, $this->getTitle(), '', array('lim' => 10, 'conds' => $conds, 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice'))); if (!$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage) { // If there's no backing content, send a 404 Not Found // for better machine handling of broken links. $this->getContext()->getRequest()->response()->header("HTTP/1.1 404 Not Found"); } if ($validUserPage) { // Also apply the robot policy for nonexisting user pages (as those aren't served as 404) $policy = $this->getRobotPolicy('view'); $outputPage->setIndexPolicy($policy['index']); $outputPage->setFollowPolicy($policy['follow']); } $hookResult = wfRunHooks('BeforeDisplayNoArticleText', array($this)); if (!$hookResult) { return; } // WIKIHOW - Bebeth added this var to be used below for scustom messages $showHeader = false; # Show error message $oldid = $this->getOldID(); if ($oldid) { $text = wfMessage('missing-revision', $oldid)->plain(); } elseif ($this->getTitle()->getNamespace() === NS_MEDIAWIKI) { // Use the default message text $text = $this->getTitle()->getDefaultMessageText(); } elseif ($this->getTitle()->quickUserCan('create', $this->getContext()->getUser()) && $this->getTitle()->quickUserCan('edit', $this->getContext()->getUser())) { // WIKIHOW - BEBETH changed inside this if condition for // custom messages and params needed for messages if ($this->mTitle->getNamespace() == NS_USER_TALK) { $text = wfMessage('noarticletext_user_talk', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain(); $showHeader = true; } else { if (MWNamespace::isTalk($this->mTitle->getNamespace())) { $text = wfMessage('noarticletext_talk', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain(); $showHeader = true; } else { if ($this->mTitle->getNamespace() == NS_USER) { $text = wfMessage('noarticletext_user', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain(); } else { if ($this->mTitle->getNamespace() == NS_USER_KUDOS) { $text = wfMessage('noarticletext_user_kudos', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain(); } else { if ($this->mTitle->getNamespace() == NS_MAIN) { $text = wfMessage('noarticletext', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit", urlencode($this->getTitle()->getText()))->plain(); $showHeader = true; } else { $text = wfMessage('noarticletext_standard', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain(); } } } } } // original lines that were commented out inside this block // $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon'; // $text = wfMessage( $message )->plain(); } else { $text = wfMessage('noarticletext-nopermission')->plain(); } $text = "<div class='noarticletext'>\n{$text}\n</div>"; // WIKIHOW - BEBETH following 3 lines added for styling if ($showHeader) { $text = "<h2>" . wfMessage('noarticlefound')->text() . "</h2>{$text}"; } $outputPage->addWikiText($text); }
/** * Hook * * @param Title $title -- instance of EmailNotification class * @param Array $keys -- array of all special variables like $PAGETITLE etc * @param String $message (subject or body) * @param $editor User * * @static * @access public * * @return Bool true -- because it's a hook */ public static function ComposeCommonMail($title, &$keys, &$message, $editor) { global $wgEnotifUseRealName; if (MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title)) { if (!is_array($keys)) { $keys = array(); } $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName(); if ($editor->isIP($name)) { $utext = trim(wfMsgForContent('enotif_anon_editor', '')); $message = str_replace('$PAGEEDITOR', $utext, $message); $keys['$PAGEEDITOR'] = $utext; } } return true; }
protected static function load() { global $wgFlaggedRevsTags, $wgFlaggedRevTags; if (self::$loaded) { return true; } if (!FlaggedRevsSetup::isReady()) { // sanity throw new MWException('FlaggedRevs config loaded too soon! Possibly before LocalSettings.php!'); } self::$loaded = true; $flaggedRevsTags = null; if (isset($wgFlaggedRevTags)) { $flaggedRevsTags = $wgFlaggedRevTags; // b/c wfWarn('Please use $wgFlaggedRevsTags instead of $wgFlaggedRevTags in config.'); } elseif (isset($wgFlaggedRevsTags)) { $flaggedRevsTags = $wgFlaggedRevsTags; } # Assume true, then set to false if needed if (!empty($flaggedRevsTags)) { self::$qualityVersions = true; self::$pristineVersions = true; self::$binaryFlagging = count($flaggedRevsTags) <= 1; } foreach ($flaggedRevsTags as $tag => $levels) { # Sanity checks $safeTag = htmlspecialchars($tag); if (!preg_match('/^[a-zA-Z]{1,20}$/', $tag) || $safeTag !== $tag) { throw new MWException('FlaggedRevs given invalid tag name!'); } # Define "quality" and "pristine" reqs if (is_array($levels)) { $minQL = $levels['quality']; $minPL = $levels['pristine']; $ratingLevels = $levels['levels']; # B/C, $levels is just an integer (minQL) } else { global $wgFlaggedRevPristine, $wgFlaggedRevValues; $ratingLevels = isset($wgFlaggedRevValues) ? $wgFlaggedRevValues : 1; $minQL = $levels; // an integer $minPL = isset($wgFlaggedRevPristine) ? $wgFlaggedRevPristine : $ratingLevels + 1; wfWarn('Please update the format of $wgFlaggedRevsTags in config.'); } # Set FlaggedRevs tags self::$dimensions[$tag] = array(); for ($i = 0; $i <= $ratingLevels; $i++) { self::$dimensions[$tag][$i] = "{$tag}-{$i}"; } if ($ratingLevels > 1) { self::$binaryFlagging = false; // more than one level } # Sanity checks if (!is_integer($minQL) || !is_integer($minPL)) { throw new MWException('FlaggedRevs given invalid tag value!'); } if ($minQL > $ratingLevels) { self::$qualityVersions = false; self::$pristineVersions = false; } if ($minPL > $ratingLevels) { self::$pristineVersions = false; } self::$minQL[$tag] = max($minQL, 1); self::$minPL[$tag] = max($minPL, 1); self::$minSL[$tag] = 1; } global $wgFlaggedRevsTagsRestrictions, $wgFlagRestrictions; if (isset($wgFlagRestrictions)) { self::$tagRestrictions = $wgFlagRestrictions; // b/c wfWarn('Please use $wgFlaggedRevsTagsRestrictions instead of $wgFlagRestrictions in config.'); } else { self::$tagRestrictions = $wgFlaggedRevsTagsRestrictions; } # Make sure that the restriction levels are unique global $wgFlaggedRevsRestrictionLevels; self::$restrictionLevels = array_unique($wgFlaggedRevsRestrictionLevels); self::$restrictionLevels = array_filter(self::$restrictionLevels, 'strlen'); # Make sure no talk namespaces are in review namespace global $wgFlaggedRevsNamespaces; foreach ($wgFlaggedRevsNamespaces as $ns) { if (MWNamespace::isTalk($ns)) { throw new MWException('FlaggedRevs given talk namespace in $wgFlaggedRevsNamespaces!'); } elseif ($ns == NS_MEDIAWIKI) { throw new MWException('FlaggedRevs given NS_MEDIAWIKI in $wgFlaggedRevsNamespaces!'); } } self::$reviewNamespaces = $wgFlaggedRevsNamespaces; # Handle $wgFlaggedRevsAutoReview settings global $wgFlaggedRevsAutoReview, $wgFlaggedRevsAutoReviewNew; if (is_int($wgFlaggedRevsAutoReview)) { self::$autoReviewConfig = $wgFlaggedRevsAutoReview; } else { // b/c if ($wgFlaggedRevsAutoReview) { self::$autoReviewConfig = FR_AUTOREVIEW_CHANGES; } wfWarn('$wgFlaggedRevsAutoReview is now a bitfield instead of a boolean.'); } if (isset($wgFlaggedRevsAutoReviewNew)) { // b/c self::$autoReviewConfig = $wgFlaggedRevsAutoReviewNew ? self::$autoReviewConfig |= FR_AUTOREVIEW_CREATION : self::$autoReviewConfig & ~FR_AUTOREVIEW_CREATION; wfWarn('$wgFlaggedRevsAutoReviewNew is deprecated; use $wgFlaggedRevsAutoReview.'); } return true; }
/** * Get talk page IDs (if requested) and subject page IDs (if requested) * and put them in $talkids and $subjectids */ private function getTSIDs() { $getTitles = $this->talkids = $this->subjectids = array(); $db = $this->getDB(); foreach ($this->everything as $t) { if (MWNamespace::isTalk($t->getNamespace())) { if ($this->fld_subjectid) { $getTitles[] = $t->getSubjectPage(); } } else { if ($this->fld_talkid) { $getTitles[] = $t->getTalkPage(); } } } if (!count($getTitles)) { return; } // Construct a custom WHERE clause that matches // all titles in $getTitles $lb = new LinkBatch($getTitles); $this->resetQueryParams(); $this->addTables('page'); $this->addFields(array('page_title', 'page_namespace', 'page_id')); $this->addWhere($lb->constructSet('page', $db)); $res = $this->select(__METHOD__); while ($row = $db->fetchObject($res)) { if (MWNamespace::isTalk($row->page_namespace)) { $this->talkids[MWNamespace::getSubject($row->page_namespace)][$row->page_title] = intval($row->page_id); } else { $this->subjectids[MWNamespace::getTalk($row->page_namespace)][$row->page_title] = intval($row->page_id); } } }
/** * TODO: Document what the parameters are. */ static function ChangesListInsertArticleLink($changeList, &$articlelink, &$s, $rc, $unpatrolled, $watched) { $rcTitle = $rc->getAttribute('rc_title'); $rcNamespace = $rc->getAttribute('rc_namespace'); $title = Title::newFromText($rcTitle, $rcNamespace); if (MWNamespace::isTalk($rcNamespace) && ArticleComment::isTitleComment($title)) { $parts = ArticleComment::explode($rcTitle); $titleMainArticle = Title::newFromText($parts['title'], MWNamespace::getSubject($rcNamespace)); //fb#15143 if ($titleMainArticle instanceof Title) { if (defined('NS_BLOG_ARTICLE') && $rcNamespace == NS_BLOG_ARTICLE || defined('NS_BLOG_ARTICLE_TALK') && $rcNamespace == NS_BLOG_ARTICLE_TALK) { $messageKey = 'article-comments-rc-blog-comment'; } else { $messageKey = 'article-comments-rc-comment'; } $articleId = $title->getArticleId(); $articlelink = wfMsgExt($messageKey, array('parseinline'), $title->getFullURL("permalink={$articleId}#comm-{$articleId}"), $titleMainArticle->getText()); } else { //it should never happened because $rcTitle is never empty, //ArticleComment::explode() always returns an array with not-empty 'title' element, //(both files: ArticleComments/classes/ArticleComments.class.php //and WallArticleComment/classes/ArticleComments.class.php have //the same definition of explode() method) //and static constructor newFromText() should create a Title instance for $parts['title'] Wikia::log(__METHOD__, false, 'WALL_ARTICLE_COMMENT_ERROR: no main article title: ' . print_r($parts, true) . ' namespace: ' . $rcNamespace); } } return true; }
/** * Get a list of titles on a user's watchlist, excluding talk pages, * and return as a two-dimensional array with namespace and title. * * @return array */ private function getWatchlistInfo() { $titles = array(); $dbr = wfGetDB(DB_MASTER); $res = $dbr->select(array('watchlist'), array('wl_namespace', 'wl_title'), array('wl_user' => $this->getUser()->getId()), __METHOD__, array('ORDER BY' => 'wl_namespace, wl_title')); $lb = new LinkBatch(); foreach ($res as $row) { $lb->add($row->wl_namespace, $row->wl_title); if (!MWNamespace::isTalk($row->wl_namespace)) { $titles[$row->wl_namespace][$row->wl_title] = 1; } } $lb->execute(); return $titles; }
/** * Handle confirmations when page is deleted * * @param WikiPage $article */ public static function addPageDeletedConfirmation(&$article, &$user, $reason, $articleId) { global $wgOut; if (F::app()->checkSkin('oasis')) { $title = $article->getTitle(); // special handling of ArticleComments if (class_exists('ArticleComment') && MWNamespace::isTalk($title->getNamespace()) && ArticleComment::isTitleComment($title) && $title->getNamespace() != NS_USER_WALL) { self::addConfirmation(wfMessage('oasis-confirmation-comment-deleted')->escaped()); return true; } $pageName = $title->getPrefixedText(); $message = wfMessage('oasis-confirmation-page-deleted', $pageName)->inContentLanguage()->parse(); wfRunHooks('OasisAddPageDeletedConfirmationMessage', array(&$title, &$message)); self::addConfirmation($message, self::CONFIRMATION_CONFIRM, true); // redirect to main page $wgOut->redirect(Title::newMainPage()->getFullUrl(array('cb' => rand(1, 1000)))); } return true; }
/** * Is this a talk page of some sort? * * @return bool */ public function isTalkPage() { return MWNamespace::isTalk($this->getNamespace()); }
> <div id="article_header"> <div id="a_tabs"> <a href="<?php if ($wgTitle->isTalkPage()) { echo $wgTitle->getSubjectPage()->getFullURL(); } else { echo $wgTitle->getFullURL(); } ?> " id="tab_article" title="Article" <?php if (!MWNamespace::isTalk($wgTitle->getNamespace()) && $action != "edit" && $action != "history") { echo 'class="on"'; } ?> onmousedown="button_click(this);">read</a> <?php $talklink = $wgTitle->getTalkPage()->getLocalURL(); ?> <span id="gatDiscussionTab"><a href="<?php echo $talklink; ?> " <?php if ($wgTitle->isTalkPage() && $action != "edit" && $action != "history") { echo 'class="on"';