コード例 #1
0
 public function execute($par)
 {
     $this->setHeaders();
     $this->getOutput()->addModuleStyles('mediawiki.special');
     $this->edits = SiteStats::edits();
     $this->good = SiteStats::articles();
     $this->images = SiteStats::images();
     $this->total = SiteStats::pages();
     $this->users = SiteStats::users();
     $this->activeUsers = SiteStats::activeUsers();
     $this->hook = '';
     $text = Xml::openElement('table', ['class' => 'wikitable mw-statistics-table']);
     # Statistic - pages
     $text .= $this->getPageStats();
     # Statistic - edits
     $text .= $this->getEditStats();
     # Statistic - users
     $text .= $this->getUserStats();
     # Statistic - usergroups
     $text .= $this->getGroupStats();
     # Statistic - other
     $extraStats = [];
     if (Hooks::run('SpecialStatsAddExtra', [&$extraStats, $this->getContext()])) {
         $text .= $this->getOtherStats($extraStats);
     }
     $text .= Xml::closeElement('table');
     # Customizable footer
     $footer = $this->msg('statistics-footer');
     if (!$footer->isBlank()) {
         $text .= "\n" . $footer->parse();
     }
     $this->getOutput()->addHTML($text);
 }
コード例 #2
0
 public function execute($par)
 {
     global $wgMemc, $wgDisableCounters, $wgMiserMode;
     $this->setHeaders();
     $this->getOutput()->addModuleStyles('mediawiki.special');
     $this->views = SiteStats::views();
     $this->edits = SiteStats::edits();
     $this->good = SiteStats::articles();
     $this->images = SiteStats::images();
     $this->total = SiteStats::pages();
     $this->users = SiteStats::users();
     $this->activeUsers = SiteStats::activeUsers();
     $this->hook = '';
     # Staticic - views
     $viewsStats = '';
     if (!$wgDisableCounters) {
         $viewsStats = $this->getViewsStats();
     }
     # Set active user count
     if (!$wgMiserMode) {
         $key = wfMemcKey('sitestats', 'activeusers-updated');
         // Re-calculate the count if the last tally is old...
         if (!$wgMemc->get($key)) {
             $dbw = wfGetDB(DB_MASTER);
             SiteStatsUpdate::cacheUpdate($dbw);
             $wgMemc->set($key, '1', 24 * 3600);
             // don't update for 1 day
         }
     }
     $text = Xml::openElement('table', array('class' => 'wikitable mw-statistics-table'));
     # Statistic - pages
     $text .= $this->getPageStats();
     # Statistic - edits
     $text .= $this->getEditStats();
     # Statistic - users
     $text .= $this->getUserStats();
     # Statistic - usergroups
     $text .= $this->getGroupStats();
     $text .= $viewsStats;
     # Statistic - popular pages
     if (!$wgDisableCounters && !$wgMiserMode) {
         $text .= $this->getMostViewedPages();
     }
     # Statistic - other
     $extraStats = array();
     if (wfRunHooks('SpecialStatsAddExtra', array(&$extraStats))) {
         $text .= $this->getOtherStats($extraStats);
     }
     $text .= Xml::closeElement('table');
     #<Wikia>
     wfRunHooks("CustomSpecialStatistics", array(&$this, &$text));
     #</Wikia>
     # Customizable footer
     $footer = wfMessage('statistics-footer');
     if (!$footer->isBlank()) {
         $text .= "\n" . $footer->parse();
     }
     $this->getOutput()->addHTML($text);
 }
コード例 #3
0
 public function execute($par)
 {
     global $wgOut, $wgMemc;
     global $wgDisableCounters, $wgMiserMode;
     $this->setHeaders();
     $this->views = SiteStats::views();
     $this->edits = SiteStats::edits();
     $this->good = SiteStats::articles();
     $this->images = SiteStats::images();
     $this->total = SiteStats::pages();
     $this->users = SiteStats::users();
     $this->activeUsers = SiteStats::activeUsers();
     $this->admins = SiteStats::numberingroup('sysop');
     $this->hook = '';
     # Staticic - views
     $viewsStats = '';
     if (!$wgDisableCounters) {
         $viewsStats = $this->getViewsStats();
     }
     # Set active user count
     if (!$wgMiserMode) {
         $key = wfMemcKey('sitestats', 'activeusers-updated');
         // Re-calculate the count if the last tally is old...
         if (!$wgMemc->get($key)) {
             $dbw = wfGetDB(DB_MASTER);
             SiteStatsUpdate::cacheUpdate($dbw);
             $wgMemc->set($key, '1', 24 * 3600);
             // don't update for 1 day
         }
     }
     $text = Xml::openElement('table', array('class' => 'wikitable mw-statistics-table'));
     # Statistic - pages
     $text .= $this->getPageStats();
     # Statistic - edits
     $text .= $this->getEditStats();
     # Statistic - users
     $text .= $this->getUserStats();
     # Statistic - usergroups
     $text .= $this->getGroupStats();
     $text .= $viewsStats;
     # Statistic - popular pages
     if (!$wgDisableCounters && !$wgMiserMode) {
         $text .= $this->getMostViewedPages();
     }
     # Statistic - other
     $extraStats = array();
     if (wfRunHooks('SpecialStatsAddExtra', array(&$extraStats))) {
         $text .= $this->getOtherStats($extraStats);
     }
     $text .= Xml::closeElement('table');
     # Customizable footer
     $footer = wfMsgExt('statistics-footer', array('parseinline'));
     if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') {
         $text .= "\n" . $footer;
     }
     $wgOut->addHTML($text);
 }
