function printVideo($vidId, &$vidTitle, &$t) { $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('templatelinks', array('tl_from'), array('tl_namespace' => NS_VIDEO, 'tl_title' => $t->getDBKey()), __METHOD__, array('LIMIT 1')); if ($row = $dbr->fetchObject($res)) { $nt = Title::newFromId($row->tl_from); if ($nt && $nt->exists()) { $day30 = Pagestats::get30day($row->tl_from, $dbr); echo "{$vidId}\t{$vidTitle}\thttp://www.wikihow.com" . $nt->getLocalUrl() . "\t{$day30}\n"; } } }
public function getStatsByUser($u, $past30days) { $html = ''; $dbr = wfGetDB(DB_SLAVE); if ($past30days) { //cutoff = past 30 days $cutoff = wfTimestamp(TS_MW, time() - 60 * 60 * 24 * 30); } else { $cutoff = 0; } $conds = array('page_id=rev_page', 'rev_user' => $u->getID(), 'page_is_redirect' => 0, 'page_namespace' => NS_MAIN); if ($cutoff) { $conds[] = 'rev_timestamp > ' . $cutoff; } //grab all started articles in the past timeframe $res = $dbr->select(array('revision', 'page'), array('rev_page', 'page_title'), $conds, __METHOD__, array('GROUP BY' => 'rev_page')); foreach ($res as $row) { $stats = Pagestats::get30day($row->rev_page, $dbr); $total += (int) $stats; } return (int) $total; }