本文整理汇总了PHP中MimeMagic::extensionLoaded方法的典型用法代码示例。如果您正苦于以下问题:PHP MimeMagic::extensionLoaded方法的具体用法?PHP MimeMagic::extensionLoaded怎么用?PHP MimeMagic::extensionLoaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MimeMagic
的用法示例。
在下文中一共展示了MimeMagic::extensionLoaded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfDl
/** Initializes the MimeMagic object. This is called by MimeMagic::singleton().
*
* This constructor parses the mime.types and mime.info files and build internal mappings.
*/
function __construct()
{
/**
* --- load mime.types ---
*/
global $wgMimeTypeFile, $IP, $wgLoadFileinfoExtension;
$types = MM_WELL_KNOWN_MIME_TYPES;
if ($wgMimeTypeFile == 'includes/mime.types') {
$wgMimeTypeFile = "{$IP}/{$wgMimeTypeFile}";
}
if ($wgLoadFileinfoExtension && !self::$extensionLoaded) {
self::$extensionLoaded = true;
wfDl('fileinfo');
}
if ($wgMimeTypeFile) {
if (is_file($wgMimeTypeFile) and is_readable($wgMimeTypeFile)) {
wfDebug(__METHOD__ . ": loading mime types from {$wgMimeTypeFile}\n");
$types .= "\n";
$types .= file_get_contents($wgMimeTypeFile);
} else {
wfDebug(__METHOD__ . ": can't load mime types from {$wgMimeTypeFile}\n");
}
} else {
wfDebug(__METHOD__ . ": no mime types file defined, using build-ins only.\n");
}
$types = str_replace(array("\r\n", "\n\r", "\n\n", "\r\r", "\r"), "\n", $types);
$types = str_replace("\t", " ", $types);
$this->mMimeToExt = array();
$this->mToMime = array();
$lines = explode("\n", $types);
foreach ($lines as $s) {
$s = trim($s);
if (empty($s)) {
continue;
}
if (strpos($s, '#') === 0) {
continue;
}
$s = strtolower($s);
$i = strpos($s, ' ');
if ($i === false) {
continue;
}
$mime = substr($s, 0, $i);
$ext = trim(substr($s, $i + 1));
if (empty($ext)) {
continue;
}
if (!empty($this->mMimeToExt[$mime])) {
$this->mMimeToExt[$mime] .= ' ' . $ext;
} else {
$this->mMimeToExt[$mime] = $ext;
}
$extensions = explode(' ', $ext);
foreach ($extensions as $e) {
$e = trim($e);
if (empty($e)) {
continue;
}
if (!empty($this->mExtToMime[$e])) {
$this->mExtToMime[$e] .= ' ' . $mime;
} else {
$this->mExtToMime[$e] = $mime;
}
}
}
/**
* --- load mime.info ---
*/
global $wgMimeInfoFile;
if ($wgMimeInfoFile == 'includes/mime.info') {
$wgMimeInfoFile = "{$IP}/{$wgMimeInfoFile}";
}
$info = MM_WELL_KNOWN_MIME_INFO;
if ($wgMimeInfoFile) {
if (is_file($wgMimeInfoFile) and is_readable($wgMimeInfoFile)) {
wfDebug(__METHOD__ . ": loading mime info from {$wgMimeInfoFile}\n");
$info .= "\n";
$info .= file_get_contents($wgMimeInfoFile);
} else {
wfDebug(__METHOD__ . ": can't load mime info from {$wgMimeInfoFile}\n");
}
} else {
wfDebug(__METHOD__ . ": no mime info file defined, using build-ins only.\n");
}
$info = str_replace(array("\r\n", "\n\r", "\n\n", "\r\r", "\r"), "\n", $info);
$info = str_replace("\t", " ", $info);
$this->mMimeTypeAliases = array();
$this->mMediaTypes = array();
$lines = explode("\n", $info);
foreach ($lines as $s) {
$s = trim($s);
if (empty($s)) {
continue;
}
if (strpos($s, '#') === 0) {
//.........这里部分代码省略.........