Example #1
0
function wfSpecialCheckquality($par)
{
    global $wgRequest, $wgSitename, $wgLanguageCode;
    global $wgDeferredUpdateList, $wgOut, $wgUser;
    $fname = "wfCheckquality";
    $sk = $wgUser->getSkin();
    $target = $wgRequest->getVal('target');
    if ($target == '') {
        $wgOut->addHTML(wfMsg('checkquality_notitle'));
        return;
    }
    $t = Title::newFromText($target);
    $id = $t->getArticleID();
    if ($id == 0) {
        $wgOut->addHTML(wfMsg("checkquality_titlenonexistant"));
        return;
    }
    $dbr = wfGetDB(DB_SLAVE);
    $related = $dbr->selectField("pagelinks", "count(*)", array('pl_from' => $id), "wfSpecialCheckquality");
    $inbound = $dbr->selectField("pagelinks", "count(*)", array('pl_namespace' => $t->getNamespace(), 'pl_title' => $t->getDBKey()), "wfSpecialCheckquality");
    // talk page
    $f = Title::newFromText("Featured", NS_TEMPLATE);
    $tp = $t->getTalkPage();
    $featured = $dbr->selectField("templatelinks", "count(*)", array('tl_from' => $tp->getArticleID(), 'tl_namespace' => 10, 'tl_title' => 'Featured'), "wfSpecialCheckquality");
    $fadate = "";
    if ($featured > 0) {
        $rev = Revision::newFromTitle($tp);
        $text = $rev->getText();
        $matches = array();
        preg_match('/{{Featured.*}}/', $text, &$matches);
        $fadate = $matches[0];
        $fadate = str_replace("{{Featured|", "", $fadate);
        $fadate = str_replace("}}", "", $fadate);
    }
    $rev = Revision::newFromTitle($t);
    $section = Article::getSection($rev->getText(), 0);
    $intro_photo = preg_match('/\\[\\[Image:/', $section);
    $section = Article::getSection($rev->getText(), 1);
    $num_steps = preg_match_all('/^#/im', $section, $matches);
    $num_step_photos = preg_match_all('/\\[\\[Image:/', $section, $matches);
    $linkshere = Title::newFromText("Whatlinkshere", NS_SPECIAL);
    $linksherelink = $sk->makeLinkObj($linkshere, $inbound, "target=" . $t->getPrefixedURL());
    $articlelink = $sk->makeLinkObj($t, wfMsg('howto', $t->getFullText()));
    $numvotes = $dbr->selectField("rating", "count(*)", array('rat_page' => $t->getArticleID()), "wfSpecialCheckquality");
    $rating = $dbr->selectField("rating", "avg(rat_rating)", array('rat_page' => $t->getArticleID(), 'rat_isdeleted' => 0), "wfSpecialCheckquality");
    $rating = number_format($rating * 100, 0, "", "");
    $a = new Article(&$t);
    $pageviews = number_format($a->getCount(), 0, "", ",");
    $wgOut->addHTML("\n\n<style type='text/css'>\n\n.roundcont {\n\twidth: 450px;\n\tbackground-color: #f90;\n}\n\n.roundcont p {\n\tmargin: 0 10px;\n}\n\n.roundtop { \n\tbackground: url(http://kalsey.com/tools/css/rounded/images/tr.gif) no-repeat top right; \n}\n\n.roundbottom {\n\tbackground: url(http://kalsey.com/tools/css/rounded/images/br.gif) no-repeat top right; \n}\n\nimg.corner {\n   width: 15px;\n   height: 15px;\n   border: none;\n   display: block !important;\n}\n</style>\n\t\t\n<div class='roundcont'>\n   <div class='roundtop'>\n\t <img src='http://kalsey.com/tools/css/rounded/images/tl.gif' alt='' \n\t width='15' height='15' class='corner' \n\t style='display: none' />\n   </div>\n\t<p> {$articlelink}<br/>\n\t<table border=0 cellpadding=5>\n\t\t\t<tr><td><b># related wikihows:</td><td> {$related} <br/></td></tr>\n\t\t\t<tr><td><b># inbound links</td><td>  {$linksherelink} <br/></td></tr>\n\t\t\t<tr><td><b>featured? </td><td>1=yes,0=no (optional date): {$featured} ({$fadate}) <br/></td></tr>\n\t\t\t<tr><td><b>Has intro photo? </td><td>{$intro_photo} <br/></td></tr>\n\t\t\t<tr><td><b>Number of steps:</td><td> {$num_steps} <br/></td></tr>\n\t\t\t<tr><td><b>Number of step photos:</td><td> {$num_step_photos} <br/></td></tr>\n\t\t\t<tr><td><b>page views:</td><td> {$pageviews} <br/></td></tr>\n\t\t\t<tr><td><b>accuracy :</td><td> {$rating}% of people found this article accurate (based on {$numvotes} votes) <br/>\t\t\t</td></tr>\n \t</table> \n\t</p>\n   <div class='roundbottom'>\n\t <img src='http://kalsey.com/tools/css/rounded/images/bl.gif' alt='' \n\t width='15' height='15' class='corner' \n\t style='display: none' />\n\n   </div>\n</div>\n\t\t\thas tips? has warnings? should we include this? <br/> </p>\n\t\t\t");
}
 function execute($par)
 {
     global $wgRequest, $wgSitename, $wgLanguageCode;
     global $wgDeferredUpdateList, $wgOut, $wgUser;
     $fname = "wfArticlestats";
     $sk = $wgUser->getSkin();
     $this->setHeaders();
     $target = $par != '' ? $par : $wgRequest->getVal('target');
     if ($target == '') {
         $wgOut->addHTML(wfMsg('articlestats_notitle'));
         return;
     }
     $t = Title::newFromText($target);
     $id = $t->getArticleID();
     if ($id == 0) {
         $wgOut->addHTML(wfMsg("checkquality_titlenonexistant"));
         return;
     }
     $dbr =& wfGetDB(DB_SLAVE);
     $related = $dbr->selectField("pagelinks", "count(*)", array('pl_from' => $id), "wfSpecialArticlestats");
     $inbound = $dbr->selectField(array("pagelinks", "page"), "count(*)", array('pl_namespace' => $t->getNamespace(), 'pl_title' => $t->getDBKey(), 'page_id=pl_from', 'page_namespace=0'), "wfSpecialArticlestats");
     $sources = $dbr->selectField(array("externallinks"), "count(*)", array('el_from' => $t->getArticleID()), "wfSpecialArticlestats");
     $langlinks = $dbr->selectField(array("langlinks"), "count(*)", array('ll_from' => $t->getArticleID()), "wfSpecialArticlestats");
     // talk page
     $f = Title::newFromText("Featured", NS_TEMPLATE);
     $tp = $t->getTalkPage();
     $featured = $dbr->selectField("templatelinks", "count(*)", array('tl_from' => $tp->getArticleID(), 'tl_namespace' => 10, 'tl_title' => 'Featured'), "wfSpecialArticlestats");
     $fadate = "";
     if ($featured > 0) {
         $rev = Revision::newFromTitle($tp);
         $text = $rev->getText();
         $matches = array();
         preg_match('/{{Featured.*}}/', $text, $matches);
         $fadate = $matches[0];
         $fadate = str_replace("{{Featured|", "", $fadate);
         $fadate = str_replace("}}", "", $fadate);
         $fadate = "({$fadate})";
         $featured = wfMsg('articlestats_yes');
     } else {
         $featured = wfMsg('articlestats_no');
     }
     $rev = Revision::newFromTitle($t);
     $section = Article::getSection($rev->getText(), 0);
     $intro_photo = preg_match('/\\[\\[Image:/', $section) == 1 ? wfMsg('articlestats_yes') : wfMsg('articlestats_no');
     $section = Article::getSection($rev->getText(), 1);
     preg_match("/==[ ]*" . wfMsg('steps') . "/", $section, $matches, PREG_OFFSET_CAPTURE);
     if (sizeof($matches) == 0 || $matches[0][1] != 0) {
         $section = Article::getSection($rev->getText(), 2);
     }
     $num_steps = preg_match_all('/^#/im', $section, $matches);
     $num_step_photos = preg_match_all('/\\[\\[Image:/', $section, $matches);
     $has_stepbystep_photos = wfMsg('articlestats_no');
     if ($num_steps > 0) {
         $has_stepbystep_photos = $num_step_photos / $num_steps > 0.5 ? wfMsg('articlestats_yes') : wfMsg('articlestats_no');
     }
     $linkshere = Title::newFromText("Whatlinkshere", NS_SPECIAL);
     $linksherelink = $sk->makeLinkObj($linkshere, $inbound, "target=" . $t->getPrefixedURL());
     $articlelink = $sk->makeLinkObj($t, wfMsg('howto', $t->getFullText()));
     $numvotes = $dbr->selectField("rating", "count(*)", array('rat_page' => $t->getArticleID(), "rat_isdeleted=0"), "wfSpecialArticlestats");
     $rating = $dbr->selectField("rating", "avg(rat_rating)", array('rat_page' => $t->getArticleID(), 'rat_isdeleted' => 0), "wfSpecialArticlestats");
     $unique = $dbr->selectField("rating", "count(distinct(rat_user_text))", array('rat_page' => $t->getArticleID(), "rat_isdeleted=0"), "wfSpecialArticlestats");
     $rating = number_format($rating * 100, 0, "", "");
     $a = new Article($t);
     $count = $a->getCount();
     $pageviews = number_format($count, 0, "", ",");
     $accuracy = '<img src="/skins/WikiHow/images/grey_ball.png">&nbsp; &nbsp;' . wfMsg('articlestats_notenoughvotes');
     if ($numvotes >= 5) {
         if ($rating > 70) {
             $accuracy = '<img src="/skins/WikiHow/images/green_ball.png">';
         } else {
             if ($rating > 40) {
                 $accuracy = '<img src="/skins/WikiHow/images/yellow_ball.png">';
             } else {
                 $accuracy = '<img src="/skins/WikiHow/images/red_ball.png">';
             }
         }
         $accuracy .= "&nbsp; &nbsp;" . wfMsg('articlestats_rating', $rating, $numvotes, $unique);
     }
     if ($index > 10 || $index == 0) {
         $index = wfMsg('articlestats_notintopten', wfMsg('howto', urlencode($t->getText())));
         $index .= "<br/>" . wfMsg('articlestats_lastchecked', substr($max, 0, 10));
     } else {
         if ($index < 0) {
             $index = wfMsg('articlestats_notcheckedyet', wfMsg('howto', urlencode($t->getText())));
         } else {
             $index = wfMsg('articlestats_indexrank', wfMsg('howto', urlencode($t->getText())), $index);
             $index .= wfMsg('articlestats_lastchecked', substr($max, 0, 10));
         }
     }
     $cl = SpecialPage::getTitleFor('Clearratings', $t->getText());
     $wgOut->addHTML("\n\t\n\t\t<p> {$articlelink}<br/>\n\t\t<table border=0 cellpadding=5>\n\t\t\t\t<tr><td width='350px;' valign='middle' > \n\t\t\t\t\t\t" . wfMsgExt('articlestats_accuracy', 'parseinline', $cl->getFullText()) . " </td><td valign='middle'> {$accuracy}<br/>\t\t\t</td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_hasphotoinintro', 'parseinline') . "</td><td>{$intro_photo} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_stepbystepphotos', 'parseinline') . "</td><td> {$has_stepbystep_photos} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_isfeatured', 'parseinline') . "</td><td> {$featured} {$fadate} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_numinboundlinks', 'parseinline') . "</td><td>  {$linksherelink}</td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_outboundlinks', 'parseinline') . "</td><td> {$related} </td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_sources', 'parseinline') . "</td><td> {$sources}</td></tr>\n\t\t\t\t<tr><td>" . wfMsgExt('articlestats_langlinks', 'parseinline') . "</td><td> {$langlinks}</td></tr>\n\t \t</table> \n\t\t</p> " . wfMsgExt('articlestats_footer', 'parseinline') . "\n\t\t\t\t");
 }
