protected function _fields($fields, $context)
{
$alias = $context->alias();
$models = $context->models($this);
$list = array();
foreach ($fields as $key => $field) {
if (!is_string($field)) {
if (isset($models[$key])) {
$field = array_fill_keys($field, true);
$list[$key] = isset($list[$key]) ? array_merge($list[$key], $field) : $field;
} else {
$list[0][] = is_array($field) ? reset($field) : $field;
}
continue;
}
if (preg_match('/^([a-z0-9_-]+|\\*)$/i', $field)) {
isset($models[$field]) ? $list[$field]['*'] = true : ($list[$alias][$field] = true);
} elseif (preg_match('/^([a-z0-9_-]+)\\.(.*)$/i', $field, $matches)) {
$list[$matches[1]][$matches[2]] = true;
} else {
$list[0][] = $field;
}
}
return $list;
}