function execute($par) { global $wgRequest, $wgOut, $wgUser; $target = isset($par) ? $par : $wgRequest->getVal('target'); #if ($wgRequest->wasPosted() || true) { if ($wgRequest->getVal('interests')) { $wgOut->disable(); $x = new LSearch(); $interests = split("\n", $wgRequest->getVal('interests')); //$hits= $x->googleSearchResultTitles('"' . implode('" OR "', $interests) . '"'); $result = array(); $result['titles'] = array(); /*foreach ($hits as $t) { $result['titles'][] = $t->getText(); } */ $hits = array(Title::newFromText('French-Kiss'), Title::newFromText('Save-a-Wet-Cell-Phone'), Title::newFromText('Ollie-off-a-Kicker')); foreach ($hits as $t) { $dbr = wfGetDB(DB_SLAVE); $x = array(); $x['url'] = $t->getFullURL(); $x['title'] = $t->getText(); $row = $dbr->selectRow('page', array('page_counter', 'page_touched', 'page_further_editing'), array('page_id' => $t->getArticleID())); $x['counter'] = number_format($row->page_counter, 0, "", ","); $x['touched'] = wfTimeAgo($row->page_touched); if ($row->page_further_editing) { $x['morehelp'] = "yes"; } else { $x['morehelp'] = "no"; } $result['titles'][] = $x; } echo json_encode($result); return; } EasyTemplate::set_path(dirname(__FILE__)); $wgOut->addHTML(EasyTemplate::html('interests.tmpl.php')); }
/** * Load revision metadata for the specified articles. If newid is 0, then compare * the old article in oldid to the current article; if oldid is 0, then * compare the current article to the immediately previous one (ignoring the * value of newid). * * If oldid is false, leave the corresponding revision object set * to false. This is impossible via ordinary user input, and is provided for * API convenience. */ function loadRevisionData() { global $wgLang, $wgTitle, $wgLanguageCode, $wgRequest; if ($this->mRevisionsLoaded) { return true; } else { // Whether it succeeds or fails, we don't want to try again $this->mRevisionsLoaded = true; } // Load the new revision object $this->mNewRev = $this->mNewid ? Revision::newFromId($this->mNewid) : Revision::newFromTitle($this->mTitle); if (!$this->mNewRev instanceof Revision) { return false; } // Update the new revision ID in case it was 0 (makes life easier doing UI stuff) $this->mNewid = $this->mNewRev->getId(); // Set assorted variables $timestamp = wfTimeAgo($this->mNewRev->getTimestamp()); $this->mNewDate = $timestamp; $this->mNewPage = $this->mNewRev->getTitle(); if ($this->mNewRev->isCurrent()) { $newLink = $this->mNewPage->escapeLocalUrl(); $this->mPagetitle = htmlspecialchars(wfMsg('currentrev')); $newEdit = $this->mNewPage->escapeLocalUrl('action=edit'); //XXADDED for quick edit if ($wgTitle->getNamespace() != NS_SPECIAL && $wgLanguageCode == 'en') { $editURL = $wgServer . '/Special:Newarticleboost?type=editform&target=' . urlencode($wgTitle->getFullText()); //$this->mNewtitle .= " <a href=\"#\" onclick=\"initPopupEdit('".$editURL."') ;\">" . htmlspecialchars( wfMsg( 'editold-quick' ) ) . "</a> | "; } $this->mNewtitle = "<a href='{$newLink}'>{$this->mPagetitle}</a>" . " (<a href='{$newEdit}'>" . wfMsg('diff_edit') . "</a>)"; } else { $newLink = $this->mNewPage->escapeLocalUrl('oldid=' . $this->mNewid); $newEdit = $this->mNewPage->escapeLocalUrl('action=edit&oldid=' . $this->mNewid); $this->mPagetitle = wfMsgHTML('revisionasof', $timestamp); //XXADDED for quick edit if ($wgTitle->getNamespace() != NS_SPECIAL && $wgLanguageCode == 'en' && $wgRequest->getVal("rcid", "") != "") { $editURL = $wgServer . '/Special:Newarticleboost?type=editform&target=' . urlencode($wgTitle->getFullText()); $this->mNewtitle .= " <a href=\"#\" onclick=\"initPopupEdit('" . $editURL . "') ;\">" . htmlspecialchars(wfMsg('editold-quick')) . "</a> | "; } $this->mNewtitle = "<a href='{$newLink}'>{$this->mPagetitle}</a>" . " (<a href='{$newEdit}'>" . wfMsg('diff_edit') . "</a>) "; } if (!$this->mNewRev->userCan(Revision::DELETED_TEXT)) { $this->mNewtitle = "<span class='history-deleted'>{$this->mPagetitle}</span>"; } else { if ($this->mNewRev->isDeleted(Revision::DELETED_TEXT)) { $this->mNewtitle = '<span class="history-deleted">' . $this->mNewtitle . '</span>'; } } // Load the old revision object $this->mOldRev = false; if ($this->mOldid) { $this->mOldRev = Revision::newFromId($this->mOldid); } elseif ($this->mOldid === 0) { $rev = $this->mNewRev->getPrevious(); if ($rev) { $this->mOldid = $rev->getId(); $this->mOldRev = $rev; } else { // No previous revision; mark to show as first-version only. $this->mOldid = false; $this->mOldRev = false; } } /* elseif ( $this->mOldid === false ) leave mOldRev false; */ if (is_null($this->mOldRev)) { return false; } if ($this->mOldRev) { $this->mOldPage = $this->mOldRev->getTitle(); $t = wfTimeAgo($this->mOldRev->getTimestamp()); $oldLink = $this->mOldPage->escapeLocalUrl('oldid=' . $this->mOldid); $oldEdit = $this->mOldPage->escapeLocalUrl('action=edit&oldid=' . $this->mOldid); //$this->mOldPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t ) ); $oldTitle = "<a href='{$oldLink}'>" . wfMsg('diff_oldrev') . "</a> "; $this->mOldtitle = $oldTitle . " (<a href='{$oldEdit}'>" . wfMsg('diff_edit') . "</a>)"; $this->mOldDate = $t; // Add an "undo" link $newUndo = $this->mNewPage->escapeLocalUrl('action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid); if ($this->mNewRev->userCan(Revision::DELETED_TEXT)) { //$this->mNewtitle .= "<span id='undolink'>(<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)</span>"; if (!$this->mOldRev->userCan(Revision::DELETED_TEXT)) { $this->mOldtitle = "<span class='history-deleted'>{$this->mOldPagetitle}</span>"; } else { if ($this->mOldRev->isDeleted(Revision::DELETED_TEXT)) { $this->mOldtitle = '<span class="history-deleted">' . $this->mOldtitle . '</span>'; } } } } return true; }
/** * Used in community dashboard to find out the most recently nabbed * article. */ public function getHighestNAB(&$dbr, $period = '7 days ago') { $startdate = strtotime($period); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $res = $dbr->select('logging', array('*', 'count(*) as C', 'MAX(log_timestamp) as recent_timestamp'), array("log_type" => 'nap', 'log_timestamp > "' . $starttimestamp . '"'), __METHOD__, array("GROUP BY" => 'log_user', "ORDER BY" => "C DESC", "LIMIT" => 1)); $row = $dbr->fetchObject($res); $nabuser = array(); $nabuser['id'] = $row->log_user; $nabuser['date'] = wfTimeAgo($row->recent_timestamp); return $nabuser; }
function onDifferenceEngineGetRevisionHeader($differenceEngine, &$header, $state, $rev) { if ($state == 'new') { if ($rev->isCurrent()) { $header = htmlspecialchars(wfMsg('currentrev')); } else { $header = wfMsgHTML('revisionasof', wfTimeAgo($differenceEngine->mNewRev->getTimestamp())); } } elseif ($state == 'old') { $header = "Old Revision"; } return true; }
public function populateUserObject($userId, $timestamp) { global $wgUser; $sk = $wgUser->getSkin(); $imguser = array(); $imguser['id'] = $userId; $imguser['date'] = wfTimeAgo($timestamp); if (strpos($imguser['date'], "Bad") !== false) { $imguser['date'] = "Just now"; } $u = User::newFromId($imguser['id']); $img = $this->getUserPic($u); $data = array(); $data['im'] = $img; if (strpos($img, 'df') === FALSE) { $data['hp'] = Avatar::getHashPath("{$userId}.jpg"); } else { $data['hp'] = ""; } if ($userId == 0) { $data['na'] = "Anonymous"; } else { $data['na'] = $u->getName(); } $data['da'] = $imguser['date']; return $data; }
public static function generateFeedItem($f) { $fname = "FeedUsertalk:generateFeedItem"; $dbr = wfGetDB(DB_SLAVE); $msg = null; $u = User::newFromName($f->fo_target_name); if (rand(0, 1) == 0) { // user's recent edit $row = $dbr->selectRow('recentchanges', array('rc_title', 'rc_namespace', 'rc_timestamp'), array('rc_namespace' => NS_MAIN, 'rc_user' => $f->fo_target_id), $fname, array("ORDER BY" => "rc_id DESC")); if ($row) { $t = Title::makeTitle($row->rc_namespace, $row->rc_title); $msg = "<a href='{$u->getUserPage()->getFullURL()}'>{$u->getName()}</a> recently edited <a href='{$t->getFullURL()}'>{$t->getText()}</a> " . wfTimeAgo($row->rc_timestamp); } } else { // user's recent article creation $row = $dbr->selectRow(array('firstedit', 'page'), array('page_title', 'page_namespace', 'fe_timestamp'), array('page_namespace' => NS_MAIN, 'fe_user' => $f->fo_target_id, 'page_id=fe_page'), $fname, array("ORDER BY" => "page_id DESC")); if ($row) { $t = Title::makeTitle($row->page_namespace, $row->page_title); $msg = "<a href='{$u->getUserPage()->getFullURL()}'>{$u->getName()}</a> recently started the article <a href='{$t->getFullURL()}'>{$t->getText()}</a> " . wfTimeAgo($row->fe_timestamp); } } $html = ""; if ($msg) { $av = $av = Avatar::getAvatarRaw($u->getName()); $url = $av['url']; if (!preg_match("@fbcdn.net@", $url)) { $url = wfGetPad("/images/avatarOut/" . $av['url']); } if ($url) { $img = "<img src='{$url}' style='width:50px; margin-right: 5px;'/>"; } $html = "<div class='feeditem'>{$img}{$msg}\n <div class='actions'><a href='{$t->getFullURL()}'>Read</a> | " . "<a href='{$t->getFullURL()}?action=edit'>Edit</a> | <a href='{$t->getFullURL()}?action=watch'>Watch</a></div></div>"; } wfProfileOut($fname); return $html; }
function fetchThumbsData($limit) { global $wgMemc, $wgUser; $isLoggedIn = $wgUser && !$wgUser->isAnon(); $skin = $wgUser->getSkin(); $cacheKey = wfMemcKey(ProfileStats::CACHE_PREFIX . 'thumbs', $this->user->getID(), $limit); $result = $wgMemc->get($cacheKey); if (!$this->isOwnPage && $result) { return $result; } $dbr = wfGetDB(DB_SLAVE); $order = array(); $order['GROUP BY'] = 'thumb_rev_id'; $order['ORDER BY'] = 'rev_id DESC'; if ($limit) { $order['LIMIT'] = $limit + 1; } $res = $dbr->select(array('thumbs', 'page', 'revision'), array('page_namespace', 'page_id', 'page_title', 'count(thumb_rev_id) as cnt', 'thumb_rev_id', 'rev_timestamp'), array('thumb_recipient_id' => $this->user->getID(), 'thumb_exclude=0', 'thumb_page_id=page_id', 'thumb_rev_id = rev_id'), "", $order); if ($res) { foreach ($res as $row) { $results[] = $row; } } $dbr->freeResult($res); if ($results) { foreach ($results as $row) { $row->title = Title::newFromID($row->page_id); $row->text = wfTimeAgo($row->rev_timestamp); if ($isLoggedIn) { $row->text = $skin->makeKnownLinkObj($row->title, $row->text, 'diff=' . $row->thumb_rev_id . '&oldid=PREV'); } } } $wgMemc->set($cacheKey, $results, 60 * 10); return $results; }
function execute($par) { global $wgOut, $wgUser, $wgTitle, $wgLanguageCode, $wgHooks; if ($wgLanguageCode != 'en') { $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext'); $wgOut->setRobotPolicy('noindex,nofollow'); return; } require_once 'Leaderboard.body.php'; wfLoadExtensionMessages('RequestTopic'); $wgOut->addHTML('<style type="text/css" media="all">/*<![CDATA[*/ @import "' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.css?rev=') . WH_SITEREV . '"; /*]]>*/</style>'); $wgOut->addScript('<script type="text/javascript" src="' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.js?rev=') . WH_SITEREV . '"></script>'); ListRequestedTopics::setActiveWidget(); ListRequestedTopics::setTopAuthorWidget(); ListRequestedTopics::getNewArticlesWidget(); $wgHooks["pageTabs"][] = array("wfRequestedTopicsTabs"); $wgOut->setHTMLTitle('Articles Started By You - wikiHow'); $wgOut->setRobotPolicy('noindex,nofollow'); //heading with link $request = '<a href="/Special:RequestTopic" class="edit">' . wfMsg('requesttopic') . '</a>'; $heading = $request . '<h2>' . wfMsg('your_articles_header') . '</h2>'; //add surpise button $heading .= "<a href='/Special:RecommendedArticles?surprise=1' class='button buttonright secondary' id='suggested_surprise'>" . wfMsg('suggested_list_button_surprise') . "</a><br /><br /><br />"; $wgOut->addHTML($heading); if ($wgUser->getID() > 0) { $dbr = wfGetDB(DB_SLAVE); $res = $dbr->query("select * from firstedit left join page on fe_page=page_id\n\t\t\t\t\tleft join suggested_titles on page_title=st_title and page_namespace= 0 where fe_user={$wgUser->getID()} and page_id is not NULL order by st_category"); if ($dbr->numRows($res) == 0) { $wgOut->addHTML(wfMsg("yourarticles_none")); return; } $last_cat = "-"; // group it by categories // sometimes st_category is not set, so we have to grab the top category // from the title object of the target article $articles = array(); while ($row = $dbr->fetchObject($res)) { $t = Title::makeTitle(NS_MAIN, $row->page_title); $cat = $row->st_category; if ($cat == '') { $str = Categoryhelper::getTopCategory($t); if ($str != '') { $title = Title::makeTitle(NS_CATEGORY, $str); $cat = $title->getText(); } else { $cat = "Other"; } } if (!isset($articles[$cat])) { $articles[$cat] = array(); } $articles[$cat][] = $row; } foreach ($articles as $cat => $article_array) { $image = ListRequestedTopics::getCategoryImage($cat); $style = ""; if ($image == "") { $style = "style='padding-left:67px;'"; } $wgOut->addHTML('<h2>' . $cat . '</h2><div class="wh_block"><table class="suggested_titles_list">'); foreach ($article_array as $row) { $t = Title::makeTitle(NS_MAIN, $row->page_title); $ago = wfTimeAgo($row->page_touched); $authors = array_keys($this->getAuthors($t)); $a_out = array(); for ($i = 0; $i < 2 && sizeof($authors) > 0; $i++) { $a = array_shift($authors); if ($a == 'anonymous') { $a_out[] = "Anonymous"; // duh } else { $u = User::newFromName($a); if (!$u) { echo "{$a} broke"; exit; } $a_out[] = "<a href='{$u->getUserPage()->getFullURL()}'>{$u->getName()}</a>"; } } $skin = $wgUser->getSkin(); $img = $skin->getGalleryImage($t, 46, 35); $wgOut->addHTML("<tr><td class='article_image'><img src='{$img}' alt='' width='46' height='35' /></td>" . "<td><h3><a href='{$t->getFullURL()}' class='title'>" . wfMsg('howto', $t->getFullText()) . "</a></h3>" . "<p class='meta_info'>Authored by: <a href='{$wgUser->getUserPage()->getFullURL()}'>You</a></p>" . "<p class='meta_info'>Edits by: " . implode(", ", $a_out) . " (<a href='{$t->getFullURL()}?action=credits'>see all</a>)</p>" . "<p class='meta_info'>Last updated {$ago}</p>" . "</td>" . "<td class='view_count'>" . number_format($row->page_counter, 0, "", ",") . "</td></tr>"); } $wgOut->addHTML('</table></div>'); } } else { $rt = $wgTitle->getPrefixedURL(); $q = "returnto={$rt}"; $wgOut->addHTML(wfMsg('yourarticles_anon', $q)); } }
public static function getTopPatroller(&$dbr, $period = '7 days ago') { $startdate = strtotime($period); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; // fix Patrol Recent Changes Votebot showing bug. $bots = self::getBotIDs(); $bot = " AND log_user NOT IN (" . $dbr->makeList($bots) . ")"; $sql = "SELECT log_user, count(log_user) as rc_count, MAX(log_timestamp) as recent_timestamp FROM logging WHERE log_type='patrol' and log_timestamp >= '{$starttimestamp}' {$bot} GROUP BY log_user ORDER BY rc_count DESC"; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); $rcuser = array(); $rcuser['id'] = $row->log_user; $rcuser['date'] = wfTimeAgo($row->recent_timestamp); return $rcuser; }
} else { ?> <?php echo wfMsg('lsearch_edited_by_others', $editorLink, $result['num_editors'] - 1); ?> <?php } ?> </div> <?php if (!empty($result['last_editor']) && $result['num_editors'] > 1) { ?> <div> <?php echo wfMsg('lsearch_last_updated', wfTimeAgo(wfTimestamp(TS_UNIX, $result['timestamp']), true), $sk->makeLinkObj(Title::makeTitle(NS_USER, $result['last_editor']), $result['last_editor'])); ?> </div> <?php } ?> <?php } ?> <ul class="search_results_stats"> <?php if ($result['is_featured']) { ?> <li class="sr_featured"><?php echo wfMsg('lsearch_featured');
/** * * Returns the html for the box at the * top of NFD Guardian which contains * information about the current * article being voted on. * */ function getArticleInfoBox() { global $wgOut; //first find out who the author was $articleInfo = $this->getArticleInfo(); if (intval($articleInfo->fe_user) > 0) { $u = User::newFromId($articleInfo->fe_user); $userLink = $u->getUserPage()->getInternalURL(); $userName = $u->getName(); $cp = new ContribsPager(ContextSource::getContext(), array($userName)); $uEdits = $cp->getNumRows(); } else { $u = User::newFromName($articleInfo->fe_user_text); $userLink = "/User:"******"") { $t = Title::newFromText($nfdReason['article']); if ($t) { $nfdLongReason .= " with [[" . $t->getText() . "]]"; } } //finally check the number of discussion items for this //article. We ask for confirmation for articles //with a lot of discussion items. $t = Title::newFromID($this->mResult->nfd_page); if ($t) { $a = new Article($t); // $pageHistory = new PageHistory($a); // $pager = new PageHistoryPager( $pageHistory ); // $edits = $pager->getNumRows(); $pageHistory = new HistoryPage($a); $items = $pageHistory->fetchRevisions(100000, 0, 1); $edits = $items->numRows(); $discussionTitle = Title::newFromText($t->getText(), NS_TALK); if ($discussionTitle) { $discussionArticle = new Article($discussionTitle); // $pageHistory = new PageHistory($discussionArticle); // $pager = new PageHistoryPager( $pageHistory ); // $discussion = $pager->getNumRows(); $pageHistory = new HistoryPage($discussionArticle); $items = $pageHistory->fetchRevisions(100000, 0, 1); $discussion = $items->numRows(); } else { $discussion = 0; } } $articleInfo = $this->getArticleInfo(); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('age' => wfTimeAgo($this->mResult->nfd_fe_timestamp), 'authorUrl' => $userLink, 'authorName' => $userName, 'views' => $articleInfo->page_counter, 'nfd' => $wgOut->parse($nfdLongReason), 'edits' => $edits, 'userEdits' => $uEdits, 'nfdVotes' => $this->getTotalVotes($this->mResult->nfd_id), 'discussion' => $discussion)); $html = $tmpl->execute('NFDinfo.tmpl.php'); return $html; }
/** * * Returns the id/date of the highest VAdder */ function getHighestVA(&$dbr, $period = '7 days ago') { $startdate = strtotime($period); $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000'; $sql = ""; $bots = WikihowUser::getBotIDs(); if (sizeof($bots) > 0) { $sql = " AND va_user NOT IN (" . $dbr->makeList($bots) . ") "; } $sql = "SELECT *, count(va_user) as va_count, MAX(va_timestamp) as va_recent FROM `videoadder` WHERE va_timestamp >= '" . $starttimestamp . "'" . $sql . " AND va_skipped_accepted IN ('0','1') GROUP BY va_user ORDER BY va_count DESC"; $res = $dbr->query($sql); $row = $dbr->fetchObject($res); $vauser = array(); $vauser['id'] = $row->va_user; $vauser['date'] = wfTimeAgo($row->va_recent); return $vauser; }