<?php

//навигация по статьям (4 статьи на странице)
// include_once ROOT . '/models/ArticleModel.php';
$count = Article::getCount();
// на одной стринице будет выводиться 4 статьи
//	'1' => '1,2,3,4',
//	'2'	=> '5,6,7,8',
//   etc...
// генерация массива нечетных чисел через одно: 1,5,9,13,.... - 'эти числа есть первые числа в элементx массива'
$k = 1;
$arr = array();
for ($j = 1; $j <= $count; $j++) {
    if ($j % 2 != 0) {
        $arr["{$k}"] = $j;
        // массив нечетных чисел
        $k++;
    }
}
$arr2 = array();
$l = 1;
foreach ($arr as $key => $value) {
    if ($key % 2 != 0) {
        $arr2["{$l}"] = $value;
        // массив нечетных числе через одно
        $l++;
    }
}
$requestURI = $_SERVER['REQUEST_URI'];
$requestURI_array = explode('/', $requestURI);
$navID = array_pop($requestURI_array);
Example #4
0
 function getPageViews()
 {
     global $wgLang, $wgTitle;
     $a = new Article($wgTitle);
     $count = $wgLang->formatNum($a->getCount());
     $s = wfMsg('viewcountuser', $count);
     return $s;
 }
Example #5
0
 public function getCommentCount()
 {
     return Article::getCount(['article_id' => $this->id]);
 }
 function getPageViews()
 {
     global $wgLang, $wgTitle;
     $a = new Article($wgTitle);
     $count = $a ? (int) $a->getCount() : 0;
     $countFormatted = $wgLang->formatNum($count);
     $s = wfMessage('viewcountuser', $countFormatted)->text();
     return $s;
 }
 /**
  * initialize various variables and generate the template
  *
  * @param $out OutputPage
  */
 function outputPage(OutputPage $out)
 {
     global $wgUser, $wgLang, $wgContLang;
     global $wgScript, $wgStylePath;
     global $wgMimeType, $wgJsMimeType, $wgRequest;
     global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
     global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
     global $wgMaxCredits, $wgShowCreditsIfMax;
     global $wgPageShowWatchingUsers;
     global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments;
     global $wgArticlePath, $wgScriptPath, $wgServer;
     wfProfileIn(__METHOD__);
     Profiler::instance()->setTemplated(true);
     $oldid = $wgRequest->getVal('oldid');
     $diff = $wgRequest->getVal('diff');
     $action = $wgRequest->getVal('action', 'view');
     wfProfileIn(__METHOD__ . '-init');
     $this->initPage($out);
     $tpl = $this->setupTemplate($this->template, 'skins');
     wfProfileOut(__METHOD__ . '-init');
     wfProfileIn(__METHOD__ . '-stuff');
     $this->thispage = $this->getTitle()->getPrefixedDBkey();
     $this->userpage = $wgUser->getUserPage()->getPrefixedText();
     $query = array();
     if (!$wgRequest->wasPosted()) {
         $query = $wgRequest->getValues();
         unset($query['title']);
         unset($query['returnto']);
         unset($query['returntoquery']);
     }
     $this->thisquery = wfArrayToCGI($query);
     $this->loggedin = $wgUser->isLoggedIn();
     $this->iscontent = $this->getTitle()->getNamespace() != NS_SPECIAL;
     $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
     $this->username = $wgUser->getName();
     if ($wgUser->isLoggedIn() || $this->showIPinHeader()) {
         $this->userpageUrlDetails = self::makeUrlDetails($this->userpage);
     } else {
         # This won't be used in the standard skins, but we define it to preserve the interface
         # To save time, we check for existence
         $this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage);
     }
     $this->titletxt = $this->getTitle()->getPrefixedText();
     wfProfileOut(__METHOD__ . '-stuff');
     wfProfileIn(__METHOD__ . '-stuff-head');
     if ($this->useHeadElement) {
         $pagecss = $this->setupPageCss();
         if ($pagecss) {
             $out->addInlineStyle($pagecss);
         }
     } else {
         $this->setupUserCss($out);
         $tpl->set('pagecss', $this->setupPageCss());
         $tpl->set('usercss', false);
         $this->userjs = $this->userjsprev = false;
         # @todo FIXME: This is the only use of OutputPage::isUserJsAllowed() anywhere; can we
         # get rid of it?  For that matter, why is any of this here at all?
         $this->setupUserJs($out->isUserJsAllowed());
         $tpl->setRef('userjs', $this->userjs);
         $tpl->setRef('userjsprev', $this->userjsprev);
         if ($wgUseSiteJs) {
             $jsCache = $this->loggedin ? '&smaxage=0' : '';
             $tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName())));
         } else {
             $tpl->set('jsvarurl', false);
         }
         $tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace);
         $tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces);
         $tpl->set('html5version', $wgHtml5Version);
         $tpl->set('headlinks', $out->getHeadLinks($this));
         $tpl->set('csslinks', $out->buildCssLinks($this));
         if ($wgUseTrackbacks && $out->isArticleRelated()) {
             $tpl->set('trackbackhtml', $out->getTitle()->trackbackRDF());
         } else {
             $tpl->set('trackbackhtml', null);
         }
     }
     wfProfileOut(__METHOD__ . '-stuff-head');
     wfProfileIn(__METHOD__ . '-stuff2');
     $tpl->set('title', $out->getPageTitle());
     $tpl->set('pagetitle', $out->getHTMLTitle());
     $tpl->set('displaytitle', $out->mPageLinkTitle);
     $tpl->set('pageclass', $this->getPageClasses($this->getTitle()));
     $tpl->set('skinnameclass', 'skin-' . Sanitizer::escapeClass($this->getSkinName()));
     $nsname = MWNamespace::exists($this->getTitle()->getNamespace()) ? MWNamespace::getCanonicalName($this->getTitle()->getNamespace()) : $this->getTitle()->getNsText();
     $tpl->set('nscanonical', $nsname);
     $tpl->set('nsnumber', $this->getTitle()->getNamespace());
     $tpl->set('titleprefixeddbkey', $this->getTitle()->getPrefixedDBKey());
     $tpl->set('titletext', $this->getTitle()->getText());
     $tpl->set('articleid', $this->getTitle()->getArticleId());
     $tpl->set('currevisionid', $this->getTitle()->getLatestRevID());
     $tpl->set('isarticle', $out->isArticle());
     $tpl->setRef('thispage', $this->thispage);
     $subpagestr = $this->subPageSubtitle();
     $tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle());
     $undelete = $this->getUndeleteLink();
     $tpl->set('undelete', !empty($undelete) ? '<span class="subpages">' . $undelete . '</span>' : '');
     $tpl->set('catlinks', $this->getCategories());
     if ($out->isSyndicated()) {
         $feeds = array();
         foreach ($out->getSyndicationLinks() as $format => $link) {
             $feeds[$format] = array('text' => wfMsg("feed-{$format}"), 'href' => $link);
         }
         $tpl->setRef('feeds', $feeds);
     } else {
         $tpl->set('feeds', false);
     }
     $tpl->setRef('mimetype', $wgMimeType);
     $tpl->setRef('jsmimetype', $wgJsMimeType);
     $tpl->set('charset', 'UTF-8');
     $tpl->setRef('wgScript', $wgScript);
     $tpl->setRef('skinname', $this->skinname);
     $tpl->set('skinclass', get_class($this));
     $tpl->setRef('stylename', $this->stylename);
     $tpl->set('printable', $out->isPrintable());
     $tpl->set('handheld', $wgRequest->getBool('handheld'));
     $tpl->setRef('loggedin', $this->loggedin);
     $tpl->set('notspecialpage', $this->getTitle()->getNamespace() != NS_SPECIAL);
     /* XXX currently unused, might get useful later
     		$tpl->set( 'editable', ( $this->getTitle()->getNamespace() != NS_SPECIAL ) );
     		$tpl->set( 'exists', $this->getTitle()->getArticleID() != 0 );
     		$tpl->set( 'watch', $this->getTitle()->userIsWatching() ? 'unwatch' : 'watch' );
     		$tpl->set( 'protect', count( $this->getTitle()->isProtected() ) ? 'unprotect' : 'protect' );
     		$tpl->set( 'helppage', wfMsg( 'helppage' ) );
     		*/
     $tpl->set('searchaction', $this->escapeSearchLink());
     $tpl->set('searchtitle', SpecialPage::getTitleFor('Search')->getPrefixedDBKey());
     $tpl->set('search', trim($wgRequest->getVal('search')));
     $tpl->setRef('stylepath', $wgStylePath);
     $tpl->setRef('articlepath', $wgArticlePath);
     $tpl->setRef('scriptpath', $wgScriptPath);
     $tpl->setRef('serverurl', $wgServer);
     $tpl->setRef('logopath', $wgLogo);
     $contentlang = $wgContLang->getCode();
     $contentdir = $wgContLang->getDir();
     $userlang = $wgLang->getCode();
     $userdir = $wgLang->getDir();
     $tpl->set('lang', $userlang);
     $tpl->set('dir', $userdir);
     $tpl->set('rtl', $wgLang->isRTL());
     $tpl->set('capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '');
     $tpl->set('showjumplinks', $wgUser->getOption('showjumplinks'));
     $tpl->set('username', $wgUser->isAnon() ? null : $this->username);
     $tpl->setRef('userpage', $this->userpage);
     $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']);
     $tpl->set('userlang', $userlang);
     // Users can have their language set differently than the
     // content of the wiki. For these users, tell the web browser
     // that interface elements are in a different language.
     $tpl->set('userlangattributes', '');
     $tpl->set('specialpageattributes', '');
     # obsolete
     if ($userlang !== $contentlang || $userdir !== $contentdir) {
         $attrs = " lang='{$userlang}' dir='{$userdir}'";
         $tpl->set('userlangattributes', $attrs);
     }
     $newtalks = $this->getNewtalks($out);
     wfProfileOut(__METHOD__ . '-stuff2');
     wfProfileIn(__METHOD__ . '-stuff3');
     $tpl->setRef('newtalk', $newtalks);
     $tpl->setRef('skin', $this);
     $tpl->set('logo', $this->logoText());
     if ($out->isArticle() && (!isset($oldid) || isset($diff)) && $this->getTitle()->exists()) {
         $article = new Article($this->getTitle(), 0);
         if (!$wgDisableCounters) {
             $viewcount = $wgLang->formatNum($article->getCount());
             if ($viewcount) {
                 $tpl->set('viewcount', wfMsgExt('viewcount', array('parseinline'), $viewcount));
             } else {
                 $tpl->set('viewcount', false);
             }
         } else {
             $tpl->set('viewcount', false);
         }
         if ($wgPageShowWatchingUsers) {
             $dbr = wfGetDB(DB_SLAVE);
             $res = $dbr->select('watchlist', array('COUNT(*) AS n'), array('wl_title' => $dbr->strencode($this->getTitle()->getDBkey()), 'wl_namespace' => $this->getTitle()->getNamespace()), __METHOD__);
             $x = $dbr->fetchObject($res);
             $numberofwatchingusers = $x->n;
             if ($numberofwatchingusers > 0) {
                 $tpl->set('numberofwatchingusers', wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($numberofwatchingusers)));
             } else {
                 $tpl->set('numberofwatchingusers', false);
             }
         } else {
             $tpl->set('numberofwatchingusers', false);
         }
         $tpl->set('copyright', $this->getCopyright());
         $this->credits = false;
         if ($wgMaxCredits != 0) {
             $this->credits = Action::factory('credits', $article)->getCredits($wgMaxCredits, $wgShowCreditsIfMax);
         } else {
             $tpl->set('lastmod', $this->lastModified($article));
         }
         $tpl->setRef('credits', $this->credits);
     } elseif (isset($oldid) && !isset($diff)) {
         $tpl->set('copyright', $this->getCopyright());
         $tpl->set('viewcount', false);
         $tpl->set('lastmod', false);
         $tpl->set('credits', false);
         $tpl->set('numberofwatchingusers', false);
     } else {
         $tpl->set('copyright', false);
         $tpl->set('viewcount', false);
         $tpl->set('lastmod', false);
         $tpl->set('credits', false);
         $tpl->set('numberofwatchingusers', false);
     }
     wfProfileOut(__METHOD__ . '-stuff3');
     wfProfileIn(__METHOD__ . '-stuff4');
     $tpl->set('copyrightico', $this->getCopyrightIcon());
     $tpl->set('poweredbyico', $this->getPoweredBy());
     $tpl->set('disclaimer', $this->disclaimerLink());
     $tpl->set('privacy', $this->privacyLink());
     $tpl->set('about', $this->aboutLink());
     $tpl->set('footerlinks', array('info' => array('lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright'), 'places' => array('privacy', 'about', 'disclaimer')));
     global $wgFooterIcons;
     $tpl->set('footericons', $wgFooterIcons);
     foreach ($tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock) {
         if (count($footerIconsBlock) > 0) {
             foreach ($footerIconsBlock as &$footerIcon) {
                 if (isset($footerIcon['src'])) {
                     if (!isset($footerIcon['width'])) {
                         $footerIcon['width'] = 88;
                     }
                     if (!isset($footerIcon['height'])) {
                         $footerIcon['height'] = 31;
                     }
                 }
             }
         } else {
             unset($tpl->data['footericons'][$footerIconsKey]);
         }
     }
     if ($wgDebugComments) {
         $tpl->setRef('debug', $out->mDebugtext);
     } else {
         $tpl->set('debug', '');
     }
     $tpl->set('reporttime', wfReportTime());
     $tpl->set('sitenotice', $this->getSiteNotice());
     $tpl->set('bottomscripts', $this->bottomScripts($out));
     $tpl->set('printfooter', $this->printSource());
     # Add a <div class="mw-content-ltr/rtl"> around the body text
     # not for special pages or file pages AND only when viewing AND if the page exists
     # (or is in MW namespace, because that has default content)
     if (!in_array($this->getTitle()->getNamespace(), array(NS_SPECIAL, NS_FILE)) && in_array($action, array('view', 'historysubmit')) && ($this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI)) {
         $pageLang = $this->getTitle()->getPageLanguage();
         $realBodyAttribs = array('lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), 'class' => 'mw-content-' . $pageLang->getDir());
         $out->mBodytext = Html::rawElement('div', $realBodyAttribs, $out->mBodytext);
     }
     $tpl->setRef('bodytext', $out->mBodytext);
     # Language links
     $language_urls = array();
     if (!$wgHideInterlanguageLinks) {
         foreach ($out->getLanguageLinks() as $l) {
             $tmp = explode(':', $l, 2);
             $class = 'interwiki-' . $tmp[0];
             unset($tmp);
             $nt = Title::newFromText($l);
             if ($nt) {
                 $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'title' => $nt->getText(), 'class' => $class, 'lang' => $nt->getInterwiki(), 'hreflang' => $nt->getInterwiki());
             }
         }
     }
     if (count($language_urls)) {
         $tpl->setRef('language_urls', $language_urls);
     } else {
         $tpl->set('language_urls', false);
     }
     wfProfileOut(__METHOD__ . '-stuff4');
     wfProfileIn(__METHOD__ . '-stuff5');
     # Personal toolbar
     $tpl->set('personal_urls', $this->buildPersonalUrls($out));
     $content_navigation = $this->buildContentNavigationUrls($out);
     $content_actions = $this->buildContentActionUrls($content_navigation);
     $tpl->setRef('content_navigation', $content_navigation);
     $tpl->setRef('content_actions', $content_actions);
     $tpl->set('sidebar', $this->buildSidebar());
     $tpl->set('nav_urls', $this->buildNavUrls($out));
     // Set the head scripts near the end, in case the above actions resulted in added scripts
     if ($this->useHeadElement) {
         $tpl->set('headelement', $out->headElement($this));
     } else {
         $tpl->set('headscripts', $out->getScript());
     }
     $tpl->set('debughtml', $this->generateDebugHTML());
     // original version by hansm
     if (!wfRunHooks('SkinTemplateOutputPageBeforeExec', array(&$this, &$tpl))) {
         wfDebug(__METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n");
     }
     // Set the bodytext to another key so that skins can just output it on it's own
     // and output printfooter and debughtml separately
     $tpl->set('bodycontent', $tpl->data['bodytext']);
     // Append printfooter and debughtml onto bodytext so that skins that were already
     // using bodytext before they were split out don't suddenly start not outputting information
     $tpl->data['bodytext'] .= Html::rawElement('div', array('class' => 'printfooter'), "\n{$tpl->data['printfooter']}") . "\n";
     $tpl->data['bodytext'] .= $tpl->data['debughtml'];
     // allow extensions adding stuff after the page content.
     // See Skin::afterContentHook() for further documentation.
     $tpl->set('dataAfterContent', $this->afterContentHook());
     wfProfileOut(__METHOD__ . '-stuff5');
     // execute template
     wfProfileIn(__METHOD__ . '-execute');
     $res = $tpl->execute();
     wfProfileOut(__METHOD__ . '-execute');
     // result may be an error
     $this->printOrError($res);
     wfProfileOut(__METHOD__);
 }
 function formatResult($skin, $result)
 {
     global $wgLang, $wgContLang;
     $title = Title::newFromID($result->nfd_page);
     if ($title) {
         $revision = Revision::newFromTitle($title);
         $previsionRevision = $revision->getPrevious();
         $article = new Article($title);
         if ($revision != null) {
             $link = $wgLang->date($revision->getTimestamp()) . " " . $skin->makeKnownLinkObj($title, htmlspecialchars($wgContLang->convert($title->getPrefixedText())), 'redirect=no', " (" . number_format($previsionRevision->getSize(), 0, "", ",") . " bytes, " . number_format($article->getCount(), 0, "", ",") . " Views) ");
             $redirectTitle = Title::newFromRedirect($revision->getText());
             if ($redirectTitle) {
                 $link .= " => " . $skin->makeKnownLinkObj($redirectTitle, htmlspecialchars($wgContLang->convert($redirectTitle->getPrefixedText())));
             }
         }
     }
     return $link;
 }
