本文整理汇总了PHP中Article::getCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::getCount方法的具体用法?PHP Article::getCount怎么用?PHP Article::getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::getCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfSpecialCheckquality
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");
}
示例2: execute
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"> ' . 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 .= " " . 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");
}
示例3: array
<?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);
示例4: getPageViews
function getPageViews()
{
global $wgLang, $wgTitle;
$a = new Article($wgTitle);
$count = $wgLang->formatNum($a->getCount());
$s = wfMsg('viewcountuser', $count);
return $s;
}
示例5: getCommentCount
public function getCommentCount()
{
return Article::getCount(['article_id' => $this->id]);
}
示例6: getPageViews
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;
}
示例7: outputPage
//.........这里部分代码省略.........
$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);
示例8: formatResult
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;
}
示例9: pageStats
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();
}