index.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * copyright 2009 Lucas Baudin <xapantu@gmail.com>
  4. * 2014-2015 Daniel Butum <danibutum at gmail dot com>
  5. * This file is part of stk-addons.
  6. *
  7. * stk-addons is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * stk-addons is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with stk-addons. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. require_once(__DIR__ . DIRECTORY_SEPARATOR . "config.php");
  21. $description = _h('This is the official SuperTuxKart add-on repository. It contains extra karts and tracks for the SuperTuxKart game.');
  22. $tpl = StkTemplate::get('index.tpl')
  23. ->assign('title', _h('SuperTuxKart Add-ons'))
  24. ->assign("show_stk_image", true)
  25. ->setMetaDesc($description)
  26. ->addScriptInclude("jquery.newsticker.js")
  27. ->addScriptInline('$("#news-messages").newsTicker();', StkTemplate::ORDER_AFTER);
  28. // Display index menu
  29. $type_kart = Addon::typeToString(Addon::KART);
  30. $type_track = Addon::typeToString(Addon::TRACK);
  31. $type_arena = Addon::typeToString(Addon::ARENA);
  32. $tpl->assign(
  33. 'index_menu',
  34. [
  35. [
  36. 'href' => URL::rewriteFromConfig('addons.php?type=' . $type_kart),
  37. 'label' => _h('Karts'),
  38. 'type' => $type_kart
  39. ],
  40. [
  41. 'href' => URL::rewriteFromConfig('addons.php?type=' . $type_track),
  42. 'label' => _h('Tracks'),
  43. 'type' => $type_track
  44. ],
  45. [
  46. 'href' => URL::rewriteFromConfig('addons.php?type=' . $type_arena),
  47. 'label' => _h('Arenas'),
  48. 'type' => $type_arena
  49. ],
  50. [
  51. 'href' => 'https://github.com/supertuxkart/stk-addons/wiki',
  52. 'label' => 'Help',
  53. 'type' => 'help'
  54. ]
  55. ]
  56. );
  57. // Display news messages
  58. $news_messages = News::getWebVisible();
  59. // Note most downloaded track and kart
  60. $pop_kart = Statistic::mostDownloadedAddon(Addon::KART);
  61. $pop_track = Statistic::mostDownloadedAddon(Addon::TRACK);
  62. if ($pop_track !== null)
  63. {
  64. array_unshift(
  65. $news_messages,
  66. sprintf(_h('The most downloaded track is %s.'), $pop_track)
  67. );
  68. }
  69. if ($pop_kart !== null)
  70. {
  71. array_unshift(
  72. $news_messages,
  73. sprintf(_h('The most downloaded kart is %s.'), $pop_kart)
  74. );
  75. }
  76. $tpl->assign('news_messages', $news_messages);
  77. echo $tpl;