/**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * @param $title Title
  * @param $append bool
  * @return array|bool
  */
 function loadCollection($title, $append = false)
 {
     global $wgOut;
     if (is_null($title)) {
         $wgOut->showErrorPage('coll-notitle_title', 'coll-notitle_msg');
         return;
     }
     if (!$title->exists()) {
         $wgOut->showErrorPage('coll-notfound_title', 'coll-notfound_msg');
         return false;
     }
     if (!$append || !CollectionSession::hasSession()) {
         $collection = array('title' => '', 'subtitle' => '');
         $items = array();
     } else {
         $collection = CollectionSession::getCollection();
         $items = $collection['items'];
     }
     $article = new Article($title);
     foreach (preg_split('/[\\r\\n]+/', $article->getContent()) as $line) {
         $item = $this->parseCollectionLine($collection, $line, $append);
         if (!is_null($item)) {
             $items[] = $item;
         }
     }
     $collection['items'] = $items;
     return $collection;
 }