private static function extract($from, $on) { $out = array(); is_file($from) or $from = \Tailor\Helpers::resolve($from, $on); if (!is_file($from)) { throw new \Exception("The file '{$from}' does not exists"); } $ext = static::extension($on); $dir = \Tailor\Config::get($on); $url = \Tailor\Config::get(str_replace('_dir', '_url', $on)); // TODO: accept other formats? if (preg_match_all('/\\s+\\*=\\s+(\\w+)\\s+(\\S+)/m', read($from), $match)) { foreach ($match[1] as $i => $key) { $tmp = path($dir, $match[2][$i]); $old = \Tailor\Helpers::findfile("{$tmp}*", 0); if (is_dir($old)) { \IO\Dir::open($old, function ($file) use(&$out, $key) { $out[$key][] = $file; }); } else { if (!is_file($old)) { $old = "{$url}/{$match[2][$i]}"; substr($old, -strlen($ext)) != $ext && ($old .= ".{$ext}"); } $out[$key][] = $old; } } } return $out; }