Datatypes\jQueryFileUpload\Editor::load PHP Method

load() public method

Load upload editor
public load ( ) : string
return string
    public function load()
    {
        $parameters = $this->getConfig();
        $options = empty($parameters['options']) ? array() : $parameters['options'];
        $this->initScript();
        $fileList = array();
        $files = unserialize($this->getValue());
        if (!empty($files)) {
            $fileClass = new File();
            $fileClass->load($this->getProperty(), $this->getDatatype()->getDocument());
            foreach ($files as $fileData) {
                $fileObject = array();
                $fileObject['name'] = $fileData['value'];
                $fileObject['filename'] = $fileData['value'];
                $fileObject['thumbnail_url'] = $fileData['value'];
                $router = Registry::get('Application')->getMvcEvent()->getRouter();
                $fileObject['delete_url'] = $router->assemble(array('document_id' => $this->getDatatype()->getDocument()->getId(), 'property_id' => $this->getProperty()->getId(), 'file' => base64_encode($fileData['value'])), array('name' => 'content/media/remove'));
                $fileObject['delete_type'] = 'DELETE';
                $fileList[] = $fileObject;
            }
        }
        return $this->addPath(__DIR__)->render('upload-editor.phtml', array('property' => $this->getProperty(), 'uploadUrl' => $this->getUploadUrl(), 'name' => $this->getName(), 'files' => json_encode($fileList), 'options' => $options));
    }

Usage Example

Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testLoad()
 {
     $this->object->setValue(serialize(array(array('value' => __DIR__ . '/_files/test.jpg'))));
     $this->assertInternalType('string', $this->object->load());
 }