コード例 #4
0
/**
* 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);
        }
    }
}
コード例 #5
0
 public function execute($par)
 {
     global $wgOut, $wgRequest, $wgMessageCache;
     global $wgDisableCounters, $wgMiserMode;
     $wgMessageCache->loadAllMessages();
     $this->setHeaders();
     $this->views = SiteStats::views();
     $this->edits = SiteStats::edits();
     $this->good = SiteStats::articles();
     $this->images = SiteStats::images();
     $this->total = SiteStats::pages();
     $this->users = SiteStats::users();
     $this->activeUsers = SiteStats::activeUsers();
     $this->admins = SiteStats::numberingroup('sysop');
     $this->numJobs = SiteStats::jobs();
     # Staticic - views
     $viewsStats = '';
     if (!$wgDisableCounters) {
         $viewsStats = $this->getViewsStats();
     }
     # Set active user count
     if (!$wgMiserMode) {
         $dbw = wfGetDB(DB_MASTER);
         SiteStatsUpdate::cacheUpdate($dbw);
     }
     # Do raw output
     if ($wgRequest->getVal('action') == 'raw') {
         $this->doRawOutput();
     }
     $text = Xml::openElement('table', array('class' => 'mw-statistics-table'));
     # Statistic - pages
     $text .= $this->getPageStats();
     # Statistic - edits
     $text .= $this->getEditStats();
     # Statistic - users
     $text .= $this->getUserStats();
     # Statistic - usergroups
     $text .= $this->getGroupStats();
     $text .= $viewsStats;
     # Statistic - popular pages
     if (!$wgDisableCounters && !$wgMiserMode) {
         $text .= $this->getMostViewedPages();
     }
     $text .= Xml::closeElement('table');
     # Customizable footer
     $footer = wfMsgExt('statistics-footer', array('parseinline'));
     if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') {
         $text .= "\n" . $footer;
     }
     $wgOut->addHTML($text);
 }
コード例 #6
0
 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;
 }
コード例 #7
0
ファイル: SpecialStatistics.php プロジェクト: D66Ha/mediawiki
 public function execute($par)
 {
     global $wgMemc;
     $miserMode = $this->getConfig()->get('MiserMode');
     $this->setHeaders();
     $this->getOutput()->addModuleStyles('mediawiki.special');
     $this->edits = SiteStats::edits();
     $this->good = SiteStats::articles();
     $this->images = SiteStats::images();
     $this->total = SiteStats::pages();
     $this->users = SiteStats::users();
     $this->activeUsers = SiteStats::activeUsers();
     $this->hook = '';
     # Set active user count
     if (!$miserMode) {
         $key = wfMemcKey('sitestats', 'activeusers-updated');
         // Re-calculate the count if the last tally is old...
         if (!$wgMemc->get($key)) {
             $dbw = wfGetDB(DB_MASTER);
             SiteStatsUpdate::cacheUpdate($dbw);
             $wgMemc->set($key, '1', 24 * 3600);
             // don't update for 1 day
         }
     }
     $text = Xml::openElement('table', array('class' => 'wikitable mw-statistics-table'));
     # Statistic - pages
     $text .= $this->getPageStats();
     # Statistic - edits
     $text .= $this->getEditStats();
     # Statistic - users
     $text .= $this->getUserStats();
     # Statistic - usergroups
     $text .= $this->getGroupStats();
     # Statistic - other
     $extraStats = array();
     if (Hooks::run('SpecialStatsAddExtra', array(&$extraStats, $this->getContext()))) {
         $text .= $this->getOtherStats($extraStats);
     }
     $text .= Xml::closeElement('table');
     # Customizable footer
     $footer = $this->msg('statistics-footer');
     if (!$footer->isBlank()) {
         $text .= "\n" . $footer->parse();
     }
     $this->getOutput()->addHTML($text);
 }
コード例 #8
0
/**
 * 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);
    }
}
コード例 #9
0
ファイル: WidgetCommunity.php プロジェクト: Tjorriemorrie/app
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;
}
コード例 #10
0
 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);
 }
コード例 #11
0
ファイル: Parser.php プロジェクト: laiello/media-wiki-law
 /**
  * Return value of a magic variable (like PAGENAME)
  *
  * @private
  *
  * @param $index integer
  * @param $frame PPFrame
  *
  * @return string
  */
 function getVariableValue($index, $frame = false)
 {
     global $wgContLang, $wgSitename, $wgServer;
     global $wgArticlePath, $wgScriptPath, $wgStylePath;
     if (is_null($this->mTitle)) {
         // If no title set, bad things are going to happen
         // later. Title should always be set since this
         // should only be called in the middle of a parse
         // operation (but the unit-tests do funky stuff)
         throw new MWException(__METHOD__ . ' Should only be ' . ' called while parsing (no title set)');
     }
     /**
      * Some of these require message or data lookups and can be
      * expensive to check many times.
      */
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
         if (isset($this->mVarCache[$index])) {
             return $this->mVarCache[$index];
         }
     }
     $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     # Use the time zone
     global $wgLocaltimezone;
     if (isset($wgLocaltimezone)) {
         $oldtz = date_default_timezone_get();
         date_default_timezone_set($wgLocaltimezone);
     }
     $localTimestamp = date('YmdHis', $ts);
     $localMonth = date('m', $ts);
     $localMonth1 = date('n', $ts);
     $localMonthName = date('n', $ts);
     $localDay = date('j', $ts);
     $localDay2 = date('d', $ts);
     $localDayOfWeek = date('w', $ts);
     $localWeek = date('W', $ts);
     $localYear = date('Y', $ts);
     $localHour = date('H', $ts);
     if (isset($wgLocaltimezone)) {
         date_default_timezone_set($oldtz);
     }
     $pageLang = $this->getFunctionLang();
     switch ($index) {
         case 'currentmonth':
             $value = $pageLang->formatNum(gmdate('m', $ts));
             break;
         case 'currentmonth1':
             $value = $pageLang->formatNum(gmdate('n', $ts));
             break;
         case 'currentmonthname':
             $value = $pageLang->getMonthName(gmdate('n', $ts));
             break;
         case 'currentmonthnamegen':
             $value = $pageLang->getMonthNameGen(gmdate('n', $ts));
             break;
         case 'currentmonthabbrev':
             $value = $pageLang->getMonthAbbreviation(gmdate('n', $ts));
             break;
         case 'currentday':
             $value = $pageLang->formatNum(gmdate('j', $ts));
             break;
         case 'currentday2':
             $value = $pageLang->formatNum(gmdate('d', $ts));
             break;
         case 'localmonth':
             $value = $pageLang->formatNum($localMonth);
             break;
         case 'localmonth1':
             $value = $pageLang->formatNum($localMonth1);
             break;
         case 'localmonthname':
             $value = $pageLang->getMonthName($localMonthName);
             break;
         case 'localmonthnamegen':
             $value = $pageLang->getMonthNameGen($localMonthName);
             break;
         case 'localmonthabbrev':
             $value = $pageLang->getMonthAbbreviation($localMonthName);
             break;
         case 'localday':
             $value = $pageLang->formatNum($localDay);
             break;
         case 'localday2':
             $value = $pageLang->formatNum($localDay2);
             break;
         case 'pagename':
             $value = wfEscapeWikiText($this->mTitle->getText());
             break;
         case 'pagenamee':
             $value = wfEscapeWikiText($this->mTitle->getPartialURL());
             break;
         case 'fullpagename':
             $value = wfEscapeWikiText($this->mTitle->getPrefixedText());
             break;
         case 'fullpagenamee':
             $value = wfEscapeWikiText($this->mTitle->getPrefixedURL());
             break;
         case 'subpagename':
             $value = wfEscapeWikiText($this->mTitle->getSubpageText());
             break;
         case 'subpagenamee':
             $value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm());
             break;
         case 'basepagename':
             $value = wfEscapeWikiText($this->mTitle->getBaseText());
             break;
         case 'basepagenamee':
             $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())));
             break;
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 $value = wfEscapeWikiText($talkPage->getPrefixedText());
             } else {
                 $value = '';
             }
             break;
         case 'talkpagenamee':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 $value = wfEscapeWikiText($talkPage->getPrefixedUrl());
             } else {
                 $value = '';
             }
             break;
         case 'subjectpagename':
             $subjPage = $this->mTitle->getSubjectPage();
             $value = wfEscapeWikiText($subjPage->getPrefixedText());
             break;
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             $value = wfEscapeWikiText($subjPage->getPrefixedUrl());
             break;
         case 'revisionid':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n");
             $value = $this->mRevisionId;
             break;
         case 'revisionday':
             # 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__ . ": {{REVISIONDAY}} used, setting vary-revision...\n");
             $value = intval(substr($this->getRevisionTimestamp(), 6, 2));
             break;
         case 'revisionday2':
             # 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__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 6, 2);
             break;
         case 'revisionmonth':
             # 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__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 4, 2);
             break;
         case 'revisionmonth1':
             # 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__ . ": {{REVISIONMONTH1}} used, setting vary-revision...\n");
             $value = intval(substr($this->getRevisionTimestamp(), 4, 2));
             break;
         case 'revisionyear':
             # 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__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 0, 4);
             break;
         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");
             $value = $this->getRevisionTimestamp();
             break;
         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");
             $value = $this->getRevisionUser();
             break;
         case 'namespace':
             $value = str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace()));
             break;
         case 'namespacee':
             $value = wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace()));
             break;
         case 'talkspace':
             $value = $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '';
             break;
         case 'talkspacee':
             $value = $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '';
             break;
         case 'subjectspace':
             $value = $this->mTitle->getSubjectNsText();
             break;
         case 'subjectspacee':
             $value = wfUrlencode($this->mTitle->getSubjectNsText());
             break;
         case 'currentdayname':
             $value = $pageLang->getWeekdayName(gmdate('w', $ts) + 1);
             break;
         case 'currentyear':
             $value = $pageLang->formatNum(gmdate('Y', $ts), true);
             break;
         case 'currenttime':
             $value = $pageLang->time(wfTimestamp(TS_MW, $ts), false, false);
             break;
         case 'currenthour':
             $value = $pageLang->formatNum(gmdate('H', $ts), 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) gmdate('W', $ts));
             break;
         case 'currentdow':
             $value = $pageLang->formatNum(gmdate('w', $ts));
             break;
         case 'localdayname':
             $value = $pageLang->getWeekdayName($localDayOfWeek + 1);
             break;
         case 'localyear':
             $value = $pageLang->formatNum($localYear, true);
             break;
         case 'localtime':
             $value = $pageLang->time($localTimestamp, false, false);
             break;
         case 'localhour':
             $value = $pageLang->formatNum($localHour, 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) $localWeek);
             break;
         case 'localdow':
             $value = $pageLang->formatNum($localDayOfWeek);
             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':
             $value = $pageLang->formatNum(SiteStats::views());
             break;
         case 'currenttimestamp':
             $value = wfTimestamp(TS_MW, $ts);
             break;
         case 'localtimestamp':
             $value = $localTimestamp;
             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;
         default:
             $ret = null;
             if (wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret, &$frame))) {
                 return $ret;
             } else {
                 return null;
             }
     }
     if ($index) {
         $this->mVarCache[$index] = $value;
     }
     return $value;
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 protected function appendStatistics($property)
 {
     $data = array();
     $data['pages'] = intval(SiteStats::pages());
     $data['articles'] = intval(SiteStats::articles());
     if (!$this->getConfig()->get('DisableCounters')) {
         $data['views'] = intval(SiteStats::views());
     }
     $data['edits'] = intval(SiteStats::edits());
     $data['images'] = intval(SiteStats::images());
     $data['users'] = intval(SiteStats::users());
     $data['activeusers'] = intval(SiteStats::activeUsers());
     $data['admins'] = intval(SiteStats::numberingroup('sysop'));
     $data['jobs'] = intval(SiteStats::jobs());
     wfRunHooks('APIQuerySiteInfoStatisticsInfo', array(&$data));
     return $this->getResult()->addValue('query', $property, $data);
 }
コード例 #14
0
 /**
  * Render page header for Hubs
  *
  * @param: array $params
  */
 public function executeHubs($params)
 {
     global $wgSupressPageTitle;
     wfProfileIn(__METHOD__);
     $this->displaytitle = true;
     // Leave this for now. To discuss do we want PageTitle
     if ($this->displaytitle) {
         $this->title = wfMessage('oasis-home')->escaped();
     }
     // number of pages on this wiki
     $this->tallyMsg = wfMessage('oasis-total-articles-mainpage', SiteStats::articles())->parse();
     if (!empty($wgSupressPageTitle)) {
         $this->title = '';
     }
     wfProfileOut(__METHOD__);
 }
