function __construct($controller, $name, $company) { // Define fields ////////////////////////////////////// if ($company->canEditProfile()) { $fields = new FieldList(new TextField('Name', 'Company Name'), new TextField('URL', 'Company Web Address (URL)'), new LiteralField('Break', '<p></p>'), new LiteralField('Break', '<hr/>'), $big_logo = new FileAttachmentField('BigLogo', 'Large Company Logo'), $small_logo = new FileAttachmentField('Logo', 'Small Company Logo'), new LiteralField('Break', '<p></p>'), new LiteralField('Break', '<hr/>'), new TextField('Industry', 'Industry (less than 4 Words)'), $desc = new HtmlEditorField('Description', 'Company Description'), new LiteralField('Break', '<p></p>'), $contrib = new HtmlEditorField('Contributions', 'How you are contributing to OpenStack (less than 150 words)'), new LiteralField('Break', '<p></p>'), $products = new HtmlEditorField('Products', 'Products/Services Related to OpenStack (less than 100 words)'), new LiteralField('Break', '<p></p>'), new LiteralField('Break', '<p></p>'), new ColorField("Color", "Company Color"), new LiteralField('Break', '<p></p>'), new LiteralField('Break', '<hr/>'), new TextField('ContactEmail', 'Best Contact email address (optional)'), new LiteralField('Break', '<p>This email address will be displayed on your profile and may be different than your own address.')); $desc->addExtraClass("company-description"); $contrib->addExtraClass("company-contributions"); $products->addExtraClass("company-products"); $big_logo_validator = new Upload_Image_Validator(); $big_logo_validator->setAllowedExtensions(array('jpg', 'png', 'jpeg')); $big_logo_validator->setAllowedMaxImageWidth(500); $big_logo->setAcceptedFiles(array('jpg', 'png', 'jpeg')); $big_logo->setView('grid'); $big_logo->setFolderName('companies/main_logo'); $big_logo->setValidator($big_logo_validator); $small_logo_validator = new Upload_Image_Validator(); $small_logo_validator->setAllowedExtensions(array('jpg', 'png', 'jpeg')); $small_logo_validator->setAllowedMaxImageWidth(200); $small_logo->setAcceptedFiles(array('jpg', 'png', 'jpeg')); $small_logo->setView('grid'); $small_logo->setFolderName('companies/main_logo'); $small_logo->setValidator($small_logo_validator); } else { if ($company->canEditLogo()) { $fields = new FieldList(new ReadonlyField('Name', 'Company Name'), new ReadonlyField('URL', 'Company Web Address (URL)'), new LiteralField('Break', '<p></p>'), new LiteralField('Break', '<hr/>'), new CustomUploadField('BigLogo', 'Large Company Logo'), new CustomUploadField('Logo', 'Small Company Logo')); } } $actionButton = new FormAction('save', 'Save Changes'); //$actionButton->addExtraClass('btn green-btn'); $actions = new FieldList($actionButton); parent::__construct($controller, $name, $fields, $actions); }
public function getFormField() { $field = FileAttachmentField::create($this->Name, $this->Title); // $field = FileField::create($this->Name, $this->Title); if ($this->getSetting('Folder')) { $folder = Folder::get()->byId($this->getSetting('Folder')); if ($folder) { $field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename)); } } if ($this->getSetting('Obfuscate')) { $folder = rtrim($field->getFolderName(), '/'); $folder .= '/' . md5(time() + mt_rand()); $field->setFolderName($folder); } if ($this->getSetting('MultipleUploads')) { $field->setMultiple(true); } if ($this->Required) { // Required validation can conflict so add the Required validation messages // as input attributes $errorMessage = $this->getErrorMessage()->HTML(); $field->setAttribute('data-rule-required', 'true'); $field->setAttribute('data-msg-required', $errorMessage); } return $field; }
function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Sort"); $fields->removeByName("PageID"); $image = FileAttachmentField::create('Image', 'Slide image')->setThumbnailHeight(200)->setThumbnailWidth(200)->setAutoProcessQueue(true)->setMaxFilesize(10)->imagesOnly(); $fields->addFieldToTab("Root.Main", $image); return $fields; }
public function updateCMSFields(FieldList $fields) { $fields->removeByName('Access'); // if(!Permission::check("ADMIN")) { // $fields->removeByName('Them e'); // } $fields->addFieldToTab("Root.Main", $resume = FileAttachmentField::create('Resume', 'Upload resume')->setAcceptedFiles(array('.pdf'))->setThumbnailHeight(200)->setThumbnailWidth(200)->setAutoProcessQueue(true)->setMaxFilesize(10)); $fields->tab('Main')->text("Unions")->text("ImdbURL")->text("ActorsAccessURL")->tab('Social')->text("FacebookURL")->text("TwitterURL")->text("InstagramURL")->text("PinterestURL")->text("VimeoURL")->text("SoundCloudURL")->text("YouTubeURL", "Enter the full URL of your YouTube channel")->tab('Contact')->text("Phone")->email("Email")->textarea("Address"); }
/** * PresentationMediaUploadForm constructor. * @param Controller $controller * @param string $name * @param SummitEvent $presentation */ public function __construct($controller, $name, SummitEvent $presentation) { $this->presentation = $presentation; $fields = FieldList::create(FileAttachmentField::create('Slide', 'File')->setFolderName('/presentation-media/')->setPermissions(['upload' => true, 'detach' => false, 'delete' => false])); $actions = FieldList::create(FormAction::create('doUpload', 'Upload File')); $validator = RequiredFields::create(['Slide']); parent::__construct($controller, $name, $fields, $actions, $validator); $material = $presentation->MaterialType('PresentationSlide'); if ($material) { $this->loadDataFrom($material); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("BTSImages"); $gallery = FileAttachmentField::create('Images', 'Upload images')->setThumbnailHeight(200)->setThumbnailWidth(200)->setAutoProcessQueue(true)->setMaxFilesize(10)->imagesOnly(); $bts = FileAttachmentField::create('BTSImages', 'Upload BTS images')->setThumbnailHeight(200)->setThumbnailWidth(200)->setAutoProcessQueue(true)->setMaxFilesize(10)->imagesOnly(); $conf = GridFieldConfig_RelationEditor::create(10); $conf->addComponent(new GridFieldSortableRows('Sort')); $fields->addFieldToTab('Root.Clips', new GridField('Clips', 'Clips', $this->Clips(), $conf)); $fields->addFieldToTab('Root.Images', $gallery); $fields->addFieldToTab('Root.BTS', $bts); return $fields; }
public function onBeforeRender(FileAttachmentField $field) { if ($field->getSetting('sortable') && $this->owner->isCMS()) { $field->setSetting('sortable-action', $field->Link('sort')); $field->setSetting('sort-column', $this->getSortableColumn()); $field->addExtraClass('is-sortable'); Requirements::javascript(DROPZONE_SORTABLE_DIR . '/javascript/dropzone-sortable.js'); Requirements::css(DROPZONE_SORTABLE_DIR . '/css/dropzone-sortable.css'); } }
/** * Sets the value of the form field based on data from the request. Automatically * adds the "ID" to the field name. Assumes a $has_one relation to the file. * * @param string The value to set * @param array The array of form data */ public function setValue($value = null, $data = null) { if (!is_numeric($value)) { if ($id = Controller::curr()->getRequest()->requestVar($this->Name() . "ID")) { $value = $id; } elseif (!$value && $data && $data instanceof DataObject && $data->hasMethod($this->name)) { $funcName = $this->name; if ($obj = $data->{$funcName}()) { if ($obj instanceof Image) { $value = $obj->ID; } } } } parent::setValue($value, $data); }
public function getCMSFields() { $fields = parent::getCMSFields(); $image = FileAttachmentField::create('Image', 'Featured image')->setThumbnailHeight(200)->setThumbnailWidth(200)->setAutoProcessQueue(true)->setMaxFilesize(10)->imagesOnly(); $gallery = FileAttachmentField::create('Images', 'Upload images')->setThumbnailHeight(200)->setThumbnailWidth(200)->setAutoProcessQueue(true)->setMaxFilesize(10)->setView('grid')->imagesOnly(); // ->setPermissions(array( // 'delete' => false, // 'detach' => function () { // return Member::currentUser() && Member::currentUser()->inGroup('editors'); // } // ) $conf = GridFieldConfig_RelationEditor::create(10); $conf->addComponent(new GridFieldSortableRows('Sort')); $fields->addFieldToTab('Root.Slider', new GridField('Slider', 'Slider', $this->Slider(), $conf)); $fields->addFieldToTab("Root.Images", $image); $fields->addFieldToTab("Root.Images", $gallery); return $fields; }
/** * Creates a JSON string of all the variables that can be set in the Config * * @return string */ public function JSONConfig() { $r = $this->request; // Remove null values and normalise leading dot $allExts = $r->getVar('allowedExtensions') ? explode(',', $r->getVar('allowedExtensions')) : File::config()->allowed_extensions; $exts = array_map(function ($item) { return $item[0] == '.' ? $item : '.' . $item; }, array_filter($allExts, 'strlen')); $types = explode(',', $r->getVar('allowedTypes')); return Convert::array2json(array('baseRoute' => Controller::join_links(Director::baseURL(), $this->Link()), 'maxFilesize' => FileAttachmentField::get_filesize_from_ini(), 'allowedExtensions' => implode(',', $exts), 'thumbnailsDir' => DROPZONE_DIR . '/images/file-icons', 'langNewFolder' => _t('AssetAdmin.NEWFOLDER', 'NewFolder'), 'iconSize' => self::ICON_SIZE, 'thumbnailWidth' => self::IMAGE_WIDTH, 'thumbnailHeight' => self::IMAGE_HEIGHT, 'defaultSort' => $this->config()->default_sort, 'defaultView' => $this->config()->default_view, 'maxCacheSize' => $this->config()->max_cache_size, 'folderExtension' => self::FOLDER_EXTENSION, 'allowSelection' => (bool) $r->getVar('allowSelection'), 'maxSelection' => (int) $r->getVar('maxSelection'), 'canUpload' => (bool) $r->getVar('canUpload'), 'canDelete' => (bool) $r->getVar('canDelete'), 'canEdit' => (bool) $r->getVar('canEdit'), 'canCreateFolder' => (bool) $r->getVar('canCreateFolder'), 'allowedTypes' => !empty($types) ? $types : null)); }
public function UploadForm() { $member = $this->securityContext->getMember(); if (!$member) { return; } if (!$this->Options()->EnableUploads) { return; } $fields = FieldList::create(); $actions = FieldList::create(); $fields->push($upload = FileAttachmentField::create('Attachment', _t('MicroBlog.FILE_UPLOAD', 'Files'))); $folderName = $member->memberFolder()->Filename . '/' . substr(mt_rand(0, 4242424242) . date(DateTime::ISO8601), 0, 12); if (strpos($folderName, 'assets/') === 0) { $folderName = substr($folderName, 7); } $upload->setFolderName($folderName); // megahack; for some reason the module doesn't bind the dropzone interface unless the backend class is set $upload->setFieldHolderTemplate('MbFileAttachmentField_holder'); $form = new Form($this, 'UploadForm', $fields, $actions); $form->addExtraClass('fileUploadForm'); return $form; }
public function Link($action = null) { if ($this->multiRecordAction) { return $this->form->FormAction() . '/field/' . $this->multiRecordAction . '/' . $action; } return parent::Link($action); }