本文整理匯總了PHP中QApplication::RequestMode方法的典型用法代碼示例。如果您正苦於以下問題:PHP QApplication::RequestMode方法的具體用法?PHP QApplication::RequestMode怎麽用?PHP QApplication::RequestMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類QApplication
的用法示例。
在下文中一共展示了QApplication::RequestMode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Run
public static function Run($strFormId, $strAlternateHtmlFile = null)
{
// Ensure strFormId is a class
$objClass = new $strFormId();
//Set Default CallTypes
$objClass->strCallType = QCallType::None;
QApplication::$RequestMode = QRequestMode::Standard;
$objClass->objConfig = new MJaxTouchConfig();
$objClass->strFormId = $strFormId;
// Ensure strFormId is a subclass of QForm
if (!$objClass instanceof MJaxTouchPage) {
throw new QCallerException('Object is not a subclass of MJaxTouchPage (note, it can NOT be a subclass of QFormBase): ' . $strFormId);
}
//Check to see if the form has posted data
if (key_exists(MJaxTouchScreenPostData::MJaxTouchPage__FormState, $_POST)) {
//Tell the object and the application what the call type is
$strPostDataState = $_POST[MJaxTouchScreenPostData::MJaxTouchPage__FormState];
if ($strPostDataState) {
// We might have a valid form state -- let's see by unserializing this object
$objClass = MJaxTouchPage::Unserialize($strPostDataState);
}
$objClass->ParsePostData();
$objClass->strCallType = QCallType::Ajax;
QApplication::$RequestMode = QRequestMode::Ajax;
}
if (key_exists(MJaxTouchScreenPostData::EVENT, $_POST)) {
self::$strCurrEvent = $_POST[MJaxTouchScreenPostData::EVENT];
switch (self::$strCurrEvent) {
case MJaxTouchPageEvent::LOAD_SCREEN:
$objClass->SetActiveScreen($_POST[MJaxTouchScreenPostData::ACTIVE_SCREEN]);
break;
case MJaxTouchPageEvent::CONTROL_EVENT:
$objClass->TriggerControlEvent($_POST[MJaxTouchScreenPostData::CONTROL_ID], $_POST[MJaxTouchScreenPostData::EVENT_TYPE]);
break;
}
} else {
$objClass->Form_Create();
if (!is_null($objClass->scnLoadScreen)) {
$objClass->AddJSAppCall('SetLoadScreenId', array(sprintf('"%s"', $objClass->scnLoadScreen->ControlId)));
$objClass->AddJSAppCall('SetActiveScreenId', array(sprintf('"%s"', $objClass->scnActiveScreen->ControlId)));
}
}
//Figure out template situation
if (is_null($strAlternateHtmlFile)) {
$objClass->strTemplate = $_SERVER[MLCServer::SCRIPT_FILENAME];
} else {
$objClass->strTemplate = $strAlternateHtmlFile;
}
//Call the appropriate render
if ($objClass->strCallType == QCallType::Ajax) {
$objClass->RenderAjax();
} else {
$objClass->Render();
}
}
示例2: Run
public static function Run($strFormId, $strAlternateHtmlFile = null)
{
// Ensure strFormId is a class
$objClass = new $strFormId();
// Ensure strFormId is a subclass of QForm
if (!$objClass instanceof QForm) {
throw new QCallerException('Object is not a subclass of QForm (note, it can NOT be a subclass of QFormBase): ' . $strFormId);
}
// See if we can get a Form Class out of PostData
$objClass = null;
if (array_key_exists('Qform__FormId', $_POST) && $_POST['Qform__FormId'] == $strFormId && array_key_exists('Qform__FormState', $_POST)) {
$strPostDataState = $_POST['Qform__FormState'];
if ($strPostDataState) {
// We might have a valid form state -- let's see by unserializing this object
$objClass = QForm::Unserialize($strPostDataState);
}
}
if ($objClass) {
global ${$strFormId};
${$strFormId} = $objClass;
$objClass->strCallType = $_POST['Qform__FormCallType'];
$objClass->intFormStatus = QFormBase::FormStatusUnrendered;
if ($objClass->strCallType == QCallType::Ajax) {
QApplication::$RequestMode = QRequestMode::Ajax;
}
// Globalize and Set Variable
global ${$strFormId};
${$strFormId} = $objClass;
// Iterate through all the control modifications
$strModificationArray = explode("\n", trim($_POST['Qform__FormUpdates']));
if ($strModificationArray) {
foreach ($strModificationArray as $strModification) {
$strModification = trim($strModification);
if ($strModification) {
$intPosition = strpos($strModification, ' ');
$strControlId = substr($strModification, 0, $intPosition);
$strModification = substr($strModification, $intPosition + 1);
$intPosition = strpos($strModification, ' ');
if ($intPosition !== false) {
$strProperty = substr($strModification, 0, $intPosition);
$strValue = substr($strModification, $intPosition + 1);
} else {
$strProperty = $strModification;
$strValue = null;
}
switch ($strProperty) {
case 'Parent':
if ($strValue) {
if ($strValue == $objClass->FormId) {
$objClass->objControlArray[$strControlId]->SetParentControl(null);
} else {
$objClass->objControlArray[$strControlId]->SetParentControl($objClass->objControlArray[$strValue]);
}
} else {
// Remove all parents
$objClass->objControlArray[$strControlId]->SetParentControl(null);
$objClass->objControlArray[$strControlId]->SetForm(null);
$objClass->objControlArray[$strControlId] = null;
unset($objClass->objControlArray[$strControlId]);
}
break;
default:
if (array_key_exists($strControlId, $objClass->objControlArray)) {
$objClass->objControlArray[$strControlId]->__set($strProperty, $strValue);
}
break;
}
}
}
}
// Clear the RenderedCheckableControlArray
$objClass->blnRenderedCheckableControlArray = array();
$strCheckableControlList = trim($_POST['Qform__FormCheckableControls']);
$strCheckableControlArray = explode(' ', $strCheckableControlList);
foreach ($strCheckableControlArray as $strCheckableControl) {
$objClass->blnRenderedCheckableControlArray[trim($strCheckableControl)] = true;
}
// Iterate through all the controls
foreach ($objClass->objControlArray as $objControl) {
// If they were rendered last time and are visible (and if ServerAction, enabled), then Parse its post data
if ($objControl->Visible && ($objClass->strCallType == QCallType::Ajax || $objControl->Enabled) && $objControl->RenderMethod) {
// Call each control's ParsePostData()
$objControl->ParsePostData();
}
// Reset the modified/rendered flags and the validation
// in ALL controls
$objControl->ResetFlags();
$objControl->ValidationReset();
}
// Trigger Run Event (if applicable)
$objClass->Form_Run();
// Trigger Load Event (if applicable)
$objClass->Form_Load();
// Trigger a triggered control's Server- or Ajax- action (e.g. PHP method) here (if applicable)
$objClass->TriggerActions();
} else {
// We have no form state -- Create Brand New One
$objClass = new $strFormId();
// Setup HTML Include File Path, based on passed-in strAlternateHtmlFile (if any)
try {
//.........這裏部分代碼省略.........
示例3: Run
/**
* This method initializes the actual layout of the form
* It runs in all cases including initial form (the time when Form_Create is run) as well as on
* trigger actions (QServerAction, QAjaxAction, QServerControlAction and QAjaxControlAction)
*
* It is responsible for implementing the logic and sequence in which page wide checks are done
* such as running Form_Validate and Control validations for every control of the page and their
* child controls. Checking for an existing FormState and loading them before trigerring any action
* is also a responsibility of this method.
* @param string $strFormClass The class of the form to create when creating a new form.
* @param string|null $strAlternateHtmlFile location of the alternate HTML template file.
* @param string|null $strFormId The html id to use for the form. If null, $strFormClass will be used.
*
* @throws QCallerException
* @throws QInvalidFormStateException
* @throws Exception
*/
public static function Run($strFormClass, $strAlternateHtmlFile = null, $strFormId = null)
{
// See if we can get a Form Class out of PostData
$objClass = null;
if ($strFormId === null) {
$strFormId = $strFormClass;
}
if (array_key_exists('Qform__FormId', $_POST) && $_POST['Qform__FormId'] == $strFormId && array_key_exists('Qform__FormState', $_POST)) {
$strPostDataState = $_POST['Qform__FormState'];
if ($strPostDataState) {
// We might have a valid form state -- let's see by unserializing this object
$objClass = QForm::Unserialize($strPostDataState);
}
// If there is no QForm Class, then we have an Invalid Form State
if (!$objClass) {
self::InvalidFormState();
}
}
if ($objClass) {
// Globalize
global $_FORM;
$_FORM = $objClass;
$objClass->strCallType = $_POST['Qform__FormCallType'];
$objClass->intFormStatus = QFormBase::FormStatusUnrendered;
if ($objClass->strCallType == QCallType::Ajax) {
QApplication::$RequestMode = QRequestMode::Ajax;
}
// Cleanup ajax post data if the encoding does not match, since ajax data is always utf-8
if ($objClass->strCallType == QCallType::Ajax && QApplication::$EncodingType != 'UTF-8') {
foreach ($_POST as $key => $val) {
if (substr($key, 0, 6) != 'Qform_') {
$_POST[$key] = iconv('UTF-8', QApplication::$EncodingType, $val);
}
}
}
if (!empty($_POST['Qform__FormParameter'])) {
$_POST['Qform__FormParameter'] = self::UnpackPostVar($_POST['Qform__FormParameter']);
}
// Decode custom post variables from server calls
if (!empty($_POST['Qform__AdditionalPostVars'])) {
$val = self::UnpackPostVar($_POST['Qform__AdditionalPostVars']);
$_POST = array_merge($_POST, $val);
}
// Iterate through all the control modifications
if (!empty($_POST['Qform__FormUpdates'])) {
$controlUpdates = $_POST['Qform__FormUpdates'];
if (is_string($controlUpdates)) {
// Server post is encoded, ajax not encoded
$controlUpdates = self::UnpackPostVar($controlUpdates);
}
if (!empty($controlUpdates)) {
foreach ($controlUpdates as $strControlId => $params) {
foreach ($params as $strProperty => $strValue) {
switch ($strProperty) {
case 'Parent':
if ($strValue) {
if ($strValue == $objClass->FormId) {
$objClass->objControlArray[$strControlId]->SetParentControl(null);
} else {
$objClass->objControlArray[$strControlId]->SetParentControl($objClass->objControlArray[$strValue]);
}
} else {
// Remove all parents
$objClass->objControlArray[$strControlId]->SetParentControl(null);
$objClass->objControlArray[$strControlId]->SetForm(null);
$objClass->objControlArray[$strControlId] = null;
unset($objClass->objControlArray[$strControlId]);
}
break;
default:
if (array_key_exists($strControlId, $objClass->objControlArray)) {
$objClass->objControlArray[$strControlId]->__set($strProperty, $strValue);
}
break;
}
}
}
}
}
// Set the RenderedCheckableControlArray
if (!empty($_POST['Qform__FormCheckableControls'])) {
$vals = $_POST['Qform__FormCheckableControls'];
if (is_string($vals)) {
//.........這裏部分代碼省略.........
示例4: Run
public static function Run($strFormId, $strAlternateHtmlFile = null)
{
// Ensure strFormId is a class
$objClass = new $strFormId();
$objClass->strFormId = $strFormId;
// Ensure strFormId is a subclass of QForm
if (!$objClass instanceof MJaxForm) {
throw new QCallerException('Object is not a subclass of MJaxForm (note, it can NOT be a subclass of QFormBase): ' . $strFormId);
}
//Check to see if the form has posted data
if (key_exists(MJaxFormPostData::MJaxForm__FormState, $_POST)) {
//Tell the object and the application what the call type is
$strPostDataState = $_POST[MJaxFormPostData::MJaxForm__FormState];
if ($strPostDataState) {
// We might have a valid form state -- let's see by unserializing this object
$objClass = MJaxForm::Unserialize($strPostDataState);
}
$objClass->ParsePostData();
$objClass->strCallType = QCallType::Ajax;
QApplication::$RequestMode = QRequestMode::Ajax;
} elseif (key_exists(MJaxFormPostData::ACTION, $_POST) && $_POST[MJaxFormPostData::ACTION] == MJaxFormAction::CHANGE_PAGE) {
$objClass->strCallType = QCallType::Ajax;
QApplication::$RequestMode = QRequestMode::Ajax;
//Create a proxy for the main content panel
$objClass->pxyMainWindow = new MJaxControlProxy($objClass, 'mainWindow_inner');
$objClass->Form_Create();
} else {
$objClass->strCallType = QCallType::None;
QApplication::$RequestMode = QRequestMode::Standard;
//Create a proxy for the main content panel
$objClass->pxyMainWindow = new MJaxControlProxy($objClass, 'mainWindow_inner');
$objClass->Form_Create();
}
if (key_exists(MJaxFormPostData::ACTION, $_POST)) {
self::$strCurrAction = $_POST[MJaxFormPostData::ACTION];
switch (self::$strCurrAction) {
case MJaxFormAction::CONTROL_EVENT:
$objClass->TriggerControlEvent($_POST[MJaxFormPostData::CONTROL_ID], $_POST[MJaxFormPostData::EVENT]);
break;
}
}
if (is_null($strAlternateHtmlFile)) {
$objClass->strTemplate = $_SERVER[MLCServer::SCRIPT_FILENAME];
} else {
$objClass->strTemplate = $strAlternateHtmlFile;
}
$objClass->Form_PreRender();
if ($objClass->strCallType == QCallType::Ajax) {
$objClass->RenderAjax();
} else {
$objClass->Render();
}
$objClass->Form_Exit();
}