コード例 #15
0
 public function executeIndex()
 {
     wfProfileIn(__METHOD__);
     $this->total = SiteStats::articles();
     wfProfileOut(__METHOD__);
 }
コード例 #16
0
 public function prepareVariables()
 {
     global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath;
     global $wgContLanguageCode;
     global $wgTitle;
     $this->mRevisionId = $this->mTitle->getLatestRevID();
     $ts = time();
     # Use the time zone
     global $wgLocaltimezone;
     if (isset($wgLocaltimezone)) {
         $oldtz = getenv('TZ');
         putenv('TZ=' . $wgLocaltimezone);
     }
     wfSuppressWarnings();
     // E_STRICT system time bitching
     $localTimestamp = date('YmdHis', $ts);
     $localMonth = date('m', $ts);
     $localMonthName = date('n', $ts);
     $localDay = date('j', $ts);
     $localDay2 = date('d', $ts);
     $localDayOfWeek = date('w', $ts);
     $localWeek = date('W', $ts);
     $localYear = date('Y', $ts);
     $localHour = date('H', $ts);
     if (isset($wgLocaltimezone)) {
         putenv('TZ=' . $oldtz);
     }
     wfRestoreWarnings();
     // some simpler ones...
     $w2lVars = array('currentmonth' => $wgContLang->formatNum(gmdate('m', $ts)), 'currentmonthname' => $wgContLang->getMonthName(gmdate('n', $ts)), 'currentmonthnamegen' => $wgContLang->getMonthNameGen(gmdate('n', $ts)), 'currentmonthabbrev' => $wgContLang->getMonthAbbreviation(gmdate('n', $ts)), 'currentday' => $wgContLang->formatNum(gmdate('j', $ts)), 'currentday2' => $wgContLang->formatNum(gmdate('d', $ts)), 'localmonth' => $wgContLang->formatNum($localMonth), 'localmonthname' => $wgContLang->getMonthName($localMonthName), 'localmonthnamegen' => $wgContLang->getMonthNameGen($localMonthName), 'localmonthabbrev' => $wgContLang->getMonthAbbreviation($localMonthName), 'localday' => $wgContLang->formatNum($localDay), 'localday2' => $wgContLang->formatNum($localDay2), 'pagename' => wfEscapeWikiText($this->mTitle->getText()), 'pagenamee' => $this->mTitle->getPartialURL(), 'fullpagename' => wfEscapeWikiText($this->mTitle->getPrefixedText()), 'fullpagenamee' => $this->mTitle->getPrefixedURL(), 'subpagename' => wfEscapeWikiText($this->mTitle->getSubpageText()), 'subpagenamee' => $this->mTitle->getSubpageUrlForm(), 'basepagename' => wfEscapeWikiText($this->mTitle->getBaseText()), 'basepagenamee' => wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())), 'revisionid' => $this->mRevisionId, 'revisionday' => intval(substr($this->getRevisionTimestamp(), 6, 2)), 'revisionday2' => substr($this->getRevisionTimestamp(), 6, 2), 'revisionmonth' => substr($this->getRevisionTimestamp(), 4, 2), 'revisionmonth1' => intval(substr($this->getRevisionTimestamp(), 4, 2)), 'revisionyear' => substr($this->getRevisionTimestamp(), 0, 4), 'revisiontimestamp' => $this->getRevisionTimestamp(), 'namespace' => str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace())), 'namespacee' => wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace())), 'talkspace' => $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '', 'talkspacee' => $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '', 'subjectspace' => $this->mTitle->getSubjectNsText(), 'subjectspacee' => wfUrlencode($this->mTitle->getSubjectNsText()), 'currentdayname' => $wgContLang->getWeekdayName(gmdate('w', $ts) + 1), 'currentyear' => $wgContLang->formatNum(gmdate('Y', $ts), true), 'currenttime' => $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false), 'currenthour' => $wgContLang->formatNum(gmdate('H', $ts), true), 'currentweek' => $wgContLang->formatNum((int) gmdate('W', $ts)), 'currentdow' => $wgContLang->formatNum(gmdate('w', $ts)), 'localdayname' => $wgContLang->getWeekdayName($localDayOfWeek + 1), 'localyear' => $wgContLang->formatNum($localYear, true), 'localtime' => $wgContLang->time($localTimestamp, false, false), 'localhour' => $wgContLang->formatNum($localHour, true), 'localweek' => $wgContLang->formatNum((int) $localWeek), 'localdow' => $wgContLang->formatNum($localDayOfWeek), 'numberofarticles' => $wgContLang->formatNum(SiteStats::articles()), 'numberoffiles' => $wgContLang->formatNum(SiteStats::images()), 'numberofusers' => $wgContLang->formatNum(SiteStats::users()), 'numberofpages' => $wgContLang->formatNum(SiteStats::pages()), 'numberofadmins' => $wgContLang->formatNum(SiteStats::numberingroup('sysop')), 'numberofedits' => $wgContLang->formatNum(SiteStats::edits()), 'currenttimestamp' => wfTimestampNow(), 'localtimestamp' => $localTimestamp, 'currentversion' => SpecialVersion::getVersion(), 'sitename' => $wgSitename, 'server' => $wgServer, 'servername' => $wgServerName, 'scriptpath' => $wgScriptPath, 'directionmark' => $wgContLang->getDirMark(), 'contentlanguage' => $wgContLanguageCode, 'pageid' => $this->mTitle->getArticleID(), 'namespacenumber' => $this->mTitle->getNamespace(), 'numberofactiveusers' => $wgContLang->formatNum(SiteStats::activeUsers()), 'revisionuser' => $this->mRevision->getUserText(), 'stylepath' => $wgStylePath);
     // These are a bit more complicated...
     //case 'talkpagename':
     if ($this->mTitle->canTalk()) {
         $talkPage = $this->mTitle->getTalkPage();
         $talkpagename = wfEscapeWikiText($talkPage->getPrefixedText());
     } else {
         $talkpagename = '';
     }
     $w2lVars['talkpagename'] = $talkpagename;
     //case 'talkpagenamee':
     if ($this->mTitle->canTalk()) {
         $talkPage = $this->mTitle->getTalkPage();
         $talkpagenamee = $talkPage->getPrefixedUrl();
     } else {
         $talkpagenamee = '';
     }
     $w2lVars['talkpagenamee'] = $talkpagenamee;
     //case 'subjectpagename':
     $subjPage = $this->mTitle->getSubjectPage();
     $w2lVars['subjectpagename'] = wfEscapeWikiText($subjPage->getPrefixedText());
     $w2lVars['subjectpagenamee'] = $subjPage->getPrefixedUrl();
     wfRunHooks('w2lTemplateVars', array(&$this, &$w2lVars));
     $w2lVars = array_change_key_case($w2lVars, CASE_UPPER);
     return $w2lVars;
 }
