Example #1
0
 function __construct($controller, $name, $use_actions = true)
 {
     $fields = new FieldList();
     //main info
     $fields->push(new TextField('title', 'Title'));
     $fields->push(new TextField('url', 'Url'));
     $categoryField = new TextField('event_category', 'Category');
     $categoryField->setAttribute('class', 'event-category-autocomplete text');
     $fields->push($categoryField);
     //location
     $fields->push(new TextField('location', 'Location'));
     //duration
     $fields->push($start_date = new TextField('start_date', 'Start Date'));
     $fields->push($end_date = new TextField('end_date', 'End Date'));
     $start_date->addExtraClass('date');
     $end_date->addExtraClass('date');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveEvent', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'location'), new RequiredFields('start_date', 'end_date')));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 function __construct($controller, $name)
 {
     $fields = new FieldList(new TextField('Email', 'Email'));
     $actions = new FieldList(new FormAction('SendMemberVerificationEmail', 'Send It!'));
     // Create validators
     $validator = new RequiredFields('Email');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Example #3
0
 function loadDataFrom($data, $clearMissingFields = false, $fieldList = null)
 {
     $res = parent::loadDataFrom($data, $clearMissingFields, $fieldList);
     // Check if the honeypot has been filled out
     if (is_array($data) && isset($data[self::FieldName]) && $data[self::FieldName] != '') {
         SS_Log::log(sprintf('honeypot triggered (data: %s)', http_build_query($data)), SS_Log::NOTICE);
         return $this->httpError(403);
     }
     return $res;
 }
 function __construct($controller, $name, $use_actions = true)
 {
     $event_manager = new EventManager($this->repository, new EventRegistrationRequestFactory(), null, new SapphireEventPublishingService(), new EventValidatorFactory(), SapphireTransactionManager::getInstance());
     $fields = new FieldList();
     //point of contact
     $fields->push(new TextField('point_of_contact_name', 'Name'));
     $fields->push(new EmailField('point_of_contact_email', 'Email'));
     //main info
     $fields->push(new TextField('title', 'Title'));
     $fields->push(new TextField('url', 'Url'));
     $types = $event_manager->getAllTypes();
     foreach ($types as $type) {
         $options[$type] = $type;
     }
     $categoryField = new DropdownField('category', 'Category', $options);
     $categoryField->setEmptyString('-- select a category --');
     $fields->push($categoryField);
     //location
     $fields->push(new TextField('city', 'City'));
     $fields->push(new TextField('state', 'State'));
     $countryField = new CountryDropdownField('country', 'Country');
     $countryField->setEmptyString('-- select a country --');
     $fields->push($countryField);
     //duration
     $fields->push($start_date = new TextField('start_date', 'Start Date'));
     $fields->push($end_date = new TextField('end_date', 'End Date'));
     $start_date->addExtraClass('date');
     $end_date->addExtraClass('date');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveEventRegistrationRequest', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'city'), new RequiredFields('point_of_contact_name', 'point_of_contact_email', 'start_date', 'end_date', 'country')));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Example #5
0
 public function loadDataFrom($data, $mergeStrategy = 0, $fieldList = null)
 {
     if (count($_POST) == 0) {
         $Gender = is_array($data) ? @$data['Gender'] : $data->Gender;
         if ($Gender != 'Male' && $Gender != 'Female' && $Gender != 'Prefer not to say') {
             $this->fields->dataFieldByName('GenderSpecify')->setValue($Gender);
             $this->fields->dataFieldByName('GenderSpecify')->removeExtraClass('hide');
         }
     }
     parent::loadDataFrom($data, $mergeStrategy, $fieldList);
 }
 function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "First Name");
     $LastNameField = new TextField('LastName', "Last Name");
     $TitleField = new TextField('Title', "Title");
     $BioField = new TinyMCEEditorField('Bio', "Bio");
     $BioField->addExtraClass('bio');
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country of Residence', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $WillingVideoField = new CheckboxField('WillingToPresentVideo', "Willing to present via video conference.");
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Willing to travel
     $WillingToTravel = new OptionSetField('WillingToTravel', 'I am willing to travel to events:', array(1 => 'Yes', 0 => 'No'));
     // Countries to travel
     $CountriesToTravelField = new MultiDropdownField('CountriesToTravel', 'Countries willing to travel to:', $CountryCodes);
     $CountriesToTravelField->addExtraClass('travel-field');
     // Spoken Languages
     $LanguageField1 = new TextField('Language[1]', '#1');
     $LanguageField2 = new TextField('Language[2]', '#2');
     $LanguageField3 = new TextField('Language[3]', '#3');
     $LanguageField4 = new TextField('Language[4]', '#4');
     $LanguageField5 = new TextField('Language[5]', '#5');
     // Area of Expertise
     $ExpertiseField1 = new TextField('Expertise[1]', '#1');
     $ExpertiseField2 = new TextField('Expertise[2]', '#2');
     $ExpertiseField3 = new TextField('Expertise[3]', '#3');
     $ExpertiseField4 = new TextField('Expertise[4]', '#4');
     $ExpertiseField5 = new TextField('Expertise[5]', '#5');
     // Links To Presentations
     $PresentationLinkField1 = new TextField('PresentationLink[1]', '#1');
     $PresentationTitleField1 = new TextField('PresentationTitle[1]', '');
     $PresentationLinkField2 = new TextField('PresentationLink[2]', '#2');
     $PresentationTitleField2 = new TextField('PresentationTitle[2]', '');
     $PresentationLinkField3 = new TextField('PresentationLink[3]', '#3');
     $PresentationTitleField3 = new TextField('PresentationTitle[3]', '');
     $PresentationLinkField4 = new TextField('PresentationLink[4]', '#4');
     $PresentationTitleField4 = new TextField('PresentationTitle[4]', '');
     $PresentationLinkField5 = new TextField('PresentationLink[5]', '#5');
     $PresentationTitleField5 = new TextField('PresentationTitle[5]', '');
     $NotesField = new TinyMCEEditorField('Notes', "Notes");
     $NotesField->addExtraClass('notes');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $PhotoField->setValue(null, $speaker);
         $OptInField->setValue($speaker->AvailableForBureau);
         $WillingVideoField->setValue($speaker->WillingToPresentVideo);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $WillingToTravel->setValue($speaker->WillingToTravel);
         $NotesField->setValue($speaker->Notes);
         foreach ($speaker->AreasOfExpertise() as $key => $expertise) {
             if ($key > 4) {
                 break;
             }
             ${'ExpertiseField' . ($key + 1)}->setValue($expertise->Expertise);
         }
         foreach ($speaker->Languages() as $key => $language) {
             if ($key > 4) {
                 break;
             }
             ${'LanguageField' . ($key + 1)}->setValue($language->Language);
         }
         $country_array = array();
         foreach ($speaker->TravelPreferences() as $pref_country) {
             $country_array[] = $pref_country->Country;
         }
         $CountriesToTravelField->setValue(implode(',', $country_array));
         foreach ($speaker->OtherPresentationLinks() as $key => $presentation) {
             ${'PresentationLinkField' . ($key + 1)}->setValue($presentation->LinkUrl);
             ${'PresentationTitleField' . ($key + 1)}->setValue($presentation->Title);
         }
     } elseif ($member) {
         $FirstNameField->setValue($member->FirstName);
         $LastNameField->setValue($member->LastName);
         $BioField->setValue($member->Bio);
         $MemberIDField->setValue($member->ID);
         $IRCHandleField->setValue($member->IRCHandle);
         $TwiiterNameField->setValue($member->TwitterName);
     }
     $fields = new FieldList($FirstNameField, $LastNameField, $TitleField, $CountryField, $BioField, $SpeakerIDField, $MemberIDField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, $IRCHandleField, $TwiiterNameField, $PhotoField, $OptInField, $WillingVideoField, $FundedTravelField, $WillingToTravel, $CountriesToTravelField, $LanguageField1, $LanguageField2, $LanguageField3, $LanguageField4, $LanguageField5, $ExpertiseField1, $ExpertiseField2, $ExpertiseField3, $ExpertiseField4, $ExpertiseField5, $PresentationLinkField1, $PresentationTitleField1, $PresentationLinkField2, $PresentationTitleField2, $PresentationLinkField3, $PresentationTitleField3, $PresentationLinkField4, $PresentationTitleField4, $PresentationLinkField5, $PresentationTitleField5, $NotesField);
     $save_action = new FormAction('addAction', 'Save Speaker Details');
     $save_action->addExtraClass('btn btn-primary');
     $actions = new FieldList($save_action);
     $validator = new RequiredFields('FirstName', 'LastName', 'Title');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "Speaker's First Name");
     $LastNameField = new TextField('LastName', "Speaker's Last Name");
     $TitleField = new TextField('Title', "Speaker's Title");
     $BioField = new TextAreaField('Bio', "Speaker's Bio");
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $Divider = new LiteralField('hr', '<hr/>');
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     $ExpertiseField = new TextareaField('Expertise', 'Topics of interest (one per line)');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $OptInField->setValue($speaker->AvailableForBureau);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $ExpertiseField->setValue($speaker->Expertise);
         $PhotoField->setValue(null, $speaker);
     } elseif ($member) {
         $FirstNameField->setValue($member->FirstName);
         $LastNameField->setValue($member->LastName);
         $BioField->setValue($member->Bio);
         $MemberIDField->setValue($member->ID);
         $IRCHandleField->setValue($member->IRCHandle);
         $TwiiterNameField->setValue($member->TwitterName);
     }
     $fields = new FieldList($FirstNameField, $LastNameField, $TitleField, $BioField, $SpeakerIDField, $MemberIDField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, $IRCHandleField, $TwiiterNameField, $PhotoField, $Divider, $OptInField, $FundedTravelField, $CountryField, $ExpertiseField);
     $actions = new FieldList(new FormAction('addAction', 'Save Speaker Details'));
     $validator = new RequiredFields('FirstName', 'LastName', 'Title');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }