Skip to content

Instantly share code, notes, and snippets.

@CanRau
Created July 13, 2014 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CanRau/72c862e021eb47a7f4a4 to your computer and use it in GitHub Desktop.
Save CanRau/72c862e021eb47a7f4a4 to your computer and use it in GitHub Desktop.
// Override limit based on user input
if($userLimit = (int) $input->get->limit) {
$remeberLimit = "?limit=$userLimit";
$limit = $userLimit;
$input->whitelist('limit', $limit);
}
// Get year filter
if($userYear = (int) $sanitizer->selectorValue($input->get->year)) {
$year = $userYear;
$input->whitelist('year', $year);
$start = ', date>'.strtotime("01.01.$year");
$end = ', date<'.strtotime("31.12.$year");
}
else {
$start = $end = '';
}
//Get album years if any
foreach($page->children->sort('-date') as $years) {
$years->of(false);
if($years->date) $yearsList[] = date('Y', $years->date);
$years->of(true);
}
if(count(array_unique($yearsList)) > 1 || count($page->children) > $limit) {
$content .= "<div class='row'><div class='right'>";
//Output unique years as selectbox
if(count(array_unique($yearsList)) > 1) {
$content .= "<form class='left' action='./' method='get'><select name='year' class='submitOnChange'>";
foreach(array_unique($yearsList) as $y) $content .= "<option value='{$y}'>{$y}</option>";
$content .= "</select></form>";
}
//Output limit selectbox if $children > $limit
if(count($page->children) > $limit) {
$limiters = array((int) $page->limit => (int) $page->limit.' Alben', '0' => 'Alle anzeigen');
$content .= "<form class='left' action='./' method='get'><select name='limit' class='submitOnChange'>";
foreach($limiters as $l => $label) $content .= "<option value='{$l}'>{$label}</option>";
$content .= "</select></form>";
}
$content .= "</div></div>";
} //endif filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment