當前位置: 首頁>>代碼示例>>PHP>>正文


PHP modMediaSource::getObjectContents方法代碼示例

本文整理匯總了PHP中modMediaSource::getObjectContents方法的典型用法代碼示例。如果您正苦於以下問題:PHP modMediaSource::getObjectContents方法的具體用法?PHP modMediaSource::getObjectContents怎麽用?PHP modMediaSource::getObjectContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在modMediaSource的用法示例。


在下文中一共展示了modMediaSource::getObjectContents方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: download

 public function download()
 {
     $file = $this->getProperty('file');
     $contents = $this->source->getObjectContents($file);
     @session_write_close();
     header("Content-Type: application/force-download");
     header("Content-Disposition: attachment; filename=\"{$contents['basename']}\"");
     echo $contents['content'];
     die;
 }
開發者ID:rosstimson,項目名稱:revolution,代碼行數:10,代碼來源:download.class.php

示例2: process

 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $source = $this->getSource();
     if ($source !== true) {
         return $source;
     }
     $this->source = $this->getProperty('source', 1);
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }
開發者ID:rosstimson,項目名稱:revolution,代碼行數:20,代碼來源:get.class.php

示例3: process

 public function process()
 {
     @session_write_close();
     $src = $this->getProperty('src');
     if (empty($src)) {
         return $this->failure();
     }
     $this->getSource($this->getProperty('source'));
     if (empty($this->source)) {
         $this->failure($this->modx->lexicon('source_err_nf'));
     }
     // Prevent another media sources requests for security reasons
     if ($this->source->getTypeName() != 'WebDAV') {
         $this->failure($this->modx->lexicon('source_err_nfs'));
     }
     $body = $this->source->getObjectContents($src);
     if (empty($body)) {
         $this->failure($this->modx->lexicon('file_err_nf'));
     }
     header('Content-Type: ' . $body['mime']);
     echo $body['content'];
 }
開發者ID:Burick,項目名稱:modx-WebDAV,代碼行數:22,代碼來源:proxy.class.php

示例4: process

 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $loaded = $this->getSource();
     if ($loaded !== true) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('delete')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:22,代碼來源:get.class.php

示例5: _phpThumb

 /**
  * @param array $options
  * @param null $raw
  *
  * @return bool|null
  */
 protected function _phpThumb(array $options = array(), $raw = null)
 {
     if ($this->get('type') != 'image') {
         return false;
     } elseif (!class_exists('modPhpThumb')) {
         /** @noinspection PhpIncludeInspection */
         require MODX_CORE_PATH . 'model/phpthumb/modphpthumb.class.php';
     }
     if (empty($raw)) {
         $prepare = $this->prepareSource();
         if ($prepare !== true) {
             return $prepare;
         }
         $filename = $this->get('path') . $this->get('file');
         $info = $this->mediaSource->getObjectContents($filename);
         if (!is_array($info)) {
             return "Could not retrieve contents of file {$filename} from media source.";
         } elseif (!empty($this->mediaSource->errors['file'])) {
             return "Could not retrieve file {$filename} from media source: " . $this->mediaSource->errors['file'];
         }
         $raw = $info['content'];
     }
     $phpThumb = new modPhpThumb($this->xpdo);
     $phpThumb->initialize();
     $tmp = tempnam(MODX_BASE_PATH, 'uf_');
     file_put_contents($tmp, $raw);
     $phpThumb->setSourceFilename($tmp);
     foreach ($options as $k => $v) {
         $phpThumb->setParameter($k, $v);
     }
     if ($phpThumb->GenerateThumbnail()) {
         ImageInterlace($phpThumb->gdimg_output, true);
         if ($phpThumb->RenderOutput()) {
             @unlink($phpThumb->sourceFilename);
             @unlink($tmp);
             $this->xpdo->log(modX::LOG_LEVEL_INFO, '[Uploadify] phpThumb messages for "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
             return $phpThumb->outputImageData;
         }
     }
     @unlink($phpThumb->sourceFilename);
     @unlink($tmp);
     $this->xpdo->log(modX::LOG_LEVEL_ERROR, '[Uploadify] Could not resize "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
     return false;
 }
開發者ID:bendasvadim,項目名稱:modx-uploadify,代碼行數:50,代碼來源:ufile.class.php


注:本文中的modMediaSource::getObjectContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。