["name" => "All Categories", "price" => true], 3 => ["name" => "Clothing", "subcategories" => [8, 11, 2, 12], "price" => true], 4 => ["name" => "Body Parts", "subcategories" => [17, 18], "price" => true], 5 => ["name" => "Gear", "type" => 19, "price" => true], 6 => ["name" => "Models", "type" => 10, "price" => false], 8 => ["name" => "Decals", "type" => 13, "price" => false], 9 => ["name" => "Audio", "type" => 3, "price" => false], ]; $sorts = [ 0 => "sales DESC", 1 => "updated DESC", 2 => "price DESC", 3 => "price" ]; function getUrl($strings) { global $cat, $subcat; $url = "?"; if($subcat) $url .= "Subcategory=".$subcat."&"; $url .= "CurrencyType=%currency%&SortType=%sort%&Category=".$cat; return str_replace(["%currency%", "%sort%"], $strings, $url); } $cat = $_GET['Category'] ?? 3; $subcat = $_GET['Subcategory'] ?? false; $keyword = $_GET['Keyword'] ?? ""; $currency = $_GET['CurrencyType'] ?? 0; $sort = $_GET['SortType'] ?? 1; $page = $_GET['PageNumber'] ?? 1; if($cat == 3 && !isset($_GET['Category'])) $subcat = 8; if(!isset($cats[$cat])) die(header("Location: /catalog")); if($subcat && ($cat == 1 || isset($cats[$cat]["type"]) || !is_numeric($subcat) || !in_array($subcat, $cats[$cat]["subcategories"]))) die(header("Location: /catalog?Category=".$cat)); if(!in_array($currency, [0, 1, 2])) die(header("Location: ".getUrl([0, $sort]))); if(!isset($sorts[$sort])) die(header("Location: ".getUrl([$currency, 0]))); $queryparam = ""; $type = $subcat ?: $cats[$cat]["type"] ?? 2; // adding "is not null" fetches the item even if the price is 0 $unavailable = isset($_GET['IncludeNotForSale']) && $_GET['IncludeNotForSale'] == "true"; if($unavailable) $queryparam .= "IS NOT NULL "; // process query parameters for the item type $queryparam .= "AND type"; if($cat == 1) $queryparam .= " IN (2, 3, 8, 10, 11, 12, 13, 17, 18, 19)"; elseif(isset($cats[$cat]["type"]) || $subcat) $queryparam .= " = ".($cats[$cat]["type"] ?? $subcat); else $queryparam .= " IN (".implode(", ", $cats[$cat]["subcategories"]).")"; // process query parameters for the item price $queryparam .= " AND price"; if(is_numeric($currency) && $currency == 0) $queryparam .= " IS NOT NULL"; elseif($currency == 2) $queryparam .= " = 0"; // get the number of assets matching the query $results = Database::singleton()->run( "SELECT COUNT(*) FROM assets WHERE type != 1 AND name LIKE :keywd AND approved != 2 AND sale $queryparam", [":keywd" => "%{$keyword}%"] )->fetchColumn(); $pagination = Pagination($page, $results, 18); $query = Database::singleton()->run( "SELECT assets.*, users.username FROM assets INNER JOIN users ON creator = users.id WHERE type != 1 AND name LIKE :keywd AND approved != 2 AND sale $queryparam ORDER BY ".$sorts[$sort]." LIMIT 18 OFFSET :offset", [":keywd" => "%{$keyword}%", ":offset" => $pagination->Offset] ); $pageBuilder = new PageBuilder(["title" => "Avatar Items, Virtual Avatars, Virtual Goods"]); $pageBuilder->addResource("polygonScripts", "/js/polygon/catalog.js"); $pageBuilder->buildHeader(); ?>
=plural(Catalog::GetTypeByNum($type))?>
$cat_data) { ?>Showing =number_format($pagination->Offset+1)?> - =number_format($pagination->Offset+$query->rowCount())?> of =number_format($results)?> results
No results matched your criteria
=Polygon::FilterText($item->name)?>
sale) { ?>=$item->price ? ' '.number_format($item->price):'Free'?>
Creator: =$item->username?>
Updated: =timeSince($item->updated)?>
Sales: =number_format($item->Sales)?>