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)); }
/** * @param array $options * @param null $raw * * @return bool|string */ public function Resize(array $options, $raw = null) { if ($this->get('type') != 'image') { return false; } elseif (!($raw = $this->_phpThumb($options, $raw))) { return false; } $filename = $this->get('path') . $this->get('file'); if ($this->prepareSource()) { $this->mediaSource->updateObject($filename, $raw); if (empty($this->mediaSource->errors['file'])) { $this->set('size', strlen($raw)); $this->save(); return $this->mediaSource->getObjectUrl($filename); } else { $this->xpdo->log(modX::LOG_LEVEL_ERROR, "Could not update file {$filename}: " . $this->mediaSource->errors['file']); } } return false; }