function readConstraints() { #define list of allowed generic constraints #Should material be added (if so it's soft)? Left out for now due to municipal concerns $getConstraints = array('id', 'title', 'artist', 'year', 'type', 'address', 'county', 'muni', 'county_name', 'muni_name', 'district', 'bbox', 'BBOX', 'source', 'changed', 'created', 'wiki', 'list', 'commons_cat', 'official_url', 'free', 'owner', 'has_cmt', 'is_inside', 'has_ugc', 'has_image', 'has_coords', 'has_wiki', 'has_list', 'has_same', 'is_removed'); $artistConstraints = array('id', 'wiki', 'first_name', 'last_name', 'name', 'birth_year', 'death_year', 'is_dead', 'lifespan'); $allowed = array_merge($getConstraints, $artistConstraints); $maxValues = 50; try { ApiBase::largeParam(); } catch (Exception $e) { throw $e; } if (empty($_GET)) { return null; } else { try { foreach ($_GET as $key => $value) { if (empty($value)) { continue; } elseif (!in_array($key, $allowed)) { continue; } elseif (substr_count($value, '|') > $maxValues) { throw new ValueLimitException('You can enter a maximum of ' . $maxValues . ' values per parameter (you entered ' . substr_count($value, '|') . ' values for the parameter "' . $key . '").'); continue; } switch ($key) { case 'BBOX': #dynamicKml gives comma separated bbox $value = implode('|', explode(',', $value)); case 'bbox': $params[$key] = self::bboxParam($key, $value); break; case 'lifespan': $params[$key] = self::multiRangedParam('birth_year', 'death_year', $value); break; case 'year': case 'created': case 'changed': case 'birth_year': case 'death_year': $params[$key] = self::rangedParam($key, $value); break; case 'muni_name': case 'county_name': $keyparts = explode('_', $key); $params[$keyparts[0]] = self::namedParam($keyparts[0], $value); break; case 'is_inside': case 'is_removed': case 'has_ugc': case 'has_coords': case 'has_cmt': case 'has_image': case 'has_wiki': case 'has_list': case 'has_same': case 'is_dead': $val = self::boolParam($key, $value); if (!empty($val)) { $keyparts = explode('_', $key); if ($keyparts[1] == 'wiki') { $params['has_wiki'] = $val; # since 'wiki' is already claimed } elseif ($keyparts[1] == 'list') { $params['has_list'] = $val; # since 'list' is already claimed } else { $params[$keyparts[1]] = $val; } } break; case 'artist': case 'title': case 'address': case 'first_name': $params[$key] = self::softParam($key, $value); break; case 'name': $params[$key] = self::softParam(array('first_name', 'last_name'), $value); break; default: $params[$key] = $value; break; } } } catch (Exception $e) { throw $e; } return $params; } }