diff options
author | Evan Prodromou <evan@status.net> | 2009-12-12 15:00:22 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-12-12 15:00:22 -0500 |
commit | a3660fbea46be4d9408cd0f824166a75b8c865ab (patch) | |
tree | 545c947b5c2d638371cc6d08476a43fa7805ee04 /lib | |
parent | c622d144400026dac65c39303994d11f114c0f5b (diff) | |
parent | b42b2e1d05867b2dd4cdb3e1b7e278c63001d355 (diff) |
Merge branch '0.9.x' into forward
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/action.php b/lib/action.php index 87d8a4399..dac0e2583 100644 --- a/lib/action.php +++ b/lib/action.php @@ -952,6 +952,36 @@ class Action extends HTMLOutputter // lawsuit } /** + * Integer value of an argument + * + * @param string $key query key we're interested in + * @param string $defValue optional default value (default null) + * @param string $maxValue optional max value (default null) + * @param string $minValue optional min value (default null) + * + * @return integer integer value + */ + + function int($key, $defValue=null, $maxValue=null, $minValue=null) + { + $arg = strtolower($this->trimmed($key)); + + if (is_null($arg) || !is_integer($arg)) { + return $defValue; + } + + if (!is_null($maxValue)) { + $arg = min($arg, $maxValue); + } + + if (!is_null($minValue)) { + $arg = max($arg, $minValue); + } + + return $arg; + } + + /** * Server error * * @param string $msg error message to display |