- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jokob-sk
committed
Jan 25, 2025
1 parent
890e533
commit 4443c69
Showing
23 changed files
with
448 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
//------------------------------------------------------------------------------ | ||
// Check if authenticated | ||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php'; | ||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/server/db.php'; | ||
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/language/lang.php'; | ||
|
||
// Function to render a filter dropdown | ||
function renderFilterDropdown($headerKey, $columnName, $values) { | ||
// Generate dropdown options | ||
$optionsHtml = '<option value="" selected>All</option>'; // Default "All" option | ||
foreach ($values as $value) { | ||
$escapedValue = htmlspecialchars($value); | ||
$optionsHtml .= '<option value="' . $escapedValue . '">' . $escapedValue . '</option>'; | ||
} | ||
|
||
// Generate the dropdown HTML | ||
return ' | ||
<div class="filter-group"> | ||
<label for="filter_' . htmlspecialchars($columnName) . '">' . lang($headerKey) . '</label> | ||
<select id="filter_' . htmlspecialchars($columnName) . '" class="filter-dropdown" data-column="' . htmlspecialchars($columnName) . '"> | ||
' . $optionsHtml . ' | ||
</select> | ||
</div>'; | ||
} | ||
|
||
// Get filterObject from POST data | ||
$filterObject = isset($_POST['filterObject']) ? json_decode($_POST['filterObject'], true) : []; | ||
|
||
// Validate filterObject structure | ||
if (!isset($filterObject['filters']) || !is_array($filterObject['filters'])) { | ||
echo '<p class="error">Invalid filter data provided.</p>'; | ||
exit(); | ||
} | ||
|
||
// Generate HTML for each filter in the filterObject | ||
$html = ''; | ||
foreach ($filterObject['filters'] as $filter) { | ||
if (isset($filter['column'], $filter['headerKey'], $filter['options'])) { | ||
$html .= renderFilterDropdown($filter['headerKey'], $filter['column'], $filter['options']); | ||
} else { | ||
// Skip invalid entries | ||
continue; | ||
} | ||
} | ||
|
||
// Output the generated HTML | ||
echo $html; | ||
exit(); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.