function JobRegistrationRequestForm() { $data = Session::get("FormInfo.Form_JobRegistrationRequestForm.data"); $form = new JobRegistrationRequestForm($this, 'JobRegistrationRequestForm'); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
function JobForm() { $data = Session::get("FormInfo.Form_JobForm.data"); Requirements::css('jobs/css/job.registration.form.css'); Requirements::javascript("jobs/js/job.registration.form.js"); $form = new JobForm($this, 'JobForm'); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
public function EventForm() { $this->commonScripts(); Requirements::css('events/css/event.registration.form.css'); Requirements::javascript("events/js/event.registration.form.js"); $data = Session::get("FormInfo.Form_EventForm.data"); $form = new EventForm($this->owner, 'EventForm', false); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
public function NewsRequestForm() { $this->commonScripts(); Requirements::css('news/code/ui/frontend/css/news.form.css'); Requirements::javascript("news/code/ui/frontend/js/news.form.js"); $data = Session::get("FormInfo.Form_NewsRequestForm.data"); $article = null; $is_news_manager = Member::currentUser() && Member::currentUser()->isNewsManager(); if (isset($this->requestParams['articleID']) && $is_news_manager) { $article_id = $this->requestParams['articleID']; $article = $this->news_repository->getNewsByID($article_id); } $form = new NewsRequestForm($this, 'NewsRequestForm', $article, $is_news_manager, false); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
public function MarketPlaceReviewForm() { Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"); Requirements::javascript(Director::protocol() . "ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"); Requirements::combine_files('marketplace_review_form.js', array("themes/openstack/javascript/jquery.validate.custom.methods.js", "marketplace/code/ui/frontend/js/star-rating.min.js", "marketplace/code/ui/frontend/js/marketplace.review.js")); $css_files = array("marketplace/code/ui/frontend/css/star-rating.min.css", "marketplace/code/ui/frontend/css/marketplace-review.css"); foreach ($css_files as $css_file) { Requirements::css($css_file); } $form = new MarketPlaceReviewForm($this, 'MarketPlaceReviewForm'); $data = Session::get("FormInfo.Form_MarketPlaceReviewForm.data"); $review = $this->review_repository->getReview($this->company_service_ID, Member::CurrentUserID()); if (is_array($data)) { //get data from cache $form->loadDataFrom($data); } elseif ($review) { // get submitted review $form->loadDataFrom($review); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
/** * Disable the AJAX commenting and update the form * with the {@link SpamProtectorField} which is enabled */ function alterCommentForm(&$form) { SpamProtectorManager::update_form($form, null, array('Name' => 'author_name', 'CommenterURL' => 'author_url', 'Comment' => 'post_body', 'Email' => 'author_email')); }
/** * @uses MemberProfilePage_Controller::getProfileFields * @return Form */ public function RegisterForm() { $form = new Form($this, 'RegisterForm', $this->getProfileFields('Registration'), new FieldList(new FormAction('register', _t('MemberProfiles.REGISTER', 'Register'))), new MemberProfileValidator($this->Fields())); if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } $this->extend('updateRegisterForm', $form); return $form; }
function Form() { if (isset($_REQUEST["BackURL"])) { Session::set('BackURL', $_REQUEST["BackURL"]); } $member = Member::currentUser(); $fields = new FieldList(); $passwordField = null; if ($member) { $name = $member->getName(); //if($member && $member->Password != '') {$passwordField->setCanBeEmpty(true);} $action = new FormAction("submit", "Update your details"); $action->addExtraClass("updateButton"); $actions = new FieldList($action); } else { $passwordField = new ConfirmedPasswordField("Password", "Password"); $action = new FormAction("submit", "Register"); $action->addExtraClass("registerButton"); $actions = new FieldList($action); $member = new Member(); } $memberFormFields = $member->getMemberFormFields(); if ($memberFormFields) { if (is_array(self::$fields_to_remove) && count(self::$fields_to_remove)) { foreach (self::$fields_to_remove as $fieldName) { $memberFormFields->removeByName($fieldName); } } $fields->merge($memberFormFields); } if ($passwordField) { $fields->push($passwordField); } foreach (self::$required_fields as $fieldName) { $fields->fieldByName($fieldName)->addExtraClass("RequiredField"); } $requiredFields = new RequiredFields(self::$required_fields); $form = new Form($this, "Form", $fields, $actions, $requiredFields); // Load any data avaliable into the form. if ($member) { $member->Password = null; $form->loadDataFrom($member); } $data = Session::get("FormInfo.Form_Form.data"); if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } if (!isset($_REQUEST["Password"])) { $form->fields()->fieldByName("Password")->SetValue(""); } return $form; }
/** * Factory method for the registration form * * @return Form Returns the registration form */ function RegistrationForm() { $data = Session::get("FormInfo.Form_RegistrationForm.data"); $use_openid = $this->getForumHolder()->OpenIDAvailable() == true && (isset($data['IdentityURL']) && !empty($data['IdentityURL'])) || isset($_POST['IdentityURL']) && !empty($_POST['IdentityURL']); $fields = singleton('Member')->getForumFields($use_openid, true); // If a BackURL is provided, make it hidden so the post-registration // can direct to it. if (isset($_REQUEST['BackURL'])) { $fields->push(new HiddenField('BackURL', 'BackURL', $_REQUEST['BackURL'])); } $validator = singleton('Member')->getForumValidator(!$use_openid); $form = new Form($this, 'RegistrationForm', $fields, new FieldSet(new FormAction("doregister", _t('ForumMemberProfile.REGISTER', 'Register'))), $validator); // 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". if (ForumHolder::$use_honeypot_on_register) { $form->Fields()->push(new LiteralField('HoneyPot', '<div style="position: absolute; left: -9999px;">' . '<label for="RegistrationForm_username">' . _t('ForumMemberProfile.LeaveBlank', 'Don\'t enter anything here') . '</label>' . '<input type="text" name="username" id="RegistrationForm_username" value="" />' . '</div>')); } $member = new Member(); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager') && ForumHolder::$use_spamprotection_on_register) { SpamProtectorManager::update_form($form); } return $form; }
function PostCommentForm() { $fields = new FieldSet(new HiddenField("ParentID", "ParentID", $this->page->ID)); $member = Member::currentUser(); if ((self::$comments_require_login || self::$comments_require_permission) && $member && $member->FirstName) { // note this was a ReadonlyField - which displayed the name in a span as well as the hidden field but // it was not saving correctly. Have changed it to a hidden field. It passes the data correctly but I // believe the id of the form field is wrong. $fields->push(new ReadonlyField("NameView", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName())); $fields->push(new HiddenField("Name", "", $member->getName())); } else { $fields->push(new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name'))); } // optional commenter URL $fields->push(new TextField("CommenterURL", _t('PageCommentInterface.COMMENTERURL', "Your website URL"))); if (MathSpamProtection::isEnabled()) { $fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion()))); } $fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments"))); $form = new PageCommentInterface_Form($this, "PostCommentForm", $fields, new FieldSet(new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post')))); // Set it so the user gets redirected back down to the form upon form fail $form->setRedirectToFormOnValidationError(true); // Optional Spam Protection. if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form, null, array('Name', 'CommenterURL', 'Comment')); self::set_use_ajax_commenting(false); } // Shall We use AJAX? if (self::$use_ajax_commenting) { Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js'); Requirements::javascript(THIRDPARTY_DIR . '/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js'); Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js'); } // Load the data from Session $form->loadDataFrom(array("Name" => Cookie::get("PageCommentInterface_Name"), "Comment" => Cookie::get("PageCommentInterface_Comment"), "CommenterURL" => Cookie::get("PageCommentInterface_CommenterURL"))); return $form; }
function PostCommentForm() { if (!$this->page->ProvideComments) { return false; } $fields = new FieldSet(new HiddenField("ParentID", "ParentID", $this->page->ID)); $member = Member::currentUser(); if ((self::$comments_require_login || self::$comments_require_permission) && $member && $member->FirstName) { // note this was a ReadonlyField - which displayed the name in a span as well as the hidden field but // it was not saving correctly. Have changed it to a hidden field. It passes the data correctly but I // believe the id of the form field is wrong. $fields->push(new ReadonlyField("NameView", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName())); $fields->push(new HiddenField("Name", "", $member->getName())); } else { $fields->push(new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name'))); } // optional commenter URL $fields->push(new TextField("CommenterURL", _t('PageCommentInterface.COMMENTERURL', "Your website URL"))); if (MathSpamProtection::isEnabled()) { $fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion()))); } $fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments"))); $form = new PageCommentInterface_Form($this, "PostCommentForm", $fields, new FieldSet(new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post'))), new RequiredFields('Name', 'Comment')); // Set it so the user gets redirected back down to the form upon form fail $form->setRedirectToFormOnValidationError(true); // Optional Spam Protection. if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form, null, array('Name' => 'author_name', 'CommenterURL' => 'author_url', 'Comment' => 'post_body')); self::set_use_ajax_commenting(false); } // Add note about moderated comments if (PageComment::moderationEnabled()) { $fields->push(new LiteralField('ModerationNote', sprintf('<p class="moderationMessage"><small>%s</small></p>', _t('PageCommentInterface.ModerationEnabledNote', 'Note: Comments are moderated and won\'t show until they are approved')))); } // Shall We use AJAX? if (self::$use_ajax_commenting) { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js'); Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js'); Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js'); } $this->extend('updatePageCommentForm', $form); // Load the users data from a cookie $cookie = Cookie::get('PageCommentInterface_Data'); if ($cookie) { $visibleFields = array(); foreach ($fields as $field) { if (!$field instanceof HiddenField) { $visibleFields[] = $field->Name(); } } $form->loadDataFrom(Convert::json2array($cookie), false, $visibleFields); } return $form; }
function JobForm() { $this->commonScripts(); Requirements::javascript(Director::protocol() . "maps.googleapis.com/maps/api/js?sensor=false"); Requirements::javascript("marketplace/code/ui/admin/js/geocoding.jquery.js"); Requirements::css('jobs/css/job.registration.form.css'); Requirements::javascript("jobs/js/job.registration.form.js"); $data = Session::get("FormInfo.Form_JobForm.data"); $form = new JobForm($this->owner, 'JobForm', false); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager')) { SpamProtectorManager::update_form($form); } return $form; }
/** * Factory method for the registration form * * @return Form Returns the registration form */ function RegistrationForm() { $data = Session::get("FormInfo.Form_RegistrationForm.data"); $use_openid = $this->getForumHolder()->OpenIDAvailable() == true && (isset($data['IdentityURL']) && !empty($data['IdentityURL'])) || isset($_POST['IdentityURL']) && !empty($_POST['IdentityURL']); $fields = singleton('Member')->getForumFields($use_openid, true); // If a BackURL is provided, make it hidden so the post-registration // can direct to it. if (isset($_REQUEST['BackURL'])) { $fields->push(new HiddenField('BackURL', 'BackURL', $_REQUEST['BackURL'])); } $validator = singleton('Member')->getForumValidator(!$use_openid); $form = new Form($this, 'RegistrationForm', $fields, new FieldSet(new FormAction("doregister", _t('ForumMemberProfile.REGISTER', 'Register'))), $validator); $member = new Member(); // we should also load the data stored in the session. if failed if (is_array($data)) { $form->loadDataFrom($data); } // Optional spam protection if (class_exists('SpamProtectorManager') && ForumHolder::$use_spamprotection_on_register) { SpamProtectorManager::update_form($form); } return $form; }