Example #9
0
 function pageStats()
 {
     global $wgOut, $wgLang, $wgRequest, $wgUser;
     global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
     if (!is_null($wgRequest->getVal('oldid')) || !is_null($wgRequest->getVal('diff'))) {
         return '';
     }
     if (!$wgOut->isArticle() || !$this->getSkin()->getTitle()->exists()) {
         return '';
     }
     $article = new Article($this->getSkin()->getTitle(), 0);
     $s = '';
     if (!$wgDisableCounters) {
         $count = $wgLang->formatNum($article->getCount());
         if ($count) {
             $s = wfMsgExt('viewcount', array('parseinline'), $count);
         }
     }
     if ($wgMaxCredits != 0) {
         $s .= ' ' . Action::factory('credits', $article)->getCredits($wgMaxCredits, $wgShowCreditsIfMax);
     } else {
         $s .= $this->data['lastmod'];
     }
     if ($wgPageShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
         $dbr = wfGetDB(DB_SLAVE);
         $res = $dbr->select('watchlist', array('COUNT(*) AS n'), array('wl_title' => $dbr->strencode($this->getSkin()->getTitle()->getDBkey()), 'wl_namespace' => $this->getSkin()->getTitle()->getNamespace()), __METHOD__);
         $x = $dbr->fetchObject($res);
         $s .= ' ' . wfMsgExt('number_of_watching_users_pageview', array('parseinline'), $wgLang->formatNum($x->n));
     }
     return $s . ' ' . $this->getSkin()->getCopyright();
 }