本文整理匯總了PHP中ImportMap::retrieve方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImportMap::retrieve方法的具體用法?PHP ImportMap::retrieve怎麽用?PHP ImportMap::retrieve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImportMap
的用法示例。
在下文中一共展示了ImportMap::retrieve方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getImportMap
private function getImportMap()
{
if (!empty($_REQUEST['source_id'])) {
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($_REQUEST['source_id'], false);
return $import_map_seed->getMapping();
} else {
return array();
}
}
示例2: display
/**
* display the form
*/
public function display()
{
global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map;
global $import_mod_strings;
$this->ss->assign("MODULE_TITLE", get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_2_TITLE'], true));
$this->ss->assign("MOD", $mod_strings);
$this->ss->assign("APP", $app_strings);
$this->ss->assign("IMP", $import_mod_strings);
$this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
$this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities(!empty($_REQUEST['custom_enclosure']) && $_REQUEST['custom_enclosure'] != 'other' ? $_REQUEST['custom_enclosure'] : (!empty($_REQUEST['custom_enclosure_other']) ? $_REQUEST['custom_enclosure_other'] : "")));
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
$this->ss->assign("JAVASCRIPT", $this->_getJS());
// load bean
$focus = loadImportBean($_REQUEST['import_module']);
if (!$focus) {
showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], $_REQUEST['import_module']);
return;
}
// special for importing from Outlook
if ($_REQUEST['source'] == "outlook") {
$this->ss->assign("SOURCE", $_REQUEST['source']);
$this->ss->assign("SOURCE_NAME", "Outlook ");
$this->ss->assign("HAS_HEADER_CHECKED", " CHECKED");
} elseif (strncasecmp("custom:", $_REQUEST['source'], 7) == 0) {
$id = substr($_REQUEST['source'], 7);
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($id, false);
$this->ss->assign("SOURCE_ID", $import_map_seed->id);
$this->ss->assign("SOURCE_NAME", $import_map_seed->name);
$this->ss->assign("SOURCE", $import_map_seed->source);
if (isset($import_map_seed->delimiter)) {
$this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
}
if (isset($import_map_seed->enclosure)) {
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
}
if ($import_map_seed->has_header) {
$this->ss->assign("HAS_HEADER_CHECKED", " CHECKED");
}
} else {
$classname = 'ImportMap' . ucfirst($_REQUEST['source']);
require "modules/Import/{$classname}.php";
$import_map_seed = new $classname();
if (isset($import_map_seed->delimiter)) {
$this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
}
if (isset($import_map_seed->enclosure)) {
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
}
if ($import_map_seed->has_header) {
$this->ss->assign("HAS_HEADER_CHECKED", " CHECKED");
}
$this->ss->assign("SOURCE", $_REQUEST['source']);
}
// add instructions for anything other than custom_delimited
if ($_REQUEST['source'] != 'other') {
$instructions = array();
$lang_key = '';
switch ($_REQUEST['source']) {
case "act":
$lang_key = "ACT";
break;
case "outlook":
$lang_key = "OUTLOOK";
break;
case "salesforce":
$lang_key = "SF";
break;
case "tab":
$lang_key = "TAB";
break;
case "jigsaw":
$lang_key = "JIGSAW";
break;
case "csv":
$lang_key = "CUSTOM";
break;
}
if ($lang_key != '') {
for ($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_{$i}"]); $i++) {
$instructions[] = array("STEP_NUM" => $mod_strings["LBL_NUM_{$i}"], "INSTRUCTION_STEP" => $mod_strings["LBL_{$lang_key}_NUM_{$i}"]);
}
$this->ss->assign("INSTRUCTIONS_TITLE", $mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
$this->ss->assign("instructions", $instructions);
}
}
$this->ss->display('modules/Import/tpls/step2.tpl');
}
示例3: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale;
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$has_header = isset($_REQUEST['has_header']) ? 1 : 0;
$sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
// Clear out this user's last import
$seedUsersLastImport = new UsersLastImport();
$seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
ImportCacheFiles::clearCacheFiles();
// attempt to lookup a preexisting field map
// use the custom one if specfied to do so in step 1
$field_map = array();
$default_values = array();
$ignored_fields = array();
if (!empty($_REQUEST['source_id'])) {
$mapping_file = new ImportMap();
$mapping_file->retrieve($_REQUEST['source_id'], false);
$_REQUEST['source'] = $mapping_file->source;
$has_header = $mapping_file->has_header;
if (isset($mapping_file->delimiter)) {
$_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
}
if (isset($mapping_file->enclosure)) {
$_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
}
$field_map = $mapping_file->getMapping();
$default_values = $mapping_file->getDefaultValues();
$this->ss->assign("MAPNAME", $mapping_file->name);
$this->ss->assign("CHECKMAP", 'checked="checked" value="on"');
} else {
// Try to see if we have a custom mapping we can use
// based upon the where the records are coming from
// and what module we are importing into
$classname = 'ImportMap' . ucfirst($_REQUEST['source']);
if (file_exists("modules/Import/{$classname}.php")) {
require_once "modules/Import/{$classname}.php";
} elseif (file_exists("custom/modules/Import/{$classname}.php")) {
require_once "custom/modules/Import/{$classname}.php";
} else {
require_once "custom/modules/Import/ImportMapOther.php";
$classname = 'ImportMapOther';
$_REQUEST['source'] = 'other';
}
if (class_exists($classname)) {
$mapping_file = new $classname();
if (isset($mapping_file->delimiter)) {
$_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
}
if (isset($mapping_file->enclosure)) {
$_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
}
$ignored_fields = $mapping_file->getIgnoredFields($_REQUEST['import_module']);
$field_map = $mapping_file->getMapping($_REQUEST['import_module']);
}
}
$this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
$this->ss->assign("CUSTOM_ENCLOSURE", !empty($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : "");
// handle uploaded file
$uploadFile = new UploadFile('userfile');
if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
$uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
$uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
} else {
$this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2');
return;
}
// split file into parts
$splitter = new ImportFileSplitter($uploadFileName, $sugar_config['import_max_records_per_file']);
$splitter->splitSourceFile($_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), $has_header);
// Now parse the file and look for errors
$importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
if (!$importFile->fileExists()) {
$this->_showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2');
return;
}
// retrieve first 3 rows
$rows = array();
$system_charset = $locale->default_export_charset;
$user_charset = $locale->getExportCharset();
$other_charsets = 'UTF-8, UTF-7, ASCII, CP1252, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP';
$detectable_charsets = "UTF-8, {$user_charset}, {$system_charset}, {$other_charsets}";
// Bug 26824 - mb_detect_encoding() thinks CP1252 is IS0-8859-1, so use that instead in the encoding list passed to the function
$detectable_charsets = str_replace('CP1252', 'ISO-8859-1', $detectable_charsets);
$charset_for_import = $user_charset;
//We will set the default import charset option by user's preference.
$able_to_detect = function_exists('mb_detect_encoding');
for ($i = 0; $i < 3; $i++) {
$rows[$i] = $importFile->getNextRow();
if (!empty($rows[$i]) && $able_to_detect) {
foreach ($rows[$i] as &$temp_value) {
$current_charset = mb_detect_encoding($temp_value, $detectable_charsets);
if (!empty($current_charset) && $current_charset != "UTF-8") {
$temp_value = $locale->translateCharset($temp_value, $current_charset);
// we will use utf-8 for displaying the data on the page.
$charset_for_import = $current_charset;
//set the default import charset option according to the current_charset.
//.........這裏部分代碼省略.........
示例4: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale;
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$has_header = isset($_REQUEST['has_header']) ? 1 : 0;
$sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
$this->ss->assign("CURRENT_STEP", $this->currentStep);
// attempt to lookup a preexisting field map
// use the custom one if specfied to do so in step 1
$mapping_file = new ImportMap();
$field_map = $mapping_file->set_get_import_wizard_fields();
$default_values = array();
$ignored_fields = array();
if (!empty($_REQUEST['source_id'])) {
$GLOBALS['log']->fatal("Loading import map properties.");
$mapping_file = new ImportMap();
$mapping_file->retrieve($_REQUEST['source_id'], false);
$_REQUEST['source'] = $mapping_file->source;
$has_header = $mapping_file->has_header;
if (isset($mapping_file->delimiter)) {
$_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
}
if (isset($mapping_file->enclosure)) {
$_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
}
$field_map = $mapping_file->getMapping();
//print_r($field_map);die();
$default_values = $mapping_file->getDefaultValues();
$this->ss->assign("MAPNAME", $mapping_file->name);
$this->ss->assign("CHECKMAP", 'checked="checked" value="on"');
} else {
$classname = $this->getMappingClassName(ucfirst($_REQUEST['source']));
//Set the $_REQUEST['source'] to be 'other' for ImportMapOther special case
if ($classname == 'ImportMapOther') {
$_REQUEST['source'] = 'other';
}
if (class_exists($classname)) {
$mapping_file = new $classname();
$ignored_fields = $mapping_file->getIgnoredFields($_REQUEST['import_module']);
$field_map2 = $mapping_file->getMapping($_REQUEST['import_module']);
$field_map = array_merge($field_map, $field_map2);
}
}
$delimiter = $this->getRequestDelimiter();
$this->ss->assign("CUSTOM_DELIMITER", $delimiter);
$this->ss->assign("CUSTOM_ENCLOSURE", !empty($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : "");
//populate import locale values from import mapping if available, these values will be used througout the rest of the code path
$uploadFileName = $_REQUEST['file_name'];
// Now parse the file and look for errors
$importFile = new ImportFile($uploadFileName, $delimiter, html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), FALSE);
if (!$importFile->fileExists()) {
$this->_showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2');
return;
}
$charset = $importFile->autoDetectCharacterSet();
// retrieve first 3 rows
$rows = array();
//Keep track of the largest row count found.
$maxFieldCount = 0;
for ($i = 0; $i < 3; $i++) {
$rows[] = $importFile->getNextRow();
$maxFieldCount = $importFile->getFieldCount() > $maxFieldCount ? $importFile->getFieldCount() : $maxFieldCount;
}
$ret_field_count = $maxFieldCount;
// Bug 14689 - Parse the first data row to make sure it has non-empty data in it
$isempty = true;
if ($rows[(int) $has_header] != false) {
foreach ($rows[(int) $has_header] as $value) {
if (strlen(trim($value)) > 0) {
$isempty = false;
break;
}
}
}
if ($isempty || $rows[(int) $has_header] == false) {
$this->_showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2');
return;
}
// save first row to send to step 4
$this->ss->assign("FIRSTROW", base64_encode(serialize($rows[0])));
// Now build template
$this->ss->assign("TMP_FILE", $uploadFileName);
$this->ss->assign("SOURCE", $_REQUEST['source']);
$this->ss->assign("TYPE", $_REQUEST['type']);
$this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('basic_search', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
$this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('advanced_search', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
$this->instruction = 'LBL_SELECT_MAPPING_INSTRUCTION';
$this->ss->assign('INSTRUCTION', $this->getInstruction());
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false));
$this->ss->assign("STEP4_TITLE", strip_tags(str_replace("\n", "", getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_STEP_4_TITLE']), false))));
$this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
// we export it as email_address, but import as email1
$field_map['email_address'] = 'email1';
// build each row; row count is determined by the the number of fields in the import file
$columns = array();
$mappedFields = array();
// this should be populated if the request comes from a 'Back' button click
//.........這裏部分代碼省略.........
示例5: testMarkUnpublishedNameConflict
public function testMarkUnpublishedNameConflict()
{
$this->_addMapping();
$this->_importMap->mark_published($GLOBALS['current_user']->id, true);
$id = $this->_importMap->id;
$GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
$this->_importMap = new ImportMap();
$this->_addMapping();
$importMapRetrieve = new ImportMap();
$importMapRetrieve->retrieve($id, false);
$this->assertFalse($this->_importMap->mark_published($GLOBALS['current_user']->id, false));
$query = "SELECT * FROM import_maps \n WHERE id = '{$id}'";
$result = $GLOBALS['db']->query($query);
$row = $GLOBALS['db']->fetchByAssoc($result);
$this->assertEquals($row['is_published'], 'yes');
}
示例6: getImportMap
private function getImportMap($importSource)
{
if (strncasecmp("custom:", $importSource, 7) == 0) {
$id = substr($importSource, 7);
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($id, false);
$this->ss->assign("SOURCE_ID", $import_map_seed->id);
$this->ss->assign("SOURCE_NAME", $import_map_seed->name);
$this->ss->assign("SOURCE", $import_map_seed->source);
} else {
$classname = 'ImportMap' . ucfirst($importSource);
if (file_exists("modules/Import/maps/{$classname}.php")) {
require_once "modules/Import/maps/{$classname}.php";
} elseif (file_exists("custom/modules/Import/maps/{$classname}.php")) {
require_once "custom/modules/Import/maps/{$classname}.php";
} else {
require_once "custom/modules/Import/maps/ImportMapOther.php";
$classname = 'ImportMapOther';
$importSource = 'other';
}
if (class_exists($classname)) {
$import_map_seed = new $classname();
$this->ss->assign("SOURCE", $importSource);
}
}
return $import_map_seed;
}
示例7: substr
// see if the source starts with 'custom'
// if so, pull off the id, load that map, and get the name
if ($_REQUEST['source'] == "outlook") {
$xtpl->assign("SOURCE", $_REQUEST['source']);
$xtpl->assign("SOURCE_NAME", "Outlook ");
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
} else {
if ($_REQUEST['source'] == "act") {
$xtpl->assign("SOURCE", $_REQUEST['source']);
$xtpl->assign("SOURCE_NAME", "ACT! ");
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
} else {
if (strncasecmp("custom:", $_REQUEST['source'], 7) == 0) {
$id = substr($_REQUEST['source'], 7);
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($id, false);
$xtpl->assign("SOURCE_ID", $import_map_seed->id);
$xtpl->assign("SOURCE_NAME", $import_map_seed->name);
$xtpl->assign("SOURCE", $import_map_seed->source);
if ($import_map_seed->has_header) {
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
}
} else {
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
$xtpl->assign("SOURCE", $_REQUEST['source']);
}
}
}
$xtpl->assign("JAVASCRIPT", get_validate_upload_js());
$lang_key = '';
if ($_REQUEST['source'] == "outlook") {
示例8: array
require_once "modules/Import/{$bean}.php";
$focus = new $bean();
} else {
echo "Imports aren't set up for this module type\n";
exit;
}
//setup the importable fields array.
$importable_fields = array();
$translated_column_fields = array();
get_importable_fields($focus, $importable_fields, $translated_column_fields);
$firstrow = $rows[0];
$field_map = $outlook_contacts_field_map;
$mapping_arr = array();
if (!empty($_REQUEST['source_id'])) {
$mapping_file = new ImportMap();
$mapping_file->retrieve($_REQUEST['source_id'], false);
$mapping_content = $mapping_file->content;
$_REQUEST['source'] = $mapping_file->source;
if (isset($mapping_content) && $mapping_content != "") {
$pairs = split("&", $mapping_content);
foreach ($pairs as $pair) {
list($name, $value) = split("=", $pair);
$mapping_arr["{$name}"] = $value;
}
}
}
//$xtpl->assign("SOURCE_NAME", $source_to_name[$_REQUEST['source']] );
if (count($mapping_arr) > 0) {
$field_map = $mapping_arr;
} else {
if ($_REQUEST['source'] == 'other') {