当前位置: 首页>>代码示例>>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;未经允许,请勿转载。