예제 #1
0
 function outputPage(OutputPage $out = null)
 {
     global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang, $wgOut;
     global $wgScript, $wgStylePath, $wgLanguageCode, $wgContLanguageCode;
     global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages;
     global $wgRequest, $wgUseNewInterlanguage;
     global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses;
     global $wgMaxCredits, $wgShowCreditsIfMax, $wgHideInterlanguageLinks;
     global $wgServer;
     global $wgSquidMaxage, $IP;
     $fname = __METHOD__;
     wfProfileIn($fname);
     wfRunHooks('BeforePageDisplay', array(&$wgOut, &$this));
     $this->mTitle = $wgTitle;
     extract($wgRequest->getValues('oldid', 'diff'));
     wfProfileIn("{$fname}-init");
     //$this->initPage( $out );
     $tpl = $this->setupTemplate('WikiHowTemplate', 'skins');
     $tpl->setTranslator(new MediaWiki_I18N());
     wfProfileOut("{$fname}-init");
     wfProfileIn("{$fname}-stuff");
     $this->thispage = $wgTitle->getPrefixedDbKey();
     $this->thisurl = $wgTitle->getPrefixedURL();
     $this->loggedin = $wgUser->getID() != 0;
     $this->iscontent = $wgTitle->getNamespace() != NS_SPECIAL;
     $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
     $this->username = $wgUser->getName();
     $this->userpage = $wgContLang->getNsText(NS_USER) . ":" . $wgUser->getName();
     $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage);
     $this->usercss = $this->userjs = $this->userjsprev = false;
     //$this->setupUserCss();
     //$this->setupUserJs(false);
     $this->titletxt = $wgTitle->getPrefixedText();
     wfProfileOut("{$fname}-stuff");
     // add utm
     wfProfileIn("{$fname}-stuff2");
     $tpl->set('title', $wgOut->getPageTitle());
     $tpl->setRef("thispage", $this->thispage);
     $undelete = $this->getUndeleteLink();
     $tpl->set("undelete", !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : '');
     $tpl->set('headscripts', $out->getHeadScripts() . $out->getHeadItems());
     $description = ArticleMetaInfo::getCurrentTitleMetaDescription();
     if ($description) {
         $wgOut->addMeta('description', $description);
     }
     $keywords = ArticleMetaInfo::getCurrentTitleMetaKeywords();
     if ($keywords) {
         $wgOut->mKeywords = array();
         $wgOut->addMeta('keywords', $keywords);
     }
     ArticleMetaInfo::addFacebookMetaProperties($tpl->data['title']);
     ArticleMetaInfo::addTwitterMetaProperties();
     if ($wgOut->isSyndicated()) {
         $feeds = array();
         foreach ($wgFeedClasses as $format => $class) {
             $feeds[$format] = array('text' => $format, 'href' => $wgRequest->appendQuery("feed={$format}"), 'ttip' => wfMessage('tooltip-' . $format)->text());
         }
         $tpl->setRef('feeds', $feeds);
     } else {
         $tpl->set('feeds', false);
     }
     $tpl->setRef('mimetype', $wgMimeType);
     $tpl->setRef('charset', $wgOutputEncoding);
     $tpl->set('headlinks', $out->getHeadLinks());
     $tpl->setRef('wgScript', $wgScript);
     $tpl->setRef('skinname', $this->skinname);
     $tpl->setRef('stylename', $this->stylename);
     $tpl->setRef('loggedin', $this->loggedin);
     $tpl->set('nsclass', 'ns-' . $wgTitle->getNamespace());
     $tpl->set('notspecialpage', $wgTitle->getNamespace() != NS_SPECIAL);
     /* XXX currently unused, might get useful later
     		$tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
     		$tpl->set( "exists", $wgTitle->getArticleID() != 0 );
     		$tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
     		$tpl->set( "protect", count($wgTitle->isProtected()) ? "unprotect" : "protect" );
     		$tpl->set( "helppage", wfMessage('helppage')->text());
     		*/
     $tpl->set('searchaction', $this->escapeSearchLink());
     $tpl->set('search', trim($wgRequest->getVal('search')));
     $tpl->setRef('stylepath', $wgStylePath);
     $tpl->setRef('logopath', $wgLogo);
     $tpl->setRef("lang", $wgContLanguageCode);
     $tpl->set('dir', $wgContLang->isRTL() ? "rtl" : "ltr");
     $tpl->set('rtl', $wgContLang->isRTL());
     $tpl->set('langname', $wgContLang->getLanguageName($wgContLanguageCode));
     $tpl->setRef('username', $this->username);
     $tpl->setRef('userpage', $this->userpage);
     $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']);
     $tpl->setRef('usercss', $this->usercss);
     $tpl->setRef('userjs', $this->userjs);
     $tpl->setRef('userjsprev', $this->userjsprev);
     if ($this->iseditable && $wgUser->getOption('editsectiononrightclick')) {
         $tpl->set('body_onload', 'setupRightClickEdit()');
     } else {
         $tpl->set('body_onload', false);
     }
     global $wgUseSiteJs;
     if ($wgUseSiteJs) {
         if ($this->loggedin) {
             $tpl->set('jsvarurl', $this->makeUrl($this->userpage . '/-', 'action=raw&gen=js&maxage=' . $wgSquidMaxage));
         } else {
             $tpl->set('jsvarurl', $this->makeUrl('-', 'action=raw&gen=js'));
         }
     } else {
         $tpl->set('jsvarurl', false);
     }
     wfProfileOut("{$fname}-stuff2");
     wfProfileIn("{$fname}-stuff3");
     $tpl->setRef('newtalk', $ntl);
     $tpl->setRef('skin', $this);
     $tpl->set('logo', $this->logoText());
     if ($wgOut->isArticle() and (!isset($oldid) or isset($diff)) and $this->getContext()->canUseWikiPage() && 0 != $this->getContext()->getWikiPage()->getId()) {
         if (!$wgDisableCounters) {
             $viewcount = $this->getContext()->getWikiPage()->getCount();
             if ($viewcount) {
                 $tpl->set('viewcount', wfMessage("viewcount", $viewcount)->text());
             } else {
                 $tpl->set('viewcount', false);
             }
         } else {
             $tpl->set('viewcount', false);
         }
         $tpl->set('lastmod', $this->lastModified());
         $tpl->set('copyright', $this->getCopyright());
         $this->credits = false;
         if (isset($wgMaxCredits) && $wgMaxCredits != 0) {
             require_once "{$IP}/includes/Credits.php";
             $this->credits = getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax);
         }
         $tpl->setRef('credits', $this->credits);
     } elseif (isset($oldid) && !isset($diff)) {
         $tpl->set('copyright', $this->getCopyright());
         $tpl->set('viewcount', false);
         $tpl->set('lastmod', false);
         $tpl->set('credits', false);
     } else {
         $tpl->set('copyright', false);
         $tpl->set('viewcount', false);
         $tpl->set('lastmod', false);
         $tpl->set('credits', false);
     }
     wfProfileOut("{$fname}-stuff3");
     wfProfileIn("{$fname}-stuff4");
     $tpl->set('copyrightico', $this->getCopyrightIcon());
     $tpl->set('poweredbyico', $this->getPoweredBy());
     $tpl->set('disclaimer', $this->disclaimerLink());
     $tpl->set('about', $this->aboutLink());
     $tpl->setRef('debug', $out->mDebugtext);
     //$out->addHTML($printfooter);
     $tpl->set('bottomscripts', $this->bottomScripts());
     if ($wgTitle->getNamespace() == NS_USER && $wgUser->getId() == 0 && !UserPagePolicy::isGoodUserPage($wgTitle->getDBKey())) {
         $txt = $out->parse(wfMessage('noarticletext_user')->text());
         $tpl->setRef('bodytext', $txt);
         header('HTTP/1.1 404 Not Found');
     } else {
         if (!is_null($out)) {
             $tpl->setRef('bodytext', $out->getHTML());
         }
     }
     # Language links
     $language_urls = array();
     if (!$wgHideInterlanguageLinks) {
         foreach ($wgOut->getLanguageLinks() as $l) {
             $tmp = explode(':', $l, 2);
             $class = 'interwiki-' . $tmp[0];
             $code = $tmp[0];
             $lTitle = $tmp[1];
             unset($tmp);
             $nt = Title::newFromText($l);
             $language = $wgContLang->fetchLanguageName($nt->getInterwiki(), $wgLanguageCode);
             $language_urls[] = array('code' => $code, 'href' => $nt->getFullURL(), 'text' => $lTitle, 'class' => $class, 'language' => ($language != '' ? Misc::capitalize($language) : $l) . ": ");
         }
     }
     if (count($language_urls)) {
         $tpl->setRef('language_urls', $language_urls);
     } else {
         $tpl->set('language_urls', false);
     }
     wfProfileOut("{$fname}-stuff4");
     # Personal toolbar
     //$tpl->set('personal_urls', $this->buildPersonalUrls());
     /*$content_actions = $this->buildContentActionUrls();
     		$tpl->setRef('content_actions', $content_actions);
     
     		// XXX: attach this from javascript, same with section editing
     		if($this->iseditable && $wgUser->getOption("editondblclick") ) {
     			$tpl->set('body_ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
     		} else {
     			$tpl->set('body_ondblclick', false);
     		}
     		*/
     //$tpl->set( 'navigation_urls', $this->buildNavigationUrls() );
     //$tpl->set( 'nav_urls', $this->buildNavUrls() );
     // execute template
     wfProfileIn("{$fname}-execute");
     $res = $tpl->execute();
     wfProfileOut("{$fname}-execute");
     // result may be an error
     $this->printOrError($res);
     wfProfileOut($fname);
 }
