/** * Main entrypoint * * @param $mode (type string) 'add', 'ban' or 'remove' * 'add' => add article to the book * 'ban' => ban article from the proposals * 'remove' => remove article from the book * 'addNum' => (type int) add the first $param articles to the collection * 'addVal' => (type float) add all propossals to the collection with * a value higher then $param * @param $param (type string) name of the article to be added, banned or removed * or a number of articles to add or a value (1 - 1.5) all articles with a * higher value will be added to the collection */ public static function run($mode = '', $param = '') { global $wgOut; if (!CollectionSession::hasSession()) { CollectionSession::startSession(); } if (!isset($_SESSION['wsCollectionSuggestBan']) || $mode == 'resetbans') { $_SESSION['wsCollectionSuggestBan'] = array(); } if (!isset($_SESSION['wsCollectionSuggestProp'])) { $_SESSION['wsCollectionSuggestProp'] = array(); } $template = self::getCollectionSuggestTemplate($mode, $param); $wgOut->setPageTitle(wfMsg('coll-suggest_title')); $wgOut->addModules('ext.collection.suggest'); $wgOut->addTemplate($template); }
/** * @param $title Title * @param $oldid int * @return bool */ static function addArticle($title, $oldid = 0) { global $wgCollectionHierarchyDelimiter; $latest = $title->getLatestRevID(); $currentVersion = 0; if ($oldid == 0) { $currentVersion = 1; $oldid = $latest; } $prefixedText = $title->getPrefixedText(); $index = CollectionSession::findArticle($prefixedText, $oldid); if ($index != -1) { return false; } if (!CollectionSession::hasSession()) { CollectionSession::startSession(); } $collection = CollectionSession::getCollection(); $revision = Revision::newFromTitle($title, $oldid); $item = array('type' => 'article', 'content_type' => 'text/x-wiki', 'title' => $prefixedText, 'revision' => strval($oldid), 'latest' => strval($latest), 'timestamp' => wfTimestamp(TS_UNIX, $revision->getTimestamp()), 'url' => $title->getCanonicalURL(), 'currentVersion' => $currentVersion); if ($wgCollectionHierarchyDelimiter != null) { $parts = explode($wgCollectionHierarchyDelimiter, $prefixedText); if (count($parts) > 1 && end($parts) != '') { $item['displaytitle'] = end($parts); } } $collection['items'][] = $item; CollectionSession::setCollection($collection); return true; }