本文整理汇总了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;
}
示例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);
}
示例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'];
}
示例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);
}
示例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;
}