moved check for valid url-params to Util (will be reused in spells, ect)

This commit is contained in:
Sarjuuk
2013-04-20 15:48:35 +02:00
parent b6c0fa1b89
commit f8b8ee218c
2 changed files with 21 additions and 16 deletions

View File

@@ -1497,6 +1497,26 @@ class Util
return $return;
}
public static function isValidPage($struct, $keys)
{
switch (count($keys))
{
case 0:
return true;
case 1:
return !$keys[0] || isset($struct[$keys[0]]);
case 2:
if (!isset($struct[$keys[0]]))
return false;
return in_array($keys[1], $struct[$keys[0]]) || isset($struct[$keys[0]][$keys[1]]);
case 3:
return isset($struct[$keys[0]][$keys[1]]) && in_array($keys[2], $struct[$keys[0]][$keys[1]]);
}
return false;
}
// BaseType::_construct craaap!
// todo: unify names
public static function getNameFieldName($tpl)