当前位置: 首页>>代码示例>>PHP>>正文


PHP modMediaSource::getErrors方法代码示例

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


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

示例1: process

 public function process()
 {
     /* get base paths and sanitize incoming paths */
     $directory = rawurldecode($this->getProperty('directory', ''));
     $directory = ltrim(strip_tags(str_replace(array('../', './'), '', $directory)), '/');
     $name = $this->getProperty('name');
     $name = ltrim(strip_tags(str_replace(array('../', './'), '', $name)), '/');
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('create')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $path = $this->source->createObject($directory, $name, $this->getProperty('content'));
     if (empty($path)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', array('file' => $directory . ltrim($name, '/')));
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:25,代码来源:create.class.php

示例2: process

 public function process()
 {
     if (!$this->getSource()) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $this->source->setRequestProperties($this->getProperties());
     $this->source->initialize();
     if (!$this->source->checkPolicy('create')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $this->ensureSavePathExists($_POST['path']);
     $success = $this->source->uploadObjectsToContainer($_POST['path'], $_FILES);
     /* Check for upload errors
      * Remove 'directory already exists' error
      */
     $errors = array();
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         if (isset($errors['name'])) {
             unset($errors['name']);
         }
     }
     if (count($errors) > 0) {
         foreach ($errors as $k => $msg) {
             $this->modx->error->addField($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
开发者ID:neonoviy,项目名称:CET_AssetsTV,代码行数:31,代码来源:upload.class.php

示例3: process

 /**
  * @return array|string
  */
 public function process()
 {
     if (!($data = $this->handleFile())) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ns'));
     }
     $properties = $this->mediaSource->getProperties();
     $tmp = explode('.', $data['name']);
     $extension = strtolower(end($tmp));
     $image_extensions = $allowed_extensions = array();
     if (!empty($properties['imageExtensions']['value'])) {
         $image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions']['value'])));
     }
     if (!empty($properties['allowedFileTypes']['value'])) {
         $allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes']['value'])));
     }
     if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ext'));
     } else {
         if (in_array($extension, $image_extensions)) {
             $type = 'image';
         } else {
             $type = $extension;
         }
     }
     $hash = sha1($data['stream']);
     if ($this->modx->getCount('msResourceFile', array('resource_id' => $this->resource->id, 'hash' => $hash, 'parent' => 0))) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_exists'));
     }
     $filename = !empty($properties['imageNameType']) && $properties['imageNameType']['value'] == 'friendly' ? $this->resource->cleanAlias($data['name']) : $hash . '.' . $extension;
     $rank = isset($properties['imageUploadDir']) && empty($properties['imageUploadDir']['value']) ? 0 : $this->modx->getCount('msResourceFile', array('parent' => 0, 'resource_id' => $this->resource->id));
     /* @var msResourceFile $product_file */
     $product_file = $this->modx->newObject('msResourceFile', array('resource_id' => $this->resource->id, 'parent' => 0, 'name' => $data['name'], 'file' => $filename, 'path' => $this->resource->id . '/', 'source' => $this->mediaSource->get('id'), 'type' => $type, 'rank' => $rank, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'active' => 1, 'hash' => $hash, 'properties' => $data['properties']));
     $this->mediaSource->createContainer($product_file->path, '/');
     $file = $this->mediaSource->createObject($product_file->get('path'), $product_file->get('file'), $data['stream']);
     if ($file) {
         $url = $this->mediaSource->getObjectUrl($product_file->get('path') . $product_file->get('file'));
         $product_file->set('url', $url);
         $product_file->save();
         if (empty($rank)) {
             $imagesTable = $this->modx->getTableName('msResourceFile');
             $sql = "UPDATE {$imagesTable} SET rank = rank + 1 WHERE resource_id ='" . $this->resource->id . "' AND id !='" . $product_file->get('id') . "'";
             $this->modx->exec($sql);
         }
         $generate = $product_file->generateThumbnails($this->mediaSource);
         if ($generate !== true) {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not generate thumbnails for image with id = ' . $product_file->get('id') . '. ' . $generate);
             return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_thumb'));
         } else {
             return $this->success();
         }
     } else {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_save') . ': ' . print_r($this->mediaSource->getErrors(), 1));
     }
 }
开发者ID:sin4end,项目名称:ms2Gallery,代码行数:57,代码来源:upload.class.php

示例4: handleResponse

 /**
  * Handle the response from the source
  * @param string $response
  * @return array|string
  */
 public function handleResponse($response)
 {
     if (empty($response)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->modx->error->addField($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:17,代码来源:rename.class.php

示例5: process

 public function process()
 {
     if (!$this->getSource()) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $this->source->setRequestProperties($this->getProperties());
     $this->source->initialize();
     $success = $this->source->createContainer($this->getProperty('name'), $this->getProperty('parent'));
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->modx->error->addField($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:18,代码来源:create.class.php

示例6: process

 public function process()
 {
     /* get base paths and sanitize incoming paths */
     $filePath = rawurldecode($this->getProperty('file', ''));
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     $path = $this->source->updateObject($filePath, $this->getProperty('content'));
     if (empty($path)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', array('file' => $path));
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:19,代码来源:update.class.php

示例7: process

 public function process()
 {
     if (!($data = $this->handleFile())) {
         return $this->failure($this->modx->lexicon('ticket_err_file_ns'));
     }
     $properties = $this->mediaSource->getPropertyList();
     $tmp = explode('.', $data['name']);
     $extension = strtolower(end($tmp));
     $image_extensions = $allowed_extensions = array();
     if (!empty($properties['imageExtensions'])) {
         $image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions'])));
     }
     if (!empty($properties['allowedFileTypes'])) {
         $allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes'])));
     }
     if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
         return $this->failure($this->modx->lexicon('ticket_err_file_ext'));
     } elseif (in_array($extension, $image_extensions)) {
         $type = 'image';
     } else {
         $type = $extension;
     }
     $hash = sha1($data['stream']);
     $path = '0/';
     $filename = !empty($properties['imageNameType']) && $properties['imageNameType'] == 'friendly' ? $this->ticket->cleanAlias($data['name']) : $hash . '.' . $extension;
     if (strpos($filename, '.' . $extension) === false) {
         $filename .= '.' . $extension;
     }
     // Check for existing file
     $where = $this->modx->newQuery($this->classKey, array('class' => $this->class));
     if (!empty($this->ticket->id)) {
         $where->andCondition(array('parent:IN' => array(0, $this->ticket->id)));
     } else {
         $where->andCondition(array('parent' => 0));
     }
     $where->andCondition(array('file' => $filename, 'OR:hash:=' => $hash), null, 1);
     if ($this->modx->getCount($this->classKey, $where)) {
         return $this->failure($this->modx->lexicon('ticket_err_file_exists', array('file' => $data['name'])));
     }
     /* @var TicketFile $ticket_file */
     $ticket_file = $this->modx->newObject('TicketFile', array('parent' => 0, 'name' => $data['name'], 'file' => $filename, 'path' => $path, 'source' => $this->mediaSource->id, 'type' => $type, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'deleted' => 0, 'hash' => $hash, 'size' => $data['size'], 'class' => $this->class, 'properties' => $data['properties']));
     $this->mediaSource->createContainer($ticket_file->path, '/');
     unset($this->mediaSource->errors['file']);
     $file = $this->mediaSource->createObject($ticket_file->get('path'), $ticket_file->get('file'), $data['stream']);
     if ($file) {
         $url = $this->mediaSource->getObjectUrl($ticket_file->get('path') . $ticket_file->get('file'));
         $ticket_file->set('url', $url);
         $ticket_file->save();
         $ticket_file->generateThumbnail($this->mediaSource);
         return $this->success('', $ticket_file->toArray());
     } else {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[Tickets] Could not save file: ' . print_r($this->mediaSource->getErrors(), 1));
         return $this->failure($this->modx->lexicon('ticket_err_file_save'));
     }
 }
开发者ID:soulcreate,项目名称:Tickets,代码行数:55,代码来源:upload.class.php

示例8: 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

示例9: process

 public function process()
 {
     $file = $this->getProperty('file');
     if (empty($file)) {
         return $this->modx->error->failure($this->modx->lexicon('file_err_ns'));
     }
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('remove')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $success = $this->source->removeObject($file);
     if (empty($success)) {
         $errors = $this->source->getErrors();
         $msg = implode("\n", $errors);
         return $this->failure($msg);
     }
     return $this->success();
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:21,代码来源:remove.class.php

示例10: process

 public function process()
 {
     $file = $this->getProperty('file');
     if (empty($file)) {
         return $this->modx->error->failure($this->modx->lexicon('file_err_ns'));
     }
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     $success = $this->source->removeObject($file);
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure();
     }
     return $this->success();
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:21,代码来源:remove.class.php

示例11: process

 public function process()
 {
     if (!$this->validate()) {
         return $this->failure();
     }
     $oldFile = $this->getProperty('path');
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     $success = $this->source->renameObject($oldFile, $this->getProperty('name'));
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:21,代码来源:rename.class.php

示例12: 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

示例13: process

 /**
  * @return array|string
  */
 public function process()
 {
     if (!($data = $this->handleFile())) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ns'));
     }
     $properties = $this->mediaSource->getPropertyList();
     $pathinfo = $this->ms2Gallery->pathinfo($data['name']);
     $extension = strtolower($pathinfo['extension']);
     $filename = strtolower($pathinfo['filename']);
     $image_extensions = $allowed_extensions = array();
     if (!empty($properties['imageExtensions'])) {
         $image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions'])));
     }
     if (!empty($properties['allowedFileTypes'])) {
         $allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes'])));
     }
     if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
         return $this->failure($this->modx->lexicon('ms2gallery_err_wrong_ext'));
     } else {
         if (in_array($extension, $image_extensions)) {
             if (empty($data['properties']['height']) || empty($data['properties']['width'])) {
                 return $this->failure($this->modx->lexicon('ms2gallery_err_wrong_image'));
             }
             $type = 'image';
         } else {
             $type = $extension;
         }
     }
     if ($this->modx->getOption('ms2gallery_duplicate_check', null, true, true)) {
         if ($this->modx->getCount('msResourceFile', array('resource_id' => $this->resource->id, 'hash' => $data['hash'], 'parent' => 0))) {
             return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_exists'));
         }
     }
     $filename = !empty($properties['imageNameType']) && $properties['imageNameType'] == 'friendly' ? $this->resource->cleanAlias($filename) : $data['hash'];
     $filename = str_replace(',', '', $filename) . '.' . $extension;
     $tmp_filename = $filename;
     $i = 1;
     while (true) {
         if (!($count = $this->modx->getCount('msResourceFile', array('resource_id' => $this->resource->id, 'file' => $tmp_filename, 'parent' => 0)))) {
             $filename = $tmp_filename;
             break;
         } else {
             $pcre = '#(-' . ($i - 1) . '|)\\.' . $extension . '$#';
             $tmp_filename = preg_replace($pcre, "-{$i}.{$extension}", $tmp_filename);
             $i++;
         }
     }
     $rank = isset($properties['imageUploadDir']) && empty($properties['imageUploadDir']) ? 0 : $this->modx->getCount('msResourceFile', array('parent' => 0, 'resource_id' => $this->resource->id));
     /* @var msResourceFile $uploaded_file */
     $uploaded_file = $this->modx->newObject('msResourceFile', array('resource_id' => $this->resource->id, 'parent' => 0, 'name' => preg_replace('#\\.' . $extension . '$#i', '', $data['name']), 'file' => $filename, 'path' => $this->resource->id . '/', 'source' => $this->mediaSource->get('id'), 'type' => $type, 'rank' => $rank, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'active' => 1, 'hash' => $data['hash'], 'properties' => $data['properties']));
     $this->mediaSource->createContainer($uploaded_file->get('path'), '/');
     $this->mediaSource->errors = array();
     if ($this->mediaSource instanceof modFileMediaSource) {
         $upload = $this->mediaSource->createObject($uploaded_file->get('path'), $uploaded_file->get('file'), '');
         if ($upload) {
             copy($data['tmp_name'], urldecode($upload));
         }
     } else {
         $upload = $this->mediaSource->uploadObjectsToContainer($uploaded_file->get('path'), array($data));
     }
     unlink($data['tmp_name']);
     if ($upload) {
         $url = $this->mediaSource->getObjectUrl($uploaded_file->get('path') . $uploaded_file->get('file'));
         $uploaded_file->set('url', $url);
         $uploaded_file->save();
         if (empty($rank)) {
             $imagesTable = $this->modx->getTableName('msResourceFile');
             $sql = "UPDATE {$imagesTable} SET rank = rank + 1 WHERE resource_id ='" . $this->resource->id . "' AND id !='" . $uploaded_file->get('id') . "'";
             $this->modx->exec($sql);
         }
         $generate = $uploaded_file->generateThumbnails($this->mediaSource);
         if ($generate !== true) {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not generate thumbnails for image with id = ' . $uploaded_file->get('id') . '. ' . $generate);
             return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_thumb'));
         } else {
             return $this->success('', $uploaded_file);
         }
     } else {
         return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_save') . ': ' . print_r($this->mediaSource->getErrors(), 1));
     }
 }
开发者ID:Homchenkokostya,项目名称:ms2Gallery,代码行数:84,代码来源:upload.class.php


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