コード例 #17
0
    /**
     * Template filter callback for Bootstrap 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 $wgRequest, $wgUser, $wgSitename, $wgSitenameshort, $wgCopyrightLink, $wgCopyright, $wgBootstrap, $wgArticlePath, $wgGoogleAnalyticsID, $wgSiteCSS;
        global $wgEnableUploads;
        global $wgLogo, $wgHuijiPrefix, $wgFavicon;
        global $wgTOCLocation;
        global $wgNavBarClasses;
        global $wgSubnavBarClasses;
        global $wgParser, $wgTitle, $wgEmailAuthentication;
        $wgFavicon = (new wSiteAvatar($wgHuijiPrefix, 'l'))->getAvatarImage();
        $this->skin = $this->data['skin'];
        $action = $wgRequest->getText('action');
        $url_prefix = str_replace('$1', '', $wgArticlePath);
        $NS = $wgTitle->getNamespace();
        // Suppress warnings to prevent notices about missing indexes in $this->data
        wfSuppressWarnings();
        $this->html('headelement');
        if ($wgUser->isLoggedIn()) {
            $usf = new UserSiteFollow();
            $followed = $usf->checkUserSiteFollow($wgUser, $wgHuijiPrefix) !== false;
        } else {
            $followed = false;
        }
        ?>
        <!--[if lt IE 8]>
            <p class="alert alert-warning alert-dismissible browsehappy">
              你正在使用一个<strong>过时</strong>的浏览器。请<a class="link" href="http://browsehappy.com">升级你的浏览器</a>以查看此页面。</p>
            </p>
        <![endif]-->
        <script>
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
            ga('create', 'UA-10190882-3', 'auto');
            ga('send', 'pageview');
        </script>
       <!-- <script type="text/javascript" src="/resources/qc/qc_loader.js" data-appid="101264508" charset="utf-8"></script>-->
        <script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=2445834038" type="text/javascript" charset="utf-8"></script>
        <div id="wrapper" class="toggled">
        <script>
            var menutoggle;
            document.domain = "huiji.wiki";
            menutoggle = localStorage.getItem("menu-toggle");
            document.getElementById('wrapper').className = menutoggle;
        </script>
        <?php 
        echo $this->showHeader();
        ?>
        <script>
            var classlst;
            var x = 0;
            classlst = document.getElementById('wrapper').className.split(/\s+/);
            for(x in classlst) {
                if(classlst[x] == 'toggled') {
                    var list = document.getElementById('menu-toggle').className;
                    var blank,added;
                    blank = (list!='')?' ':'';
                    added = list + blank + 'menu-active';
                    document.getElementById('menu-toggle').className = added;
                }
            }
        </script>
        <?php 
        if (($wgHuijiPrefix === 'slx.test' || $wgHuijiPrefix === 'test' || $wgHuijiPrefix === 'zs.test' || $wgHuijiPrefix === 'www') && $this->getSkin()->getTitle()->isMainPage()) {
            include 'View/Sidebar.php';
            echo FrontPage::showPage();
            include 'View/Modal.php';
        } else {
            ?>
            
            <?php 
            include 'View/Sidebar.php';
            ?>

            <div id="wiki-outer-body">

                <div id="content-actions" class="subnav subnav-fixed">
                    <div class="container-fluid">
                        <ul class="nav nav-pills">
                            <li>
                                <a class="navbar-brand logo-wiki-user" href="<?php 
            echo $this->data['nav_urls']['mainpage']['href'];
            ?>
" title="<?php 
            echo $wgSitename;
            ?>
"><?php 
            echo (new wSiteAvatar($wgHuijiPrefix, 'm'))->getAvatarHtml(array('style' => 'height : 1em; padding-bottom:0.2em;'));
            echo '&nbsp;' . ($wgSitenameshort ? $wgSitenameshort : $wgSitename);
            ?>
</a>
                            </li>
                            <li><span id="user-site-follow" class="mw-ui-button <?php 
            echo $followed ? '' : 'mw-ui-progressive';
            echo $followed ? 'unfollow' : '';
            ?>
 "><?php 
            echo $followed ? '取消关注' : '<span class="glyphicon glyphicon-plus"></span>关注';
            ?>
</span> </li>
                            <?php 
            echo $this->nav($this->get_page_links('Bootstrap:Subnav'));
            ?>
                            <li class="site-count"><p><a id="site-article-count" href="<?php 
            echo $url_prefix;
            ?>
Special:AllPages"><?php 
            $result = self::format_nice_number(SiteStats::articles());
            $result2 = self::format_nice_number(SiteStats::edits());
            echo $result;
            ?>
</a>页面<a href="/wiki/Special:RecentChanges"><?php 
            echo $result2;
            ?>
</a>编辑<a id="site-follower-count" data-toggle="modal" data-target=".follow-msg"><?php 
            echo self::format_nice_number(UserSiteFollow::getFollowerCount($wgHuijiPrefix));
            ?>
</a>关注</p></li>
                            <span id="subnav-toggle"><i class="fa fa-ellipsis-h"></i></span>
                        </ul>
                    </div>
                </div>

                <div id="wiki-body" class="container">
                    <div id="content">
                        <div class="row">
                            <nav class="hidden-md hidden-sm hidden-xs hidden-print toc-sidebar" role="complementary navigation"></nav>
                            <section class="col-md-12 wiki-body-section" role="main">



                        <div id="firstHeading" class="pagetitle page-header">
                            <div class="pull-right"><?php 
            if ($this->data['isarticle']) {
                echo $this->getIndicators();
            }
            ?>
 </div>
                            <h1><?php 
            $this->html('title');
            ?>
 
                                <?php 
            if (isset($this->data['content_actions']['edit'])) {
                $isVisualEditorEnabled = $wgUser->getOption('visualeditor-enable', '1');
                $editHref = $this->data['content_actions']['edit']['href'];
                $veHref = $this->data['content_actions']['ve-edit']['href'];
                if ($isVisualEditorEnabled == 1 && isset($this->data['content_actions']['ve-edit'])) {
                    ?>
                                            <div id="huiji-h1-edit-button" class="huiji-h1-edit-button">

                                                <a id="ca-ve-edit" href="<?php 
                    echo $veHref;
                    ?>
" class="icon-pencil" data-toggle="tooltip" data-placement="top" title="使用可视化编辑器"></a>
                                                <span class="mw-editsection-divider"></span>
                                                <a id="ca-edit" href="<?php 
                    echo $editHref;
                    ?>
" class="icon-edit-code " data-toggle="tooltip" data-placement="top" title="使用源代码编辑器"></a>
                                            </div>
                                        <?php 
                } else {
                    ?>
                                            <div id="huiji-h1-edit-button" class="huiji-h1-edit-button">
                                                <a id="ca-edit" href="<?php 
                    echo $editHref;
                    ?>
" class="icon-edit-code" title="<?php 
                    echo wfMsg('bootstrap-mediawiki-view-edit');
                    ?>
"></a>
                                            </div>                                   
                                        <?php 
                }
            }
            ?>
                               
                                <div id="contentSub">
                                    <small>
                                    <?php 
            $this->html('subtitle');
            ?>
                                    <?php 
            if ($this->data['isarticle'] && !$this->getSkin()->getTitle()->isMainPage() && $this->getSkin()->getTitle()->exists()) {
                $revPageId = $this->getSkin()->getTitle()->getArticleId();
                $editinfo = UserStats::getLastEditer($revPageId, $wgHuijiPrefix);
                $userPage = Title::makeTitle(NS_USER, $editinfo['rev_user_text']);
                $userPageURL = htmlspecialchars($userPage->getFullURL());
                $bjtime = strtotime($editinfo['rev_timestamp']) + 8 * 60 * 60;
                $edittime = CommentFunctions::getTimeAgo($bjtime);
                echo '<a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="' . $userPageURL . '">' . $editinfo['rev_user_text'] . '</a>&nbsp于' . $edittime . '前编辑了此页面';
                echo '<div class="bdsharebuttonbox pull-right hidden-sm hidden-xs" data-tag="share_2"><a href="#" class="icon-weixin-share" data-tag="share_2" data-cmd="weixin" title="分享到微信"></a><a href="#" class="icon-weibo-share" data-tag="share_2" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="icon-qqspace-share" data-tag="share_2" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="icon-tieba-share" data-tag="share_2" data-cmd="tieba" title="分享到百度贴吧"></a><a href="#" class="icon-douban-share" data-tag="share_2" data-cmd="douban" title="分享到豆瓣网"></a></div>';
            }
            ?>
                                    </small>
                                </div>
                                
                            </h1>
                        </div>
                        <?php 
            if ($this->data['isarticle']) {
                ?>
<div id="siteSub" class="alert alert-info visible-print-block" role="alert"><?php 
                $this->msg('tagline');
                ?>
</div><?php 
            }
            ?>
                        <!-- ConfirmEmail -->
                        <?php 
            if ($wgUser->isLoggedIn() && !$wgUser->isEmailConfirmed() && !$this->getSkin()->getTitle()->isMainPage()) {
                ?>
                        <div class="alert alert-danger" role="alert">
                            <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                            <span class="sr-only">Error:</span>
                            只有确认邮件后才能对页面进行编辑&nbsp:)
                            <a href="/wiki/%E7%89%B9%E6%AE%8A:%E7%A1%AE%E8%AE%A4%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6">点此确认</a>&nbsp|&nbsp
                            <a href="/wiki/特殊:修改邮箱地址">修改邮箱地址</a>
                        </div> 
                        <?php 
            }
            ?>
  
                        <!-- /ConfirmEmail -->
                        <?php 
            if ($this->data['undelete']) {
                ?>
                        <!-- undelete -->
                        <div id="contentSub2" class="alert alert-warning alert-dismissible">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                            <?php 
                $this->html('undelete');
                ?>
                        </div>
                        <!-- /undelete -->
                        <?php 
            }
            ?>
                        <?php 
            if ($this->data['newtalk']) {
                ?>
                        <!-- newtalk -->
                        <div class="usermessage"><?php 
                $this->html('newtalk');
                ?>
</div>
                        <!-- /newtalk -->
                        <?php 
            }
            ?>
                        <div id="bodyContent" class="body">                     
                        <?php 
            $this->html('bodytext');
            ?>
                        </div>
                        <?php 
            if ($this->data['catlinks']) {
                ?>
                        <div class="category-links">
                        <!-- catlinks -->
                        <?php 
                $this->html('catlinks');
                ?>
                        <!-- /catlinks -->
                        </div>
                        <?php 
            }
            ?>
                        <div class="bdsharebuttonbox pull-right" data-tag="share_1"><a href="#" class="icon-weixin-share hidden-xs hidden-sm" data-tag="share_1" data-cmd="weixin" title="分享到微信"></a><a href="#" class="icon-weibo-share" data-tag="share_1" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="icon-qqspace-share" data-tag="share_1" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="icon-tieba-share" data-tag="share_1" data-cmd="tieba" title="分享到百度贴吧"></a><a href="#" class="icon-douban-share" data-tag="share_1" data-cmd="douban" title="分享到豆瓣网"></a></div>
                        <?php 
            if ($this->data['isarticle'] && !$this->getSkin()->getTitle()->isMainPage() && $this->getSkin()->getTitle()->exists()) {
                $commentHtml = '<div class="clearfix"></div>';
                $wgParser->setTitle($this->getSkin()->getTitle());
                $commentHtml .= CommentsHooks::displayComments('', array(), $wgParser);
                echo $commentHtml;
            }
            ?>
                        <?php 
            if ($this->data['dataAfterContent']) {
                ?>
                        <div class="data-after-content">
                        <!-- dataAfterContent -->
                        <?php 
                $this->html('dataAfterContent');
                ?>
                    
                        <!-- /dataAfterContent -->
                        </div>
                        <?php 
            }
            ?>
                        <?php 
            if ('sidebar' == $wgTOCLocation) {
                ?>
                                </section></section>
                                <?php 
            }
            //end if
            ?>
                    </div>
                </div><!-- container -->
            </div>
            <?php 
            include 'View/Modal.php';
            ?>
            <div class="bottom">
                <div class="container">
                    <?php 
            self::includePage('Bootstrap:Footer');
            ?>
                    <?php 
            if ($this->data['sitenotice']) {
                ?>
                        <div id="siteNotice" class="site-notice">
                            <?php 
                $this->html('sitenotice');
                ?>
                        </div>
                    <?php 
            }
            ?>
                    <footer>
                        <p class="text-center">
                            <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BA%E5%81%9C%E6%9C%BA%E5%9D%AA">灰机停机坪</a> |
                            <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://www.huiji.wiki/wiki/%E7%BB%B4%E5%9F%BA%E5%AE%B6%E5%9B%AD%E8%AE%A1%E5%88%92">维基家园计划</a> |
                            <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://www.huiji.wiki/wiki/%E5%AE%87%E5%AE%99%E5%B0%BD%E5%A4%B4%E7%9A%84%E7%81%B0%E6%9C%BAwiki">关于灰机wiki</a> |
                            <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BAwiki:%E4%BD%BF%E7%94%A8%E6%9D%A1%E6%AC%BE%E5%92%8C%E5%86%85%E5%AE%B9%E5%A3%B0%E6%98%8E">使用条款和声明</a> |
                            <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://www.huiji.wiki/wiki/%E7%81%B0%E6%9C%BAwiki:%E7%94%A8%E6%88%B7%E7%BC%96%E8%BE%91%E6%9D%A1%E6%AC%BE">编辑条款</a><br>Powered by
                            <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://mediawiki.org">MediaWiki</a> <a class="mw-ui-anchor mw-ui-progressive mw-ui-quiet" href="http://www.miitbeian.gov.cn/">京ICP备15015138号</a></p>
                    </footer>
                </div><!-- container -->
            </div><!-- bottom -->
        </div><!-- /#wrapper -->
        <?php 
        }
        ?>
 <!-- mainpage if end -->
        <?php 
        $this->html('bottomscripts');
        /* JS call to runBodyOnloadHook */
        $this->html('reporttime');
        if ($this->data['debug']) {
            ?>
            <!-- Debug output:
            <?php 
            $this->text('debug');
            ?>
            -->
            <?php 
        }
        //end if
        ?>
        <script>
        (function(){
            var bp = document.createElement('script');
            bp.src = '//push.zhanzhang.baidu.com/push.js';
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(bp, s);
        })();
        </script>
        <script>window._bd_share_config={
            "common": {
                "bdSnsKey": {},
                "bdText": "",
                "bdMini": "2",
                "bdMiniList": false,
                "bdPic": "",
                "bdStyle": "2"
            },
            "share": [
                {
                    "tag": "share_1",
                    "bdSize": 32
                },
                {
                    "tag": "share_2",
                    "bdSize": 16
                }
            ]
        };with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>        
        </body>
        </html>
        <?php 
    }
