• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MimeMagic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中MimeMagic的典型用法代码示例。如果您正苦于以下问题:PHP MimeMagic类的具体用法?PHP MimeMagic怎么用?PHP MimeMagic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MimeMagic类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: MimeMagicInit

 /**
  * Hook: MimeMagicInit
  *
  * @param MimeMagic $mimeMagic
  * @param object $addToList Callback function
  * @return bool Always true
  */
 public static function MimeMagicInit($mimeMagic)
 {
     static $extraTypes = 'model/x-pdb	pdb';
     static $extraInfo = 'model/x-pdb	[MODEL]';
     $mimeMagic->addExtraTypes($extraTypes);
     $mimeMagic->addExtraInfo($extraInfo);
     return true;
 }
开发者ID:neuroinformatics,项目名称:mediawiki-extensions-PDBHandler,代码行数:15,代码来源:PDBHandlerHooks.php


示例2: execute

 /**
  * This is called upon loading the special page. It should write output to the page with $wgOut.
  * 
  * @param string $par The portion of the URI after Special:StaticDocServer/
  */
 public function execute($par)
 {
     #TODO: switch to $this->getOuput() and $this->getRequest() when we upgrade MW
     global $wgOut, $wgRequest;
     $wgOut->disable();
     $found = FALSE;
     list($productName, $versionName, $path) = explode('/', $par, 3);
     if (substr($par, -1, 1) == '/') {
         $par .= 'index.html';
     }
     // Validate parameters are set
     if (isset($productName) && isset($versionName) && PonyDocsProduct::GetProductByShortName($productName) && PonyDocsProductVersion::GetVersionByName($productName, $versionName)) {
         $filename = PONYDOCS_STATIC_DIR . "/{$par}";
         if (file_exists($filename)) {
             $found = TRUE;
         }
     }
     if (!$found) {
         $wgRequest->response()->header("HTTP/1.1 404 Not Found");
         echo "<html>\n";
         echo "<head><title>Not Found</title></head>\n";
         echo "<body>\n";
         echo "<h1>Bad Request</h1>\n";
         echo "<div>The documentation you have requested does not exist.</div>\n";
         echo "</body>\n";
         echo "</html>\n";
     } else {
         $mimeMagic = MimeMagic::singleton();
         $pathParts = pathinfo($filename);
         /* get mime-type for a specific file */
         header('Content-type: ' . $mimeMagic->guessTypesForExtension($pathParts['extension']));
         readfile($filename);
     }
 }
开发者ID:Velody,项目名称:ponydocs,代码行数:39,代码来源:SpecialStaticDocServer.php


