["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'] ?? ""; $keyword_sql = "%$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 = db::run( "SELECT COUNT(*) FROM assets WHERE type != 1 AND name LIKE :keywd AND approved != 2 AND sale $queryparam", [":keywd" => $keyword_sql] )->fetchColumn(); $pages = ceil($results/18); if($page > $pages) $page = $pages; if(!is_numeric($page) || $page < 1) $page = 1; $offset = ($page - 1)*18; $query = $pdo->prepare(" SELECT assets.*, users.username, (SELECT COUNT(*) FROM ownedAssets WHERE assetId = assets.id AND userId != assets.creator) AS sales 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"); $query->bindParam(":keywd", $keyword_sql, PDO::PARAM_STR); $query->bindParam(":offset", $offset, PDO::PARAM_INT); $query->execute(); PageBuilder::$Config["title"] = "Avatar Items, Virtual Avatars, Virtual Goods"; PageBuilder::AddResource(PageBuilder::$PolygonScripts, "/js/polygon/catalog.js"); PageBuilder::BuildHeader(); ?>
=plural(Catalog::GetTypeByNum($type))?>
$cat_data) { ?>Showing =number_format($offset+1)?> - =number_format($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)?>