コード例 #18
0
 protected function appendStatistics($property)
 {
     global $wgDisableCounters;
     $data = array();
     $data['pages'] = intval(SiteStats::pages());
     $data['articles'] = intval(SiteStats::articles());
     if (!$wgDisableCounters) {
         $data['views'] = intval(SiteStats::views());
     }
     $data['edits'] = intval(SiteStats::edits());
     $data['images'] = intval(SiteStats::images());
     $data['users'] = intval(SiteStats::users());
     $data['activeusers'] = intval(SiteStats::activeUsers());
     $data['admins'] = intval(SiteStats::numberingroup('sysop'));
     $data['jobs'] = intval(SiteStats::jobs());
     return $this->getResult()->addValue('query', $property, $data);
 }
コード例 #19
0
ファイル: Parser.php プロジェクト: Tarendai/spring-website
 /**
  * Return value of a magic variable (like PAGENAME)
  *
  * @private
  *
  * @param $index integer
  * @param bool|\PPFrame $frame
  *
  * @throws MWException
  * @return string
  */
 function getVariableValue($index, $frame = false)
 {
     global $wgContLang, $wgSitename, $wgServer;
     global $wgArticlePath, $wgScriptPath, $wgStylePath;
     if (is_null($this->mTitle)) {
         // If no title set, bad things are going to happen
         // later. Title should always be set since this
         // should only be called in the middle of a parse
         // operation (but the unit-tests do funky stuff)
         throw new MWException(__METHOD__ . ' Should only be ' . ' called while parsing (no title set)');
     }
     /**
      * Some of these require message or data lookups and can be
      * expensive to check many times.
      */
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
         if (isset($this->mVarCache[$index])) {
             return $this->mVarCache[$index];
         }
     }
     $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     $pageLang = $this->getFunctionLang();
     switch ($index) {
         case 'currentmonth':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('m'));
             break;
         case 'currentmonth1':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentmonthname':
             $value = $pageLang->getMonthName(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentmonthnamegen':
             $value = $pageLang->getMonthNameGen(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentmonthabbrev':
             $value = $pageLang->getMonthAbbreviation(MWTimestamp::getInstance($ts)->format('n'));
             break;
         case 'currentday':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('j'));
             break;
         case 'currentday2':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('d'));
             break;
         case 'localmonth':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('m'));
             break;
         case 'localmonth1':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localmonthname':
             $value = $pageLang->getMonthName(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localmonthnamegen':
             $value = $pageLang->getMonthNameGen(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localmonthabbrev':
             $value = $pageLang->getMonthAbbreviation(MWTimestamp::getLocalInstance($ts)->format('n'));
             break;
         case 'localday':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('j'));
             break;
         case 'localday2':
             $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('d'));
             break;
         case 'pagename':
             $value = wfEscapeWikiText($this->mTitle->getText());
             break;
         case 'pagenamee':
             $value = wfEscapeWikiText($this->mTitle->getPartialURL());
             break;
         case 'fullpagename':
             $value = wfEscapeWikiText($this->mTitle->getPrefixedText());
             break;
         case 'fullpagenamee':
             $value = wfEscapeWikiText($this->mTitle->getPrefixedURL());
             break;
         case 'subpagename':
             $value = wfEscapeWikiText($this->mTitle->getSubpageText());
             break;
         case 'subpagenamee':
             $value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm());
             break;
         case 'rootpagename':
             $value = wfEscapeWikiText($this->mTitle->getRootText());
             break;
         case 'rootpagenamee':
             $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getRootText())));
             break;
         case 'basepagename':
             $value = wfEscapeWikiText($this->mTitle->getBaseText());
             break;
         case 'basepagenamee':
             $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())));
             break;
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 $value = wfEscapeWikiText($talkPage->getPrefixedText());
             } else {
                 $value = '';
             }
             break;
         case 'talkpagenamee':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 $value = wfEscapeWikiText($talkPage->getPrefixedURL());
             } else {
                 $value = '';
             }
             break;
         case 'subjectpagename':
             $subjPage = $this->mTitle->getSubjectPage();
             $value = wfEscapeWikiText($subjPage->getPrefixedText());
             break;
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             $value = wfEscapeWikiText($subjPage->getPrefixedURL());
             break;
         case 'pageid':
             // requested in bug 23427
             $pageid = $this->getTitle()->getArticleID();
             if ($pageid == 0) {
                 # 0 means the page doesn't exist in the database,
                 # which means the user is previewing a new page.
                 # The vary-revision flag must be set, because the magic word
                 # will have a different value once the page is saved.
                 $this->mOutput->setFlag('vary-revision');
                 wfDebug(__METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n");
             }
             $value = $pageid ? $pageid : null;
             break;
         case 'revisionid':
             # Let the edit saving system know we should parse the page
             # *after* a revision ID has been assigned.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n");
             $value = $this->mRevisionId;
             break;
         case 'revisionday':
             # 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__ . ": {{REVISIONDAY}} used, setting vary-revision...\n");
             $value = intval(substr($this->getRevisionTimestamp(), 6, 2));
             break;
         case 'revisionday2':
             # 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__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 6, 2);
             break;
         case 'revisionmonth':
             # 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__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 4, 2);
             break;
         case 'revisionmonth1':
             # 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__ . ": {{REVISIONMONTH1}} used, setting vary-revision...\n");
             $value = intval(substr($this->getRevisionTimestamp(), 4, 2));
             break;
         case 'revisionyear':
             # 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__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n");
             $value = substr($this->getRevisionTimestamp(), 0, 4);
             break;
         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");
             $value = $this->getRevisionTimestamp();
             break;
         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");
             $value = $this->getRevisionUser();
             break;
         case 'revisionsize':
             # 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__ . ": {{REVISIONSIZE}} used, setting vary-revision...\n");
             $value = $this->getRevisionSize();
             break;
         case 'namespace':
             $value = str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace()));
             break;
         case 'namespacee':
             $value = wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace()));
             break;
         case 'namespacenumber':
             $value = $this->mTitle->getNamespace();
             break;
         case 'talkspace':
             $value = $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '';
             break;
         case 'talkspacee':
             $value = $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '';
             break;
         case 'subjectspace':
             $value = str_replace('_', ' ', $this->mTitle->getSubjectNsText());
             break;
         case 'subjectspacee':
             $value = wfUrlencode($this->mTitle->getSubjectNsText());
             break;
         case 'currentdayname':
             $value = $pageLang->getWeekdayName((int) MWTimestamp::getInstance($ts)->format('w') + 1);
             break;
         case 'currentyear':
             $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('Y'), true);
             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;
 }
