/** * Get the active Source * @return modMediaSource|boolean */ public function getSource() { $this->modx->loadClass('sources.modMediaSource'); $this->source = modMediaSource::getDefaultSource($this->modx, $this->getProperty('source')); if (empty($this->source) || !$this->source->getWorkingContext()) { return false; } return $this->source; }
/** * @return boolean|string */ public function getSource() { /** @var modMediaSource $source */ $this->modx->loadClass('sources.modMediaSource'); $this->source = $this->modx->getObject('modMediaSource', $_POST['sourceID']); if (!$this->source->getWorkingContext()) { return $this->modx->lexicon('permission_denied'); } $this->source->setRequestProperties($this->getProperties()); return $this->source->initialize(); }
/** * @return boolean|string */ public function getSource() { $source = $this->getProperty('source', 1); /** @var modMediaSource $source */ $this->modx->loadClass('sources.modMediaSource'); $this->source = modMediaSource::getDefaultSource($this->modx, $source); if (!$this->source->getWorkingContext()) { return $this->modx->lexicon('permission_denied'); } $this->source->setRequestProperties($this->getProperties()); return $this->source->initialize(); }
/** * Test getBases with a provided file and default settings */ public function testGetBasesWithProvidedFile() { $this->source->initialize(); $bases = $this->source->getBases('assets/images/logo.png'); $this->assertEquals('', $bases['path'], 'Index "path" does not match expected.'); $this->assertEquals(true, $bases['pathIsRelative'], 'Index "pathIsRelative" does not match expected.'); $this->assertEquals(MODX_BASE_PATH, $bases['pathAbsolute'], 'Index "pathAbsolute" does not match expected.'); $this->assertEquals(MODX_BASE_PATH . 'assets/images/logo.png', $bases['pathAbsoluteWithPath'], 'Index "pathAbsoluteFull" does not match expected.'); $this->assertEquals('assets/images/logo.png', $bases['pathRelative'], 'Index "pathRelative" does not match expected.'); $this->assertEquals('', $bases['url'], 'Index "url" does not match expected.'); $this->assertEquals(true, $bases['urlIsRelative'], 'Index "urlIsRelative" does not match expected.'); $this->assertEquals('/', $bases['urlAbsolute'], 'Index "urlAbsolute" does not match expected.'); $this->assertEquals('/assets/images/logo.png', $bases['urlAbsoluteWithPath'], 'Index "urlAbsoluteWithPath" does not match expected.'); $this->assertEquals('assets/images/logo.png', $bases['urlRelative'], 'Index "urlRelative" does not match expected.'); }
/** * Get the source to load the paths from * * @param int $sourceId * @return modMediaSource|modFileMediaSource */ public function getSource($sourceId) { /** @var modMediaSource|modFileMediaSource $source */ $this->modx->loadClass('sources.modMediaSource'); $this->source = modMediaSource::getDefaultSource($this->modx, $sourceId, false); if (empty($this->source)) { return false; } if (!$this->source->getWorkingContext()) { return false; } $this->source->setRequestProperties($this->getProperties()); $this->source->initialize(); return $this->source; }
/** * Get the active Source * @return modMediaSource|boolean */ public function getSource() { $this->modx->loadClass('sources.modMediaSource'); $this->source = $this->modx->getObject('modMediaSource', $_POST['sourceID']); if (empty($this->source) || !$this->source->getWorkingContext()) { return false; } return $this->source; }
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); }