summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorDavid Flatz2017-01-25 16:25:40 +0100
committerDavid Flatz2017-01-25 16:26:40 +0100
commit9343a50dad78bc43eef2268623e5daf97cb255fb (patch)
tree16be1807640ac5302a4ddf69b64536f013c43a2d /it.class
parentee8607940a1af96f2366ad4ea75db5b7c2c15c8f (diff)
downloaditools-9343a50dad78bc43eef2268623e5daf97cb255fb.tar.gz
itools-9343a50dad78bc43eef2268623e5daf97cb255fb.tar.bz2
itools-9343a50dad78bc43eef2268623e5daf97cb255fb.zip
revert changes in it::map
This reverts commit ee8607940a1af96f2366ad4ea75db5b7c2c15c8f. This reverts commit f59a46a6dfe0194ba43092304029b2b843ed54bc.
Diffstat (limited to 'it.class')
-rw-r--r--it.class24
1 files changed, 16 insertions, 8 deletions
diff --git a/it.class b/it.class
index 4dfb889..a9b6662 100644
--- a/it.class
+++ b/it.class
@@ -950,22 +950,18 @@ static function date($format = "", $stamp = null)
* Iterate over an array, replacing every element by function value or expression
* @param $code The function or expression to apply. Expression may contain $k for keys and $v for values
* @param $array The array to iterate over
- * @param $p['keys'] Only modify elements with given keys (keys can be array or comma separated)
*/
-static function map($code, $array, $p = null)
+static function map($code, $array)
{
static $cache = array();
- if (is_string($code) && it::match('^[\w:]+$', $code))
- $code .= '($v)';
-
if (!is_callable($func = $code) && !($func = $cache[$code]))
$func = $cache[$code] = create_function('$k,$v', "return $code;");
- foreach ($p['keys'] ? it::filter_keys($array, $p['keys']) : $array as $k => $v)
- $array[$k] = $func($k, $v);
+ foreach ($array as $k => $v)
+ $result[$k] = $func($k, $v);
- return (array)$array;
+ return (array)$result;
}
/**
@@ -1086,4 +1082,16 @@ static function mod($a, $n)
return (($a % $n) + $n) % $n;
}
+/**
+ * Same as php tempnam() but $dir defaults to tmp/ in service home
+ */
+static function tempnam($dir, $prefix)
+{
+ $dir = $dir ?: $GLOBALS['ULTRAHOME'] . "/tmp";
+ if (!is_writable($dir))
+ it::error("tempnam: '$dir' not writable");
+
+ return tempnam($dir, $prefix);
+}
+
}