Back to PhocaDownloadFile class

Method getMimeType

public static
getMimeType
(mixed $extension, mixed $params)

Method getMimeType - Source code

public static function getMimeType($extension, $params)
{
    $regex_one = '/({\\s*)(.*?)(})/si';
    $regex_all = '/{\\s*.*?}/si';
    $matches = array();
    $count_matches = preg_match_all($regex_all, $params, $matches, PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER);
    $returnMime = '';
    for ($i = 0; $i < $count_matches; $i++) {
        $phocaDownload = $matches[0][$i][0];
        preg_match($regex_one, $phocaDownload, $phocaDownloadParts);
        $values_replace = array("/^'/", "/'\$/", "/^'/", "/'\$/", "/<br \\/>/");
        $values = explode("=", $phocaDownloadParts[2], 2);
        foreach ($values_replace as $key2 => $values2) {
            $values = preg_replace($values2, '', $values);
        }
        // Return mime if extension call it
        if ($extension == $values[0]) {
            $returnMime = $values[1];
        }
    }
    if ($returnMime != '') {
        return $returnMime;
    } else {
        return "PhocaErrorNoMimeFound";
    }
}