Skip to content

Commit

Permalink
(Sub-)Typenfilter invertierbar
Browse files Browse the repository at this point in the history
fixes #237
  • Loading branch information
Cassandre committed Nov 17, 2020
1 parent 102e533 commit 1a11bae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
6 changes: 6 additions & 0 deletions class_Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ private function compare($value, $operator, $reference) {
} else {
return (in_array($value, $reference));
}
case "not":
if (is_string($value)) {
return (!in_array(strtolower($value),array_map('strtolower', $reference)));
} else {
return (!in_array($value, $reference));
}
case "le":
return ($value <= $reference);
case "lt":
Expand Down
2 changes: 1 addition & 1 deletion class_Publikationen.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function pubNachTyp($param = array(), $field = '', $content = '', $fsp =
} else {
foreach ($pubList as $array_type => $publications) {
// Zwischenüberschrift (= Publikationstyp), außer wenn nur ein Typ gefiltert wurde
if (empty($type)) {
if (empty($type) || strpos($type, '-') === 0 || strpos($type, ',') !== false) {
$title = Tools::getTitle('publications', $array_type, $param['display_language']);
if (!shortcode_exists('collapsibles') || $format != 'accordion') {
$output .= "<h3>";
Expand Down
37 changes: 30 additions & 7 deletions class_Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,28 +242,51 @@ public static function publication_filter($year = '', $start = '', $end = '', $t
$type = str_replace(' ', '', $type);
$types = explode(',', $type);
foreach($types as $v) {
$pubTyp[] = self::getType('publications', $v);
if (strpos($v, '-') === 0) {
$tmpType = substr($v, 1);
$pubTypExclude[] = self::getType('publications', $tmpType);
} else {
$pubTyp[] = self::getType('publications', $v);
}
}
} else {
$pubTyp = (array) self::getType('publications', $type);
if (strpos($type, '-') === 0) {
$tmpType = substr($type, 1);
$pubTypExclude = (array)self::getType('publications', $tmpType);
} else {
$pubTyp = (array)self::getType('publications', $type);
}
}
if (empty($pubTyp)) {
if (empty($pubTyp) && empty($pubTypExclude)) {
$output = '<p>' . __('Falscher Parameter für Publikationstyp', 'fau-cris') . '</p>';
return $output;
}
$filter['publication type__eq'] = $pubTyp;
if (!empty($pubTyp)) {
$filter['publication type__eq'] = $pubTyp;
} elseif (!empty($pubTypExclude)) {
$filter['publication type__not'] = $pubTypExclude;
}
}
if ($subtype !== '' && $subtype !== NULL) {
$subtype = str_replace(' ', '', $subtype);
$subtypes = explode(',', $subtype);
foreach($subtypes as $v) {
$pubSubTyp[] = self::getType('publications', $v, $pubTyp[0]);
if (strpos($v, '-') === 0) {
$tmpSubType = substr($v, 1);
$pubSubTypExclude[] = self::getType('publications', $tmpSubType, $pubTyp[0]);
} else {
$pubSubTyp[] = self::getType('publications', $v, $pubTyp[0]);
}
}
if (empty($pubSubTyp)) {
if (empty($pubSubTyp) && empty($pubSubTypExclude)) {
$output = '<p>' . __('Falscher Parameter für Publikationssubtyp', 'fau-cris') . '</p>';
return $output;
}
$filter['subtype__eq'] = $pubSubTyp;
if (!empty($pubSubTyp)) {
$filter['subtype__eq'] = $pubSubTyp;
} elseif (!empty($pubSubTypExclude)) {
$filter['subtype__not'] = $pubSubTypExclude;
}
}
if ($fau !== '') {
if ($fau == 1) {
Expand Down

0 comments on commit 1a11bae

Please sign in to comment.