addons-menu.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright 2009 Lucas Baudin <xapantu@gmail.com>
  4. * 2011-2014 Stephen Just <stephenjust@gmail.com>
  5. * 2014-2015 Daniel Butum <danibutum at gmail dot com>
  6. * This file is part of stk-addons.
  7. *
  8. * stk-addons is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * stk-addons is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with stk-addons. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
  22. try
  23. {
  24. $type = isset($_GET['type']) ? Addon::stringToType($_GET['type']) : null;
  25. $sort = isset($_GET['sort']) ? $_GET['sort'] : Addon::SORT_FEATURED;
  26. $order = isset($_GET['order']) ? $_GET['order'] : null;
  27. $addon_name = empty($_GET['name']) ? null : $_GET['name'];
  28. $current_page = PaginationTemplate::getPageNumber();
  29. $limit = PaginationTemplate::getLimitNumber();
  30. $addons = Addon::getAll($type, $limit, $current_page, $sort, $order);
  31. $template_addons = Addon::filterMenuTemplate($addons, $addon_name);
  32. $pagination = PaginationTemplate::get()
  33. ->setItemsPerPage($limit)
  34. ->setTotalItems(count(Addon::getAll($type)))
  35. ->setCurrentPage($current_page);
  36. $tpl = StkTemplate::get("addons/menu.tpl")
  37. ->assign("addons", $template_addons)
  38. ->assign("pagination", $pagination->toString());
  39. echo $tpl;
  40. }
  41. catch (AddonException $e)
  42. {
  43. echo $e->getMessage();
  44. }