Guest User

Untitled

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