本文整理汇总了PHP中SiteStats类的典型用法代码示例。如果您正苦于以下问题:PHP SiteStats类的具体用法?PHP SiteStats怎么用?PHP SiteStats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SiteStats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
*/
public function execute($par)
{
global $wgUploadPath, $wgUser, $wgHuijiPrefix;
$templateParser = new TemplateParser(__DIR__ . '/pages');
$out = $this->getOutput();
$user = $this->getUser();
if (!$user->isAllowed('AdminDashboard')) {
$out->permissionRequired('AdminDashboard');
return;
}
// Set the page title, robot policies, etc.
$this->setHeaders();
// Add CSS
$out->addModules('ext.socialprofile.userprofile.css');
$out->addModules('ext.socialprofile.admindashboard.css');
// Add js and message
// $out->addModules( 'skin.bootstrapmediawiki.huiji.getRecordsInterface.js' );
$out->addModules('ext.socialprofile.admindashboard.js');
$out->addModules('ext.socialprofile.userprofile.js');
$output = '';
// Prevent E_NOTICE
$yesterday = date("Y-m-d", strtotime("-1 day"));
$totaledit = SiteStats::edits();
$ueb = new UserEditBox();
$rankInfo = AllSitesInfo::getAllSitesRankData($wgHuijiPrefix, $yesterday);
$usf = new UserSiteFollow();
$follows = $usf->getSiteFollowers('', $wgHuijiPrefix);
// print_r($follows);
$followCount = count($follows);
if ($followCount >= 8) {
$follows = array_slice($follows, 0, 8);
$display = '';
} else {
$display = 'none';
}
$newFollow = array();
foreach ($follows as $value) {
$arr['user_name'] = $value['user_name'];
$userPage = Title::makeTitle(NS_USER, $value['user_name']);
$arr['user_url'] = htmlspecialchars($userPage->getFullURL());
$arr['follow_date'] = wfMessage('comments-time-ago', HuijiFunctions::getTimeAgo(strtotime($value['follow_date'])))->text();
$newFollow[] = $arr;
}
$sentToAll = SpecialPage::getTitleFor('SendToFollowers')->getFullURL();
$showMore = SpecialPage::getTitleFor('EditRank')->getFullURL();
$rightsManage = SpecialPage::getTitleFor('用户权限')->getFullURL();
$blockUsers = SpecialPage::getTitleFor('封禁')->getFullURL();
$freezeUsers = SpecialPage::getTitleFor('解除封禁')->getFullURL();
$replaceText = SpecialPage::getTitleFor('替换文本')->getFullURL();
$siteRankPage = SpecialPage::getTitleFor('SiteRank')->getFullURL();
$allSpecial = SpecialPage::getTitleFor('特殊页面')->getFullURL();
$siteAvatar = (new wSiteAvatar($wgHuijiPrefix, 'l'))->getAvatarHtml();
$token = $user->getEditToken();
if (is_null($newFollow)) {
$newFollow = false;
}
$output .= $templateParser->processTemplate('admin_index', array('siteRank' => isset($rankInfo[0]['site_rank']) ? $rankInfo[0]['site_rank'] : '暂无', 'siteScore' => isset($rankInfo[0]['site_score']) ? $rankInfo[0]['site_score'] : '暂无', 'yesterdayCount' => UserSiteFollow::getFollowerCountOneday($wgHuijiPrefix, $yesterday), 'totalCount' => UserSiteFollow::getFollowerCount($wgHuijiPrefix), 'yesterdayEdit' => $ueb->getSiteEditCount('', $wgHuijiPrefix, $yesterday, $yesterday), 'totalEdit' => $totaledit, 'totalView' => $ueb->getSiteViewCount(-1, $wgHuijiPrefix, '', ''), 'yesterdayView' => $ueb->getSiteViewCount(-1, $wgHuijiPrefix, $yesterday, $yesterday), 'newFollow' => $newFollow, 'sendToAll' => $sentToAll, 'showMore' => $showMore, 'display' => $display, 'rightsManage' => $rightsManage, 'blockUsers' => $blockUsers, 'freezeUsers' => $freezeUsers, 'replaceText' => $replaceText, 'siteRankPage' => $siteRankPage, 'allSpecial' => $allSpecial, 'siteAvatar' => $siteAvatar, 'token' => $token));
$out->addHtml($output);
}
示例2: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
*/
function execute( $par ) {
global $wgOut, $wgUser;
global $wgOpenIDShowUrlOnUserPage;
global $wgOpenIDTrustEmailAddress;
global $wgOpenIDAllowExistingAccountSelection;
global $wgOpenIDAllowNewAccountname;
global $wgOpenIDUseEmailAsNickname;
global $wgOpenIDProposeUsernameFromSREG;
global $wgOpenIDAllowAutomaticUsername;
global $wgOpenIDOnly;
global $wgOpenIDClientOnly;
global $wgOpenIDAllowServingOpenIDUserAccounts;
global $wgOpenIDShowProviderIcons;
if ( !$this->userCanExecute( $wgUser ) ) {
$this->displayRestrictionError();
return;
}
$totalUsers = SiteStats::users();
$OpenIDdistinctUsers = $this->getOpenIDUsers( 'distinctusers' );
$OpenIDUsers = $this->getOpenIDUsers();
$this->setHeaders();
$this->outputHeader();
$wgOut->addWikiMsg( 'openid-dashboard-introduction', 'http://www.mediawiki.org/wiki/Extension:OpenID' );
$wgOut->addHTML(
Html::openElement( 'table', array( 'style' => 'width:50%;', 'class' => 'mw-openiddashboard-table wikitable' ) )
);
# Here we show some basic version infos. Retrieval of SVN revision number of OpenID appears to be too difficult
$out = $this->show( 'OpenID ' . wfMsg( 'version-software-version' ), MEDIAWIKI_OPENID_VERSION );
$out .= $this->show( 'MediaWiki ' . wfMsg( 'version-software-version' ), SpecialVersion::getVersion() );
$out .= $this->show( '$wgOpenIDOnly', $wgOpenIDOnly );
$out .= $this->show( '$wgOpenIDClientOnly', $wgOpenIDClientOnly );
$out .= $this->show( '$wgOpenIDAllowServingOpenIDUserAccounts', $wgOpenIDAllowServingOpenIDUserAccounts );
$out .= $this->show( '$wgOpenIDTrustEmailAddress', $wgOpenIDTrustEmailAddress );
$out .= $this->show( '$wgOpenIDAllowExistingAccountSelection', $wgOpenIDAllowExistingAccountSelection );
$out .= $this->show( '$wgOpenIDAllowAutomaticUsername', $wgOpenIDAllowAutomaticUsername );
$out .= $this->show( '$wgOpenIDAllowNewAccountname', $wgOpenIDAllowNewAccountname );
$out .= $this->show( '$wgOpenIDUseEmailAsNickname', $wgOpenIDUseEmailAsNickname );
$out .= $this->show( '$wgOpenIDProposeUsernameFromSREG', $wgOpenIDProposeUsernameFromSREG );
$out .= $this->show( '$wgOpenIDShowUrlOnUserPage', $wgOpenIDShowUrlOnUserPage );
$out .= $this->show( '$wgOpenIDShowProviderIcons', $wgOpenIDShowProviderIcons );
$out .= $this->show( wfMsgExt( 'statistics-users', array( 'parseinline' ) ), $totalUsers );
$out .= $this->show( wfMsg( 'openid-dashboard-number-openid-users' ), $OpenIDdistinctUsers );
$out .= $this->show( wfMsg( 'openid-dashboard-number-openids-in-database' ), $OpenIDUsers );
$out .= $this->show( wfMsg( 'openid-dashboard-number-users-without-openid' ), $totalUsers - $OpenIDdistinctUsers );
$wgOut->addHTML( $out . Html::closeElement( 'table' ) . "\n" );
}
示例3: wfSpecialStatistics
/**
* constructor
*/
function wfSpecialStatistics()
{
global $wgOut, $wgLang, $wgRequest;
$fname = 'wfSpecialStatistics';
$action = $wgRequest->getVal('action');
$dbr = wfGetDB(DB_SLAVE);
$views = SiteStats::views();
$edits = SiteStats::edits();
$good = SiteStats::articles();
$images = SiteStats::images();
$total = SiteStats::pages();
$users = SiteStats::users();
$admins = $dbr->selectField('user_groups', 'COUNT(*)', array('ug_group' => 'sysop'), $fname);
$numJobs = $dbr->estimateRowCount('job');
if ($action == 'raw') {
$wgOut->disable();
header('Pragma: nocache');
echo "total={$total};good={$good};views={$views};edits={$edits};users={$users};admins={$admins};images={$images};jobs={$numJobs}\n";
return;
} else {
$text = '==' . wfMsg('sitestats') . "==\n";
$text .= wfMsgExt('sitestatstext', array('parsemag'), $wgLang->formatNum($total), $wgLang->formatNum($good), $wgLang->formatNum($views), $wgLang->formatNum($edits), $wgLang->formatNum(sprintf('%.2f', $total ? $edits / $total : 0)), $wgLang->formatNum(sprintf('%.2f', $edits ? $views / $edits : 0)), $wgLang->formatNum($numJobs), $wgLang->formatNum($images));
$text .= "\n==" . wfMsg('userstats') . "==\n";
$text .= wfMsgExt('userstatstext', array('parsemag'), $wgLang->formatNum($users), $wgLang->formatNum($admins), '[[' . wfMsgForContent('grouppage-sysop') . ']]', $wgLang->formatNum(sprintf('%.2f', $admins / $users * 100)), User::makeGroupLinkWiki('sysop'));
$wgOut->addWikiText($text);
global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
if (!$wgDisableCounters && !$wgMiserMode) {
$page = $dbr->tableName('page');
$sql = "SELECT page_namespace, page_title, page_counter FROM {$page} WHERE page_is_redirect = 0 AND page_counter > 0 ORDER BY page_counter DESC";
$sql = $dbr->limitResult($sql, 10, 0);
$res = $dbr->query($sql, $fname);
if ($res) {
$wgOut->addHtml('<h2>' . wfMsgHtml('statistics-mostpopular') . '</h2>');
$skin = $wgUser->getSkin();
$wgOut->addHtml('<ol>');
while ($row = $dbr->fetchObject($res)) {
// BizzWiki begin {{
if (!$wgUser->isAllowed('browse', $row->page_namespace)) {
continue;
}
// BizzWiki end }}
$link = $skin->makeKnownLinkObj(Title::makeTitleSafe($row->page_namespace, $row->page_title));
$dirmark = $wgContLang->getDirMark();
$wgOut->addHtml('<li>' . $link . $dirmark . ' [' . $wgLang->formatNum($row->page_counter) . ']</li>');
}
$wgOut->addHtml('</ol>');
$dbr->freeResult($res);
}
}
$footer = wfMsg('statistics-footer');
if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') {
$wgOut->addWikiText($footer);
}
}
}
示例4: setColorConverters
private function setColorConverters()
{
$expected_number_of_edits_to_white = SiteStats::edits() / SiteStats::articles();
$wiki_color = $this->wikiColor;
$red = hexdec(substr($wiki_color, 0, -4));
$green = hexdec(substr($wiki_color, 2, -2));
$blue = hexdec(substr($wiki_color, -2));
$red_diff = 255 - $red;
$green_diff = 255 - $green;
$blue_diff = 255 - $blue;
$this->redConverter = $red_diff / $expected_number_of_edits_to_white;
$this->greenConverter = $green_diff / $expected_number_of_edits_to_white;
$this->blueConverter = $blue_diff / $expected_number_of_edits_to_white;
}
示例5: WidgetCommunity
function WidgetCommunity($id, $params)
{
global $wgEnableCommunityWidget, $wgTitle;
if (empty($wgEnableCommunityWidget)) {
return '';
}
if ($params['skinname'] != 'oasis') {
return '';
}
if (!class_exists('ActivityFeedHelper')) {
return '';
}
wfProfileIn(__METHOD__);
global $wgUser, $wgLang, $wgLanguageCode, $wgStylePath, $wgEnableMyHomeExt, $wgContentNamespaces;
$total = SiteStats::articles();
/* RT#64490: Strange Article Count in Latest Activity on some new wikis */
if ($total < 0 || $total > 1.0E+18) {
$total = 0;
}
$total = $wgLang->formatNum($total);
$footerButton = array();
if (!empty($wgEnableMyHomeExt)) {
$footerButton['text'] = wfMsg('widget-community-more');
$footerButton['href'] = Skin::makeSpecialUrl($wgUser->isLoggedIn() ? 'MyHome' : 'ActivityFeed');
$footerButton['class'] = 'wikia-button forward';
} else {
$footerButton['text'] = wfMsg('recentchanges');
$footerButton['href'] = Skin::makeSpecialUrl('RecentChanges');
$footerButton['class'] = 'wikia-button forward';
}
$maxElements = 5;
$includeNamespaces = implode('|', $wgContentNamespaces);
$uselang = $wgLang->getCode();
//this should be the same as in /extensions/wikia/MyHome/ActivityFeedHelper.php
$parameters = array('type' => 'widget', 'tagid' => $id, 'maxElements' => $maxElements, 'flags' => array('shortlist'), 'uselang' => $uselang, 'includeNamespaces' => $includeNamespaces);
$userLangEqContent = $uselang == $wgLanguageCode;
$feedHTML = ActivityFeedHelper::getListForWidget($parameters, $userLangEqContent);
// template stuff
$tmpl = new EasyTemplate(dirname(__FILE__));
$tmpl->set_vars(array('tagid' => $id, 'timestamp' => wfTimestampNow(), 'header' => wfMsg('monaco-articles-on', $total), 'feedHTML' => $feedHTML, 'footerButton' => $footerButton));
$output = $tmpl->render('WidgetCommunity');
wfProfileOut(__METHOD__);
return $output;
}
示例6: wfSpecialStatistics
/**
* Show the special page
*
* @param mixed $par (not used)
*/
function wfSpecialStatistics($par = '')
{
global $wgOut, $wgLang, $wgRequest;
$dbr = wfGetDB(DB_SLAVE);
$views = SiteStats::views();
$edits = SiteStats::edits();
$good = SiteStats::articles();
$images = SiteStats::images();
$total = SiteStats::pages();
$users = SiteStats::users();
$admins = SiteStats::admins();
$numJobs = SiteStats::jobs();
if ($wgRequest->getVal('action') == 'raw') {
$wgOut->disable();
header('Pragma: nocache');
echo "total={$total};good={$good};views={$views};edits={$edits};users={$users};admins={$admins};images={$images};jobs={$numJobs}\n";
return;
} else {
$text = "__NOTOC__\n";
$text .= '==' . wfMsg('sitestats') . "==\n";
$text .= wfMsgExt('sitestatstext', array('parsemag'), $wgLang->formatNum($total), $wgLang->formatNum($good), $wgLang->formatNum($views), $wgLang->formatNum($edits), $wgLang->formatNum(sprintf('%.2f', $total ? $edits / $total : 0)), $wgLang->formatNum(sprintf('%.2f', $edits ? $views / $edits : 0)), $wgLang->formatNum($numJobs), $wgLang->formatNum($images)) . "\n";
$text .= "==" . wfMsg('userstats') . "==\n";
$text .= wfMsgExt('userstatstext', array('parsemag'), $wgLang->formatNum($users), $wgLang->formatNum($admins), '[[' . wfMsgForContent('grouppage-sysop') . ']]', $wgLang->formatNum(sprintf('%.2f', $admins / $users * 100)), User::makeGroupLinkWiki('sysop')) . "\n";
global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
if (!$wgDisableCounters && !$wgMiserMode) {
$res = $dbr->select('page', array('page_namespace', 'page_title', 'page_counter'), array('page_is_redirect' => 0, 'page_counter > 0'), __METHOD__, array('ORDER BY' => 'page_counter DESC', 'LIMIT' => 10));
if ($res->numRows() > 0) {
$text .= "==" . wfMsg('statistics-mostpopular') . "==\n";
while ($row = $res->fetchObject()) {
$title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
if ($title instanceof Title) {
$text .= '* [[:' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum($row->page_counter) . ")\n";
}
}
$res->free();
}
}
$footer = wfMsg('statistics-footer');
if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') {
$text .= "\n" . $footer;
}
$wgOut->addWikiText($text);
}
}
示例7: getSQL
function getSQL()
{
global $wgMiserMode;
$dbr = wfGetDB(DB_SLAVE);
# In miser mode, reduce the query cost by adding a threshold for large wikis
if ($wgMiserMode) {
$numPages = SiteStats::pages();
if ($numPages > 10000) {
$cutoff = 100;
} elseif ($numPages > 100) {
$cutoff = intval(sqrt($numPages));
} else {
$cutoff = 1;
}
} else {
$cutoff = 1;
}
list($pagelinks, $page) = $dbr->tableNamesN('pagelinks', 'page');
return "SELECT 'Mostlinked' AS type,\n\t\t\t\tpl_namespace AS namespace,\n\t\t\t\tpl_title AS title,\n\t\t\t\tCOUNT(*) AS value\n\t\t\tFROM {$pagelinks}\n\t\t\tLEFT JOIN {$page} ON pl_namespace=page_namespace AND pl_title=page_title\n\t\t\tGROUP BY pl_namespace, pl_title\n\t\t\tHAVING COUNT(*) > {$cutoff}";
}
示例8: incEditCount
/**
* Updates user's points after they've made an edit in a namespace that is
* listed in the $wgNamespacesForEditPoints array.
*/
function incEditCount($article, $revision, $baseRevId)
{
global $wgUser, $wgNamespacesForEditPoints, $wgMemc, $wgHuijiPrefix;
// only keep tally for allowable namespaces
if (!is_array($wgNamespacesForEditPoints) || in_array($article->getTitle()->getNamespace(), $wgNamespacesForEditPoints)) {
$stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName());
$stats->incStatField('edit');
}
$dbr = wfGetDB(DB_SLAVE);
$num = SiteStats::edits();
$sg = SystemGifts::checkEditsCounts($num);
$usg = new UserSystemGifts($wgUser->getName());
if ($sg) {
$usg->sendSystemGift(17);
}
$key = wfForeignMemcKey('huiji', '', 'revision', 'high_edit_site_followed', $wgUser->getName(), $wgHuijiPrefix);
$wgMemc->incr($key);
$key = wfForeignMemcKey('huiji', '', 'revision', 'last_edit_user', $article->getTitle()->getArticleId(), $wgHuijiPrefix);
$wgMemc->delete($key);
return true;
}
示例9: execute
public function execute($subPage)
{
if (!$this->userCanExecute($this->getUser())) {
$this->displayRestrictionError();
return;
}
$this->setHeaders();
$out = $this->getOutput();
$out->setPageTitle($this->msg('ultimatecleaner')->text());
$numPages = SiteStats::pages();
$out->addHTML(Linker::link(SpecialPage::getTitleFor('UltimateCleanerTrustedUsers'), wfMessage('ultimatecleaner-view-trusted-users')->text(), array('target' => '_blank')));
$out->addHTML('<h2>' . $this->msg('ultimatecleaner-spam-pages-list-heading')->text() . '</h2>');
$out->addHTML('<div id="pagination"></div>');
$out->addHTML(Html::openElement('form', array('method' => 'post', 'id' => 'UltimateCleaner-delete-pages')));
$out->addHTML('<div id="UltimateCleaner-select-options"></div>');
$out->addHTML('<input type="submit" value="' . $this->msg('ultimatecleaner-delete-selected') . '" style="display:none;">');
$out->addHTML(Html::openElement('div', array('id' => 'UltimateCleaner-page-list')));
$out->addHTML(Html::closeElement('div'));
$out->addHTML('<input type="submit" value="' . $this->msg('ultimatecleaner-delete-selected') . '" style="display:none;">');
$out->addHTML(Html::closeElement('form'));
}
示例10: appendUserGroups
protected function appendUserGroups($property, $numberInGroup)
{
$config = $this->getConfig();
$data = array();
$result = $this->getResult();
$allGroups = User::getAllGroups();
foreach ($config->get('GroupPermissions') as $group => $permissions) {
$arr = array('name' => $group, 'rights' => array_keys($permissions, true));
if ($numberInGroup) {
$autopromote = $config->get('Autopromote');
if ($group == 'user') {
$arr['number'] = SiteStats::users();
// '*' and autopromote groups have no size
} elseif ($group !== '*' && !isset($autopromote[$group])) {
$arr['number'] = SiteStats::numberInGroup($group);
}
}
$groupArr = array('add' => $config->get('AddGroups'), 'remove' => $config->get('RemoveGroups'), 'add-self' => $config->get('GroupsAddToSelf'), 'remove-self' => $config->get('GroupsRemoveFromSelf'));
foreach ($groupArr as $type => $rights) {
if (isset($rights[$group])) {
$groups = array_intersect($rights[$group], $allGroups);
if ($groups) {
$arr[$type] = $groups;
ApiResult::setIndexedTagName($arr[$type], 'group');
}
}
}
ApiResult::setIndexedTagName($arr['rights'], 'permission');
$data[] = $arr;
}
ApiResult::setIndexedTagName($data, 'group');
return $result->addValue('query', $property, $data);
}
示例11: getGroupStats
private function getGroupStats()
{
global $wgGroupPermissions, $wgImplicitGroups;
$text = '';
foreach ($wgGroupPermissions as $group => $permissions) {
# Skip generic * and implicit groups
if (in_array($group, $wgImplicitGroups) || $group == '*') {
continue;
}
$groupname = htmlspecialchars($group);
$msg = $this->msg('group-' . $groupname);
if ($msg->isBlank()) {
$groupnameLocalized = $groupname;
} else {
$groupnameLocalized = $msg->text();
}
$msg = $this->msg('grouppage-' . $groupname)->inContentLanguage();
if ($msg->isBlank()) {
$grouppageLocalized = MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname;
} else {
$grouppageLocalized = $msg->text();
}
$linkTarget = Title::newFromText($grouppageLocalized);
$grouppage = Linker::link($linkTarget, htmlspecialchars($groupnameLocalized));
$grouplink = Linker::linkKnown(SpecialPage::getTitleFor('Listusers'), $this->msg('listgrouprights-members')->escaped(), array(), array('group' => $group));
# Add a class when a usergroup contains no members to allow hiding these rows
$classZero = '';
$countUsers = SiteStats::numberingroup($groupname);
if ($countUsers == 0) {
$classZero = ' statistics-group-zero';
}
$text .= $this->formatRow($grouppage . ' ' . $grouplink, $this->getLanguage()->formatNum($countUsers), array('class' => 'statistics-group-' . Sanitizer::escapeClass($group) . $classZero));
}
return $text;
}
示例12: getVariableValue
//.........这里部分代码省略.........
break;
case 'currenttime':
$value = $pageLang->time(wfTimestamp(TS_MW, $ts), false, false);
break;
case 'currenthour':
$value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('H'), true);
break;
case 'currentweek':
# @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
# int to remove the padding
$value = $pageLang->formatNum((int) MWTimestamp::getInstance($ts)->format('W'));
break;
case 'currentdow':
$value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('w'));
break;
case 'localdayname':
$value = $pageLang->getWeekdayName((int) MWTimestamp::getLocalInstance($ts)->format('w') + 1);
break;
case 'localyear':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('Y'), true);
break;
case 'localtime':
$value = $pageLang->time(MWTimestamp::getLocalInstance($ts)->format('YmdHis'), false, false);
break;
case 'localhour':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('H'), true);
break;
case 'localweek':
# @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
# int to remove the padding
$value = $pageLang->formatNum((int) MWTimestamp::getLocalInstance($ts)->format('W'));
break;
case 'localdow':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('w'));
break;
case 'numberofarticles':
$value = $pageLang->formatNum(SiteStats::articles());
break;
case 'numberoffiles':
$value = $pageLang->formatNum(SiteStats::images());
break;
case 'numberofusers':
$value = $pageLang->formatNum(SiteStats::users());
break;
case 'numberofactiveusers':
$value = $pageLang->formatNum(SiteStats::activeUsers());
break;
case 'numberofpages':
$value = $pageLang->formatNum(SiteStats::pages());
break;
case 'numberofadmins':
$value = $pageLang->formatNum(SiteStats::numberingroup('sysop'));
break;
case 'numberofedits':
$value = $pageLang->formatNum(SiteStats::edits());
break;
case 'numberofviews':
global $wgDisableCounters;
$value = !$wgDisableCounters ? $pageLang->formatNum(SiteStats::views()) : '';
break;
case 'currenttimestamp':
$value = wfTimestamp(TS_MW, $ts);
break;
case 'localtimestamp':
$value = MWTimestamp::getLocalInstance($ts)->format('YmdHis');
break;
case 'currentversion':
$value = SpecialVersion::getVersion();
break;
case 'articlepath':
return $wgArticlePath;
case 'sitename':
return $wgSitename;
case 'server':
return $wgServer;
case 'servername':
$serverParts = wfParseUrl($wgServer);
return $serverParts && isset($serverParts['host']) ? $serverParts['host'] : $wgServer;
case 'scriptpath':
return $wgScriptPath;
case 'stylepath':
return $wgStylePath;
case 'directionmark':
return $pageLang->getDirMark();
case 'contentlanguage':
global $wgLanguageCode;
return $wgLanguageCode;
case 'cascadingsources':
$value = CoreParserFunctions::cascadingsources($this);
break;
default:
$ret = null;
wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret, &$frame));
return $ret;
}
if ($index) {
$this->mVarCache[$index] = $value;
}
return $value;
}
示例13: getVariableValue
//.........这里部分代码省略.........
// *after* a revision ID has been assigned. This is for null edits.
$this->mOutput->setFlag('vary-revision');
wfDebug(__METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n");
return substr($this->getRevisionTimestamp(), 0, 4);
case 'revisiontimestamp':
// Let the edit saving system know we should parse the page
// *after* a revision ID has been assigned. This is for null edits.
$this->mOutput->setFlag('vary-revision');
wfDebug(__METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n");
return $this->getRevisionTimestamp();
case 'revisionuser':
// Let the edit saving system know we should parse the page
// *after* a revision ID has been assigned. This is for null edits.
$this->mOutput->setFlag('vary-revision');
wfDebug(__METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n");
return $this->getRevisionUser();
case 'namespace':
return str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace()));
case 'namespacee':
return wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace()));
case 'talkspace':
return $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '';
case 'talkspacee':
return $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '';
case 'subjectspace':
return $this->mTitle->getSubjectNsText();
case 'subjectspacee':
return wfUrlencode($this->mTitle->getSubjectNsText());
case 'currentdayname':
return $this->mVarCache[$index] = $wgContLang->getWeekdayName(gmdate('w', $ts) + 1);
case 'currentyear':
return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('Y', $ts), true);
case 'currenttime':
return $this->mVarCache[$index] = $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false);
case 'currenthour':
return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('H', $ts), true);
case 'currentweek':
// @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
// int to remove the padding
return $this->mVarCache[$index] = $wgContLang->formatNum((int) gmdate('W', $ts));
case 'currentdow':
return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('w', $ts));
case 'localdayname':
return $this->mVarCache[$index] = $wgContLang->getWeekdayName($localDayOfWeek + 1);
case 'localyear':
return $this->mVarCache[$index] = $wgContLang->formatNum($localYear, true);
case 'localtime':
return $this->mVarCache[$index] = $wgContLang->time($localTimestamp, false, false);
case 'localhour':
return $this->mVarCache[$index] = $wgContLang->formatNum($localHour, true);
case 'localweek':
// @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
// int to remove the padding
return $this->mVarCache[$index] = $wgContLang->formatNum((int) $localWeek);
case 'localdow':
return $this->mVarCache[$index] = $wgContLang->formatNum($localDayOfWeek);
case 'numberofarticles':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::articles());
case 'numberoffiles':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::images());
case 'numberofusers':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::users());
case 'numberofactiveusers':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::activeUsers());
case 'numberofpages':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::pages());
case 'numberofadmins':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::numberingroup('sysop'));
case 'numberofedits':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::edits());
case 'numberofviews':
return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::views());
case 'currenttimestamp':
return $this->mVarCache[$index] = wfTimestamp(TS_MW, $ts);
case 'localtimestamp':
return $this->mVarCache[$index] = $localTimestamp;
case 'currentversion':
return $this->mVarCache[$index] = SpecialVersion::getVersion();
case 'sitename':
return $wgSitename;
case 'server':
return $wgServer;
case 'servername':
return $wgServerName;
case 'scriptpath':
return $wgScriptPath;
case 'directionmark':
return $wgContLang->getDirMark();
case 'contentlanguage':
global $wgContLanguageCode;
return $wgContLanguageCode;
default:
$ret = null;
if (wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret))) {
return $ret;
} else {
return null;
}
}
}
示例14: appendStatistics
protected function appendStatistics($property)
{
$data = array();
$data['pages'] = intval(SiteStats::pages());
$data['articles'] = intval(SiteStats::articles());
$data['views'] = intval(SiteStats::views());
$data['edits'] = intval(SiteStats::edits());
$data['images'] = intval(SiteStats::images());
$data['users'] = intval(SiteStats::users());
$data['admins'] = intval(SiteStats::admins());
$data['jobs'] = intval(SiteStats::jobs());
$this->getResult()->addValue('query', $property, $data);
}
示例15: jobs
/**
* @return int
*/
static function jobs()
{
if (!isset(self::$jobs)) {
// wikia change start, eloy
global $wgMemc;
$key = wfMemcKey('SiteStats', 'jobs');
self::$jobs = $wgMemc->get($key);
if (!self::$jobs) {
// wikia change end
$dbr = wfGetDB(DB_SLAVE);
self::$jobs = $dbr->estimateRowCount('job');
/* Zero rows still do single row read for row that doesn't exist, but people are annoyed by that */
if (self::$jobs == 1) {
self::$jobs = 0;
}
$wgMemc->set($key, self::$jobs, 3600);
}
}
return self::$jobs;
}