public function getFormField() { $field = new FileField($this->Name, $this->Title); if ($this->getSetting('Folder')) { $folder = Folder::get()->byId($this->getSetting('Folder')); if ($folder) { $field->setFolderName(preg_replace("/^assets\\//", "", $folder->Filename)); } } return $field; }
function Form() { if ($this->request->requestVar('_REDIRECT_BACK_URL')) { $url = $this->request->requestVar('_REDIRECT_BACK_URL'); } else { if ($this->request->getHeader('Referer')) { $url = $this->request->getHeader('Referer'); } else { $url = Director::baseURL(); } } $folder = Folder::find_or_make("ErrorScreenshots"); $whatDidYouTryDoField = new TextareaField('WhatDidYouTryToDo', 'What did you try to do'); $whatDidYouTryDoField->setRows(3); $whatWentWrongField = new TextareaField('WhatWentWrong', 'What went wrong'); $whatWentWrongField->setRows(3); $screenshotField = new FileField('Screenshot', 'To take a screenshot press the PRT SCR button on your keyboard, then open MS Word or MS Paint and paste the screenshot. Save the file and then attach (upload) the file here.'); $screenshotField->setFolderName($folder->Name); $form = new Form($this, 'Form', new FieldList(new TextField('Name'), new TextField('Email'), new TextField('URL', 'What is the URL of the page the error occured (this is the address shown in the address bar (e.g. http://www.mysite.com/mypage/with/errors/)', $url), $whatDidYouTryDoField, $whatWentWrongField, $screenshotField), new FieldList(new FormAction('senderror', 'Submit Error')), new RequiredFields(array("Email", "Name"))); return $form; }
/** * Get the fields needed by the forum module * * @param bool $showIdentityURL Should a field for an OpenID or an i-name * be shown (always read-only)? * @return FieldList Returns a FieldList containing all needed fields for * the registration of new users */ function getForumFields($showIdentityURL = false, $addmode = false) { $gravatarText = DataObject::get_one("ForumHolder", "\"AllowGravatars\" = 1") ? '<small>' . _t('ForumRole.CANGRAVATAR', 'If you use Gravatars then leave this blank') . '</small>' : ""; //Sets the upload folder to the Configurable one set via the ForumHolder or overridden via Config::inst()->update(). $avatarField = new FileField('Avatar', _t('ForumRole.AVATAR', 'Avatar Image') . ' ' . $gravatarText); $avatarField->setFolderName(Config::inst()->get('ForumHolder', 'avatars_folder')); $avatarField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png')); $personalDetailsFields = new CompositeField(new HeaderField("PersonalDetails", _t('ForumRole.PERSONAL', 'Personal Details')), new LiteralField("Blurb", "<p id=\"helpful\">" . _t('ForumRole.TICK', 'Tick the fields to show in public profile') . "</p>"), new TextField("Nickname", _t('ForumRole.NICKNAME', 'Nickname')), new CheckableOption("FirstNamePublic", new TextField("FirstName", _t('ForumRole.FIRSTNAME', 'First name'))), new CheckableOption("SurnamePublic", new TextField("Surname", _t('ForumRole.SURNAME', 'Surname'))), new CheckableOption("OccupationPublic", new TextField("Occupation", _t('ForumRole.OCCUPATION', 'Occupation')), true), new CheckableOption('CompanyPublic', new TextField('Company', _t('ForumRole.COMPANY', 'Company')), true), new CheckableOption('CityPublic', new TextField('City', _t('ForumRole.CITY', 'City')), true), new CheckableOption("CountryPublic", new ForumCountryDropdownField("Country", _t('ForumRole.COUNTRY', 'Country')), true), new CheckableOption("EmailPublic", new EmailField("Email", _t('ForumRole.EMAIL', 'Email'))), new ConfirmedPasswordField("Password", _t('ForumRole.PASSWORD', 'Password')), $avatarField); // Don't show 'forum rank' at registration if (!$addmode) { $personalDetailsFields->push(new ReadonlyField("ForumRank", _t('ForumRole.RATING', 'User rating'))); } $personalDetailsFields->setID('PersonalDetailsFields'); $fieldset = new FieldList($personalDetailsFields); if ($showIdentityURL) { $fieldset->insertBefore(new ReadonlyField('IdentityURL', _t('ForumRole.OPENIDINAME', 'OpenID/i-name')), 'Password'); $fieldset->insertAfter(new LiteralField('PasswordOptionalMessage', '<p>' . _t('ForumRole.PASSOPTMESSAGE', 'Since you provided an OpenID respectively an i-name the password is optional. If you enter one, you will be able to log in also with your e-mail address.') . '</p>'), 'IdentityURL'); } if ($this->owner->IsSuspended()) { $fieldset->insertAfter(new LiteralField('SuspensionNote', '<p class="message warning suspensionWarning">' . $this->ForumSuspensionMessage() . '</p>'), 'Blurb'); } $this->owner->extend('updateForumFields', $fieldset); return $fieldset; }