function getLastArticle($userName) { global $wgUser; $lastArticle = null; $res = ProfileBox::fetchEditedData($userName, 1); foreach ($res as $row) { $t = Title::newFromId($row->page_id); if ($t && $t->exists()) { $lastArticle = '[[' . $t->getFullText() . ']]'; } } return $lastArticle; }
public static function suggestCategoryInterests() { global $wgUser; $interests = array(); if ($wgUser->getId() == 0) { return $interests; } $dbr = wfGetDB(DB_SLAVE); $res = ProfileBox::fetchEditedData($wgUser->getName(), 10); while ($row = $dbr->fetchObject($res)) { $t = Title::newFromId($row->page_id); if ($t && $t->exists()) { $interests = array_merge($interests, CatSearch::getParentCats($t)); } } $interests = array_unique($interests); foreach ($interests as $k => $interest) { if (CatSearch::ignoreCategory($interest)) { unset($interests[$k]); } } // Give them some random top-level categories if they haven't done any edits yet if (!sizeof($interests)) { global $wgCategoryNames; $topCats = array_values($wgCategoryNames); $rnd = rand(1, 6); for ($i = 1; $i < 4; $i++) { $interests[] = str_replace(" ", "-", $topCats[$i * $rnd]); } } return array_slice(array_values($interests), 0, 3); }