本文整理汇总了PHP中getDelimiter函数的典型用法代码示例。如果您正苦于以下问题:PHP getDelimiter函数的具体用法?PHP getDelimiter怎么用?PHP getDelimiter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDelimiter函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: template_handle_export
function template_handle_export(&$reporter)
{
ini_set('zlib.output_compression', 'Off');
$reporter->plain_text_output = true;
//disable paging so we get all results in one pass
$reporter->enable_paging = false;
$reporter->run_query();
$reporter->_load_currency();
$header_arr = array();
$header_row = $reporter->get_header_row();
$content = '';
foreach ($header_row as $cell) {
array_push($header_arr, $cell);
}
$header = implode("\"" . getDelimiter() . "\"", array_values($header_arr));
$header = "\"" . $header;
$header .= "\"\r\n";
$content .= $header;
while (($row = $reporter->get_next_row('result', 'display_columns', false, true)) != 0) {
$new_arr = array();
for ($i = 0; $i < count($row['cells']); $i++) {
array_push($new_arr, preg_replace("/\"/", "\"\"", from_html($row['cells'][$i])));
}
$line = implode("\"" . getDelimiter() . "\"", $new_arr);
$line = "\"" . $line;
$line .= "\"\r\n";
$content .= $line;
}
global $locale;
$transContent = $GLOBALS['locale']->translateCharset($content, 'UTF-8', $GLOBALS['locale']->getExportCharset());
ob_clean();
header("Pragma: cache");
header("Content-type: application/octet-stream; charset=" . $locale->getExportCharset());
header("Content-Disposition: attachment; filename={$_REQUEST['module']}.csv");
header("Content-transfer-encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . TimeDate::httpTime());
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Length: " . mb_strlen($transContent, '8bit'));
$BOM = "";
print $BOM . $transContent;
}
示例2: getDelimiter
$xtpl->assign('REPORTS_TO_ID', $focus->reports_to_id);
$xtpl->assign('REPORTS_TO_NAME', $focus->reports_to_name);
$xtpl->assign('PHONE_HOME', $focus->phone_home);
$xtpl->assign('PHONE_MOBILE', $focus->phone_mobile);
$xtpl->assign('PHONE_WORK', $focus->phone_work);
$xtpl->assign('PHONE_OTHER', $focus->phone_other);
$xtpl->assign('PHONE_FAX', $focus->phone_fax);
$xtpl->assign('EMAIL1', $focus->email1);
$xtpl->assign('EMAIL2', $focus->email2);
$xtpl->assign('ADDRESS_STREET', $focus->address_street);
$xtpl->assign('ADDRESS_CITY', $focus->address_city);
$xtpl->assign('ADDRESS_STATE', $focus->address_state);
$xtpl->assign('ADDRESS_POSTALCODE', $focus->address_postalcode);
$xtpl->assign('ADDRESS_COUNTRY', $focus->address_country);
$xtpl->assign('DESCRIPTION', $focus->description);
$xtpl->assign('EXPORT_DELIMITER', getDelimiter());
$xtpl->assign('EXPORT_CHARSET', get_select_options_with_id($locale->availableCharsets, $locale->getExportCharset()));
if ($focus->getPreference('use_real_names') == 'on') {
$xtpl->assign('USE_REAL_NAMES', 'CHECKED');
}
if ($focus->getPreference('no_opps') == 'on') {
$xtpl->assign('NO_OPPS', 'CHECKED');
}
///////////////////////////////////////////////////////////////////////////////
//// NEW USER CREATION ONLY
if (empty($focus->id)) {
$xtpl->assign('LBL_NEW_PASSWORD1', $mod_strings['LBL_NEW_PASSWORD1'] . ': <span class="required">' . $app_strings['LBL_REQUIRED_SYMBOL'] . '</span>');
$xtpl->assign('LBL_NEW_PASSWORD2', $mod_strings['LBL_NEW_PASSWORD2'] . ': <span class="required">' . $app_strings['LBL_REQUIRED_SYMBOL'] . '</span>');
$xtpl->assign('NEW_PASSWORD1', '<input id="new_password1" name="new_password1" tabindex="2" type="password" size="25" maxlength="25">');
$xtpl->assign('NEW_PASSWORD2', '<input id="new_password2" name="new_password2" tabindex="2" type="password" size="25" maxlength="25">');
}
示例3: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null, $members = false)
{
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
global $app_list_strings;
global $timedate;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
$focus = 0;
$content = '';
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$where = $ret_array['where'];
$searchFields = $ret_array['searchFields'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$ret_array = create_export_query_relate_link_patch($type, $searchFields, $where);
if (!empty($ret_array['join'])) {
$query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
} else {
$query = $focus->create_export_query($order_by, $ret_array['where']);
}
}
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$fields_array = $db->getFieldsArray($result, true);
// setup the "header" line with proper delimiters
$header = implode("\"" . getDelimiter() . "\"", array_values($fields_array));
if ($members) {
$header = str_replace('"ea_deleted"' . getDelimiter() . '"ear_deleted"' . getDelimiter() . '"primary_address"' . getDelimiter() . '', '', $header);
}
$header = "\"" . $header;
$header .= "\"\r\n";
$content .= $header;
$pre_id = '';
while ($val = $db->fetchByAssoc($result, -1, false)) {
$new_arr = array();
if ($members) {
if ($pre_id == $val['id']) {
continue;
}
if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) {
$val['primary_email_address'] = '';
}
unset($val['ea_deleted']);
unset($val['ear_deleted']);
unset($val['primary_address']);
}
$pre_id = $val['id'];
$vals = array_values($val);
foreach ($vals as $key => $value) {
//getting content values depending on their types
$fieldType = $focus->field_name_map[$fields_array[$key]]['type'];
if (isset($fieldType)) {
switch ($fieldType) {
//if our value is a currency field, then apply the users locale
//.........这里部分代码省略.........
示例4: build_report_csv
function build_report_csv()
{
ini_set('zlib.output_compression', 'Off');
ob_start();
require_once 'include/export_utils.php';
$delimiter = getDelimiter();
$csv = '';
//text/comma-separated-values
$sql = "SELECT id FROM aor_fields WHERE aor_report_id = '" . $this->id . "' AND deleted = 0 ORDER BY field_order ASC";
$result = $this->db->query($sql);
$fields = array();
$i = 0;
while ($row = $this->db->fetchByAssoc($result)) {
$field = new AOR_Field();
$field->retrieve($row['id']);
$path = unserialize(base64_decode($field->module_path));
$field_module = $this->report_module;
if ($path[0] != $this->report_module) {
foreach ($path as $rel) {
$field_module = getRelatedModule($field_module, $rel);
}
}
$label = str_replace(' ', '_', $field->label) . $i;
$fields[$label]['field'] = $field->field;
$fields[$label]['display'] = $field->display;
$fields[$label]['function'] = $field->field_function;
$fields[$label]['module'] = $field_module;
if ($field->display) {
$csv .= $this->encloseForCSV($field->label);
$csv .= $delimiter;
}
++$i;
}
$sql = $this->build_report_query();
$result = $this->db->query($sql);
while ($row = $this->db->fetchByAssoc($result)) {
$csv .= "\r\n";
foreach ($fields as $name => $att) {
if ($att['display']) {
if ($att['function'] != '') {
$csv .= $this->encloseForCSV($row[$name]);
} else {
$csv .= $this->encloseForCSV(trim(strip_tags(getModuleField($att['module'], $att['field'], $att['field'], 'DetailView', $row[$name]))));
}
$csv .= $delimiter;
}
}
}
$csv = $GLOBALS['locale']->translateCharset($csv, 'UTF-8', $GLOBALS['locale']->getExportCharset());
ob_clean();
header("Pragma: cache");
header("Content-type: text/comma-separated-values; charset=" . $GLOBALS['locale']->getExportCharset());
header("Content-Disposition: attachment; filename={$this->name}.csv");
header("Content-transfer-encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . TimeDate::httpTime());
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Length: " . mb_strlen($csv, '8bit'));
if (!empty($sugar_config['export_excel_compatible'])) {
$csv == chr(255) . chr(254) . mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8');
}
print $csv;
sugar_cleanup(true);
}
示例5: getDelimiter
$sugar_smarty->assign('REPORTS_TO_ID', $focus->reports_to_id);
$sugar_smarty->assign('REPORTS_TO_NAME', $focus->reports_to_name);
$sugar_smarty->assign('PHONE_HOME', $focus->phone_home);
$sugar_smarty->assign('PHONE_MOBILE', $focus->phone_mobile);
$sugar_smarty->assign('PHONE_WORK', $focus->phone_work);
$sugar_smarty->assign('PHONE_OTHER', $focus->phone_other);
$sugar_smarty->assign('PHONE_FAX', $focus->phone_fax);
$sugar_smarty->assign('EMAIL1', $focus->email1);
$sugar_smarty->assign('EMAIL2', $focus->email2);
$sugar_smarty->assign('ADDRESS_STREET', $focus->address_street);
$sugar_smarty->assign('ADDRESS_CITY', $focus->address_city);
$sugar_smarty->assign('ADDRESS_STATE', $focus->address_state);
$sugar_smarty->assign('ADDRESS_POSTALCODE', $focus->address_postalcode);
$sugar_smarty->assign('ADDRESS_COUNTRY', $focus->address_country);
$sugar_smarty->assign('DESCRIPTION', $focus->description);
$sugar_smarty->assign('EXPORT_DELIMITER', getDelimiter());
$sugar_smarty->assign('PWDSETTINGS', $GLOBALS['sugar_config']['passwordsetting']);
if (!empty($GLOBALS['sugar_config']['authenticationClass'])) {
$sugar_smarty->assign('EXTERNAL_AUTH_CLASS_1', $GLOBALS['sugar_config']['authenticationClass']);
$sugar_smarty->assign('EXTERNAL_AUTH_CLASS', $GLOBALS['sugar_config']['authenticationClass']);
} else {
if (!empty($GLOBALS['system_config']->settings['system_ldap_enabled'])) {
$sugar_smarty->assign('EXTERNAL_AUTH_CLASS_1', $mod_strings['LBL_LDAP']);
$sugar_smarty->assign('EXTERNAL_AUTH_CLASS', $mod_strings['LBL_LDAP_AUTHENTICATION']);
}
}
if (!empty($focus->external_auth_only)) {
$sugar_smarty->assign('EXTERNAL_AUTH_ONLY_CHECKED', 'CHECKED');
}
if ($is_current_admin) {
$sugar_smarty->assign('IS_ADMIN', '1');
示例6: getExportContentFromResult
/**
* getExportContentsFromResult
*
* This is a function to handle the processing of generating the export contents.
*
* @param Mixed $focus SugarBean instance we are retrieving export results for
* @param Mixed $result database result resource from the export SQL
* @param bool $members used to indicate whether or not to apply filtering for header rows; false by default
* @param array $remove_from_members Array of header columns to filter out; empty by default
* @param bool $populate boolean used to indicate whether or not to populate with test data; false by default
* @return string
*/
function getExportContentFromResult($focus, $result, $members = false, $remove_from_members = array(), $populate = false)
{
global $current_user, $locale, $app_strings;
$sampleRecordNum = 5;
$delimiter = getDelimiter();
$timedate = TimeDate::getInstance();
$db = DBManagerFactory::getInstance();
$fields_array = $db->getFieldsArray($result, true);
// check if ID field is contained in query result
$is_id_exported = in_array('id', $fields_array);
//set up the order on the header row
$fields_array = get_field_order_mapping($focus->module_dir, $fields_array, true, $focus->fields_to_exclude);
//set up labels to be used for the header row
$field_labels = array();
foreach ($fields_array as $key => $dbname) {
//Remove fields that are only used for logic
if ($members && in_array($dbname, $remove_from_members)) {
continue;
}
//default to the db name of label does not exist
$field_labels[$key] = translateForExport($dbname, $focus);
}
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ($locale->getExportCharset() == 'UTF-8' && !preg_match('/macintosh|mac os x|mac_powerpc/i', $user_agent)) {
//Bug 55520 - add BOM to the exporting CSV so any symbols are displayed correctly in Excel
$BOM = "";
$content = $BOM;
} else {
$content = '';
}
$pre_id = '';
// Setup the "header" row with proper delimiters
$content .= "\"" . implode("\"" . getDelimiter() . "\"", array_values($field_labels)) . "\"\r\n";
if ($populate) {
//this is a sample request with no data, so create fake datarows
$content .= returnFakeDataRow($focus, $fields_array, $sampleRecordNum);
} else {
$records = array();
//process retrieved record
$isAdminUser = is_admin($current_user);
while ($val = $db->fetchByAssoc($result, false)) {
//order the values in the record array
$val = get_field_order_mapping($focus->module_dir, $val);
$new_arr = array();
if (!$isAdminUser) {
$focus->id = !empty($val['id']) ? $val['id'] : '';
$focus->assigned_user_id = !empty($val['assigned_user_id']) ? $val['assigned_user_id'] : '';
$focus->created_by = !empty($val['created_by']) ? $val['created_by'] : '';
$focus->ACLFilterFieldList($val, array(), array("blank_value" => true));
}
if ($members) {
if ($is_id_exported && $pre_id == $val['id']) {
continue;
}
if (isset($val['ea_deleted']) && isset($val['primary_email_address']) && ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1)) {
$val['primary_email_address'] = '';
}
unset($val['ea_deleted']);
unset($val['ear_deleted']);
unset($val['primary_address']);
}
$pre_id = $is_id_exported ? $val['id'] : '';
require_once 'include/SugarFields/SugarFieldHandler.php';
//replace user_name with full name if use_real_name preference setting is enabled
//and this is a user name field
$useRealNames = $current_user->getPreference('use_real_names');
foreach ($val as $key => $value) {
//if key is not part of field map, then continue
if (!isset($fields_array[$key])) {
continue;
}
//getting content values depending on their types
$fieldNameMapKey = $fields_array[$key];
if (isset($focus->field_name_map[$fieldNameMapKey]) && $focus->field_name_map[$fieldNameMapKey]['type']) {
$sfh = SugarFieldHandler::getSugarField($focus->field_name_map[$fieldNameMapKey]['type']);
$value = $sfh->exportSanitize($value, $focus->field_defs[$key], $focus, $val);
}
if (isset($focus->field_name_map[$fields_array[$key]]['custom_type']) && $focus->field_name_map[$fields_array[$key]]['custom_type'] == 'teamset') {
require_once 'modules/Teams/TeamSetManager.php';
$value = TeamSetManager::getCommaDelimitedTeams($val['team_set_id'], !empty($val['team_id']) ? $val['team_id'] : '');
}
if ($useRealNames) {
$value = formatRealNameField($focus, $fields_array, $key, $value);
}
// Keep as $key => $value for post-processing
$new_arr[$key] = str_replace('"', '""', $value);
}
//foreach
//.........这里部分代码省略.........
示例7: define
// TODO: Convert to Idiorm if this is ever needed again
require_once 'phplib/util.php';
require_once 'phplib/ads/adsModule.php';
require_once 'phplib/ads/diverta/divertaAdsModule.php';
define('IMG_URL_PREFIX', 'http://www.dol.ro/wcsstore/DOL/');
define('ORIG_FILE_PREFIX', '/tmp/dol/big/');
define('THUMB_PREFIX', util_getRootPath() . 'wwwbase/img/diverta/thumb/');
define('IMG_NORMAL', 0);
define('IMG_NOT_JPEG', 1);
define('IMG_CORRUPT', 2);
$opts = getopt('f:h:d:s:t:a:p:u:i:o:');
if (count($opts) != 10) {
usage();
}
define('CSV_DELIMITER', getDelimiter($opts['d']));
OS::executeAndAssert('mkdir -p ' . ORIG_FILE_PREFIX);
if (!file_exists($opts['f'])) {
print "Input file does not exist.\n";
exit;
}
$handle = fopen($opts['f'], "r");
$i = 0;
while (($fields = fgetcsv($handle, 10000, CSV_DELIMITER)) !== false) {
$i++;
if ($i <= $opts['h']) {
continue;
}
$sku = $fields[$opts['s']];
print "Line {$i}: [{$sku}]\n";
// Reuse the record or create a new one
示例8: export
//.........这里部分代码省略.........
}
$result = '';
$populate = false;
if ($sample) {
$result = $db->limitQuery($query, 0, $sampleRecordNum, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
if ($focus->_get_num_rows_in_query($query) < 1) {
$populate = true;
}
} else {
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
}
$fields_array = $db->getFieldsArray($result, true);
//set up the order on the header row
$fields_array = get_field_order_mapping($focus->module_dir, $fields_array);
//set up labels to be used for the header row
$field_labels = array();
foreach ($fields_array as $key => $dbname) {
//Remove fields that are only used for logic
if ($members && in_array($dbname, $remove_from_members)) {
continue;
}
//default to the db name of label does not exist
$field_labels[$key] = translateForExport($dbname, $focus);
}
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ($locale->getExportCharset() == 'UTF-8' && !preg_match('/macintosh|mac os x|mac_powerpc/i', $user_agent)) {
//Bug 55520 - add BOM to the exporting CSV so any symbols are displayed correctly in Excel
$BOM = "";
$content = $BOM;
} else {
$content = '';
}
// setup the "header" line with proper delimiters
$content .= "\"" . implode("\"" . getDelimiter() . "\"", array_values($field_labels)) . "\"\r\n";
$pre_id = '';
if ($populate) {
//this is a sample request with no data, so create fake datarows
$content .= returnFakeDataRow($focus, $fields_array, $sampleRecordNum);
} else {
$records = array();
//process retrieved record
while ($val = $db->fetchByAssoc($result, false)) {
//order the values in the record array
$val = get_field_order_mapping($focus->module_dir, $val);
$new_arr = array();
if ($members) {
if ($pre_id == $val['id']) {
continue;
}
if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) {
$val['primary_email_address'] = '';
}
unset($val['ea_deleted']);
unset($val['ear_deleted']);
unset($val['primary_address']);
}
$pre_id = $val['id'];
foreach ($val as $key => $value) {
//getting content values depending on their types
$fieldNameMapKey = $fields_array[$key];
if (isset($focus->field_name_map[$fieldNameMapKey]) && $focus->field_name_map[$fieldNameMapKey]['type']) {
$fieldType = $focus->field_name_map[$fieldNameMapKey]['type'];
switch ($fieldType) {
//if our value is a currency field, then apply the users locale
case 'currency':
require_once 'modules/Currencies/Currency.php';
示例9: getDelimiter
$xtpl->assign("IS_GROUP", "checked");
}
if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id) && $focus->is_admin == '1') {
$xtpl->assign("IS_ADMIN", "checked");
}
if ($focus->receive_notifications) {
$xtpl->assign("RECEIVE_NOTIFICATIONS", "checked");
}
if ($focus->getPreference('gridline') == 'on') {
$xtpl->assign("GRIDLINE_CHECK", "checked");
}
if ($focus->getPreference('mailmerge_on') == 'on') {
$xtpl->assign("MAILMERGE_ON", "checked");
}
$xtpl->assign("SETTINGS_URL", $sugar_config['site_url']);
$xtpl->assign("EXPORT_DELIMITER", getDelimiter());
$xtpl->assign('EXPORT_CHARSET', $locale->getExportCharset('', $focus));
$xtpl->assign('USE_REAL_NAMES', $focus->getPreference('use_real_names'));
global $timedate;
$xtpl->assign("DATEFORMAT", $sugar_config['date_formats'][$timedate->get_date_format()]);
$xtpl->assign("TIMEFORMAT", $sugar_config['time_formats'][$timedate->get_time_format()]);
$userTZ = $focus->getPreference('timezone');
if (!empty($userTZ) && !empty($timezones[$userTZ])) {
$value = $timezones[$userTZ];
}
if (!empty($value['dstOffset'])) {
$dst = " (+DST)";
} else {
$dst = "";
}
$gmtOffset = $value['gmtOffset'] / 60;
示例10: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null)
{
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
$focus = 0;
$content = '';
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$db = PearDatabase::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (isset($_SESSION['export_where']) && !empty($_SESSION['export_where'])) {
// bug 4679
$where = $_SESSION['export_where'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$query = $focus->create_export_query($order_by, $where);
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$fields_array = $db->getFieldsArray($result);
// setup the "header" line with quotation marks
$header = implode("\"" . getDelimiter() . "\"", array_values($fields_array));
$header = "\"" . $header;
$header .= "\"\r\n";
$content .= $header;
while ($val = $db->fetchByAssoc($result, -1, false)) {
$new_arr = array();
foreach (array_values($val) as $value) {
array_push($new_arr, preg_replace("/\"/", "\"\"", $value));
}
$line = implode("\"" . getDelimiter() . "\"", $new_arr);
$line = "\"" . $line;
$line .= "\"\r\n";
$content .= $line;
}
return $content;
}
示例11: export
//.........这里部分代码省略.........
$result = $db->limitQuery($query, 0, $sampleRecordNum, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
if ($focus->_get_num_rows_in_query($query) < 1) {
$populate = true;
}
} else {
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
}
$fields_array = $db->getFieldsArray($result, true);
//set up the order on the header row
$fields_array = get_field_order_mapping($focus->module_dir, $fields_array);
//set up labels to be used for the header row
$field_labels = array();
foreach ($fields_array as $key => $dbname) {
//Remove fields that are only used for logic
if ($members && in_array($dbname, $remove_from_members)) {
continue;
}
//If labels should not be exportable skip them
if (isset($focus->field_name_map[$key]) && isset($focus->field_name_map[$key]['exportable']) && $focus->field_name_map[$key]['exportable'] === false) {
continue;
}
//default to the db name of label does not exist
$field_labels[$key] = translateForExport($dbname, $focus);
}
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if ($locale->getExportCharset() == 'UTF-8' && !preg_match('/macintosh|mac os x|mac_powerpc/i', $user_agent)) {
//Bug 55520 - add BOM to the exporting CSV so any symbols are displayed correctly in Excel
$BOM = "";
$content = $BOM;
} else {
$content = '';
}
// setup the "header" line with proper delimiters
$content .= "\"" . implode("\"" . getDelimiter() . "\"", array_values($field_labels)) . "\"\r\n";
$pre_id = '';
if ($populate) {
//this is a sample request with no data, so create fake datarows
$content .= returnFakeDataRow($focus, $fields_array, $sampleRecordNum);
} else {
$records = array();
//process retrieved record
while ($val = $db->fetchByAssoc($result, false)) {
if ($members) {
$focus = BeanFactory::getBean($val['related_type']);
} else {
// field order mapping is not applied for member-exports, as they include multiple modules
//order the values in the record array
$val = get_field_order_mapping($focus->module_dir, $val);
}
$new_arr = array();
if ($members) {
if ($pre_id == $val['id']) {
continue;
}
if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) {
$val['primary_email_address'] = '';
}
unset($val['ea_deleted']);
unset($val['ear_deleted']);
unset($val['primary_address']);
}
$pre_id = $val['id'];
foreach ($val as $key => $value) {
//getting content values depending on their types
$fieldNameMapKey = $fields_array[$key];
//Dont export fields that have been explicitly marked not to be exportable
示例12: getExportDataContent
/**
* getExportDataContent
*
* Returns the export content for the data portion
*
* @param $data
* @param $focus
* @param $fields_array
* @param string $filter_by What field that should be filtered on
* @param array $filters The values to check $filter_by
*
* @return string content for the data portion of export
*/
protected function getExportDataContent($data, $focus, $fields_array, $filter_by = null, array $filters = array())
{
require_once 'include/SugarFields/SugarFieldHandler.php';
require_once 'include/export_utils.php';
global $current_user;
$content = '';
$delimiter = getDelimiter();
//process retrieved record
$isAdminUser = is_admin($current_user);
foreach ($data as $val) {
if (!empty($filter_by) && !empty($filters) && isset($val[$filter_by]) && !in_array($val[$filter_by], $filters)) {
// make sure the value from the row is in the filters
// skip this row as it's not in the filters
continue;
}
$new_arr = array();
if (!$isAdminUser) {
$focus->id = !empty($val['id']) ? $val['id'] : '';
$focus->assigned_user_id = !empty($val['assigned_user_id']) ? $val['assigned_user_id'] : '';
$focus->created_by = !empty($val['created_by']) ? $val['created_by'] : '';
$focus->ACLFilterFieldList($val, array(), array("blank_value" => true));
}
foreach ($fields_array as $key => $label) {
$value = $val[$key];
//getting content values depending on their types
if (isset($focus->field_defs[$key])) {
$sfh = SugarFieldHandler::getSugarField($focus->field_defs[$key]['type']);
$value = $sfh->exportSanitize($value, $focus->field_defs[$key], $focus, $val);
}
$new_arr[$key] = preg_replace("/\"/", "\"\"", $value);
}
$line = implode("\"" . $delimiter . "\"", $new_arr);
$content .= "\"" . $line . "\"\r\n";
}
return $content;
}
示例13: array_push
$activity->date_start = $timedate->to_display_date_time($row['date_start']);
if ($row['status'] == 'None') {
$activity->status = $mod_strings['LBL_NONE_STRING'];
} else {
$activity->status = $row['status'];
}
$activity->type = $app_list_strings['moduleListSingular'][$row['call']];
$activity->id = $row['id'];
array_push($activities, $activity);
$row = $focus->db->fetchByAssoc($result);
}
if (isset($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
require_once 'include/export_utils.php';
$content = '"' . preg_replace("/\"/", "\"\"", $mod_strings['LBL_TYPE']) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $mod_strings['LBL_SUBJECT']) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $mod_strings['LBL_DATE']) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $mod_strings['LBL_STATUS']) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $mod_strings['LBL_CHART_DESCRIPTION']) . '"' . "\r\n";
foreach ($activities as $activity) {
$content .= '"' . preg_replace("/\"/", "\"\"", $activity->type) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $activity->name) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $timedate->to_display_date_time($activity->date_start)) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $activity->status) . '"' . getDelimiter() . '"' . preg_replace("/\"/", "\"\"", $activity->description) . '"' . "\r\n";
}
ob_clean();
header("Pragma: cache");
header("Content-type: application/octet-stream; charset=" . $locale->getExportCharset());
header("Content-Disposition: attachment; filename={$_REQUEST['module']}.csv");
header("Content-transfer-encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Length: " . strlen($content));
print $GLOBALS['locale']->translateCharset($content, 'UTF-8', $locale->getExportCharset());
exit;
}
}
$sugar_smarty->assign('count', count($activities));
示例14: export
$content = export(clean_string($_REQUEST['module']));
}
}
$filename = $_REQUEST['module'];
//use label if one is defined
if (!empty($app_list_strings['moduleList'][$_REQUEST['module']])) {
$filename = $app_list_strings['moduleList'][$_REQUEST['module']];
}
//strip away any blank spaces
$filename = str_replace(' ', '', $filename);
if ($_REQUEST['members'] == true) {
$filename .= '_' . 'members';
}
$content = explode("\"\r\n\"", $content);
foreach ($content as $val) {
$temp = explode("\"" . getDelimiter() . "\"", $val);
$data[] = $temp;
}
/**
* added by Hoc Bui
*/
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("OnlineCRM")->setLastModifiedBy("OnlineCRM")->setTitle($filename)->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
// Add export data
$activeSheet = $objPHPExcel->setActiveSheetIndex(0);
$focus = new $GLOBALS['beanList'][$the_module]();
$row_num = 1;
foreach ($data as $row) {
$col_num = 0;
foreach ($row as $key => $value) {