public static function insertTagToSrc($data)
{
$return = '';
$paths = preg_split('/((src|href)="([^"]*)\\{\\{file::([^"\\}]+)\\}\\}")/i', $data, -1, PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0, $c = count($paths); $i < $c; $i = $i + 5) {
$return .= $paths[$i];
if (!isset($paths[$i + 1])) {
continue;
}
$file = \FilesModel::findByUuid($paths[$i + 4]);
if ($file !== null) {
$return .= $paths[$i + 2] . '="' . $paths[$i + 3] . $file->path . '"';
} else {
$return .= $paths[$i + 2] . '="' . $paths[$i + 3] . $paths[$i + 4] . '"';
}
}
return $return;
}