/**
  * Get the header for the watchlist page
  * @param User $user
  * @param int $id
  * @param string $actionUrl
  * @return string Parsed HTML
  */
 private function getHeader(User $user, $id, $actionUrl)
 {
     $html = Html::openElement('form', array('action' => $actionUrl)) . Html::openElement('select', array('name' => 'collection-id'));
     $collections = models\CollectionsList::newFromApi($user, true);
     foreach ($collections as $collection) {
         $attrs = array('value' => $collection->getId());
         if ($collection->getId() === $id) {
             $attrs['selected'] = true;
         }
         $html .= Html::element('option', $attrs, $collection->getTitle());
     }
     $html .= Html::closeElement('select') . Html::submitButton(wfMessage('gather-editfeed-show'), array('class' => CSS::buttonClass('progressive'))) . Html::closeElement('form');
     return '<div class="gather-edit-feed-header content-header">' . $html . '</div>';
 }
 /**
  * Renders a list of user collections
  *
  * @param User $user owner of collections
  */
 public function renderUserCollectionsList(User $user)
 {
     $currentUser = $this->getUser();
     $collectionsList = models\CollectionsList::newFromApi($user, $this->getUser()->equals($user), false, $this->getRequest()->getValues());
     if ($collectionsList->getCount() > 0) {
         $this->addMetaInformation(wfMessage('gather-meta-description', $user->getName()), models\Image::getThumbnail($collectionsList->getFile()));
         if ($collectionsList->isOwner($currentUser)) {
             $this->renderTabs(1);
         }
         $this->render(new views\CollectionsList($currentUser, $collectionsList));
     } else {
         $this->renderError(new views\NoPublic($user));
     }
 }
 /**
  * Generate UserPageCollectionsList from api result
  * @param User $user collection list owner (currently ignored)
  * @param boolean [$includePrivate] if the list should show private collections or not
  * @param string|boolean [$memberTitle] title of member to check for
  * @param array [$params] generate collection list with additional api parameters
  * @param string [$mode] listing mode (public/private/review)
  * @param integer [$limit] of number of collections to show
  * @return models\CollectionsList List of collections.
  */
 public static function newFromApi($user = null, $includePrivate = false, $memberTitle = false, $params = array(), $mode = null, $limit = 50)
 {
     $collectionsList = new CollectionsList($user, $includePrivate);
     $query = array_merge($params, array('action' => 'query', 'list' => 'lists', 'lstprop' => 'label|description|public|image|count|updated|owner', 'lstlimit' => $limit, 'continue' => ''));
     if ($memberTitle) {
         $query['lsttitle'] = $memberTitle;
     }
     if ($user) {
         $query['lstowner'] = $user->getName();
     }
     if ($mode) {
         $query['lstmode'] = $mode === 'review' ? $mode : "all{$mode}";
     } else {
         $mode = '';
     }
     $api = new ApiMain(new FauxRequest($query));
     $api->execute();
     $data = $api->getResult()->getResultData(null, array('Strip' => 'all'));
     if (isset($data['query']['lists'])) {
         $lists = $data['query']['lists'];
         foreach ($lists as $list) {
             $public = $list['perm'] === 'public';
             if ($public || $includePrivate) {
                 $image = isset($list['image']) ? wfFindFile($list['image']) : false;
                 $info = new models\CollectionInfo($list['id'], User::newFromName($list['owner']), $list['label'], $list['description'], $public, $image);
                 $info->setCount($list['count']);
                 $info->setUpdated($list['updated']);
                 if ($list['perm'] === 'hidden') {
                     $info->setHidden();
                 }
                 if ($memberTitle) {
                     $info->setMember($memberTitle, $list['title']);
                 }
                 $collectionsList->add($info);
             }
         }
     }
     if (isset($data['continue'])) {
         $collectionsList->setContinueQueryString($data['continue'], $mode);
     }
     return $collectionsList;
 }