summaryrefslogtreecommitdiff
path: root/lib/action.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-15 16:24:52 -0500
committerEvan Prodromou <evan@status.net>2009-12-15 16:24:52 -0500
commit2a1468ec8b2918553b490ddaef6bdede3e2d5b1b (patch)
treec94a68a1239a5a3c35d5564323967fcd4ff14523 /lib/action.php
parente9b733e7f036bc03353ae6dd7b096ea179698a4d (diff)
parentf3d27cc3ae92e2b7412dd998d7de7a2b58dc8e6a (diff)
Merge branch '0.9.x' into testing
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