예제 #2
0
 public function displayHtml()
 {
     global $IP, $wgTitle, $wgOut, $wgUser, $wgRequest, $wgContLanguageCode;
     global $wgLang, $wgContLang, $wgXhtmlDefaultNamespace;
     $sk = new SkinWikihowskin();
     $articleName = $wgTitle->getText();
     $partialUrl = $wgTitle->getPartialURL();
     $isMainPage = $articleName == wfMsg('mainpage');
     $action = $wgRequest->getVal('action', 'view');
     //$lang = $this->getSiteLanguage();
     //$deviceOpts = $this->getDevice();
     $pageExists = $wgTitle->exists();
     $randomUrl = '/' . wfMsg('special-randomizer');
     $titleBar = wfMsg('pagetitle', $articleName);
     $canonicalUrl = 'http://' . $IP . '/' . $wgTitle->getPartialURL();
     $rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
     $head_element = "<html xmlns:fb=\"https://www.facebook.com/2008/fbml\" xmlns=\"{$wgXhtmlDefaultNamespace}\" xml:lang=\"{$wgContLanguageCode}\" lang=\"{$wgContLanguageCode}\" {$rtl}>\n";
     $css = '/extensions/min/f/skins/WikiHow/new.css,extensions/wikihow/common/jquery-ui-themes/jquery-ui.css,extensions/wikihow/gallery/prettyPhoto-3.12/src/prettyPhoto.css,extensions/wikihow/NewLayout/Layout_03.css';
     if ($wgUser->getID() > 0) {
         $css .= ',/skins/WikiHow/loggedin.css';
     }
     $css .= '?' . WH_SITEREV;
     $css = wfGetPad($css);
     if ($wgIsDomainTest) {
         $base_href = '<base href="http://www.wikihow.com/" />';
     } else {
         $base_href = '';
     }
     $out = new OutputPage();
     $headlinks = $out->getHeadLinks();
     if (!$wgIsDomainTest) {
         $canonicalUrl = '<link rel="canonical" href="' . $wgTitle->getFullURL() . '" />';
     }
     //get login/sign up stuff
     $login = "";
     $li = $wgLang->specialPage("Userlogin");
     $lo = $wgLang->specialPage("Userlogout");
     $rt = $wgTitle->getPrefixedURL();
     if (0 == strcasecmp(urlencode($lo), $rt)) {
         $q = "";
     } else {
         $q = "returnto={$rt}";
     }
     if ($wgUser->getID()) {
         $uname = $wgUser->getName();
         if (strlen($uname) > 16) {
             $uname = substr($uname, 0, 16) . "...";
         }
         $login = wfMsg('welcome_back', $wgUser->getUserPage()->getFullURL(), $uname);
         if ($wgLanguageCode == 'en' && $wgUser->isFacebookUser()) {
             $login = wfMsg('welcome_back_fb', $wgUser->getUserPage()->getFullURL(), $wgUser->getName());
         }
     } else {
         $login = wfMsg('signup_or_login', $q) . " " . wfMsg('facebook_connect_header', wfGetPad("/skins/WikiHow/images/facebook_share_icon.gif"));
     }
     if ($wgUser->getID() > 0) {
         $helplink = $sk->makeLinkObj(Title::makeTitle(NS_CATEGORY, wfMsg('help')), wfMsg('help'));
         $logoutlink = $sk->makeLinkObj(Title::makeTitle(NS_SPECIAL, 'Userlogout'), wfMsg('logout'));
         $login .= " | " . $helplink . " | " . $logoutlink;
     }
     $headerVars = array('title' => $titleBar, 'head_element' => $head_element, 'base_href' => $base_href, 'globalvar_script' => Skin::makeGlobalVariablesScript($this->data), 'css' => $css, 'headlinks' => $headlinks, 'canon' => $canonicalUrl, 'headitems' => $wgOut->getHeadItems(), 'login' => $login);
     if ($wgUser->getID() > 0) {
         $footer_links = wfMsgExt('site_footer_new', 'parse');
     } else {
         $footer_links = wfMsgExt('site_footer_new_anon', 'parse');
     }
     if ($wgUser->getID() > 0 || $isMainPage) {
         $sub_foot = wfMsg('sub_footer_new', wfGetPad(), wfGetPad());
     } else {
         $sub_foot = wfMsg('sub_footer_new_anon', wfGetPad(), wfGetPad());
     }
     $footerVars = array('footer_links' => $footer_links, 'search' => GoogSearch::getSearchBox("cse-search-box-footer") . '<br />', 'cat_list' => $sk->getCategoryList(), 'sub_foot' => $sub_foot, 'footertail' => $this->getFooterTail());
     $article = $wgOut->getHTML();
     $wgOut->clearHTML();
     //parse that article text
     $article = call_user_func('self::parseArticle_' . self::ARTICLE_LAYOUT, $article);
     $wgOut->addHTML(EasyTemplate::html('header_' . self::ARTICLE_LAYOUT . '.tmpl.php', $headerVars));
     $wgOut->addHTML($article);
     $wgOut->addHTML(EasyTemplate::html('footer_' . self::ARTICLE_LAYOUT . '.tmpl.php', $footerVars));
     print $wgOut->getHTML();
 }