/** * Display the text list of all existing system gifts and a delete link to * users who are allowed to delete gifts. * * @return String: HTML */ function displayGiftList() { $output = ''; // Prevent E_NOTICE // $page = 0; $request = $this->getRequest(); $per_page = 30; $page = $request->getInt('page', 1); // $gifts = SystemGifts::getGiftList( $per_page, $page ); $gifts = SystemGifts::getGiftList($per_page, $page); $user = $this->getUser(); $pcount = SystemGifts::getGiftCount(); $output .= '<div id="views">'; if ($gifts) { foreach ($gifts as $gift) { $deleteLink = ''; if ($user->isAllowed('awardsmanage')) { $removePage = SpecialPage::getTitleFor('RemoveMasterSystemGift'); $deleteLink = '<a href="' . htmlspecialchars($removePage->getFullURL("gift_id={$gift['id']}")) . '" style="font-size:10px; color:red;">' . $this->msg('delete')->plain() . '</a>'; } $output .= '<div class="Item"> <a href="' . htmlspecialchars($this->getPageTitle()->getFullURL('id=' . $gift['id'])) . '">' . $gift['gift_name'] . '</a> ' . $deleteLink . '</div>' . "\n"; } } $output .= '</div>'; /** * Build next/prev nav */ $numofpages = $pcount / $per_page; $page_link = $this->getPageTitle(); if ($numofpages > 1) { $output .= '<div class="text-align: left"><nav class="page-nav pagination">'; if ($page > 1) { $output .= '<li>' . Linker::link($page_link, '<span aria-hidden="true">«</span>', array(), array('user' => $user_name, 'page' => $page - 1)) . '</li>'; } if ($pcount % $per_page != 0) { $numofpages++; } if ($numofpages >= 9 && $page < $pcount) { $numofpages = 9 + $page; } // if ( $numofpages >= ( $total / $per_page ) ) { // $numofpages = ( $total / $per_page ) + 1; // } for ($i = 1; $i <= $numofpages; $i++) { if ($i == $page) { $output .= '<li class="active"><a href="#">' . $i . ' <span class="sr-only">(current)</span></a></li>'; } else { $output .= '<li>' . Linker::link($page_link, $i, array(), array('page' => $i)); } } if ($pcount - $per_page * $page > 0) { $output .= '<li>' . Linker::link($page_link, '<span aria-hidden="true">»</span>', array(), array('page' => $page + 1)) . '</li>'; } $output .= '</nav></div>'; } return $output; }