本文整理汇总了PHP中Director::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::redirect方法的具体用法?PHP Director::redirect怎么用?PHP Director::redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
function submit($data, $form)
{
// if rewards added and get it button clicked then validate and save to order object
if (isset($data['action_submit']) && isset($data['Quantity'])) {
Session::clear($this->controller->RewardsSessionKey());
foreach ($data['Quantity'] as $ProductID => $quantity) {
$item = $this->controller->newReward($ProductID, $quantity);
Session::set($this->controller->RewardsSessionKey($ProductID), serialize($item));
}
if ($this->controller->RewardsTotalPoints() > Page_Controller::MemberPointsBalance()) {
$this->sessionMessage('You do not have enough points to purchase these rewards.', 'error');
Director::redirectBack();
return;
}
$new_items = $this->controller->RewardItems();
}
//delete all existing reward items for this order
$order_items = $this->controller->Order()->RewardItems();
foreach ($order_items as $o_item) {
$o_item->delete();
}
// then flush rewards from session
Session::clear($this->controller->RewardsSessionKey());
//then link the reward items to the order
if (isset($new_items)) {
foreach ($new_items as $item) {
$item->write();
}
}
// then redirect to next step
Director::redirect($this->controller->Link() . 'checkoutstep/orderconfirmationandpayment/');
}
示例2: doRegister
function doRegister($data, $form)
{
// Check for existing member emial address
if ($member = DataObject::get_one("Member", "'Email' = '" . Convert::raw2sql($data['Email']) . "'")) {
// Set error message
$form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
// Set form data from submitted values
Session::set("FormInfo.Form_RegistrationForm.data", $data);
// Return back to form
return Director::redirectBack();
}
// Otherwise create new member and log them in
$Member = new Member();
$form->saveInto($Member);
$Member->write();
$Member->login();
// Find or create the 'user' group
if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
$userGroup = new Group();
$userGroup->Code = "users";
$userGroup->Title = "Users";
$userGroup->Write();
$userGroup->Members()->add($Member);
}
// Add member to user group
$userGroup->Members()->add($Member);
// Get Profile page
if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
return Director::redirect($ProfilePage->Link('?success=1'));
}
}
示例3: doEditForm
function doEditForm($data, $form)
{
$member = Member::currentUser();
$form->saveInto($member);
$member->write();
Director::redirect('registration-edit-successful/');
}
示例4: dosave
/**
* Form action handler for ContactInquiryForm.
*
* @param array $data The form request data submitted
* @param Form $form The {@link Form} this was submitted on
*/
function dosave(array $data, Form $form, SS_HTTPRequest $request)
{
$SQLData = Convert::raw2sql($data);
$attrs = $form->getAttributes();
if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
// most probably spam - terminate silently
Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
return;
}
$item = new ContactInquiry();
$form->saveInto($item);
// $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
$item->write();
$mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
$mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
$mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
$email = new Email($mailFrom, $mailTo, $mailSubject);
$email->replyTo($SQLData['Email']);
$email->setTemplate("ContactInquiry");
$email->populateTemplate($SQLData);
$email->send();
// $this->controller->redirectBack();
if ($email->send()) {
$this->controller->redirect($this->controller->Link() . "success");
} else {
$this->controller->redirect($this->controller->Link() . "error");
}
return false;
}
示例5: redirect_to_login_prompt
static function redirect_to_login_prompt($redirect_url)
{
$redirect_url = "http://{$_SERVER['HTTP_HOST']}{$redirect_url}";
$_SESSION['state'] = md5(uniqid(rand(), TRUE));
//CSRF protection
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . FACEBOOK_APP_ID . "&redirect_uri=" . urlencode($redirect_url) . "&state=" . $_SESSION['state'] . "&scope=email";
return Director::redirect($dialog_url);
}
示例6: redirect
function redirect($status = "success", $message = "")
{
if (Director::is_ajax()) {
return $status;
//TODO: allow for custom return types, eg json - similar to ShoppingCart::return_data()
}
Director::redirect(CheckoutPage::find_link());
}
示例7: saveComplexTableField
public function saveComplexTableField($data, $form, $params)
{
$child = new $data['ClassName']();
$child->ParentID = $this->controller->ID;
$child->write();
$link = SecurityToken::inst()->addToUrl(Controller::join_links($this->Link(), 'item', $child->ID, 'edit'));
Session::set('FormInfo.ComplexTableField_Popup_DetailForm.formError', array('message' => _t('MemberProfiles.SECTIONADDED', 'Profile section added, please edit it below.'), 'type' => 'good'));
return Director::redirect($link);
}
示例8: save
/**
* Form handler. Saves all changed fields to the database, and returns back to the
* index action of the given object
*/
function save($params)
{
$record = $this->controller->data();
foreach ($this->fields as $field) {
$fieldName = $field->Name();
if (isset($params[$fieldName])) {
$record->{$fieldName} = $params[$fieldName];
}
}
$record->write();
Director::redirect($this->controller->Link());
}
示例9: activate
function activate($data, $form, $request)
{
//Check if there's a temp member with a Verification Code equal to this
//if there is, register the new member and log him in
//if not, tell him the code is wrong
//Check if this member already exists
$tempMember = TempMember::codeExists($data);
if (!$tempMember) {
$form->sessionMessage(_t("Register.REGISTRATION ERROR", "There's no account waiting for activation with this code.\n\t\t\t\t\t\t\t\t\t If you already have an account log in here <a href=\"my-events/\">here</a>"), 'bad');
Director::redirectBack();
return;
}
// Create a new Member object
$member = new Member();
$member->FirstName = $tempMember->FirstName;
$member->Surname = $tempMember->Surname;
$member->Phone = $tempMember->Phone;
$member->Email = $tempMember->Email;
$member->Password = $tempMember->Password;
$member->ReceiveMail = $tempMember->ReceiveMail;
$member->ReceiveMail = $tempMember->ReceiveMail;
$member->RequestListedAsPresenter = $tempMember->RequestListedAsPresenter;
$member->LocationAddress = $tempMember->LocationAddress;
$member->LocationLatitude = $tempMember->LocationLatitude;
$member->LocationLongitude = $tempMember->LocationLongitude;
$member->Description = $tempMember->Description;
// Write to db.
// This needs to happen before we add it to a group
$member->write();
if ($tempMember->RequestListedAsPresenter) {
$presentorApproval = new PresentorApproval();
$presentorApproval->MemberID = $member->ID;
$presentorApproval->MemberName = $tempMember->FirstName . ' ' . $tempMember->Surname;
$presentorApproval->Message = $tempMember->Description;
$presentorApproval->Email = $tempMember->Email;
$presentorApproval->Confirmation = 'Pending';
$presentorApproval->IsDone = false;
$presentorApproval->write();
}
$tempMember->delete();
$member->logIn();
// Add the member to User Group
// Check if it exists first
if ($group = DataObject::get_one('Group', 'ID = 3')) {
$member->Groups()->add($group);
// Redirect based on URL
// TO EDIT
Director::redirect('SuccessVerification');
} else {
$form->sessionMessage(_t("Register.REGISTRATION ERROR", "Your registration wasn't successful please try again"), 'bad');
Director::redirectBack();
}
}
示例10: proceed
/**
* Save the changes to the form, and redirect to the checkout page
*/
function proceed($data, $form, $request)
{
$member = Member::currentUser();
if (!$member) {
return false;
}
$form->saveInto($member);
$member->write();
$form->sessionMessage(_t("MemberForm.DETAILSSAVED", 'Your details have been saved'), 'good');
Director::redirect(CheckoutPage::find_link());
return true;
}
示例11: init
/**
* Prepare to run a sake more command.
*/
public function init()
{
// Ensure it's being run via the command line.
if (!$this->isCli()) {
// If it's not, redirect to the homepage.
Director::redirect('/');
parent::init();
return;
}
// What're the command and arguments?
if (!array_key_exists('args', $_GET)) {
$cmdargs = array();
} else {
$cmdargs = $_GET['args'];
}
// Validate them.
if (empty($cmdargs)) {
return $this->showError('Expected parameter. Type "sake more help" for a list of commands');
}
// Get all the potential commands.
$allcommands = $this->availableCommands();
// Which command is being called?
$cmd = array_shift($cmdargs);
if (!array_key_exists($cmd, $allcommands)) {
return $this->showError("Unable to find command '{$cmd}'. Run 'sake more help' for list of commands");
}
// Run the given command.
if (count($allcommands[$cmd]) == 2) {
list($class, $function) = $allcommands[$cmd];
$argarray = false;
} else {
list($class, $function, $argarray) = $allcommands[$cmd];
}
// Passing the arguments as one array or individual arguments?
if ($argarray) {
// One single array? Useful for when using unlimited arguments.
$cmdargs = array($cmdargs);
}
$object = null;
if (is_object($class)) {
// Passed an object instead of a static class? Ok.
$object = $class;
$class = get_class($object);
}
$method = new ReflectionMethod($class, $function);
$response = $method->invokeArgs($object, $cmdargs);
// Print the response.
if (!is_null($response)) {
printf("%s\n", $response);
}
// Done.
die;
}
示例12: doProcess
public function doProcess($data, $form, $request)
{
$order = new Order();
$items = $order->Items();
$member = Member::currentUserID() ? Member::currentUser() : new Member();
$paymentClass = isset($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
$payment = class_exists($paymentClass) ? new $paymentClass() : null;
$requirePayment = $order->Subtotal() > 0 ? true : false;
if (!($items && $items->Count() > 0)) {
$form->sessionMessage(_t('OrderForm.NOITEMS', 'Error placing order: You have no items in your cart.'), 'bad');
return Director::redirectBack();
}
if ($requirePayment) {
if (!($payment && $payment instanceof Payment)) {
user_error("OrderForm::doProcess(): '{$paymentClass}' is not a valid payment class!", E_USER_ERROR);
}
}
// Ensure existing members don't get their record hijacked (IMPORTANT!)
if (!$member->checkUniqueFieldValue($data)) {
$uniqueField = Member::get_unique_identifier_field();
$uniqueValue = $data[$uniqueField];
$uniqueError = "Error placing order: The %s \"%d\" is\n\t\t\t\talready taken by another member. If this belongs to you, please\n\t\t\t\tlog in first before placing your order.";
$form->sessionMessage(_t('EcommerceMemberExtension.ALREADYEXISTS', printf($uniqueError, strtolower($uniqueField), $uniqueValue), PR_MEDIUM, 'Let the user know that member already exists (e.g. %s could be "Email", %d could be "joe@somewhere.com)'), 'bad');
return Director::redirectBack();
}
$form->saveInto($member);
if (!$member->Password) {
$member->setField('Password', Member::create_new_password());
}
$member->write();
$form->saveInto($order);
try {
$result = $order->process($member->ID);
} catch (Exception $e) {
$form->sessionMessage(_t('OrderForm.PROCESSERROR', "An error occurred while placing your order: {$e->getMessage()}.<br>\n\t\t\t\t\tPlease contact the website administrator."), 'bad');
// Send an email to site admin with $e->getMessage() error
return Director::redirectBack();
}
if ($requirePayment) {
$form->saveInto($payment);
$payment->write();
$result = $payment->processPayment($data, $form);
if ($result->isSuccess()) {
$order->sendReceipt();
}
// Long payment process. e.g. user goes to external site to pay (PayPal, WorldPay)
if ($result->isProcessing()) {
return $result->getValue();
}
}
Director::redirect($order->Link());
}
示例13: setStepConfig
function setStepConfig()
{
$whichStep = Director::URLParam("ID");
$validSteps = array('twostep', 'threestep');
if (!in_array($whichStep, $validSteps)) {
return false;
}
CMSWorkflowSiteConfigDecorator::set_step_config($whichStep);
echo "<p>CMS Workflow has been set to <strong>{$whichStep}</strong></p>";
// rebuild the database schema
Director::redirect("dev/build?flush=1");
return true;
}
示例14: SubmitFilter
/**
* SubmitFilter Form
*
*/
function SubmitFilter($data, $form, $request)
{
// Get the current timestamp
$iCurrentTimestamp = self::GetCurrentTimeStamp();
/* selected Country */
$oSelectedCountry = $data['Country'];
$sFromDate = isset($data['FromDate']) && !empty($data['FromDate']) ? $data['FromDate'] : date('d/m/Y', $iCurrentTimestamp);
$sToDate = isset($data['ToDate']) && !empty($data['ToDate']) ? $data['ToDate'] : date('d/m/Y', $iCurrentTimestamp);
//set session variables to use on the showevents function
Session::set('FilterCountry', $oSelectedCountry);
Session::set('FilterFromDate', $sFromDate);
Session::set('FilterToDate', $sToDate);
Director::redirect('Events/showevents');
}
示例15: setShippingMethod
function setShippingMethod($data, $form)
{
$cart = $this->owner->Cart();
$option = null;
if (isset($data['ShippingMethodID'])) {
$option = DataObject::get_by_id("ShippingMethod", (int) $data['ShippingMethodID']);
}
//assign option to order / modifier
if ($option) {
$checkout = new Checkout($cart);
$checkout->setShippingMethod($option);
}
Director::redirect($this->NextStepLink('paymentmethod'));
}
开发者ID:tylerkidd,项目名称:silverstripe-shop-shippingframework,代码行数:14,代码来源:CheckoutStep_ShippingMethod.php