public Value filter_input_array( Env env, int type, @Optional Value definition, @Optional("true") boolean isAddEmpty) { ArrayValue inputArray; switch (type) { case INPUT_POST: inputArray = env.getInputPostArray(); break; case INPUT_GET: inputArray = env.getInputGetArray(); break; case INPUT_COOKIE: inputArray = env.getInputCookieArray(); break; case INPUT_ENV: inputArray = env.getInputEnvArray(); break; default: return env.warning(L.l("filter input type is unknown: {0}", type)); } Filter filter = getFilter(env, definition); ArrayValue array = new ArrayValueImpl(); for (Map.Entry<Value, Value> entry : inputArray.entrySet()) { Value key = entry.getKey(); Value value = entry.getValue(); Value newKey = filter.filter(env, key, definition); Value newValue = filter.filter(env, value, definition); array.put(newKey, newValue); } return array; }
public static Value filter_input( Env env, int type, StringValue name, @Optional Value filterIdV, @Optional Value flagV) { ArrayValue array; switch (type) { case INPUT_POST: array = env.getInputPostArray(); break; case INPUT_GET: array = env.getInputGetArray(); break; case INPUT_COOKIE: array = env.getInputCookieArray(); break; case INPUT_ENV: array = env.getInputEnvArray(); break; default: return env.warning(L.l("filter input type is unknown: {0}", type)); } Filter filter = getFilter(env, filterIdV); Value value = array.get(name); if (value == UnsetValue.UNSET) { int flags = AbstractFilter.getFlags(env, flagV); if ((flags & FILTER_NULL_ON_FAILURE) > 0) { return BooleanValue.FALSE; } else { return NullValue.NULL; } } return filter.filter(env, value, flagV); }