PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/themes/default/purchase/index.php

https://github.com/chokoleytdesignoper/fluxcp_choko
PHP | 116 lines | 113 code | 3 blank | 0 comment | 24 complexity | 158936a12cc610ca9bc2409251ab1a9f MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, BSD-3-Clause
  1. <?php if (!defined('FLUX_ROOT')) exit; ?>
  2. <h2>Purchase</h2>
  3. <p>Items in this shop are purchased using <span class="keyword">donation credits</span> and not real money. Donation Credits are rewarded to players who <a href="<?php echo $this->url('donate') ?>">make a donation to our server</a>, helping us cover the costs of maintaining and running the server.</p>
  4. <h2><span class="shop-server-name"><?php echo htmlspecialchars($server->serverName) ?></span> Item Shop</h2>
  5. <p class="action">
  6. <a href="<?php echo $this->url('purchase', 'index') ?>"<?php if (is_null($category)) echo ' class="current-shop-category"' ?>>
  7. <?php echo htmlspecialchars(Flux::message('AllLabel')) ?> (<?php echo number_format($total) ?>)
  8. </a>
  9. <?php foreach ($categories as $catID => $catName): ?>
  10. /
  11. <a href="<?php echo $this->url('purchase', 'index', array('category' => $catID)) ?>"<?php if (!is_null($category) && $category === (string)$catID) echo ' class="current-shop-category"' ?>>
  12. <?php echo htmlspecialchars($catName) ?> (<?php echo number_format($categoryCount[$catID]) ?>)
  13. </a>
  14. <?php endforeach ?>
  15. </p>
  16. <?php if ($categoryName): ?>
  17. <h3>Category: <?php echo htmlspecialchars($categoryName) ?></h3>
  18. <?php endif ?>
  19. <?php if ($items): ?>
  20. <?php
  21. $evens = array();
  22. $odds = array();
  23. foreach ($items as $i => $item) {
  24. if (!($i % 2)) {
  25. $evens[] = $item;
  26. }
  27. else {
  28. $odds[] = $item;
  29. }
  30. }
  31. ?>
  32. <?php if ($session->isLoggedIn()): ?>
  33. <?php if ($cartItems=$server->cart->getCartItemNames()): ?><p class="cart-items-text">Items in your cart: <span class="cart-item-name"><?php echo implode('</span>, <span class="cart-item-name">', array_map('htmlspecialchars', $cartItems)) ?></span>.</p><?php endif ?>
  34. <p class="cart-info-text">You have <span class="cart-item-count"><?php echo number_format(count($cartItems)) ?></span> item(s) in your cart.</p>
  35. <p class="cart-total-text">Your current subtotal is <span class="cart-sub-total"><?php echo number_format($server->cart->getTotal()) ?></span> credit(s).</p>
  36. <?php endif ?>
  37. <table class="shop-table">
  38. <tr>
  39. <td width="50%">
  40. <?php foreach ($evens as $i => $item): ?>
  41. <div class="shop-item <?php echo (!($i % 2) ? 'even' : 'odd') ?>">
  42. <table>
  43. <tr>
  44. <?php if (($item->shop_item_use_existing && ($image=$this->itemImage($item->shop_item_nameid))) || ($image=$this->shopItemImage($item->shop_item_id))): ?>
  45. <td>
  46. <img src="<?php echo $image ?>?nocache=<?php echo rand() ?>" class="shop-item-image" />
  47. </td>
  48. <?php endif ?>
  49. <td>
  50. <h4 class="shop-item-name"><?php echo htmlspecialchars($item->shop_item_name) ?></h4>
  51. <?php if ($item->shop_item_qty > 1): ?>
  52. <p class="shop-item-qty">Quantity: <span class="qty"><?php echo number_format($item->shop_item_qty) ?></span></p>
  53. <?php endif ?>
  54. <p class="shop-item-cost"><span class="cost"><?php echo number_format($item->shop_item_cost) ?></span> credits</p>
  55. <p class="shop-item-info"><?php echo Markdown($item->shop_item_info) ?></p>
  56. <p class="shop-item-action">
  57. <a href="<?php echo $this->url('purchase', 'add', array('id' => $item->shop_item_id)) ?>"><strong>Add to Cart</strong></a>
  58. <?php if ($auth->actionAllowed('item', 'view')): ?>
  59. / <?php echo $this->linkToItem($item->shop_item_nameid, 'View Item') ?>
  60. <?php endif ?>
  61. <?php if ($auth->allowedToEditShopItem): ?>
  62. / <a href="<?php echo $this->url('itemshop', 'edit', array('id' => $item->shop_item_id)) ?>">Modify</a>
  63. <?php endif ?>
  64. <?php if ($auth->allowedToDeleteShopItem): ?>
  65. / <a href="<?php echo $this->url('itemshop', 'delete', array('id' => $item->shop_item_id)) ?>"
  66. onclick="return confirm('Are you sure you want to remove this item from the item shop?')">Delete</a>
  67. <?php endif ?>
  68. </p>
  69. </td>
  70. </tr>
  71. </table>
  72. </div>
  73. <?php endforeach ?>
  74. </td>
  75. <td width="50%">
  76. <?php foreach ($odds as $i => $item): ?>
  77. <div class="shop-item <?php echo (!($i % 2) ? 'even' : 'odd') ?>">
  78. <table>
  79. <tr>
  80. <?php if (($item->shop_item_use_existing && ($image=$this->itemImage($item->shop_item_nameid))) || ($image=$this->shopItemImage($item->shop_item_id))): ?>
  81. <td>
  82. <img src="<?php echo $image ?>?nocache=<?php echo rand() ?>" class="shop-item-image" />
  83. </td>
  84. <?php endif ?>
  85. <td>
  86. <h4 class="shop-item-name"><?php echo htmlspecialchars($item->shop_item_name) ?></h4>
  87. <?php if ($item->shop_item_qty > 1): ?>
  88. <p class="shop-item-qty">Quantity: <span class="qty"><?php echo number_format($item->shop_item_qty) ?></span></p>
  89. <?php endif ?>
  90. <p class="shop-item-cost"><span class="cost"><?php echo number_format($item->shop_item_cost) ?></span> credits</p>
  91. <p class="shop-item-info"><?php echo Markdown($item->shop_item_info) ?></p>
  92. <p class="shop-item-action">
  93. <a href="<?php echo $this->url('purchase', 'add', array('id' => $item->shop_item_id)) ?>"><strong>Add to Cart</strong></a>
  94. / <?php echo $this->linkToItem($item->shop_item_nameid, 'View Item') ?>
  95. <?php if ($auth->allowedToEditShopItem): ?>
  96. / <a href="<?php echo $this->url('itemshop', 'edit', array('id' => $item->shop_item_id)) ?>">Modify</a>
  97. <?php endif ?>
  98. <?php if ($auth->allowedToDeleteShopItem): ?>
  99. / <a href="<?php echo $this->url('itemshop', 'delete', array('id' => $item->shop_item_id)) ?>"
  100. onclick="return confirm('Are you sure you want to remove this item from the item shop?')">Delete</a>
  101. <?php endif ?>
  102. </p>
  103. </td>
  104. </tr>
  105. </table>
  106. </div>
  107. <?php endforeach ?>
  108. </td>
  109. </tr>
  110. </table>
  111. <?php else: ?>
  112. <p>There are currently no items for sale.</p>
  113. <?php endif ?>