コード例 #20
0
ファイル: Parser.php プロジェクト: josephdye/wikireader
 /**
  * Return value of a magic variable (like PAGENAME)
  *
  * @private
  */
 function getVariableValue($index)
 {
     global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath;
     /**
      * Some of these require message or data lookups and can be
      * expensive to check many times.
      */
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
         if (isset($this->mVarCache[$index])) {
             return $this->mVarCache[$index];
         }
     }
     $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     # Use the time zone
     global $wgLocaltimezone;
     if (isset($wgLocaltimezone)) {
         $oldtz = getenv('TZ');
         putenv('TZ=' . $wgLocaltimezone);
     }
     wfSuppressWarnings();
     // E_STRICT system time bitching
     $localTimestamp = date('YmdHis', $ts);
     $localMonth = date('m', $ts);
     $localMonthName = date('n', $ts);
     $localDay = date('j', $ts);
     $localDay2 = date('d', $ts);
     $localDayOfWeek = date('w', $ts);
     $localWeek = date('W', $ts);
     $localYear = date('Y', $ts);
     $localHour = date('H', $ts);
     if (isset($wgLocaltimezone)) {
         putenv('TZ=' . $oldtz);
     }
     wfRestoreWarnings();
     switch ($index) {
         case 'currentmonth':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('m', $ts));
         case 'currentmonthname':
             return $this->mVarCache[$index] = $wgContLang->getMonthName(gmdate('n', $ts));
         case 'currentmonthnamegen':
             return $this->mVarCache[$index] = $wgContLang->getMonthNameGen(gmdate('n', $ts));
         case 'currentmonthabbrev':
             return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation(gmdate('n', $ts));
         case 'currentday':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('j', $ts));
         case 'currentday2':
             return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('d', $ts));
         case 'localmonth':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localMonth);
         case 'localmonthname':
             return $this->mVarCache[$index] = $wgContLang->getMonthName($localMonthName);
         case 'localmonthnamegen':
             return $this->mVarCache[$index] = $wgContLang->getMonthNameGen($localMonthName);
         case 'localmonthabbrev':
             return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation($localMonthName);
         case 'localday':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localDay);
         case 'localday2':
             return $this->mVarCache[$index] = $wgContLang->formatNum($localDay2);
         case 'pagename':
             return wfEscapeWikiText($this->mTitle->getText());
         case 'pagenamee':
             return $this->mTitle->getPartialURL();
         case 'fullpagename':
             return wfEscapeWikiText($this->mTitle->getPrefixedText());
         case 'fullpagenamee':
             return $this->mTitle->getPrefixedURL();
         case 'subpagename':
             return wfEscapeWikiText($this->mTitle->getSubpageText());
         case 'subpagenamee':
             return $this->mTitle->getSubpageUrlForm();
         case 'basepagename':
             return wfEscapeWikiText($this->mTitle->getBaseText());
         case 'basepagenamee':
             return wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText()));
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return wfEscapeWikiText($talkPage->getPrefixedText());
             } else {
                 return '';
             }
         case 'talkpagenamee':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return $talkPage->getPrefixedUrl();
             } else {
                 return '';
             }
         case 'subjectpagename':
             $subjPage = $this->mTitle->getSubjectPage();
             return wfEscapeWikiText($subjPage->getPrefixedText());
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             return $subjPage->getPrefixedUrl();
         case 'revisionid':
             // Let the edit saving system know we should parse the page
             // *after* a revision ID has been assigned.
             $this->mOutput->setFlag('vary-revision');
             wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n");
             return $this->mRevisionId;
         case 'revisionday':
             // 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__ . ": {{REVISIONDAY}} used, setting vary-revision...\n");
             return intval(substr($this->getRevisionTimestamp(), 6, 2));
         case 'revisionday2':
             // 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__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n");
             return substr($this->getRevisionTimestamp(), 6, 2);
         case 'revisionmonth':
             // 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__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n");
             return intval(substr($this->getRevisionTimestamp(), 4, 2));
         case 'revisionyear':
             // 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__ . ": {{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;
             }
     }
 }
コード例 #21
0
ファイル: Parser.php プロジェクト: negabaro/alfresco
 /**
  * Return value of a magic variable (like PAGENAME)
  *
  * @private
  */
 function getVariableValue($index)
 {
     global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath;
     /**
      * Some of these require message or data lookups and can be
      * expensive to check many times.
      */
     static $varCache = array();
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$varCache))) {
         if (isset($varCache[$index])) {
             return $varCache[$index];
         }
     }
     $ts = time();
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     # Use the time zone
     global $wgLocaltimezone;
     if (isset($wgLocaltimezone)) {
         $oldtz = getenv('TZ');
         putenv('TZ=' . $wgLocaltimezone);
     }
     $localTimestamp = date('YmdHis', $ts);
     $localMonth = date('m', $ts);
     $localMonthName = date('n', $ts);
     $localDay = date('j', $ts);
     $localDay2 = date('d', $ts);
     $localDayOfWeek = date('w', $ts);
     $localWeek = date('W', $ts);
     $localYear = date('Y', $ts);
     $localHour = date('H', $ts);
     if (isset($wgLocaltimezone)) {
         putenv('TZ=' . $oldtz);
     }
     switch ($index) {
         case 'currentmonth':
             return $varCache[$index] = $wgContLang->formatNum(date('m', $ts));
         case 'currentmonthname':
             return $varCache[$index] = $wgContLang->getMonthName(date('n', $ts));
         case 'currentmonthnamegen':
             return $varCache[$index] = $wgContLang->getMonthNameGen(date('n', $ts));
         case 'currentmonthabbrev':
             return $varCache[$index] = $wgContLang->getMonthAbbreviation(date('n', $ts));
         case 'currentday':
             return $varCache[$index] = $wgContLang->formatNum(date('j', $ts));
         case 'currentday2':
             return $varCache[$index] = $wgContLang->formatNum(date('d', $ts));
         case 'localmonth':
             return $varCache[$index] = $wgContLang->formatNum($localMonth);
         case 'localmonthname':
             return $varCache[$index] = $wgContLang->getMonthName($localMonthName);
         case 'localmonthnamegen':
             return $varCache[$index] = $wgContLang->getMonthNameGen($localMonthName);
         case 'localmonthabbrev':
             return $varCache[$index] = $wgContLang->getMonthAbbreviation($localMonthName);
         case 'localday':
             return $varCache[$index] = $wgContLang->formatNum($localDay);
         case 'localday2':
             return $varCache[$index] = $wgContLang->formatNum($localDay2);
         case 'pagename':
             return $this->mTitle->getText();
         case 'pagenamee':
             return $this->mTitle->getPartialURL();
         case 'fullpagename':
             return $this->mTitle->getPrefixedText();
         case 'fullpagenamee':
             return $this->mTitle->getPrefixedURL();
         case 'subpagename':
             return $this->mTitle->getSubpageText();
         case 'subpagenamee':
             return $this->mTitle->getSubpageUrlForm();
         case 'basepagename':
             return $this->mTitle->getBaseText();
         case 'basepagenamee':
             return wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText()));
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return $talkPage->getPrefixedText();
             } else {
                 return '';
             }
         case 'talkpagenamee':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return $talkPage->getPrefixedUrl();
             } else {
                 return '';
             }
         case 'subjectpagename':
             $subjPage = $this->mTitle->getSubjectPage();
             return $subjPage->getPrefixedText();
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             return $subjPage->getPrefixedUrl();
         case 'revisionid':
             return $this->mRevisionId;
         case 'revisionday':
             return intval(substr($this->getRevisionTimestamp(), 6, 2));
         case 'revisionday2':
             return substr($this->getRevisionTimestamp(), 6, 2);
         case 'revisionmonth':
             return intval(substr($this->getRevisionTimestamp(), 4, 2));
         case 'revisionyear':
             return substr($this->getRevisionTimestamp(), 0, 4);
         case 'revisiontimestamp':
             return $this->getRevisionTimestamp();
         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 $varCache[$index] = $wgContLang->getWeekdayName(date('w', $ts) + 1);
         case 'currentyear':
             return $varCache[$index] = $wgContLang->formatNum(date('Y', $ts), true);
         case 'currenttime':
             return $varCache[$index] = $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false);
         case 'currenthour':
             return $varCache[$index] = $wgContLang->formatNum(date('H', $ts), true);
         case 'currentweek':
             // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
             // int to remove the padding
             return $varCache[$index] = $wgContLang->formatNum((int) date('W', $ts));
         case 'currentdow':
             return $varCache[$index] = $wgContLang->formatNum(date('w', $ts));
         case 'localdayname':
             return $varCache[$index] = $wgContLang->getWeekdayName($localDayOfWeek + 1);
         case 'localyear':
             return $varCache[$index] = $wgContLang->formatNum($localYear, true);
         case 'localtime':
             return $varCache[$index] = $wgContLang->time($localTimestamp, false, false);
         case 'localhour':
             return $varCache[$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 $varCache[$index] = $wgContLang->formatNum((int) $localWeek);
         case 'localdow':
             return $varCache[$index] = $wgContLang->formatNum($localDayOfWeek);
         case 'numberofarticles':
             return $varCache[$index] = $wgContLang->formatNum(SiteStats::articles());
         case 'numberoffiles':
             return $varCache[$index] = $wgContLang->formatNum(SiteStats::images());
         case 'numberofusers':
             return $varCache[$index] = $wgContLang->formatNum(SiteStats::users());
         case 'numberofpages':
             return $varCache[$index] = $wgContLang->formatNum(SiteStats::pages());
         case 'numberofadmins':
             return $varCache[$index] = $wgContLang->formatNum(SiteStats::admins());
         case 'currenttimestamp':
             return $varCache[$index] = wfTimestampNow();
         case 'localtimestamp':
             return $varCache[$index] = $localTimestamp;
         case 'currentversion':
             return $varCache[$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, &$varCache, &$index, &$ret))) {
                 return $ret;
             } else {
                 return null;
             }
     }
 }
