function pageStats() { global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser; global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgTitle, $wgPageShowWatchingUsers; $oldid = $wgRequest->getVal('oldid'); $diff = $wgRequest->getVal('diff'); if (!$wgOut->isArticle()) { return ''; } if (!$wgArticle instanceof Article) { return ''; } if (isset($oldid) || isset($diff)) { return ''; } if (0 == $wgArticle->getID()) { return ''; } $s = ''; if (!$wgDisableCounters) { $count = $wgLang->formatNum($wgArticle->getCount()); if ($count) { $s = wfMsgExt('viewcount', array('parseinline'), $count); } } if ($wgMaxCredits != 0) { $s .= ' ' . Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $s .= $this->lastModified(); } if ($wgPageShowWatchingUsers && $wgUser->getOption('shownumberswatching')) { $dbr = wfGetDB(DB_SLAVE); $watchlist = $dbr->tableName('watchlist'); $sql = "SELECT COUNT(*) AS n FROM {$watchlist}\n\t\t\t\tWHERE wl_title='" . $dbr->strencode($wgTitle->getDBkey()) . "' AND wl_namespace=" . $wgTitle->getNamespace(); $res = $dbr->query($sql, 'Skin::pageStats'); $x = $dbr->fetchObject($res); $s .= ' ' . wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($x->n)); } return $s . ' ' . $this->getCopyright(); }
/** * initialize various variables and generate the template * * @param $out OutputPage */ function outputPage(OutputPage $out) { global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgContLang; global $wgScript, $wgStylePath, $wgContLanguageCode; global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces; global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; global $wgUseTrackbacks, $wgUseSiteJs; global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames; wfProfileIn(__METHOD__); $oldid = $wgRequest->getVal('oldid'); $diff = $wgRequest->getVal('diff'); wfProfileIn(__METHOD__ . "-init"); $this->initPage($out); $this->setMembers(); $tpl = $this->setupTemplate($this->template, 'skins'); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); #} wfProfileOut(__METHOD__ . "-init"); wfProfileIn(__METHOD__ . "-stuff"); $this->thispage = $this->mTitle->getPrefixedDbKey(); $this->thisurl = $this->mTitle->getPrefixedURL(); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL; $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); if ($wgUser->isLoggedIn() || $this->showIPinHeader()) { $this->userpageUrlDetails = self::makeUrlDetails($this->userpage); } else { # This won't be used in the standard skins, but we define it to preserve the interface # To save time, we check for existence $this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage); } $this->userjs = $this->userjsprev = false; $this->setupUserCss($out); $this->setupUserJs($out->isUserJsAllowed()); $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut(__METHOD__ . "-stuff"); wfProfileIn(__METHOD__ . "-stuff2"); $tpl->set('title', $out->getPageTitle()); $tpl->set('pagetitle', $out->getHTMLTitle()); $tpl->set('displaytitle', $out->mPageLinkTitle); $tpl->set('pageclass', $this->getPageClasses($this->mTitle)); $tpl->set('skinnameclass', "skin-" . Sanitizer::escapeClass($this->getSkinName())); $nsname = isset($wgCanonicalNamespaceNames[$this->mTitle->getNamespace()]) ? $wgCanonicalNamespaceNames[$this->mTitle->getNamespace()] : $this->mTitle->getNsText(); $tpl->set('nscanonical', $nsname); $tpl->set('nsnumber', $this->mTitle->getNamespace()); $tpl->set('titleprefixeddbkey', $this->mTitle->getPrefixedDBKey()); $tpl->set('titletext', $this->mTitle->getText()); $tpl->set('articleid', $this->mTitle->getArticleId()); $tpl->set('currevisionid', isset($wgArticle) ? $wgArticle->getLatest() : 0); $tpl->set('isarticle', $out->isArticle()); $tpl->setRef("thispage", $this->thispage); $subpagestr = $this->subPageSubtitle(); $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle()); $undelete = $this->getUndeleteLink(); $tpl->set("undelete", !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : ''); $tpl->set('catlinks', $this->getCategories()); if ($out->isSyndicated()) { $feeds = array(); foreach ($out->getSyndicationLinks() as $format => $link) { $feeds[$format] = array('text' => wfMsg("feed-{$format}"), 'href' => $link); } $tpl->setRef('feeds', $feeds); } else { $tpl->set('feeds', false); } if ($wgUseTrackbacks && $out->isArticleRelated()) { $tpl->set('trackbackhtml', $wgTitle->trackbackRDF()); } else { $tpl->set('trackbackhtml', null); } $tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace); $tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces); $tpl->setRef('mimetype', $wgMimeType); $tpl->setRef('jsmimetype', $wgJsMimeType); $tpl->setRef('charset', $wgOutputEncoding); $tpl->set('headlinks', $out->getHeadLinks()); $tpl->set('headscripts', $out->getScript()); $tpl->set('csslinks', $out->buildCssLinks()); $tpl->setRef('wgScript', $wgScript); $tpl->setRef('skinname', $this->skinname); $tpl->set('skinclass', get_class($this)); $tpl->setRef('stylename', $this->stylename); $tpl->set('printable', $wgRequest->getBool('printable')); $tpl->set('handheld', $wgRequest->getBool('handheld')); $tpl->setRef('loggedin', $this->loggedin); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); $tpl->set( "exists", $this->mTitle->getArticleID() != 0 ); $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" ); $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" ); $tpl->set( "helppage", wfMsg('helppage')); */ $tpl->set('searchaction', $this->escapeSearchLink()); $tpl->set('search', trim($wgRequest->getVal('search'))); $tpl->setRef('stylepath', $wgStylePath); $tpl->setRef('articlepath', $wgArticlePath); $tpl->setRef('scriptpath', $wgScriptPath); $tpl->setRef('serverurl', $wgServer); $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->set('showjumplinks', $wgUser->getOption('showjumplinks')); $tpl->set('username', $wgUser->isAnon() ? NULL : $this->username); $tpl->setRef('userpage', $this->userpage); $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']); $tpl->set('userlang', $wgLang->getCode()); $tpl->set('pagecss', $this->setupPageCss()); $tpl->setRef('usercss', $this->usercss); $tpl->setRef('userjs', $this->userjs); $tpl->setRef('userjsprev', $this->userjsprev); if ($wgUseSiteJs) { $jsCache = $this->loggedin ? '&smaxage=0' : ''; $tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName()))); } else { $tpl->set('jsvarurl', false); } $newtalks = $wgUser->getNewMessageLinks(); if (count($newtalks) == 1 && $newtalks[0]["wiki"] === wfWikiID()) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); if (!$usertalktitle->equals($this->mTitle)) { $ntl = wfMsg('youhavenewmessages', $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessageslink'), 'redirect=no'), $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessagesdifflink'), 'diff=cur')); # Disable Cache $out->setSquidMaxage(0); } } else { if (count($newtalks)) { $sep = str_replace("_", " ", wfMsgHtml("newtalkseparator")); $msgs = array(); foreach ($newtalks as $newtalk) { $msgs[] = Xml::element("a", array('href' => $newtalk["link"]), $newtalk["wiki"]); } $parts = implode($sep, $msgs); $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts); $out->setSquidMaxage(0); } else { $ntl = ''; } } wfProfileOut(__METHOD__ . "-stuff2"); wfProfileIn(__METHOD__ . "-stuff3"); $tpl->setRef('newtalk', $ntl); $tpl->setRef('skin', $this); $tpl->set('logo', $this->logoText()); if ($out->isArticle() and (!isset($oldid) or isset($diff)) and $wgArticle and 0 != $wgArticle->getID()) { if (!$wgDisableCounters) { $viewcount = $wgLang->formatNum($wgArticle->getCount()); if ($viewcount) { $tpl->set('viewcount', wfMsgExt('viewcount', array('parseinline'), $viewcount)); } else { $tpl->set('viewcount', false); } } else { $tpl->set('viewcount', false); } if ($wgPageShowWatchingUsers) { $dbr = wfGetDB(DB_SLAVE); $watchlist = $dbr->tableName('watchlist'); $sql = "SELECT COUNT(*) AS n FROM {$watchlist}\n\t\t\t\t\tWHERE wl_title='" . $dbr->strencode($this->mTitle->getDBkey()) . "' AND wl_namespace=" . $this->mTitle->getNamespace(); $res = $dbr->query($sql, 'SkinTemplate::outputPage'); $x = $dbr->fetchObject($res); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { $tpl->set('numberofwatchingusers', wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($numberofwatchingusers))); } else { $tpl->set('numberofwatchingusers', false); } } else { $tpl->set('numberofwatchingusers', false); } $tpl->set('copyright', $this->getCopyright()); $this->credits = false; if ($wgMaxCredits != 0) { $this->credits = Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $tpl->set('lastmod', $this->lastModified()); } $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); $tpl->set('numberofwatchingusers', false); } else { $tpl->set('copyright', false); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } wfProfileOut(__METHOD__ . "-stuff3"); wfProfileIn(__METHOD__ . "-stuff4"); $tpl->set('copyrightico', $this->getCopyrightIcon()); $tpl->set('poweredbyico', $this->getPoweredBy()); $tpl->set('disclaimer', $this->disclaimerLink()); $tpl->set('privacy', $this->privacyLink()); $tpl->set('about', $this->aboutLink()); $tpl->setRef('debug', $out->mDebugtext); $tpl->set('reporttime', wfReportTime()); $tpl->set('sitenotice', wfGetSiteNotice()); $tpl->set('bottomscripts', $this->bottomScripts()); $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n"; $out->mBodytext .= $printfooter; $tpl->setRef('bodytext', $out->mBodytext); # Language links $language_urls = array(); if (!$wgHideInterlanguageLinks) { foreach ($out->getLanguageLinks() as $l) { $tmp = explode(':', $l, 2); $class = 'interwiki-' . $tmp[0]; unset($tmp); $nt = Title::newFromText($l); if ($nt) { $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'class' => $class); } } } if (count($language_urls)) { $tpl->setRef('language_urls', $language_urls); } else { $tpl->set('language_urls', false); } wfProfileOut(__METHOD__ . "-stuff4"); wfProfileIn(__METHOD__ . "-stuff5"); # 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")) { $encEditUrl = Xml::escapeJsString($this->mTitle->getLocalUrl($this->editUrlOptions())); $tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";'); } else { $tpl->set('body_ondblclick', false); } $tpl->set('body_onload', false); $tpl->set('sidebar', $this->buildSidebar()); $tpl->set('nav_urls', $this->buildNavUrls()); // original version by hansm if (!wfRunHooks('SkinTemplateOutputPageBeforeExec', array(&$this, &$tpl))) { wfDebug(__METHOD__ . ': Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!'); } // allow extensions adding stuff after the page content. // See Skin::afterContentHook() for further documentation. $tpl->set('dataAfterContent', $this->afterContentHook()); wfProfileOut(__METHOD__ . "-stuff5"); // execute template wfProfileIn(__METHOD__ . "-execute"); $res = $tpl->execute(); wfProfileOut(__METHOD__ . "-execute"); // result may be an error $this->printOrError($res); wfProfileOut(__METHOD__); }
/** * Perform one of the "standard" actions * * @param $output OutputPage * @param $article Article * @param $title Title * @param $user User * @param $request WebRequest */ function performAction(&$output, &$article, &$title, &$user, &$request) { wfProfileIn(__METHOD__); if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request, $this))) { wfProfileOut(__METHOD__); return; } $action = $this->getVal('Action'); if (in_array($action, $this->getVal('DisabledActions', array()))) { /* No such action; this will switch to the default case */ $action = 'nosuchaction'; } // Workaround for bug #20966: inability of IE to provide an action dependent // on which submit button is clicked. if ($action === 'historysubmit') { if ($request->getBool('revisiondelete')) { $action = 'revisiondelete'; } else { $action = 'view'; } } switch ($action) { case 'view': $output->setSquidMaxage($this->getVal('SquidMaxage')); $article->view(); break; case 'raw': // includes JS/CSS wfProfileIn(__METHOD__ . '-raw'); $raw = new RawPage($article); $raw->view(); wfProfileOut(__METHOD__ . '-raw'); break; case 'watch': case 'unwatch': case 'delete': case 'revert': case 'rollback': case 'protect': case 'unprotect': case 'info': case 'markpatrolled': case 'render': case 'deletetrackback': case 'purge': $article->{$action}(); break; case 'print': $article->view(); break; case 'dublincore': if (!$this->getVal('EnableDublinCoreRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nodublincore')); } else { $rdf = new DublinCoreRdf($article); $rdf->show(); } break; case 'creativecommons': if (!$this->getVal('EnableCreativeCommonsRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nocreativecommons')); } else { $rdf = new CreativeCommonsRdf($article); $rdf->show(); } break; case 'credits': Credits::showPage($article); break; case 'submit': if (session_id() == '') { /* Send a cookie so anons get talk message notifications */ wfSetupSession(); } /* Continue... */ /* Continue... */ case 'edit': case 'editredlink': if (wfRunHooks('CustomEditor', array($article, $user))) { $internal = $request->getVal('internaledit'); $external = $request->getVal('externaledit'); $section = $request->getVal('section'); $oldid = $request->getVal('oldid'); if (!$this->getVal('UseExternalEditor') || $action == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) { $editor = new EditPage($article); $editor->submit(); } elseif ($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) { $mode = $request->getVal('mode'); $extedit = new ExternalEdit($article, $mode); $extedit->edit(); } } break; case 'history': if ($request->getFullRequestURL() == $title->getInternalURL('action=history')) { $output->setSquidMaxage($this->getVal('SquidMaxage')); } $history = new HistoryPage($article); $history->history(); break; case 'revisiondelete': // For show/hide submission from history page $special = SpecialPage::getPage('Revisiondelete'); $special->execute(''); break; default: if (wfRunHooks('UnknownAction', array($action, $article))) { $output->showErrorPage('nosuchaction', 'nosuchactiontext'); } } wfProfileOut(__METHOD__); }
/** * initialize various variables and generate the template * * @param $out OutputPage */ function outputPage(OutputPage $out) { global $wgArticle, $wgUser, $wgLang, $wgContLang; global $wgScript, $wgStylePath, $wgContLanguageCode; global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest; global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version; global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments; global $wgArticlePath, $wgScriptPath, $wgServer; wfProfileIn(__METHOD__); $oldid = $wgRequest->getVal('oldid'); $diff = $wgRequest->getVal('diff'); $action = $wgRequest->getVal('action', 'view'); wfProfileIn(__METHOD__ . '-init'); $this->initPage($out); $this->setMembers(); $tpl = $this->setupTemplate($this->template, 'skins'); #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText $tpl->setTranslator(new MediaWiki_I18N()); #} wfProfileOut(__METHOD__ . '-init'); wfProfileIn(__METHOD__ . '-stuff'); $this->thispage = $this->mTitle->getPrefixedDBkey(); $this->thisurl = $this->mTitle->getPrefixedURL(); $query = array(); if (!$wgRequest->wasPosted()) { $query = $wgRequest->getValues(); unset($query['title']); unset($query['returnto']); unset($query['returntoquery']); } $this->thisquery = wfUrlencode(wfArrayToCGI($query)); $this->loggedin = $wgUser->isLoggedIn(); $this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL; $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit')); $this->username = $wgUser->getName(); if ($wgUser->isLoggedIn() || $this->showIPinHeader()) { $this->userpageUrlDetails = self::makeUrlDetails($this->userpage); } else { # This won't be used in the standard skins, but we define it to preserve the interface # To save time, we check for existence $this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage); } $this->titletxt = $this->mTitle->getPrefixedText(); wfProfileOut(__METHOD__ . '-stuff'); wfProfileIn(__METHOD__ . '-stuff-head'); if ($this->useHeadElement) { $pagecss = $this->setupPageCss(); if ($pagecss) { $out->addInlineStyle($pagecss); } } else { $this->setupUserCss($out); $tpl->set('pagecss', $this->setupPageCss()); $tpl->setRef('usercss', $this->usercss); $this->userjs = $this->userjsprev = false; $this->setupUserJs($out->isUserJsAllowed()); $tpl->setRef('userjs', $this->userjs); $tpl->setRef('userjsprev', $this->userjsprev); if ($wgUseSiteJs) { $jsCache = $this->loggedin ? '&smaxage=0' : ''; $tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName()))); } else { $tpl->set('jsvarurl', false); } $tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace); $tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces); $tpl->set('html5version', $wgHtml5Version); $tpl->set('headlinks', $out->getHeadLinks()); $tpl->set('csslinks', $out->buildCssLinks()); if ($wgUseTrackbacks && $out->isArticleRelated()) { $tpl->set('trackbackhtml', $out->getTitle()->trackbackRDF()); } else { $tpl->set('trackbackhtml', null); } } wfProfileOut(__METHOD__ . '-stuff-head'); wfProfileIn(__METHOD__ . '-stuff2'); $tpl->set('title', $out->getPageTitle()); $tpl->set('pagetitle', $out->getHTMLTitle()); $tpl->set('displaytitle', $out->mPageLinkTitle); $tpl->set('pageclass', $this->getPageClasses($this->mTitle)); $tpl->set('skinnameclass', 'skin-' . Sanitizer::escapeClass($this->getSkinName())); $nsname = MWNamespace::exists($this->mTitle->getNamespace()) ? MWNamespace::getCanonicalName($this->mTitle->getNamespace()) : $this->mTitle->getNsText(); $tpl->set('nscanonical', $nsname); $tpl->set('nsnumber', $this->mTitle->getNamespace()); $tpl->set('titleprefixeddbkey', $this->mTitle->getPrefixedDBKey()); $tpl->set('titletext', $this->mTitle->getText()); $tpl->set('articleid', $this->mTitle->getArticleId()); $tpl->set('currevisionid', isset($wgArticle) ? $wgArticle->getLatest() : 0); $tpl->set('isarticle', $out->isArticle()); $tpl->setRef('thispage', $this->thispage); $subpagestr = $this->subPageSubtitle(); $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle()); $undelete = $this->getUndeleteLink(); $tpl->set('undelete', !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : ''); $tpl->set('catlinks', $this->getCategories()); if ($out->isSyndicated()) { $feeds = array(); foreach ($out->getSyndicationLinks() as $format => $link) { $feeds[$format] = array('text' => wfMsg("feed-{$format}"), 'href' => $link); } $tpl->setRef('feeds', $feeds); } else { $tpl->set('feeds', false); } $tpl->setRef('mimetype', $wgMimeType); $tpl->setRef('jsmimetype', $wgJsMimeType); $tpl->setRef('charset', $wgOutputEncoding); $tpl->setRef('wgScript', $wgScript); $tpl->setRef('skinname', $this->skinname); $tpl->set('skinclass', get_class($this)); $tpl->setRef('stylename', $this->stylename); $tpl->set('printable', $out->isPrintable()); $tpl->set('handheld', $wgRequest->getBool('handheld')); $tpl->setRef('loggedin', $this->loggedin); $tpl->set('notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL); /* XXX currently unused, might get useful later $tpl->set( "editable", ($this->mTitle->getNamespace() != NS_SPECIAL ) ); $tpl->set( "exists", $this->mTitle->getArticleID() != 0 ); $tpl->set( "watch", $this->mTitle->userIsWatching() ? "unwatch" : "watch" ); $tpl->set( "protect", count($this->mTitle->isProtected()) ? "unprotect" : "protect" ); $tpl->set( "helppage", wfMsg('helppage')); */ $tpl->set('searchaction', $this->escapeSearchLink()); $tpl->set('searchtitle', SpecialPage::getTitleFor('Search')->getPrefixedDBKey()); $tpl->set('search', trim($wgRequest->getVal('search'))); $tpl->setRef('stylepath', $wgStylePath); $tpl->setRef('articlepath', $wgArticlePath); $tpl->setRef('scriptpath', $wgScriptPath); $tpl->setRef('serverurl', $wgServer); $tpl->setRef('logopath', $wgLogo); $tpl->setRef('lang', $wgContLanguageCode); $tpl->set('dir', $wgContLang->getDir()); $tpl->set('rtl', $wgContLang->isRTL()); $tpl->set('capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : ''); $tpl->set('langname', $wgContLang->getLanguageName($wgContLanguageCode)); $tpl->set('showjumplinks', $wgUser->getOption('showjumplinks')); $tpl->set('username', $wgUser->isAnon() ? null : $this->username); $tpl->setRef('userpage', $this->userpage); $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']); $tpl->set('userlang', $wgLang->getCode()); // Users can have their language set differently than the // content of the wiki. For these users, tell the web browser // that interface elements are in a different language. $tpl->set('userlangattributes', ''); $tpl->set('specialpageattributes', ''); $lang = $wgLang->getCode(); $dir = $wgLang->getDir(); if ($lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir()) { $attrs = " lang='{$lang}' dir='{$dir}'"; $tpl->set('userlangattributes', $attrs); // The content of SpecialPages should be presented in the // user's language. Content of regular pages should not be touched. if ($this->mTitle->isSpecialPage()) { $tpl->set('specialpageattributes', $attrs); } } $newtalks = $wgUser->getNewMessageLinks(); $ntl = ''; if (count($newtalks) == 1 && $newtalks[0]['wiki'] === wfWikiID()) { $usertitle = $this->mUser->getUserPage(); $usertalktitle = $usertitle->getTalkPage(); if (!$usertalktitle->equals($this->mTitle)) { $newmessageslink = $this->link($usertalktitle, wfMsgHtml('newmessageslink'), array(), array('redirect' => 'no'), array('known', 'noclasses')); $newmessagesdifflink = $this->link($usertalktitle, wfMsgHtml('newmessagesdifflink'), array(), array('diff' => 'cur'), array('known', 'noclasses')); $ntl = wfMsg('youhavenewmessages', $newmessageslink, $newmessagesdifflink); # Disable Cache $out->setSquidMaxage(0); } } else { if (count($newtalks)) { // _>" " for BC <= 1.16 $sep = str_replace('_', ' ', wfMsgHtml('newtalkseparator')); $msgs = array(); foreach ($newtalks as $newtalk) { $msgs[] = Xml::element('a', array('href' => $newtalk['link']), $newtalk['wiki']); } $parts = implode($sep, $msgs); $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts); $out->setSquidMaxage(0); } } wfProfileOut(__METHOD__ . '-stuff2'); wfProfileIn(__METHOD__ . '-stuff3'); $tpl->setRef('newtalk', $ntl); $tpl->setRef('skin', $this); $tpl->set('logo', $this->logoText()); if ($out->isArticle() and (!isset($oldid) or isset($diff)) and $wgArticle and 0 != $wgArticle->getID()) { if (!$wgDisableCounters) { $viewcount = $wgLang->formatNum($wgArticle->getCount()); if ($viewcount) { $tpl->set('viewcount', wfMsgExt('viewcount', array('parseinline'), $viewcount)); } else { $tpl->set('viewcount', false); } } else { $tpl->set('viewcount', false); } if ($wgPageShowWatchingUsers) { $dbr = wfGetDB(DB_SLAVE); $watchlist = $dbr->tableName('watchlist'); $res = $dbr->select('watchlist', array('COUNT(*) AS n'), array('wl_title' => $dbr->strencode($this->mTitle->getDBkey()), 'wl_namespace' => $this->mTitle->getNamespace()), __METHOD__); $x = $dbr->fetchObject($res); $numberofwatchingusers = $x->n; if ($numberofwatchingusers > 0) { $tpl->set('numberofwatchingusers', wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($numberofwatchingusers))); } else { $tpl->set('numberofwatchingusers', false); } } else { $tpl->set('numberofwatchingusers', false); } $tpl->set('copyright', $this->getCopyright()); $this->credits = false; if ($wgMaxCredits != 0) { $this->credits = Credits::getCredits($wgArticle, $wgMaxCredits, $wgShowCreditsIfMax); } else { $tpl->set('lastmod', $this->lastModified()); } $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); $tpl->set('numberofwatchingusers', false); } else { $tpl->set('copyright', false); $tpl->set('viewcount', false); $tpl->set('lastmod', false); $tpl->set('credits', false); $tpl->set('numberofwatchingusers', false); } wfProfileOut(__METHOD__ . '-stuff3'); wfProfileIn(__METHOD__ . '-stuff4'); $tpl->set('copyrightico', $this->getCopyrightIcon()); $tpl->set('poweredbyico', $this->getPoweredBy()); $tpl->set('disclaimer', $this->disclaimerLink()); $tpl->set('privacy', $this->privacyLink()); $tpl->set('about', $this->aboutLink()); if ($wgDebugComments) { $tpl->setRef('debug', $out->mDebugtext); } else { $tpl->set('debug', ''); } $tpl->set('reporttime', wfReportTime()); $tpl->set('sitenotice', wfGetSiteNotice()); $tpl->set('bottomscripts', $this->bottomScripts()); $printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n"; $out->mBodytext .= $printfooter . $this->generateDebugHTML(); $tpl->setRef('bodytext', $out->mBodytext); # Language links $language_urls = array(); if (!$wgHideInterlanguageLinks) { foreach ($out->getLanguageLinks() as $l) { $tmp = explode(':', $l, 2); $class = 'interwiki-' . $tmp[0]; unset($tmp); $nt = Title::newFromText($l); if ($nt) { $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'class' => $class); } } } if (count($language_urls)) { $tpl->setRef('language_urls', $language_urls); } else { $tpl->set('language_urls', false); } wfProfileOut(__METHOD__ . '-stuff4'); wfProfileIn(__METHOD__ . '-stuff5'); # Personal toolbar $tpl->set('personal_urls', $this->buildPersonalUrls()); $content_actions = $this->buildContentActionUrls(); $tpl->setRef('content_actions', $content_actions); $tpl->set('sidebar', $this->buildSidebar()); $tpl->set('nav_urls', $this->buildNavUrls()); // Set the head scripts near the end, in case the above actions resulted in added scripts if ($this->useHeadElement) { $tpl->set('headelement', $out->headElement($this)); } else { $tpl->set('headscripts', $out->getScript()); } // original version by hansm if (!wfRunHooks('SkinTemplateOutputPageBeforeExec', array(&$this, &$tpl))) { wfDebug(__METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n"); } // allow extensions adding stuff after the page content. // See Skin::afterContentHook() for further documentation. $tpl->set('dataAfterContent', $this->afterContentHook()); wfProfileOut(__METHOD__ . '-stuff5'); // execute template wfProfileIn(__METHOD__ . '-execute'); $res = $tpl->execute(); wfProfileOut(__METHOD__ . '-execute'); // result may be an error $this->printOrError($res); wfProfileOut(__METHOD__); }
$noochCount = Database::selectValue("SELECT nooch FROM content_tracking_users WHERE uni_id=? AND content_id=? LIMIT 1", array(Me::$id, $contentID)); if ($noochCount !== false and $noochCount < 3) { if ($success = Credits::chargeInstant(Me::$id, 0.15, "Assigned a Nooch")) { $contentTrack->nooch(); $noochCount++; } } } echo json_encode(array("content_id" => $contentID, "nooch_count" => (int) $noochCount, "nooch_success" => $success)); exit; case "tip": if (!isset($_POST['amount'])) { echo 'false'; exit; } // Prepare Values $_POST['amount'] = (double) $_POST['amount']; $pass = $_POST['amount'] >= 0.1 ? true : false; // Process the UniJoule exchange if ($pass) { $pass = Credits::exchangeInstant(Me::$id, (int) $authorID, $_POST['amount'], "Tipped by " . Me::$vals['display_name']); } // Track the tip if ($pass and $success = $contentTrack->tip($_POST['amount'])) { echo json_encode(array("content_id" => (int) $contentID, "tip_boost" => floor($_POST['amount'] * 10))); } else { echo 'false'; } exit; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Credits::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function deduct($user_id, $amount, $item_id) { $user_id = (int) $user_id; if (self::checkBalance($user_id, $item_id)) { $transaction = Yii::app()->db->beginTransaction(); $history = new CreditsHistory(); $credit = Credits::model()->find('user_id = :user_id', array(':user_id' => $user_id)); try { $history_data = array('user_id' => $user_id, 'credit_item_id' => $item_id, 'type' => 'deduction', 'value' => $amount); $history->attributes = $history_data; $history->save(); $new_balance = $credit->balance - $amount; $credit_data = array('balance' => $new_balance); $credit->attributes = $credit_data; $credit->save(); $transaction->commit(); } catch (Exception $e) { $transaction->rollback(); } return true; } return false; }
/** * 文档 公共回复 * @author ChenDenlu <*****@*****.**> */ public function reply() { if (is_login()) { $_POST['documentid'] || $this->error('请选择要回复的资讯'); $this->user_replyauth(); $Document = D('Replydocument'); $status = $Document->update($_POST['documentid']); if (true !== $status) { $this->error($status); } else { $uid = session('user_auth.uid'); $Documentuid = M('Document')->where(array('id' => $_POST['documentid']))->getField('uid'); if ($Documentuid != $uid) { Credits::ag_cms_topics_comment($uid, $_POST['documentid'], '评论了一篇内容,ID:' . $_POST['documentid']); } $this->success('回复成功!'); } } else { $this->error('登陆后才能回复哦~'); } }