/**
  * @inheritdoc
  */
 public function getHtml($data = array())
 {
     $collection = $this->collection;
     $defaults = array('langdir' => 'ltr', 'articleCountMsg' => wfMessage('gather-article-count', $collection->getCount())->text(), 'privacyMsg' => $this->getPrivacyMsg(), 'collectionUrl' => $collection->getUrl(), 'hasImage' => $collection->hasImage(), 'image' => $this->image->getHtml(), 'title' => $this->getTitle());
     $owner = $collection->getOwner();
     if ($owner && $this->showOwnerLink) {
         $defaults['owner'] = array('link' => $collection->getOwnerUrl(), 'className' => helpers\CSS::iconClass('profile', 'before'), 'label' => $owner->getName());
     }
     return Template::render('CollectionsListItemCard', array_merge($defaults, $data));
 }
 /**
  * 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>';
 }
 /**
  * @inheritdoc
  */
 protected function getHtml($data = array())
 {
     $dir = isset($data['langdir']) ? $data['langdir'] : 'ltr';
     $item = $this->item;
     $title = $item->getTitle();
     $img = $this->image->getHtml();
     $pageUrl = $title->getLocalUrl();
     $isMissing = $item->isMissing();
     $data = array('dir' => $dir, 'page' => array('url' => $pageUrl, 'displayTitle' => $title->getPrefixedText()), 'msgMissing' => wfMessage('gather-page-not-found')->escaped(), 'isMissing' => $isMissing, 'progressiveAnchorClass' => CSS::anchorClass('progressive'), 'iconClass' => CSS::iconClass('collections-read-more', 'element', 'collections-read-more-arrow'));
     // Handle excerpt for titles with an extract or unknown pages
     if ($item->hasExtract()) {
         $data['extract'] = $item->getExtract();
     }
     if ($img) {
         $data['cardImage'] = $img;
     }
     return Template::render('CollectionItemCard', $data);
 }
 /**
  * Returns the html for the view
  *
  * @param array $data
  * @return string Html
  */
 public function getHtml($data = array())
 {
     $lang = $this->language;
     $user = $this->user;
     $collection = $this->collection;
     $action = isset($data['action']) ? $data['action'] : 'hide';
     $ts = $lang->userTimeAndDate($collection->getUpdated(), $user);
     $owner = $collection->getOwner();
     $title = $collection->getTitle();
     $id = $collection->getId();
     $desc = $collection->getDescription();
     $html = Html::openElement('li') . $this->collectionLink($collection) . Html::element('span', $desc ? array() : array('class' => 'empty'), $desc) . Html::element('span', array(), $collection->getCount()) . $this->userLink($owner) . Html::element('span', array(), $ts);
     if ($data['canHide']) {
         $className = CSS::buttonClass($action === 'hide' ? 'destructive' : 'constructive', 'moderate-collection');
         $label = $action === 'hide' ? wfMessage('gather-lists-hide-collection-label')->text() : wfMessage('gather-lists-show-collection-label')->text();
         $html .= Html::openElement('span', array()) . Html::element('button', array('class' => $className, 'data-id' => $id, 'data-action' => $action, 'data-label' => $title, 'data-owner' => $owner->getName()), $label) . Html::closeElement('span');
     }
     $html .= Html::closeElement('li');
     return $html;
 }
 /**
  * Add collections link in personal tools menu
  * @param array &$items Items array to be added to menu
  */
 public static function onMobilePersonalTools(&$items)
 {
     // Get an array with just watchlist in it.
     $itemArray = array_slice($items, 0, 1);
     // add collections after it.
     $itemArray[] = array('name' => 'collections', 'components' => array('text' => wfMessage('gather-lists-title')->escaped(), 'href' => SpecialPage::getTitleFor('Gather')->getLocalURL(), 'class' => CSS::iconClass('collections-icon', 'before', 'collection-menu-item hidden'), 'data-event-name' => 'collections'));
     // combine it with the rest of the array
     $items = array_merge($itemArray, array_slice($items, 1, count($items) - 1));
     return true;
 }
 /**
  * Get the HTML for the more collections button (infinite scrolling)
  * @param string $url url where the more button will point to
  * @param string $text text for the button
  * @param string $data data attributes for the button
  * @param string $classes Additional css classes for the pagination button
  */
 public static function more($url, $text, $data = array(), $classes = '')
 {
     return Html::openElement('div', array('class' => 'collections-pagination')) . Html::element('a', array_merge(array('href' => $url, 'class' => CSS::buttonClass('progressive', $classes)), $data), $text) . Html::closeElement('div');
 }
 /**
  * Get the edit button html if user should edit
  * FIXME: Move this to JavaScript.
  */
 public function getEditButtonHtml()
 {
     $id = $this->collection->getId();
     // Do not edit watchlist
     if ($id !== 0 && $this->collection->isOwner($this->user)) {
         return Html::element('a', array('href' => '#/edit-collection/' . $id, 'class' => CSS::buttonClass('progressive', 'collection-action-button edit-collection')), wfMessage('gather-edit-button')->text());
     } else {
         return '';
     }
 }
 /**
  * @param User $user
  * @return string
  */
 public static function getUsernameCSSClasses(User $user)
 {
     $isAnon = $user->isAnon();
     if ($isAnon) {
         return CSS::iconClass('anonymous', 'before', 'icon-16px mw-userlink mw-anonuserlink');
     } else {
         return CSS::iconClass('user', 'before', 'icon-16px mw-userlink');
     }
 }