コード例 #22
0
 protected function appendStatistics($property)
 {
     global $wgDisableCounters;
     $data = array();
     $data['pages'] = intval(SiteStats::pages());
     $data['articles'] = intval(SiteStats::articles());
     if (!$wgDisableCounters) {
         $data['views'] = intval(SiteStats::views());
     }
     $data['edits'] = intval(SiteStats::edits());
     $data['images'] = intval(SiteStats::images());
     $data['users'] = intval(SiteStats::users());
     $data['activeusers'] = intval(SiteStats::activeUsers());
     $data['admins'] = intval(SiteStats::numberingroup('sysop'));
     $data['jobs'] = intval(SiteStats::jobs());
     // Wikia change begin
     // @author macbre
     wfRunHooks('APIQuerySiteInfoStatistics', array($this, &$data));
     // Wikia change end
     return $this->getResult()->addValue('query', $property, $data);
 }
コード例 #23
0
ファイル: SiteLibrary.php プロジェクト: Tjorriemorrie/app
 public function loadSiteStats()
 {
     global $wgDisableCounters;
     self::$siteStatsLoaded = true;
     return array(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()));
 }
コード例 #24
0
 public static function numberofarticles($parser, $raw = null)
 {
     return self::formatRaw(SiteStats::articles(), $raw);
 }
コード例 #25
0
 protected function appendStatistics($property)
 {
     $data = [];
     $data['pages'] = intval(SiteStats::pages());
     $data['articles'] = intval(SiteStats::articles());
     $data['edits'] = intval(SiteStats::edits());
     $data['images'] = intval(SiteStats::images());
     $data['users'] = intval(SiteStats::users());
     $data['activeusers'] = intval(SiteStats::activeUsers());
     $data['admins'] = intval(SiteStats::numberingroup('sysop'));
     $data['jobs'] = intval(SiteStats::jobs());
     Hooks::run('APIQuerySiteInfoStatisticsInfo', [&$data]);
     return $this->getResult()->addValue('query', $property, $data);
 }
コード例 #26
0
 /**
  * Print basic information about this site.
  */
 public function printWikiInfo()
 {
     global $wgSitename, $wgLanguageCode;
     $this->prepareSerialization();
     $this->delay_flush = 35;
     // don't do intermediate flushes with default parameters
     // assemble export data:
     $expData = new SMWExpData(new SMWExpResource('&wiki;#wiki'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('rdf', 'type'), new SMWExpData(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'Wikisite')));
     // basic wiki information
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('rdfs', 'label'), new SMWExpLiteral($wgSitename));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'siteName'), new SMWExpLiteral($wgSitename, 'http://www.w3.org/2001/XMLSchema#string'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'pagePrefix'), new SMWExpLiteral(SMWExporter::getInstance()->expandURI('&wikiurl;'), 'http://www.w3.org/2001/XMLSchema#string'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'smwVersion'), new SMWExpLiteral(SMW_VERSION, 'http://www.w3.org/2001/XMLSchema#string'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'langCode'), new SMWExpLiteral($wgLanguageCode, 'http://www.w3.org/2001/XMLSchema#string'));
     $mainpage = Title::newMainPage();
     if (!is_null($mainpage)) {
         $ed = new SMWExpData(new SMWExpResource($mainpage->getFullURL()));
         $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'mainPage'), $ed);
     }
     // statistical information
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'pageCount'), new SMWExpLiteral(SiteStats::pages(), 'http://www.w3.org/2001/XMLSchema#int'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'contentPageCount'), new SMWExpLiteral(SiteStats::articles(), 'http://www.w3.org/2001/XMLSchema#int'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'mediaCount'), new SMWExpLiteral(SiteStats::images(), 'http://www.w3.org/2001/XMLSchema#int'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'editCount'), new SMWExpLiteral(SiteStats::edits(), 'http://www.w3.org/2001/XMLSchema#int'));
     // SiteStats::views was deprecated in MediaWiki 1.25
     // "Stop calling this function, it will be removed some time in the future"
     //$expData->addPropertyObjectValue(
     //	SMWExporter::getInstance()->getSpecialNsResource( 'swivt', 'viewCount' ),
     //	new SMWExpLiteral( SiteStats::views(), 'http://www.w3.org/2001/XMLSchema#int' )
     //);
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'userCount'), new SMWExpLiteral(SiteStats::users(), 'http://www.w3.org/2001/XMLSchema#int'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('swivt', 'adminCount'), new SMWExpLiteral(SiteStats::numberingroup('sysop'), 'http://www.w3.org/2001/XMLSchema#int'));
     $this->serializer->startSerialization();
     $this->serializer->serializeExpData(SMWExporter::getInstance()->getOntologyExpData(''));
     $this->serializer->serializeExpData($expData);
     // link to list of existing pages:
     if (strpos(SMWExporter::getInstance()->expandURI('&wikiurl;'), '?') === false) {
         // check whether we have title as a first parameter or in URL
         $nexturl = SMWExporter::getInstance()->expandURI('&export;?offset=0');
     } else {
         $nexturl = SMWExporter::getInstance()->expandURI('&export;&amp;offset=0');
     }
     $expData = new SMWExpData(new SMWExpResource($nexturl));
     $ed = new SMWExpData(SMWExporter::getInstance()->getSpecialNsResource('owl', 'Thing'));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('rdf', 'type'), $ed);
     $ed = new SMWExpData(new SMWExpResource($nexturl));
     $expData->addPropertyObjectValue(SMWExporter::getInstance()->getSpecialNsResource('rdfs', 'isDefinedBy'), $ed);
     $this->serializer->serializeExpData($expData);
     $this->serializer->finishSerialization();
     $this->flush(true);
 }
