Difference between revisions of "VbzCart/v1/class/vcPageContent ckout/DoPage"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
Line 2: Line 2:
 
==Notes==
 
==Notes==
 
'''2019-04-27''' I ''think'' what needs to happen is that things need to happen in the following order:
 
'''2019-04-27''' I ''think'' what needs to happen is that things need to happen in the following order:
* detect submitted page
+
* '''detect submitted page''' - $this->GetPageKey_forData();
* detect requested page - $this->DetectPageRequest();
+
* '''detect requested page''' - $this->DetectPageRequest();
* load all form controls needed for both submitted and requested
+
* '''determine page to show''' - $this->HandlePageRequest();
* receive submitted page
 
* process submitted page
 
* determine page to display
 
 
** calculate if requested page should be displayed
 
** calculate if requested page should be displayed
 +
* '''load all form controls needed''' to receive submitted & show display page
 +
** TO DO: where does this currently happen?
 +
* '''receive submitted page''' - $this->CapturePage($oRes);
 +
* '''process submitted page'''
  
 
To examine -- how do the following functions intersect with the above steps?:
 
To examine -- how do the following functions intersect with the above steps?:
Line 19: Line 20:
 
*** {{l/version/method|vcPageContent_ckout|DetectPageRequest}}()
 
*** {{l/version/method|vcPageContent_ckout|DetectPageRequest}}()
 
*** {{l/version/method|vcPageContent_ckout|HandlePageRequest}}()
 
*** {{l/version/method|vcPageContent_ckout|HandlePageRequest}}()
 +
* Internal states:
 +
** {Set/Get}PageKey_Request() - the page requested by the user
 +
** {Set/Get}PageKey_forShow() - the page to display
 +
** {{l/version/method|vcPageContent_ckout|GetPageKey_forData}}()
 
==Code==
 
==Code==
 
<source lang=php>
 
<source lang=php>

Revision as of 18:32, 28 April 2019

Notes

2019-04-27 I think what needs to happen is that things need to happen in the following order:

  • detect submitted page - $this->GetPageKey_forData();
  • detect requested page - $this->DetectPageRequest();
  • determine page to show - $this->HandlePageRequest();
    • calculate if requested page should be displayed
  • load all form controls needed to receive submitted & show display page
    • TO DO: where does this currently happen?
  • receive submitted page - $this->CapturePage($oRes);
  • process submitted page

To examine -- how do the following functions intersect with the above steps?:

  • $this->CapturePage($oRes);
  • $this->HandlePageRequest();

Calls

Code

    /*----
      PURPOSE: core form processing & page rendering
      ACTIONS:
	* dispatches to ParseInput_Login() & HandleInput_Login() to render/handle login controls
	* logs a Cart event to record which page was displayed
	* sets PageKey_forShow()
	* dispatches to RenderPage() to render the page
      HISTORY:
	2018-07-21
	  * ParseInput_Login() and HandleInput_Login() were defined in files which have now
	    been removed from VbzCart. This *should* now be handled automatically by Ferreteria
	    if the right page component class is used.
	  * Also, PageKey_forShow_default() no longer exists; I'm going to assume
	    that we can just use PageKey_forShow().
      TODO: Consider whether maybe this functionality should be moved into $oContent.
    */
    protected function ProcessPage() {
	$gotPgDest = FALSE;
	$gotPgSrce = FALSE;
	$sKey = fcHTTP::Request()->GetString(KSQ_ARG_PAGE_DEST);
	if (is_null($sKey)) {
	    $this->SetPageKey_forShow(KSQ_PAGE_SHIP);
	} else {
	    $gotPgDest = TRUE;
	    $this->SetPageKey_forShow($sKey);
	}

	// get actual page to display
	$sShow = $this->GetPageKey_forShow();
	
	/*
	$arEv = array(
	  fcrEvent::KF_CODE		=> 'PG-IN',
	  fcrEvent::KF_DESCR_FINISH	=> 'showing page "'.$sShow.'"',
	  fcrEvent::KF_WHERE		=> 'HandleInput()',
	  ); */
	$rcCart = $this->GetCartRecord_ifWriteable();
	if (is_null($rcCart)) {
	    $sMsg = fcApp::Me()->MessagesString();
	    $wpCart = vcGlobals::Me()->GetWebPath_forCartPage();
	    if (is_null($sMsg)) {
		// 2016-04-24 This can happen when browser fingerprint changes.
		//throw new exception('In checkout with no current cart set, but there are no error messages.');
		$sMsg = "You don't seem to have a shopping cart yet, so you can't check out. If you had one before, your IP address or browser version may have changed.";
		fcHTTP::DisplayOnReturn($sMsg);
		fcHTTP::Redirect($wpCart);
	    } else {
		fcHTTP::DisplayOnReturn($sMsg);
		fcHTTP::Redirect($wpCart);
	    }
	}
	//$rcEv = $rcCart->CreateEvent($arEv);
	$rcEv = $rcCart->CreateEvent('PG-IN',"showing page '$sShow'");	// 2018-07-22 can add array (3rd arg) with additional info if needed
	$this->doBackBtn = TRUE;
	$this->doRefrBtn = FALSE;

	// 2019-04-21 Tentatively, this needs to happen here:
	$oRes = $this->GetFormObject()->Receive($_POST);	// returns fcFormResult
	// Problem is that controls have not been added yet. (How is that not happening?)

	$this->CapturePage($oRes);
	$this->DetectPageRequest();
	$this->HandlePageRequest();

	//$this->GetSkinObject()->Content('main',$this->RenderPage());
    }