function __construct($form_name, $name, $title = null, $configuration = array()) { parent::__construct($name, $title); if (isset($value)) { $this->value = $value; } SWFUploadConfig::$form_name = $form_name; if (!empty($configuration)) { SWFUploadConfig::Configure($configuration); } $url = SWFUploadConfig::get_var('upload_url'); if (empty($url)) { SWFUploadConfig::set_var('upload_url', Director::absoluteURL(Controller::curr()->Link('handleswfupload'))); } SWFUploadConfig::Bootstrap(); }
public function UploadForm() { // Sync up the DB // singleton('Folder')->syncChildren(); $className = $this->sourceClass(); $childData = new $className(); $validator = $this->getValidatorFor($childData); if ($this->Can('upload')) { SWFUploadConfig::addPostParams(array('dataObjectClassName' => $this->sourceClass(), 'dataObjectFieldName' => $this->dataObjectFieldName, 'fileFieldName' => $this->fileFieldName, 'fileClassName' => $this->fileClassName, 'parentIDName' => $this->getParentIdName($this->getParentClass(), $this->sourceClass()), 'controllerID' => $this->controllerID, 'OverrideUploadFolder' => $this->getUploadFolder(), 'hasDataObject' => $this->hasDataObject ? 1 : 0)); if ($this->allowUploadFolderSelection) { SWFUploadConfig::addDynamicPostParam('UploadFolder', 'FileDataObjectManager_Popup_UploadForm_UploadFolder'); } if ($this->getAllowedFileTypes()) { SWFUploadConfig::addFileTypes($this->getAllowedFileTypes()); } if ($this->enableUploadDebugging) { SWFUploadConfig::set_var('debug', 'true'); } } $fields = $this->Can('upload') ? $this->getUploadFields() : new FieldSet(new HeaderField($title = sprintf(_t('DataObjectManager.ADD', 'Add %s'), $this->PluralTitle()), $headingLevel = 2)); $form = Object::create($this->popupClass, $this, 'UploadForm', $fields, $validator, false, $childData); $action = $this->Can('upload') ? new FieldSet(new FormAction('saveUploadForm', 'Upload')) : new FieldSet(); $form->setActions($action); if ($this->Can('import')) { $header = new HeaderField($title = _t('DataObjectManager.IMPORTFROMFOLDER', 'Import from an existing folder'), $headingLevel = 3); $holder = new LiteralField("holder", "<div class='ajax-loader'></div><div id='import-holder'></div>"); if (!isset($_POST['uploaded_files'])) { return $form->forTemplate() . $header->Field() . $this->ImportDropdown()->Field() . $holder->Field(); } else { return $form; } } return $form; }