當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SettingsForm::processPost方法代碼示例

本文整理匯總了PHP中SettingsForm::processPost方法的典型用法代碼示例。如果您正苦於以下問題:PHP SettingsForm::processPost方法的具體用法?PHP SettingsForm::processPost怎麽用?PHP SettingsForm::processPost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SettingsForm的用法示例。


在下文中一共展示了SettingsForm::processPost方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processPost

 /**
  * Handle processing the form when it's posted, such as saving and handling errors.
  */
 protected function processPost()
 {
     // Process data as usual
     parent::processPost();
     // ### Now manipulate the interface
     // Get currently saved account details
     $settings = TidySettings_getSettings($this->settingPrefix);
     // Only do check if we have access ID and secret ID. Code will handle hiding pro features
     // automatically if we can't get the account details.
     $accountDetails = false;
     if (isset($settings['stwwt_access_id']) && isset($settings['stwwt_secret_id'])) {
         $accountDetails = $this->checkAccountType($settings['stwwt_access_id'], $settings['stwwt_secret_id']);
     }
     // Check account level
     $accountLevel = 'invalid';
     if (isset($accountDetails['account_type'])) {
         $accountLevel = $accountDetails['account_type'];
     }
     // Save the account details to the database for use later.
     TidySettings_saveSettings($accountDetails, STWWT_SETTINGS_KEY_ACCOUNT);
     // Set the account level in the interface
     if ($accountLevel == 'invalid') {
         $this->formObj->setElementHTML('stwwt_account_level', sprintf('<span class="stwwt_account_invalid"><span class="stwwt_account_level">Invalid</span> - please provide valid account details.</span>'));
     } else {
         $displayAcctName = ucwords($accountLevel);
         if ('Plus' == $displayAcctName) {
             $displayAcctName = 'PLUS';
         }
         $this->formObj->setElementHTML('stwwt_account_level', sprintf('<span class="stwwt_account_level stwwt_account_%s">%s</span>', $accountLevel, $displayAcctName));
     }
     if (!empty($this->paramList)) {
         // Look for any elements that have an account_level value. If that account level doesn't match the
         // desired account level, then that field doesn't get rendered. For all other fields, assume they
         // have account.
         foreach ($this->paramList as $fieldName => $fieldDetails) {
             // ### Check 1 - Account level required
             if (isset($fieldDetails['account_level']) && $fieldDetails['account_level']) {
                 // Got a list of account levels? Copy them all over
                 if (is_array($fieldDetails['account_level'])) {
                     if (!in_array($accountLevel, $fieldDetails['account_level'])) {
                         $this->removeElementDueToAccountLevel($fieldName, $fieldDetails);
                     }
                 } else {
                     if ($fieldDetails['account_level'] != $accountLevel) {
                         $this->removeElementDueToAccountLevel($fieldName, $fieldDetails);
                     }
                 }
             }
             // end if account level required
             // ### Check 2 - Check for account feature (independent of account level)
             if (isset($fieldDetails['account_feature']) && $fieldDetails['account_feature']) {
                 $featureName = $fieldDetails['account_feature'];
                 if (isset($accountDetails[$featureName]) && $accountDetails[$featureName] != 1 || $accountLevel == 'invalid') {
                     $this->removeElementDueToAccountLevel($fieldName, $fieldDetails);
                 }
             }
         }
         // end foreach
     }
     // end if (!empty($paramList))
 }
開發者ID:nerdhaus,項目名稱:avse,代碼行數:64,代碼來源:stw_settings_class.inc.php


注:本文中的SettingsForm::processPost方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。