本文整理汇总了PHP中eZMimeType::defaultValue方法的典型用法代码示例。如果您正苦于以下问题:PHP eZMimeType::defaultValue方法的具体用法?PHP eZMimeType::defaultValue怎么用?PHP eZMimeType::defaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZMimeType
的用法示例。
在下文中一共展示了eZMimeType::defaultValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByURL
static function findByURL($url, $returnDefault = true)
{
$instance = eZMimeType::instance();
$file = $url;
$dirPosition = strrpos($url, '/');
if ($dirPosition !== false) {
$file = substr($url, $dirPosition + 1);
}
$suffixPosition = strrpos($file, '.');
$suffix = false;
$prefix = false;
$mimeName = false;
if ($suffixPosition !== false) {
$suffix = strtolower(substr($file, $suffixPosition + 1));
if ($suffix) {
$subURL = substr($file, 0, $suffixPosition);
$suffixList =& $instance->SuffixList;
if (array_key_exists($suffix, $suffixList)) {
$mimeName = $suffixList[$suffix];
}
}
if (!$mimeName) {
$prefixPosition = strpos($file, '.');
if ($prefixPosition !== false) {
$prefix = strtolower(substr($file, 0, $prefixPosition));
}
if ($prefix) {
$subURL = substr($file, $suffixPosition + 1);
$prefixList =& $instance->PrefixList;
if (array_key_exists($prefix, $prefixList)) {
$mimeName = $prefixList[$prefix];
}
}
}
if ($mimeName) {
$mimeList =& $instance->MIMEList;
if (array_key_exists($mimeName, $mimeList)) {
$lastDirPosition = strrpos($url, '/');
$filename = $url;
$dirpath = false;
if ($lastDirPosition !== false) {
$filename = substr($url, $lastDirPosition + 1);
$dirpath = substr($url, 0, $lastDirPosition);
}
$lastDirPosition = strrpos($subURL, '/');
$basename = $subURL;
if ($lastDirPosition !== false) {
$basename = substr($subURL, $lastDirPosition + 1);
}
$mime = $mimeList[$mimeName];
$mime['name'] = $mimeName;
$mime['url'] = $url;
$mime['filename'] = $filename;
$mime['dirpath'] = $dirpath;
$mime['basename'] = $basename;
$mime['suffix'] = $suffix;
$mime['prefix'] = $prefix;
$mime['is_valid'] = true;
return $mime;
}
}
}
return eZMimeType::defaultValue($url, $returnDefault);
}