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


PHP ImportMap::save方法代碼示例

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


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

示例1: saveMappingFile

 protected function saveMappingFile()
 {
     global $current_user;
     $firstrow = unserialize(base64_decode($_REQUEST['firstrow']));
     $mappingValsArr = $this->importColumns;
     $mapping_file = new ImportMap();
     if (isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on') {
         $header_to_field = array();
         foreach ($this->importColumns as $pos => $field_name) {
             if (isset($firstrow[$pos]) && isset($field_name)) {
                 $header_to_field[$firstrow[$pos]] = $field_name;
             }
         }
         $mappingValsArr = $header_to_field;
     }
     //get array of values to save for duplicate and locale settings
     $advMapping = $this->retrieveAdvancedMapping();
     //merge with mappingVals array
     if (!empty($advMapping) && is_array($advMapping)) {
         $mappingValsArr = $advMapping + $mappingValsArr;
     }
     //set mapping
     $mapping_file->setMapping($mappingValsArr);
     // save default fields
     $defaultValues = array();
     for ($i = 0; $i < $_REQUEST['columncount']; $i++) {
         if (isset($this->importColumns[$i]) && !empty($_REQUEST[$this->importColumns[$i]])) {
             $field = $this->importColumns[$i];
             $fieldDef = $this->bean->getFieldDefinition($field);
             if (!empty($fieldDef['custom_type']) && $fieldDef['custom_type'] == 'teamset') {
                 require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
                 $sugar_field = new SugarFieldTeamset('Teamset');
                 $teams = $sugar_field->getTeamsFromRequest($field);
                 if (isset($_REQUEST['primary_team_name_collection'])) {
                     $primary_index = $_REQUEST['primary_team_name_collection'];
                 }
                 //If primary_index was selected, ensure that the first Array entry is the primary team
                 if (isset($primary_index)) {
                     $count = 0;
                     $new_teams = array();
                     foreach ($teams as $id => $name) {
                         if ($primary_index == $count++) {
                             $new_teams[$id] = $name;
                             unset($teams[$id]);
                             break;
                         }
                     }
                     foreach ($teams as $id => $name) {
                         $new_teams[$id] = $name;
                     }
                     $teams = $new_teams;
                 }
                 //if
                 $json = getJSONobj();
                 $defaultValues[$field] = $json->encode($teams);
             } else {
                 $defaultValues[$field] = $_REQUEST[$this->importColumns[$i]];
             }
         }
     }
     $mapping_file->setDefaultValues($defaultValues);
     $result = $mapping_file->save($current_user->id, $_REQUEST['save_map_as'], $_REQUEST['import_module'], $_REQUEST['source'], isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on', $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
 }
開發者ID:delkyd,項目名稱:sugarcrm_dev,代碼行數:63,代碼來源:Importer.php

示例2: display

 /** 
  * @see SugarView::display()
  */
 public function display()
 {
     global $sugar_config;
     // Increase the max_execution_time since this step can take awhile
     ini_set("max_execution_time", max($sugar_config['import_max_execution_time'], 3600));
     // stop the tracker
     TrackerManager::getInstance()->pause();
     // use our own error handler
     set_error_handler('handleImportErrors', E_ALL);
     global $mod_strings, $app_strings, $current_user, $import_bean_map;
     global $app_list_strings, $timedate;
     $update_only = isset($_REQUEST['import_type']) && $_REQUEST['import_type'] == 'update';
     $firstrow = unserialize(base64_decode($_REQUEST['firstrow']));
     // All the Look Up Caches are initialized here
     $enum_lookup_cache = array();
     // Let's try and load the import bean
     $focus = loadImportBean($_REQUEST['import_module']);
     if (!$focus) {
         trigger_error($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], E_USER_ERROR);
     }
     // setup the importable fields array.
     $importable_fields = $focus->get_importable_fields();
     // loop through all request variables
     $importColumns = array();
     foreach ($_REQUEST as $name => $value) {
         // only look for var names that start with "fieldNum"
         if (strncasecmp($name, "colnum_", 7) != 0) {
             continue;
         }
         // pull out the column position for this field name
         $pos = substr($name, 7);
         if (isset($importable_fields[$value])) {
             // now mark that we've seen this field
             $importColumns[$pos] = $value;
         }
     }
     // set the default locale settings
     $ifs = new ImportFieldSanitize();
     $ifs->dateformat = $_REQUEST['importlocale_dateformat'];
     $ifs->timeformat = $_REQUEST['importlocale_timeformat'];
     $ifs->timezone = $_REQUEST['importlocale_timezone'];
     $currency = new Currency();
     $currency->retrieve($_REQUEST['importlocale_currency']);
     $ifs->currency_symbol = $currency->symbol;
     $ifs->default_currency_significant_digits = $_REQUEST['importlocale_default_currency_significant_digits'];
     $ifs->num_grp_sep = $_REQUEST['importlocale_num_grp_sep'];
     $ifs->dec_sep = $_REQUEST['importlocale_dec_sep'];
     $ifs->default_locale_name_format = $_REQUEST['importlocale_default_locale_name_format'];
     // Check to be sure we are getting an import file that is in the right place
     if (realpath(dirname($_REQUEST['tmp_file']) . '/') != realpath($sugar_config['upload_dir'])) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     // Open the import file
     $importFile = new ImportFile($_REQUEST['tmp_file'], $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
     if (!$importFile->fileExists()) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     $fieldDefs = $focus->getFieldDefinitions();
     unset($focus);
     while ($row = $importFile->getNextRow()) {
         $focus = loadImportBean($_REQUEST['import_module']);
         $focus->unPopulateDefaultValues();
         $focus->save_from_post = false;
         $focus->team_id = null;
         $ifs->createdBeans = array();
         $do_save = true;
         for ($fieldNum = 0; $fieldNum < $_REQUEST['columncount']; $fieldNum++) {
             // loop if this column isn't set
             if (!isset($importColumns[$fieldNum])) {
                 continue;
             }
             // get this field's properties
             $field = $importColumns[$fieldNum];
             $fieldDef = $focus->getFieldDefinition($field);
             $fieldTranslated = translate(isset($fieldDef['vname']) ? $fieldDef['vname'] : $fieldDef['name'], $_REQUEST['module']) . " (" . $fieldDef['name'] . ")";
             // Bug 37241 - Don't re-import over a field we already set during the importing of another field
             if (!empty($focus->{$field})) {
                 continue;
             }
             //DETERMINE WHETHER OR NOT $fieldDef['name'] IS DATE_MODIFIED AND SET A VAR, USE DOWN BELOW
             // translate strings
             global $locale;
             if (empty($locale)) {
                 $locale = new Localization();
             }
             if (isset($row[$fieldNum])) {
                 $rowValue = $locale->translateCharset(strip_tags(trim($row[$fieldNum])), $_REQUEST['importlocale_charset'], $sugar_config['default_charset']);
             } else {
                 $rowValue = '';
             }
             // If there is an default value then use it instead
             if (!empty($_REQUEST[$field])) {
                 if (is_array($_REQUEST[$field])) {
                     $defaultRowValue = encodeMultienumValue($_REQUEST[$field]);
                 } else {
                     $defaultRowValue = $_REQUEST[$field];
                 }
//.........這裏部分代碼省略.........
開發者ID:aldridged,項目名稱:gtg-sugar,代碼行數:101,代碼來源:view.step4.php


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