summaryrefslogtreecommitdiff
path: root/lib/action.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/action.php')
-rw-r--r--lib/action.php30
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