コード例 #27
0
	/**
	 * Render default page header (with edit dropdown, history dropdown, ...)
	 *
	 * @param: array $params
	 *    key: showSearchBox (default: false)
	 */
	public function executeIndex($params) {
		global $wgTitle, $wgArticle, $wgOut, $wgUser, $wgContLang, $wgSupressPageTitle, $wgSupressPageSubtitle, $wgSuppressNamespacePrefix, $wgCityId, $wgEnableWallExt;
		wfProfileIn(__METHOD__);

		$this->isUserLoggedIn = $wgUser->isLoggedIn();

		// page namespace
		$ns = $wgTitle->getNamespace();

		/** start of wikia changes @author nAndy */
		$this->isWallEnabled = (!empty($wgEnableWallExt) && $ns == NS_USER_WALL);
		/** end of wikia changes */

		// currently used skin
		$skin = RequestContext::getMain()->getSkin();

		// action button (edit / view soruce) and dropdown for it
		$this->prepareActionButton();

		// dropdown actions
		$this->dropdown = $this->getDropdownActions();

		/** start of wikia changes @author nAndy */
		$response = $this->getResponse();
		if( $response instanceof WikiaResponse ) {
			wfRunHooks( 'PageHeaderIndexAfterActionButtonPrepared', array($response, $ns, $skin) );
			/** @author Jakub */
			$this->extraButtons = array();
			wfRunHooks( 'PageHeaderIndexExtraButtons', array( $response ) );
		} else {
			//it happened on TimQ's devbox that $response was probably null fb#28747
			Wikia::logBacktrace(__METHOD__);
		}
		/** end of wikia changes */

		// for not existing pages page header is a bit different
		$this->pageExists = !empty($wgTitle) && $wgTitle->exists();

		// default title "settings" (RT #145371), don't touch special pages
		if ($ns != NS_SPECIAL) {
			$this->displaytitle = true;
			$this->title = $wgOut->getPageTitle();
		}
		else {
			// on special pages titles are already properly encoded (BugId:5983)
			$this->displaytitle = true;
		}

		// perform namespace and special page check

		// use service to get data
		$service = PageStatsService::newFromTitle( $wgTitle );

		// comments - moved here to display comments even on deleted/non-existant pages
		$this->comments = $service->getCommentsCount();

		if ($this->pageExists) {

			// show likes
			$this->likes = true;

			// get two popular categories this article is in
			$categories = array();

			// FIXME: Might want to make a WikiFactory variable for controlling this feature if we aren't
			// comfortable with its performance.
			// NOTE: Skip getMostLinkedCategories() on Lyrics and Marvel because we're not sure yet that it's fast enough.
			$LYRICS_CITY_ID = "43339";
			$MARVEL_CITY_ID = "2233";
			if(($wgCityId != $LYRICS_CITY_ID)  && ($wgCityId != $MARVEL_CITY_ID)){
				$categories = $service->getMostLinkedCategories();
			}

			// render links to most linked category page
			$categoriesVar = array();
			foreach($categories as $category => $cnt) {
				$title = Title::newFromText($category, NS_CATEGORY);
				if($title) {
					$categoriesVar[] = Wikia::link($title, $title->getText());
				}
			}
			$this->categories = $categoriesVar;

			// get info about current revision and list of authors of recent five edits
			$this->revisions = $this->getRecentRevisions();

			// mainpage?
			if (WikiaPageType::isMainPage()) {
				$this->isMainPage = true;
			}

			// number of pages on this wiki
			$this->tallyMsg = wfMsgExt('oasis-total-articles-mainpage', array( 'parsemag' ), SiteStats::articles() );

		}

		// remove namespaces prefix from title
		$namespaces = array(NS_MEDIAWIKI, NS_TEMPLATE, NS_CATEGORY, NS_FILE);
		if (defined('NS_VIDEO')) {
			$namespaces[] = NS_VIDEO;
		}
		if ( in_array($ns, array_merge( $namespaces, $wgSuppressNamespacePrefix ) ) ) {
			$this->title = $wgTitle->getText();
			$this->displaytitle = false;
		}

		// talk pages
		if ($wgTitle->isTalkPage()) {
			// remove comments & FB like button
			$this->comments = false;

			// Talk: <page name without namespace prefix>
			$this->displaytitle = true;
			$this->title = Xml::element('strong', array(), $wgContLang->getNsText(NS_TALK) . ':');
			$this->title .= htmlspecialchars($wgTitle->getText());

			// back to subject article link
			switch($ns) {
				case NS_TEMPLATE_TALK:
					$msgKey = 'oasis-page-header-back-to-template';
					break;

				case NS_MEDIAWIKI_TALK:
					$msgKey = 'oasis-page-header-back-to-mediawiki';
					break;

				case NS_CATEGORY_TALK:
					$msgKey = 'oasis-page-header-back-to-category';
					break;

				case NS_FILE_TALK:
					$msgKey = 'oasis-page-header-back-to-file';
					break;

				default:
					$msgKey = 'oasis-page-header-back-to-article';
			}

			$this->pageTalkSubject = Wikia::link($wgTitle->getSubjectPage(), wfMsg($msgKey), array('accesskey' => 'c'));
		}

		// category pages
		if ($ns == NS_CATEGORY) {
			// hide revisions / categories bar
			$this->categories = false;
			$this->revisions = false;
		}

		// forum namespace
		if ($ns == NS_FORUM) {
			// remove comments button
			$this->comments = false;

			// remove namespace prefix
			$this->title = $wgTitle->getText();
			$this->displaytitle = false;
		}

		// mainpage
		if (WikiaPageType::isMainPage()) {
			// change page title to just "Home"
			$this->title = wfMsg('oasis-home');
			// hide revisions / categories bar
			$this->categories = false;
			$this->revisions = false;
		}

		// render page type info
		switch($ns) {
			case NS_MEDIAWIKI:
				$this->pageType = wfMsg('oasis-page-header-subtitle-mediawiki');
				break;

			case NS_TEMPLATE:
				$this->pageType = wfMsg('oasis-page-header-subtitle-template');
				break;

			case NS_SPECIAL:
				$this->pageType = wfMsg('oasis-page-header-subtitle-special');

				// remove comments button (fix FB#3404 - Marooned)
				$this->comments = false;

				// FIXME: use PageHeaderIndexAfterExecute hook or $wgSupressPageSubtitle instead
				if($wgTitle->isSpecial('PageLayoutBuilderForm') || $wgTitle->isSpecial('PageLayoutBuilder') ) {
					$this->displaytitle = true;
					$this->pageType = "";
				}

				if($wgTitle->isSpecial('Newimages')) {
					$this->isNewFiles = true;
				}

				if($wgTitle->isSpecial('Videos')) {
					$this->isSpecialVideos = true;
					$mediaService = F::build( 'MediaQueryService' );
					$this->tallyMsg = wfMsgExt('specialvideos-wiki-videos-tally', array( 'parsemag' ), $mediaService->getTotalVideos() );
				}

				break;

			case NS_CATEGORY:
				$this->pageType = wfMsg('oasis-page-header-subtitle-category');
				break;

			case NS_FORUM:
				$this->pageType = wfMsg('oasis-page-header-subtitle-forum');
				break;
		}

		// render subpage info
		$this->pageSubject = $skin->subPageSubtitle();

		if ( in_array($wgTitle->getNamespace(), BodyController::getUserPagesNamespaces() ) ) {
			$title = explode(':', $this->title);
			if(count($title) >= 2 && $wgTitle->getNsText() == str_replace(' ', '_', $title[0]) ) // in case of error page (showErrorPage) $title is just a string (cannot explode it)
				$this->title = $title[1];
		}

		// render MW subtitle (contains old revision data)
		$this->subtitle = $wgOut->getSubtitle();

		// render redirect info (redirected from)
		if (!empty($wgArticle->mRedirectedFrom)) {
			$this->pageRedirect = trim($this->subtitle, '()');
			$this->subtitle = '';
		}

		// render redirect page (redirect to)
		if ($wgTitle->isRedirect()) {
			$this->pageType = $this->subtitle;
			$this->subtitle = '';
		}

		// if page is rendered using one column layout, show search box as a part of page header
		$this->showSearchBox = isset($params['showSearchBox']) ? $params['showSearchBox'] : false ;

		if (!empty($wgSupressPageTitle)) {
			$this->title = '';
			$this->subtitle = '';
		}

		if (!empty($wgSupressPageSubtitle)) {
			$this->subtitle = '';
			$this->pageSubtitle = '';
		}
		else {
			// render pageType, pageSubject and pageSubtitle as one message
			$subtitle = array_filter(array(
				$this->pageType,
				$this->pageTalkSubject,
				$this->pageSubject,
				$this->pageRedirect,
			));

			/*
			 * support for language variants
			 * this adds links which automatically convert the content to that variant
			 *
			 * @author tor@wikia-inc.com
			 */
			if ( $wgContLang->hasVariants() ) {
				foreach ( $wgContLang->getVariants() as $variant ) {
					if ( $variant != $wgContLang->getCode() ) {
						$subtitle[] = Xml::element(
							'a',
							array(
								'href' => $wgTitle->getLocalUrl( array( 'variant' => $variant ) ),
								'rel' => 'nofollow'
							),
							$wgContLang->getVariantname( $variant )
						);
					}
				}
			}

			$pipe = wfMsg('pipe-separator');
			$this->pageSubtitle = implode(" {$pipe} ", $subtitle);
		}

		// force AjaxLogin popup for "Add a page" button (moved from the template)
		$this->loginClass = !empty($this->wg->DisableAnonymousEditing) ? ' require-login' : '';

		if ( $this->wg->OasisNavV2 && $response instanceof WikiaResponse ) {
            $response->getView()->setTemplatePath( dirname( __FILE__ ) .'/templates/PageHeader_IndexV2.php' );
        }
		wfProfileOut(__METHOD__);
	}