mirror of
https://github.com/godotengine/godot-asset-library.git
synced 2026-02-25 06:33:01 +03:00
Merge pull request #282 from Piralein/license
Add a license select filter and remove the link filter
This commit is contained in:
1
API.md
1
API.md
@@ -133,6 +133,7 @@ Get a list of categories (needed for filtering assets) and potentially a login U
|
||||
&support=(official|community|testing)
|
||||
&filter=(search text)
|
||||
&user=(submitter username)
|
||||
&cost=(license)
|
||||
&godot_version=(major).(minor).(patch)
|
||||
&max_results=(number 1…500)
|
||||
&page=(number, pages to skip) OR &offset=(number, rows to skip)
|
||||
|
||||
@@ -71,5 +71,25 @@ return $constants = [
|
||||
'4.0',
|
||||
'unknown',
|
||||
'custom_build',
|
||||
],
|
||||
'licenses' => [
|
||||
'MIT' => 'MIT',
|
||||
'MPL-2.0' => 'MPL-2.0',
|
||||
'GPLv3' => 'GPL v3',
|
||||
'GPLv2' => 'GPL v2',
|
||||
'LGPLv3' => 'LGPL v3',
|
||||
'LGPLv2.1' => 'LGPL v2.1',
|
||||
'LGPLv2' => 'LGPL v2',
|
||||
'AGPLv3' => 'AGPL v3',
|
||||
'Apache-2.0' => 'Apache 2.0',
|
||||
'CC0' => 'CC0 1.0 Universal',
|
||||
'CC-BY-4.0' => 'CC BY 4.0 International',
|
||||
'CC-BY-3.0' => 'CC BY 3.0 Unported',
|
||||
'CC-BY-SA-4.0' => 'CC BY-SA 4.0 International',
|
||||
'CC-BY-SA-3.0' => 'CC BY-SA 3.0 Unported',
|
||||
'BSD-2-Clause' => 'BSD 2-clause License',
|
||||
'BSD-3-Clause' => 'BSD 3-clause License',
|
||||
'BSL-1.0' => 'Boost Software License',
|
||||
'Unlicense' => 'The Unlicense License'
|
||||
]
|
||||
];
|
||||
|
||||
@@ -29,7 +29,7 @@ return [
|
||||
LEFT JOIN `as_categories` USING (category_id)
|
||||
|
||||
WHERE searchable = TRUE AND category_id LIKE :category AND category_type LIKE :category_type
|
||||
AND support_level RLIKE :support_levels_regex AND username LIKE :username
|
||||
AND support_level RLIKE :support_levels_regex AND username LIKE :username AND cost LIKE :cost
|
||||
AND godot_version <= :max_godot_version AND godot_version >= :min_godot_version
|
||||
AND (
|
||||
title LIKE :filter
|
||||
@@ -63,7 +63,7 @@ return [
|
||||
LEFT JOIN `as_users` USING (user_id)
|
||||
LEFT JOIN `as_categories` USING (category_id)
|
||||
WHERE searchable = TRUE AND category_id LIKE :category AND category_type LIKE :category_type
|
||||
AND support_level RLIKE :support_levels_regex AND username LIKE :username
|
||||
AND support_level RLIKE :support_levels_regex AND username LIKE :username AND cost LIKE :cost
|
||||
AND godot_version <= :max_godot_version AND godot_version >= :min_godot_version
|
||||
AND (
|
||||
title LIKE :filter
|
||||
|
||||
@@ -8,6 +8,7 @@ $app->get('/asset', function ($request, $response, $args) {
|
||||
$category = '%';
|
||||
$filter = '%';
|
||||
$username = '%';
|
||||
$cost = '%';
|
||||
$order_column = 'modify_date';
|
||||
$support_levels = [];
|
||||
$page_size = 40;
|
||||
@@ -50,6 +51,9 @@ $app->get('/asset', function ($request, $response, $args) {
|
||||
if (isset($params['user'])) {
|
||||
$username = $params['user'];
|
||||
}
|
||||
if (isset($params['cost']) && $params['cost'] != "") {
|
||||
$cost = $params['cost'];
|
||||
}
|
||||
if (isset($params['max_results'])) {
|
||||
$page_size = min(abs((int) $params['max_results']), $max_page_size);
|
||||
}
|
||||
@@ -107,6 +111,7 @@ $app->get('/asset', function ($request, $response, $args) {
|
||||
$query->bindValue(':support_levels_regex', $support_levels);
|
||||
$query->bindValue(':filter', $filter);
|
||||
$query->bindValue(':username', $username);
|
||||
$query->bindValue(':cost', $cost);
|
||||
$query->bindValue(':order', $order_column);
|
||||
$query->bindValue(':order_direction', $order_direction);
|
||||
$query->bindValue(':page_size', $page_size, PDO::PARAM_INT);
|
||||
@@ -126,6 +131,7 @@ $app->get('/asset', function ($request, $response, $args) {
|
||||
$query_count->bindValue(':support_levels_regex', $support_levels);
|
||||
$query_count->bindValue(':filter', $filter);
|
||||
$query_count->bindValue(':username', $username);
|
||||
$query_count->bindValue(':cost', $cost);
|
||||
$query_count->execute();
|
||||
|
||||
$error = $this->utils->errorResponseIfQueryBad(false, $response, $query_count);
|
||||
|
||||
@@ -60,32 +60,12 @@ $_asset_values = array_merge([
|
||||
<label class="col-md-4 control-label required_mark" for="license">License</label>
|
||||
<div class="col-md-5">
|
||||
<select id="license" name="cost" class="form-control" required="">
|
||||
<?php $licenses = [
|
||||
'MIT' => 'MIT',
|
||||
'MPL-2.0' => 'MPL-2.0',
|
||||
'GPLv3' => 'GPL v3',
|
||||
'GPLv2' => 'GPL v2',
|
||||
'LGPLv3' => 'LGPL v3',
|
||||
'LGPLv2.1' => 'LGPL v2.1',
|
||||
'LGPLv2' => 'LGPL v2',
|
||||
'AGPLv3' => 'AGPL v3',
|
||||
'Apache-2.0' => 'Apache 2.0',
|
||||
'CC0' => 'CC0 1.0 Universal',
|
||||
'CC-BY-4.0' => 'CC BY 4.0 International',
|
||||
'CC-BY-3.0' => 'CC BY 3.0 Unported',
|
||||
'CC-BY-SA-4.0' => 'CC BY-SA 4.0 International',
|
||||
'CC-BY-SA-3.0' => 'CC BY-SA 3.0 Unported',
|
||||
'BSD-2-Clause' => 'BSD 2-clause License',
|
||||
'BSD-3-Clause' => 'BSD 3-clause License',
|
||||
'BSL-1.0' => 'Boost Software License',
|
||||
'Unlicense' => 'The Unlicense License'
|
||||
] ?>
|
||||
<?php if(!$_asset_values['cost']) { ?>
|
||||
<option value="" selected="">
|
||||
Select...
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php foreach($licenses as $id => $name) { ?>
|
||||
<?php foreach($constants['licenses'] as $id => $name) { ?>
|
||||
<option value="<?php echo raw($id) ?>" <?php if($id == $_asset_values['cost']) echo 'selected=""'; ?>>
|
||||
<?php echo esc($name) ?>
|
||||
</option>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<p class="text-muted">
|
||||
Submitted by user <a href="<?php echo raw($basepath) ?>/asset?user=<?php echo esc($data['author']) ?>" title="Search assets by '<?php echo esc($data['author']) ?>'"><?php echo esc($data['author']) ?></a>;
|
||||
<a href="<?php echo raw($basepath) ?>/asset?filter=<?php echo esc($data['cost']) ?>" title="Search assets with filter '<?php echo esc($data['cost']) ?>'"><?php echo esc($data['cost']) ?></a>;
|
||||
<?php echo esc($data['cost']) ?>;
|
||||
<?php echo esc(explode(" ", $data['modify_date'])[0]) ?>
|
||||
</p>
|
||||
<p>
|
||||
|
||||
@@ -52,6 +52,20 @@
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="license">License</label>
|
||||
<select id="license" name="cost" class="form-control">
|
||||
<option value="">
|
||||
Any
|
||||
</option>
|
||||
|
||||
<?php foreach($constants['licenses'] as $id => $license) { ?>
|
||||
<option value="<?php echo url($id) ?>" <?php if(isset($params['cost']) && $id == $params['cost']) echo 'selected=""'; ?>>
|
||||
<?php echo esc($license) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="sort">Order by</label>
|
||||
<select id="sort" name="sort" class="form-control">
|
||||
@@ -112,9 +126,7 @@
|
||||
|
||||
<p class="text-muted">
|
||||
Submitted by user <a href="?user=<?php echo esc($asset['author']) ?>" title="Search assets by '<?php echo esc($asset['author']) ?>'"><?php echo esc($asset['author']) ?></a>;
|
||||
<a href="?<?php echo esc(http_build_query([
|
||||
'filter' => $asset['cost'] // isset($params['filter']) ? $params['filter'] . ' ' . $asset['cost'] : $asset['cost']
|
||||
] + $params)) ?>" title="Search assets with filter '<?php echo esc($asset['cost']) ?>'"><?php echo esc($asset['cost']) ?></a>;
|
||||
<?php echo esc($asset['cost']) ?>;
|
||||
<span class="nowrap"><?php echo esc(explode(" ", $asset['modify_date'])[0]) ?></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user