Guest User

Untitled

a guest
Nov 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. use Bookshop\Util;
  4. use Data\DataManager;
  5.  
  6. $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
  7. $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
  8. $epp = isset($_REQUEST['epp']) ? $_REQUEST['epp'] : 4; // epp … entries per page
  9.  
  10. $page = isset($title) ? DataManager::getBooksForSearchCriteriaWithPaging($title, $offset, $epp) : null;
  11.  
  12. require_once('views/partials/header.php');
  13. ?>
  14.  
  15. <div class="page-header">
  16. <form class="form-horizontal" action="index.php" method="get">
  17. <input type="hidden" name="view" value="<?php echo $view; ?>" />
  18. <div class="input-group">
  19. <input type="text" class="form-control" id="title" name="title" placeholder="Search books by title..." value="<?php print htmlentities($title); ?>">
  20. <div class="input-group-btn">
  21. <button type="submit" class="btn btn-default">Search</button>
  22. </div>
  23. </div>
  24.  
  25. </form>
  26. </div>
  27.  
  28.  
  29. <?php if (isset($page)): ?>
  30.  
  31. <h3>Search Result</h3>
  32.  
  33. <?php if (sizeof($page->getResult()) > 0) : ?>
  34.  
  35. <p>
  36. Displaying results <?php echo Util::escape($page->getPositionOfFirst()); ?> to <?php echo Util::escape($page->getPositionOfLast()); ?> of <?php echo Util::escape($page->getTotalCount()); ?>.
  37. </p>
  38.  
  39. <?php
  40. $books = $page->getResult();
  41. require('views/partials/booklist.php');
  42. ?>
  43.  
  44. <p>
  45. <?php
  46. $p = 0;
  47. $i = 0;
  48. while ($i < $page->getTotalCount()) :
  49. ?>
  50. <a href="?view=search&title=<?php echo rawurlencode($title); ?>&offset=<?php echo rawurlencode($i); ?>&epp=<?php echo rawurlencode($epp); ?>"><?php echo Util::escape(++$p); ?></a>
  51. <?php
  52. $i += $epp;
  53. endwhile;
  54. ?>
  55. </p>
  56.  
  57. <?php else : ?>
  58. <p>No matching books found.</p>
  59. <?php endif; ?>
  60.  
  61. <?php endif; ?>
  62.  
  63. <?php require_once('views/partials/footer.php');
Add Comment
Please, Sign In to add comment