当前位置: 首页>>代码示例>>PHP>>正文


PHP CFactory::getInput方法代码示例

本文整理汇总了PHP中CFactory::getInput方法的典型用法代码示例。如果您正苦于以下问题:PHP CFactory::getInput方法的具体用法?PHP CFactory::getInput怎么用?PHP CFactory::getInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFactory的用法示例。


在下文中一共展示了CFactory::getInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _saveProfile

 /**
  * Saves a user's profile
  *
  * @access	private
  * @param	none
  */
 private function _saveProfile()
 {
     $model = $this->getModel('profile');
     $usermodel = $this->getModel('user');
     $document = JFactory::getDocument();
     $my = CFactory::getUser();
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $input = CFactory::getInput();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     $appsLib = CAppPlugins::getInstance();
     $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-profile-edit'));
     if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
         $values = array();
         $profiles = $model->getEditableProfile($my->id, $my->getProfileType());
         foreach ($profiles['fields'] as $group => $fields) {
             foreach ($fields as $data) {
                 $fieldValue = new stdClass();
                 // Get value from posted data and map it to the field.
                 // Here we need to prepend the 'field' before the id because in the form, the 'field' is prepended to the id.
                 // Grab raw, unfiltered data
                 $postData = $input->post->get('field' . $data['id'], '', 'RAW');
                 //
                 // Retrieve the privacy data for this particular field.
                 $fieldValue->access = JRequest::getInt('privacy' . $data['id'], 0, 'POST');
                 $fieldValue->value = CProfileLibrary::formatData($data['type'], $postData);
                 if (get_magic_quotes_gpc()) {
                     $fieldValue->value = stripslashes($fieldValue->value);
                 }
                 $values[$data['id']] = $fieldValue;
                 // @rule: Validate custom profile if necessary
                 if (!CProfileLibrary::validateField($data['id'], $data['type'], $values[$data['id']]->value, $data['required'], $data['visible'])) {
                     // If there are errors on the form, display to the user.
                     // If it is a drop down selection, use a different message
                     $message = '';
                     switch ($data['type']) {
                         case 'select':
                             $message = JText::sprintf('COM_COMMUNITY_FIELD_SELECT_EMPTY', $data['name']);
                             break;
                         case 'url':
                             $message = JText::sprintf('COM_COMMUNITY_FIELD_INVALID_URL', $data['name']);
                             break;
                         default:
                             $data['value'] = $values[$data['id']]->value;
                             $message = CProfileLibrary::getErrorMessage($data);
                     }
                     $mainframe->enqueueMessage(CTemplate::quote($message), 'error');
                     return false;
                 }
             }
         }
         // Rebuild new $values with field code
         $valuesCode = array();
         foreach ($values as $key => $val) {
             $fieldCode = $model->getFieldCode($key);
             if ($fieldCode) {
                 // For backward compatibility, we can't pass in an object. We need it to behave
                 // like 1.8.x where we only pass values.
                 $valuesCode[$fieldCode] = $val->value;
             }
         }
         $saveSuccess = false;
         $appsLib = CAppPlugins::getInstance();
         $appsLib->loadApplications();
         // Trigger before onBeforeUserProfileUpdate
         $args = array();
         $args[] = $my->id;
         $args[] = $valuesCode;
         $result = $appsLib->triggerEvent('onBeforeProfileUpdate', $args);
         $optionList = $model->getAllList();
         foreach ($optionList as $list) {
             // $optionList return all the list, even if the field is disabled
             // So, need to check if we're using it or not first
             if (isset($values[$list['id']]) && is_array($list['options'])) {
                 $option = $values[$list['id']]->value;
                 $option = str_replace('&', '&', $option);
                 if (JString::strlen(JString::trim($option)) != 0 && !in_array($option, $list['options'])) {
                     if (!in_array($option, CProfile::getCountryList())) {
                         $result[] = false;
                     }
                 }
             }
         }
         // make sure none of the $result is false
         if (!$result || !in_array(false, $result)) {
             $saveSuccess = true;
             $model->saveProfile($my->id, $values);
         }
     }
     // Trigger before onAfterUserProfileUpdate
     $args = array();
     $args[] = $my->id;
//.........这里部分代码省略.........
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:101,代码来源:profile.php


注:本文中的CFactory::getInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。