示例3: showFile

 function showFile()
 {
     $i = strpos($this->mBasePath, '/');
     $i = $i === false ? 0 : $i + 1;
     $filename = substr($this->mBasePath, $i);
     $i = strpos($filename, '.');
     if ($i !== false) {
         $ext = substr($filename, $i + 1);
         $mime = MimeMagic::singleton();
         $ctype = $mime->guessTypesForExtension($ext);
     } else {
         $ctype = 'application/octet-stream';
     }
     $contents = $this->svn->getFile($this->mBasePath, $this->mRev == 'HEAD' ? null : $this->mRev);
     if ($this->mAction == 'raw' || $this->mAction == 'download') {
         global $wgOut;
         $wgOut->disable();
         if ($this->mAction == 'raw') {
             header('Content-Type: ' . $ctype);
         } else {
             header('Content-Type: application/octet-stream');
         }
         header('Content-Length: ' . strlen($contents));
         print $contents;
         return;
     }
     if (substr($ctype, 0, 5) == 'text/') {
         return Xml::element('pre', array('style' => 'overflow: auto;'), $contents);
     } else {
         return wfMsgHTML('codebrowse-binary-file');
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:CodeBrowseItemView.php


示例4: getMimeType

 function getMimeType()
 {
     if (!isset($this->mime)) {
         $magic = MimeMagic::singleton();
         $this->mime = $magic->guessMimeType($this->path);
     }
     return $this->mime;
 }
开发者ID:rocLv,项目名称:conference,代码行数:8,代码来源:UnregisteredLocalFile.php


示例5: dataFile

 /**
  * Utility function: Get a new file object for a file on disk but not actually in db.
  *
  * File must be in the path returned by getFilePath()
  * @param string $name File name
  * @param string $type MIME type [optional]
  * @return UnregisteredLocalFile
  */
 protected function dataFile($name, $type = null)
 {
     if (!$type) {
         // Autodetect by file extension for the lazy.
         $magic = MimeMagic::singleton();
         $parts = explode($name, '.');
         $type = $magic->guessTypesForExtension($parts[count($parts) - 1]);
     }
     return new UnregisteredLocalFile(false, $this->repo, "mwstore://localtesting/data/{$name}", $type);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:18,代码来源:MediaWikiMediaTestCase.php


示例6: _displayFile

 private function _displayFile()
 {
     $registry = Zend_Registry::getInstance();
     // Print the contents of the file
     $file = $registry->configuration->testcase->dir . '/' . $this->getRequest()->getParam(2);
     if ($stream = fopen($file, 'r')) {
         // Disable layout
         $layout = Zend_Layout::getMvcInstance();
         $layout->disableLayout();
         /// @todo: output headers and file information
         $mm = new MimeMagic();
         /// @todo: fix in mimemagic instead
         header('Content-type: ' . $mm->get(realpath($file)));
         echo stream_get_contents($stream);
         fclose($stream);
     } else {
         throw new Exception("Attempted to view a non-existing file \"{$file}\".");
     }
 }
开发者ID:RobertGresdal,项目名称:widget-testcase-framework,代码行数:19,代码来源:ViewController.php


示例7: testFormat

 function testFormat()
 {
     $this->assertNull(MimeMagic::format(true));
     $this->assertNull(MimeMagic::format(5));
     /* Currently arrays aren't validated */
     // $this->assertNull(MimeMagic::format(array('foo' => 'bar')));
     $this->assertNull(MimeMagic::format('does-not-exist.db'));
     $file = $this->TestData->getFile('text-html.snippet.html');
     $this->assertNull(MimeMagic::format($file));
     $file = $this->TestData->getFile('magic.apache.snippet.db');
     $this->assertEqual(MimeMagic::format($file), 'Apache Module mod_mime_magic');
     $file = $this->TestData->getFile('magic.freedesktop.snippet.db');
     $this->assertEqual(MimeMagic::format($file), 'Freedesktop Shared MIME-info Database');
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:14,代码来源:mime_magic.test.php


示例8: wfGetType

/** */
function wfGetType($filename, $safe = true)
{
    global $wgTrivialMimeDetection;
    $ext = strrchr($filename, '.');
    $ext = $ext === false ? '' : strtolower(substr($ext, 1));
    # trivial detection by file extension,
    # used for thumbnails (thumb.php)
    if ($wgTrivialMimeDetection) {
        switch ($ext) {
            case 'gif':
                return 'image/gif';
            case 'png':
                return 'image/png';
            case 'jpg':
                return 'image/jpeg';
            case 'jpeg':
                return 'image/jpeg';
        }
        return 'unknown/unknown';
    }
    $magic = MimeMagic::singleton();
    // Use the extension only, rather than magic numbers, to avoid opening
    // up vulnerabilities due to uploads of files with allowed extensions
    // but disallowed types.
    $type = $magic->guessTypesForExtension($ext);
    /**
     * Double-check some security settings that were done on upload but might 
     * have changed since.
     */
    if ($safe) {
        global $wgFileBlacklist, $wgCheckFileExtensions, $wgStrictFileExtensions, $wgFileExtensions, $wgVerifyMimeType, $wgMimeTypeBlacklist, $wgRequest;
        $form = new UploadForm($wgRequest);
        list($partName, $extList) = $form->splitExtensions($filename);
        if ($form->checkFileExtensionList($extList, $wgFileBlacklist)) {
            return 'unknown/unknown';
        }
        if ($wgCheckFileExtensions && $wgStrictFileExtensions && !$form->checkFileExtensionList($extList, $wgFileExtensions)) {
            return 'unknown/unknown';
        }
        if ($wgVerifyMimeType && in_array(strtolower($type), $wgMimeTypeBlacklist)) {
            return 'unknown/unknown';
        }
    }
    return $type;
}
开发者ID:ruizrube,项目名称:spdef,代码行数:46,代码来源:StreamFile.php


示例9: setType

	function setType( $image ) {
		$this->mimetype = $image->getMimeType();
		$this->mediatype = $image->getMediaType();

		#FIXME: ugly hack! do this on upload!
		if ( $this->mimetype == 'unknown/unknown' ) {
			$mime = MimeMagic::singleton();
			$ext = preg_replace('!^.*\.([^.]+)$!', '\1', $image->getName());
			$this->mimetype = $mime->guessTypesForExtension($ext);
			$this->mediatype = $mime->getMediaType(null, $this->mimetype);
		}

		if ( preg_match('!/(x-)?ogg$!', $this->mimetype) ) {

			if ( $this->mediatype == MEDIATYPE_AUDIO ) $this->mimetype = 'audio/ogg';
			elseif ( $this->mediatype == MEDIATYPE_VIDEO ) $this->mimetype = 'video/ogg';
			else $this->mimetype = 'application/ogg';
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:PlayerClass.php


示例10: wfGetType

/** */
function wfGetType($filename)
{
    global $wgTrivialMimeDetection;
    # trivial detection by file extension,
    # used for thumbnails (thumb.php)
    if ($wgTrivialMimeDetection) {
        $ext = strtolower(strrchr($filename, '.'));
        switch ($ext) {
            case '.gif':
                return 'image/gif';
            case '.png':
                return 'image/png';
            case '.jpg':
                return 'image/jpeg';
            case '.jpeg':
                return 'image/jpeg';
        }
        return 'unknown/unknown';
    } else {
        $magic =& MimeMagic::singleton();
        return $magic->guessMimeType($filename);
        //full fancy mime detection
    }
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:25,代码来源:StreamFile.php


示例11: MimeMagic

 /**
  * Get an instance of this class
  * @return MimeMagic
  */
 public static function &singleton()
 {
     if (!isset(self::$instance)) {
         self::$instance = new MimeMagic();
     }
     return self::$instance;
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:11,代码来源:MimeMagic.php


示例12: getMediaType

 function getMediaType()
 {
     $magic = MimeMagic::singleton();
     return $magic->getMediaType(null, $this->getMimeType());
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:5,代码来源:ForeignAPIFile.php


示例13: getPropsFromPath

 /**
  * Get an associative array containing information about a file in the local filesystem.
  *
  * @param string $path Absolute local filesystem path
  * @param mixed $ext The file extension, or true to extract it from the filename.
  *                   Set it to false to ignore the extension.
  */
 static function getPropsFromPath($path, $ext = true)
 {
     wfProfileIn(__METHOD__);
     wfDebug(__METHOD__ . ": Getting file info for {$path}\n");
     $info = array('fileExists' => file_exists($path) && !is_dir($path));
     $gis = false;
     if ($info['fileExists']) {
         $magic = MimeMagic::singleton();
         $info['mime'] = $magic->guessMimeType($path, $ext);
         list($info['major_mime'], $info['minor_mime']) = self::splitMime($info['mime']);
         $info['media_type'] = $magic->getMediaType($path, $info['mime']);
         # Get size in bytes
         $info['size'] = filesize($path);
         # Height, width and metadata
         $handler = MediaHandler::getHandler($info['mime']);
         if ($handler) {
             $tempImage = (object) array();
             $info['metadata'] = $handler->getMetadata($tempImage, $path);
             $gis = $handler->getImageSize($tempImage, $path, $info['metadata']);
         } else {
             $gis = false;
             $info['metadata'] = '';
         }
         $info['sha1'] = self::sha1Base36($path);
         wfDebug(__METHOD__ . ": {$path} loaded, {$info['size']} bytes, {$info['mime']}.\n");
     } else {
         $info['mime'] = NULL;
         $info['media_type'] = MEDIATYPE_UNKNOWN;
         $info['metadata'] = '';
         $info['sha1'] = '';
         wfDebug(__METHOD__ . ": {$path} NOT FOUND!\n");
     }
     if ($gis) {
         # NOTE: $gis[2] contains a code for the image type. This is no longer used.
         $info['width'] = $gis[0];
         $info['height'] = $gis[1];
         if (isset($gis['bits'])) {
             $info['bits'] = $gis['bits'];
         } else {
             $info['bits'] = 0;
         }
     } else {
         $info['width'] = 0;
         $info['height'] = 0;
         $info['bits'] = 0;
     }
     wfProfileOut(__METHOD__);
     return $info;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:56,代码来源:File.php


示例14: __read

 /**
  * Will load a file from various sources
  *
  * Supported formats:
  * - Freedesktop Shared MIME-info Database
  * - Apache Module mod_mime_magic
  * - PHP file containing variables formatted like: $data[0] = array(item, item, item, ...)
  *
  * @param mixed $file An absolute path to a magic file in apache, freedesktop
  * 	or a filename (without .php) of a file in the configs/ dir in CakePHP format
  * @return mixed A format string or null if format could not be determined
  * @access private
  * @link http://httpd.apache.org/docs/2.2/en/mod/mod_mime_magic.html
  * @link http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.13.html
  */
 function __read($db)
 {
     $format = MimeMagic::format($db);
     if ($format === 'Array') {
         foreach ($db as $item) {
             $this->register($item);
         }
     } elseif ($format === 'PHP') {
         include $db;
         foreach ($data as $item) {
             $this->register($item);
         }
     } elseif ($format === 'Freedesktop Shared MIME-info Database') {
         $sectionRegex = '^\\[(\\d{1,3}):([-\\w.\\+]+\\/[-\\w.\\+]+)\\]$';
         $itemRegex = '^(\\d*)\\>+(\\d+)=+([^&~\\+]{2})([^&~\\+]+)&?([^~\\+]*)~?(\\d*)\\+?(\\d*).*$';
         $File = new File($db);
         $File->open('rb');
         $File->offset(12);
         while (!feof($File->handle)) {
             $line = '';
             if (!isset($chars)) {
                 $chars = array(0 => $File->read(1), 1 => $File->read(1));
             } else {
                 $chars = array(0 => $chars[1], 1 => null);
             }
             while (!feof($File->handle) && !($chars[0] === "\n" && (ctype_digit($chars[1]) || $chars[1] === '>' || $chars[1] === '['))) {
                 $line .= $chars[0];
                 $chars = array(0 => $chars[1], 1 => $File->read(1));
             }
             if (preg_match('/' . $sectionRegex . '/', $line, $matches)) {
                 $section = array('priority' => $matches[1], 'mime_type' => $matches[2]);
             } elseif (preg_match('/' . $itemRegex . '/', $line, $matches)) {
                 $indent = empty($matches[1]) ? 0 : intval($matches[1]);
                 $wordSize = empty($matches[6]) ? 1 : intval($matches[6]);
                 $item = array('offset' => intval($matches[2]), 'value_length' => current(unpack('n', $matches[3])), 'value' => $this->__formatValue($matches[4], $wordSize), 'mask' => empty($matches[5]) ? null : $this->__formatValue($matches[5], $wordSize), 'range_length' => empty($matches[7]) ? 1 : intval($matches[7]), 'mime_type' => $section['mime_type']);
                 $this->register($item, $indent, $section['priority']);
             }
         }
     } elseif ($format === 'Apache Module mod_mime_magic') {
         $itemRegex = '^(\\>*)(\\d+)\\t+(\\S+)\\t+([\\S^\\040]+)\\t*([-\\w.\\+]+\\/[-\\w.\\+]+)*\\t*(\\S*)$';
         $File = new File($db);
         $File->open('rb');
         while (!feof($File->handle)) {
             $line = trim(fgets($File->handle));
             if (empty($line) || $line[0] === '#') {
                 continue;
             }
             $line = preg_replace('/(?!\\B)\\040+/', "\t", $line);
             if (!preg_match('/' . $itemRegex . '/', $line, $matches)) {
                 continue;
             }
             $item = array('offset' => intval($matches[2]), 'value' => $this->__formatValue($matches[4], $matches[3], true), 'mask' => null, 'range_length' => 0, 'mime_type' => empty($matches[5]) ? null : $matches[5], 'encoding' => empty($matches[6]) ? null : $matches[6]);
             $item['value_length'] = strlen($item['value']);
             $this->register($item, strlen($matches[1]), 80);
         }
     } else {
         trigger_error('MimeGlob::read - Unknown db format', E_USER_WARNING);
     }
 }
开发者ID:razzman,项目名称:media,代码行数:74,代码来源:MimeMagic.php


示例15: getThumbType

 function getThumbType($ext, $mime)
 {
     global $wgDjvuOutputExtension;
     static $mime;
     if (!isset($mime)) {
         $magic = MimeMagic::singleton();
         $mime = $magic->guessTypesForExtension($wgDjvuOutputExtension);
     }
     return array($wgDjvuOutputExtension, $mime);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:10,代码来源:DjVu.php


示例16: verifyExtension

	/**
	 * Checks if the mime type of the uploaded file matches the file extension.
	 *
	 * @param string $mime the mime type of the uploaded file
	 * @param string $extension The filename extension that the file is to be served with
	 * @return bool
	 */
	function verifyExtension( $mime, $extension ) {
		$magic = MimeMagic::singleton();

		if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
			if ( !$magic->isRecognizableExtension( $extension ) ) {
				wfDebug( __METHOD__ . ": passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" );
				return true;
			} else {
				wfDebug( __METHOD__ . ": rejecting file with unknown detected mime type; recognized extension '$extension', so probably invalid file\n" );
				return false;
			}

		$match = $magic->isMatchingExtension( $extension, $mime );

		if ( $match === null ) {
			wfDebug( __METHOD__ . ": no file extension known for mime type $mime, passing file\n" );
			return true;
		} elseif ( $match === true ) {
			wfDebug( __METHOD__ . ": mime type $mime matches extension $extension, passing file\n" );
			# TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it!
			return true;
		} else {
			wfDebug( __METHOD__ . ": mime type $mime mismatches file extension $extension, rejecting file\n" );
			return false;
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:SpecialGiftManagerLogo.php


示例17: file_get_contents

         } else {
             $commentText = file_get_contents($f);
             if (!$commentText) {
                 echo " Failed to load comment file {$f}, using default comment. ";
             }
         }
     }
     if (!$commentText) {
         $commentText = $comment;
     }
 }
 # Import the file
 if (isset($options['dry'])) {
     echo " publishing {$file} by '" . $wgUser->getName() . "', comment '{$commentText}'... ";
 } else {
     $mwProps = new MWFileProps(MimeMagic::singleton());
     $props = $mwProps->getPropsFromPath($file, true);
     $flags = 0;
     $publishOptions = [];
     $handler = MediaHandler::getHandler($props['mime']);
     if ($handler) {
         $publishOptions['headers'] = $handler->getStreamHeaders($props['metadata']);
     } else {
         $publishOptions['headers'] = [];
     }
     $archive = $image->publish($file, $flags, $publishOptions);
     if (!$archive->isGood()) {
         echo "failed. (" . $archive->getWikiText(false, false, 'en') . ")\n";
         $failed++;
         continue;
     }
开发者ID:paladox,项目名称:mediawiki,代码行数:31,代码来源:importImages.php


示例18: getExtensionList

 /**
  * Given a mime type, return a comma separated list of allowed extensions.
  *
  * @param $mime String mime type
  * @return String Comma separated list of allowed extensions (e.g. ".ogg, .oga")
  */
 private function getExtensionList($mime)
 {
     $exts = MimeMagic::singleton()->getExtensionsForType($mime);
     if ($exts === null) {
         return '';
     }
     $extArray = explode(' ', $exts);
     $extArray = array_unique($extArray);
     foreach ($extArray as &$ext) {
         $ext = '.' . $ext;
     }
     return $this->getLanguage()->commaList($extArray);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:19,代码来源:SpecialMediaStatistics.php


示例19: send

 public static function send($headers, $to, $from, $subject, $body, $priority = 0, $attachments = null)
 {
     global $wgEnotifMaxRecips, $wgSMTP;
     wfProfileIn(__METHOD__);
     require_once 'Mail2.php';
     require_once 'Mail2/mime.php';
     $logContext = array_merge($headers, ['issue' => 'SOC-910', 'method' => __METHOD__, 'to' => $to, 'subject' => $subject]);
     WikiaLogger::instance()->info('Queuing email for SendGrid', $logContext);
     wfSuppressWarnings();
     $headers['Subject'] = UserMailer::quotedPrintable($subject);
     // Add a header for the server-name (helps us route where SendGrid will send bounces).
     if (!empty($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
         $headers["X-ServerName"] = $_SERVER['SERVER_NAME'];
     }
     try {
         $mail_object =& Mail2::factory(WikiaSendgridMailer::$factory, $wgSMTP);
     } catch (Exception $e) {
         $logContext['errorMessage'] = $e->getMessage();
         WikiaLogger::instance()->info('Failed to create mail object', $logContext);
         wfDebug("PEAR::Mail factory failed: " . $e->getMessage() . "\n");
         wfRestoreWarnings();
         wfProfileOut(__METHOD__);
         return $e->getMessage();
     }
     $email_body_txt = $email_body_html = "";
     if (is_array($body)) {
         if (isset($body['text'])) {
             $email_body_txt = $body['text'];
         }
         if (isset($body['html'])) {
             $email_body_html = $body['html'];
         }
     } else {
         $email_body_txt = $body;
     }
     $mime = new Mail_mime();
     $mime->setTXTBody($email_body_txt);
     $params = array('head_charset' => 'UTF-8', 'html_charset' => 'UTF-8', 'text_charset' => 'UTF-8', 'text_encoding' => 'quoted-printable', 'html_encoding' => 'quoted-printable');
     # send email with attachements
     if (!empty($attachments)) {
         if (!is_array($attachments)) {
             $attachments = array($attachments);
         }
         foreach ($attachments as $file) {
             if (!is_array($file)) {
                 $magic = MimeMagic::singleton();
                 $mimeType = $magic->guessMimeType($file);
                 $ext_file = end(explode('.', $file));
                 $file = array('file' => $file, 'ext' => $ext_file, 'mime' => $mimeType);
             }
             $filename = $file['file'];
             $ext_filename = $file['ext'];
             if (!file_exists($filename)) {
                 continue;
             }
             $name = $filename;
             #basename( $filename );
             if ($ext_filename) {
                 $name = $filename . "." . $ext_filename;
             }
             $mime->addAttachment($filename, $file['mime'], $name);
         }
     }
     # Old version (1.16 MW with Wikia changes) of sendHTML method
     if ($email_body_html) {
         $mime->setHTMLBody($email_body_html);
         //do not ever try to call these lines in reverse order
     }
     $body = $mime->get($params);
     $headers = $mime->headers($headers);
     wfDebug("Sending mail via WikiaSendgridMailer::send\n");
     $chunks = array_chunk((array) $to, $wgEnotifMaxRecips);
     foreach ($chunks as $chunk) {
         $headers['To'] = $chunk;
         $status = self::sendWithPear($mail_object, $chunk, $headers, $body);
         if (!$status->isOK()) {
             $logContext['errorMessage'] = $status->getMessage();
             WikiaLogger::instance()->info('Failed to create mail object', $logContext);
             wfRestoreWarnings();
             wfProfileOut(__METHOD__);
             return $status->getMessage();
         }
     }
     wfProfileOut(__METHOD__);
     # return false to return Status::newGood() in UserMailer::send method
     return false;
 }
开发者ID:yusufchang,项目名称:app,代码行数:87,代码来源:WikiaMailer.php


示例20: insertJobs

 /**
  * @param $upload UploadBase
  * @param $mime
  * @param $error
  * @return bool
  */
 public static function insertJobs($upload, $mime, &$error)
 {
     global $wgPdfCreateThumbnailsInJobQueue;
     if (!$wgPdfCreateThumbnailsInJobQueue) {
         return true;
     }
     if (!MimeMagic::singleton()->isMatchingExtension('pdf', $mime)) {
         return true;
         // not a PDF, abort
     }
     $title = $upload->getTitle();
     $uploadFile = $upload->getLocalFile();
     if (is_null($uploadFile)) {
         wfDebugLog('thumbnails', '$uploadFile seems to be null, should never happen...');
         return true;
         // should never happen, but it's better to be secure
     }
     $metadata = $uploadFile->getMetadata();
     $unserialized = unserialize($metadata);
     $pages = intval($unserialized['Pages']);
     $jobs = array();
     for ($i = 1; $i <= $pages; $i++) {
         $jobs[] = new CreatePdfThumbnailsJob($title, array('page' => $i, 'jobtype' => self::BIG_THUMB));
         $jobs[] = new CreatePdfThumbnailsJob($title, array('page' => $i, 'jobtype' => self::SMALL_THUMB));
     }
     Job::batchInsert($jobs);
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:34,代码来源:CreatePdfThumbnailsJob.class.php



注:本文中的MimeMagic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Minify类代码示例发布时间:2022-05-23
下一篇:
PHP Migration类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap