本文整理汇总了PHP中RGFormsModel::get_field_value_long方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_field_value_long方法的具体用法?PHP RGFormsModel::get_field_value_long怎么用?PHP RGFormsModel::get_field_value_long使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_field_value_long方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start_export
public static function start_export($form)
{
$form_id = $form['id'];
$fields = $_POST['export_field'];
$start_date = empty($_POST['export_date_start']) ? '' : self::get_gmt_date($_POST['export_date_start'] . ' 00:00:00');
$end_date = empty($_POST['export_date_end']) ? '' : self::get_gmt_date($_POST['export_date_end'] . ' 23:59:59');
$search_criteria['status'] = 'active';
$search_criteria['field_filters'] = GFCommon::get_field_filters_from_post($form);
if (!empty($start_date)) {
$search_criteria['start_date'] = $start_date;
}
if (!empty($end_date)) {
$search_criteria['end_date'] = $end_date;
}
$sorting = array('key' => 'date_created', 'direction' => 'DESC', 'type' => 'info');
GFCommon::log_debug("GFExport::start_export(): Start date: {$start_date}");
GFCommon::log_debug("GFExport::start_export(): End date: {$end_date}");
$form = self::add_default_export_fields($form);
$entry_count = GFAPI::count_entries($form_id, $search_criteria);
$page_size = 100;
$offset = 0;
//Adding BOM marker for UTF-8
$lines = chr(239) . chr(187) . chr(191);
// set the separater
$separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
$field_rows = self::get_field_row_count($form, $fields, $entry_count);
//writing header
$headers = array();
foreach ($fields as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
GFCommon::log_debug("GFExport::start_export(): Header for field ID {$field_id}: {$value}");
$headers[$field_id] = $str = preg_replace('/[^a-z\\d ]/i', '', $value);
$subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
if ($subrow_count == 0) {
$lines .= '"' . $value . '"' . $separator;
} else {
for ($i = 1; $i <= $subrow_count; $i++) {
$lines .= '"' . $value . ' ' . $i . '"' . $separator;
}
}
GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
}
$lines = substr($lines, 0, strlen($lines) - 1) . "\n";
//paging through results for memory issues
while ($entry_count > 0) {
$paging = array('offset' => $offset, 'page_size' => $page_size);
$leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
$leads = apply_filters("gform_leads_before_export_{$form_id}", apply_filters('gform_leads_before_export', $leads, $form, $paging), $form, $paging);
foreach ($leads as $lead) {
foreach ($fields as $field_id) {
switch ($field_id) {
case 'date_created':
$lead_gmt_time = mysql2date('G', $lead['date_created']);
$lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
$value = date_i18n('Y-m-d H:i:s', $lead_local_time, true);
break;
default:
$long_text = '';
if (strlen(rgar($lead, $field_id)) >= GFORMS_MAX_FIELD_LENGTH - 10) {
$long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
}
$value = !empty($long_text) ? $long_text : rgar($lead, $field_id);
$field = RGFormsModel::get_field($form, $field_id);
$input_type = RGFormsModel::get_input_type($field);
if ($input_type == 'checkbox') {
//pass in label value that has not had quotes escaped so the is_checkbox_checked function compares the unchanged label value with the lead value
$header_label_not_escaped = GFCommon::get_label($field, $field_id);
$value = GFFormsModel::is_checkbox_checked($field_id, $header_label_not_escaped, $lead, $form);
if ($value === false) {
$value = '';
}
} else {
if ($input_type == 'fileupload' && $field->multipleFiles) {
$value = !empty($value) ? implode(' , ', json_decode($value, true)) : '';
}
}
$value = preg_replace('/[^a-z\\d ]/i', '', $value);
$value = apply_filters('gform_export_field_value', $value, $form_id, $field_id, $lead);
GFCommon::log_debug("GFExport::start_export(): Value for field ID {$field_id}: {$value}");
break;
}
if (isset($field_rows[$field_id])) {
$list = empty($value) ? array() : unserialize($value);
foreach ($list as $row) {
$row_values = array_values($row);
$row_str = implode('|', $row_values);
$lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
}
//filling missing subrow columns (if any)
$missing_count = intval($field_rows[$field_id]) - count($list);
for ($i = 0; $i < $missing_count; $i++) {
$lines .= '""' . $separator;
}
} else {
$value = maybe_unserialize($value);
if (is_array($value)) {
$value = implode('|', $value);
}
$lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
//.........这里部分代码省略.........
示例2: build_lead_array
public static function build_lead_array($results, $use_long_values = true)
{
$leads = array();
$lead = array();
$form_id = 0;
if (is_array($results) && sizeof($results) > 0) {
$form_id = $results[0]->form_id;
$lead = array('id' => $results[0]->id, 'form_id' => $results[0]->form_id, 'date_created' => $results[0]->date_created, 'is_starred' => intval($results[0]->is_starred), 'is_read' => intval($results[0]->is_read), 'ip' => $results[0]->ip, 'source_url' => $results[0]->source_url, 'post_id' => $results[0]->post_id, 'currency' => $results[0]->currency, 'payment_status' => $results[0]->payment_status, 'payment_date' => $results[0]->payment_date, 'transaction_id' => $results[0]->transaction_id, 'payment_amount' => $results[0]->payment_amount, 'payment_method' => $results[0]->payment_method, 'is_fulfilled' => $results[0]->is_fulfilled, 'created_by' => $results[0]->created_by, 'transaction_type' => $results[0]->transaction_type, 'user_agent' => $results[0]->user_agent, 'status' => $results[0]->status, 'orderStatus' => $results[0]->orderStatus);
$form = RGFormsModel::get_form_meta($form_id);
$prev_lead_id = 0;
foreach ($results as $result) {
if ($prev_lead_id != $result->id && $prev_lead_id > 0) {
array_push($leads, $lead);
$lead = array('id' => $result->id, 'form_id' => $result->form_id, 'date_created' => $result->date_created, 'is_starred' => intval($result->is_starred), 'is_read' => intval($result->is_read), 'ip' => $result->ip, 'source_url' => $result->source_url, 'post_id' => $result->post_id, 'currency' => $result->currency, 'payment_status' => $result->payment_status, 'payment_date' => $result->payment_date, 'transaction_id' => $result->transaction_id, 'payment_amount' => $result->payment_amount, 'payment_method' => $result->payment_method, 'is_fulfilled' => $result->is_fulfilled, 'created_by' => $result->created_by, 'transaction_type' => $result->transaction_type, 'user_agent' => $result->user_agent, 'status' => $result->status);
}
$field_value = $result->value;
$field_number = (string) $result->field_number;
//using long values if specified
if ($use_long_values && strlen($field_value) >= GFORMS_MAX_FIELD_LENGTH - 10) {
$long_text = RGFormsModel::get_field_value_long($lead, $field_number, $form, false);
$field_value = !empty($long_text) ? $long_text : $field_value;
}
$lead[$field_number] = $field_value;
$prev_lead_id = $result->id;
}
}
//adding last lead.
if (sizeof($lead) > 0) {
array_push($leads, $lead);
}
//running entry through gform_get_field_value filter
foreach ($leads as &$lead) {
foreach ($form['fields'] as $field) {
/* @var GF_Field $field */
$inputs = $field->get_entry_inputs();
// skip types html, page and section?
if (is_array($inputs)) {
foreach ($inputs as $input) {
$lead[(string) $input['id']] = apply_filters('gform_get_input_value', rgar($lead, (string) $input['id']), $lead, $field, $input['id']);
}
} else {
$value = rgar($lead, (string) $field->id);
if (self::is_encrypted_field($lead['id'], $field->id)) {
$value = GFCommon::decrypt($value);
}
$lead[$field->id] = apply_filters('gform_get_input_value', $value, $lead, $field, '');
}
}
}
//add custom entry properties
$entry_ids = array();
foreach ($leads as $l) {
$entry_ids[] = $l['id'];
}
$entry_meta = GFFormsModel::get_entry_meta($form_id);
$meta_keys = array_keys($entry_meta);
$entry_meta_data_rows = gform_get_meta_values_for_entries($entry_ids, $meta_keys);
foreach ($leads as &$lead) {
foreach ($entry_meta_data_rows as $entry_meta_data_row) {
if ($entry_meta_data_row->lead_id == $lead['id']) {
foreach ($meta_keys as $meta_key) {
$lead[$meta_key] = $entry_meta_data_row->{$meta_key};
}
}
}
}
return $leads;
}
示例3: build_lead_array
public static function build_lead_array($results, $use_long_values = false)
{
$leads = array();
$lead = array();
$form_id = 0;
if (is_array($results) && sizeof($results) > 0) {
$form_id = $results[0]->form_id;
$lead = array("id" => $results[0]->id, "form_id" => $results[0]->form_id, "date_created" => $results[0]->date_created, "is_starred" => intval($results[0]->is_starred), "is_read" => intval($results[0]->is_read), "ip" => $results[0]->ip, "source_url" => $results[0]->source_url, "post_id" => $results[0]->post_id, "currency" => $results[0]->currency, "payment_status" => $results[0]->payment_status, "payment_date" => $results[0]->payment_date, "transaction_id" => $results[0]->transaction_id, "payment_amount" => $results[0]->payment_amount, "is_fulfilled" => $results[0]->is_fulfilled, "created_by" => $results[0]->created_by, "transaction_type" => $results[0]->transaction_type, "user_agent" => $results[0]->user_agent, "status" => $results[0]->status);
$form = RGFormsModel::get_form_meta($form_id);
$prev_lead_id = 0;
foreach ($results as $result) {
if ($prev_lead_id != $result->id && $prev_lead_id > 0) {
array_push($leads, $lead);
$lead = array("id" => $result->id, "form_id" => $result->form_id, "date_created" => $result->date_created, "is_starred" => intval($result->is_starred), "is_read" => intval($result->is_read), "ip" => $result->ip, "source_url" => $result->source_url, "post_id" => $result->post_id, "currency" => $result->currency, "payment_status" => $result->payment_status, "payment_date" => $result->payment_date, "transaction_id" => $result->transaction_id, "payment_amount" => $result->payment_amount, "is_fulfilled" => $result->is_fulfilled, "created_by" => $result->created_by, "transaction_type" => $result->transaction_type, "user_agent" => $result->user_agent, "status" => $result->status);
}
$field_value = $result->value;
//using long values if specified
if ($use_long_values && strlen($field_value) >= GFORMS_MAX_FIELD_LENGTH - 10) {
$field = RGFormsModel::get_field($form, $result->field_number);
$long_text = RGFormsModel::get_field_value_long($lead, $result->field_number, $form, false);
$field_value = !empty($long_text) ? $long_text : $field_value;
}
$lead[$result->field_number] = $field_value;
$prev_lead_id = $result->id;
}
}
//adding last lead.
if (sizeof($lead) > 0) {
array_push($leads, $lead);
}
//running entry through gform_get_field_value filter
foreach ($leads as &$lead) {
foreach ($form["fields"] as $field) {
if (isset($field["inputs"]) && is_array($field["inputs"])) {
foreach ($field["inputs"] as $input) {
$lead[(string) $input["id"]] = apply_filters("gform_get_input_value", rgar($lead, (string) $input["id"]), $lead, $field, $input["id"]);
}
} else {
$lead[$field["id"]] = apply_filters("gform_get_input_value", rgar($lead, (string) $field["id"]), $lead, $field, "");
}
}
}
//adding custom entry properties
$entry_ids = array();
foreach ($leads as $l) {
$entry_ids[] = $l["id"];
}
$entry_meta = GFFormsModel::get_entry_meta($form_id);
$meta_keys = array_keys($entry_meta);
$entry_meta_data_rows = gform_get_meta_values_for_entries($entry_ids, $meta_keys);
foreach ($leads as &$lead) {
foreach ($entry_meta_data_rows as $entry_meta_data_row) {
if ($entry_meta_data_row->lead_id == $lead["id"]) {
foreach ($meta_keys as $meta_key) {
$lead[$meta_key] = $entry_meta_data_row->{$meta_key};
}
}
}
}
return $leads;
}
示例4: start_export
public static function start_export($form)
{
$form_id = $form["id"];
$fields = $_POST["export_field"];
$start_date = $_POST["export_date_start"];
$end_date = $_POST["export_date_end"];
//adding default fields
array_push($form["fields"], array("id" => "id", "label" => __("Entry Id", "gravityforms")));
array_push($form["fields"], array("id" => "date_created", "label" => __("Entry Date", "gravityforms")));
array_push($form["fields"], array("id" => "ip", "label" => __("User IP", "gravityforms")));
array_push($form["fields"], array("id" => "source_url", "label" => __("Source Url", "gravityforms")));
array_push($form["fields"], array("id" => "payment_status", "label" => __("Payment Status", "gravityforms")));
array_push($form["fields"], array("id" => "payment_date", "label" => __("Payment Date", "gravityforms")));
array_push($form["fields"], array("id" => "transaction_id", "label" => __("Transaction Id", "gravityforms")));
$entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
$page_size = 200;
$offset = 0;
//Adding BOM marker for UTF-8
$lines = chr(239) . chr(187) . chr(191);
//writing header
foreach ($fields as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$value = '"' . str_replace('"', '""', GFCommon::get_label($field, $field_id)) . '"';
$lines .= "{$value},";
}
$lines = substr($lines, 0, strlen($lines) - 1) . "\n";
//paging through results for memory issues
while ($entry_count > 0) {
$leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
foreach ($leads as $lead) {
foreach ($fields as $field_id) {
$long_text = "";
if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH) {
$long_text = RGFormsModel::get_field_value_long($lead["id"], $field_id);
}
$value = !empty($long_text) ? $long_text : $lead[$field_id];
$lines .= '"' . str_replace('"', '""', $value) . '",';
}
$lines = substr($lines, 0, strlen($lines) - 1);
$lines .= "\n";
}
$offset += $page_size;
$entry_count -= $page_size;
if (!seems_utf8($lines)) {
$lines = utf8_encode($lines);
}
echo $lines;
$lines = "";
}
}
示例5: start_export
public static function start_export($form)
{
$form_id = $form["id"];
$fields = $_POST["export_field"];
$start_date = $_POST["export_date_start"];
$end_date = $_POST["export_date_end"];
//adding default fields
array_push($form["fields"], array("id" => "created_by", "label" => __("Created By (User Id)", "gravityforms")));
array_push($form["fields"], array("id" => "id", "label" => __("Entry Id", "gravityforms")));
array_push($form["fields"], array("id" => "date_created", "label" => __("Entry Date", "gravityforms")));
array_push($form["fields"], array("id" => "source_url", "label" => __("Source Url", "gravityforms")));
array_push($form["fields"], array("id" => "transaction_id", "label" => __("Transaction Id", "gravityforms")));
array_push($form["fields"], array("id" => "payment_amount", "label" => __("Payment Amount", "gravityforms")));
array_push($form["fields"], array("id" => "payment_date", "label" => __("Payment Date", "gravityforms")));
array_push($form["fields"], array("id" => "payment_status", "label" => __("Payment Status", "gravityforms")));
array_push($form["fields"], array("id" => "post_id", "label" => __("Post Id", "gravityforms")));
array_push($form["fields"], array("id" => "user_agent", "label" => __("User Agent", "gravityforms")));
array_push($form["fields"], array("id" => "ip", "label" => __("User IP", "gravityforms")));
$entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
$page_size = 200;
$offset = 0;
//Adding BOM marker for UTF-8
$lines = chr(239) . chr(187) . chr(191);
// set the separater
$separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
$field_rows = self::get_field_row_count($form, $fields, $entry_count);
//writing header
foreach ($fields as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
$subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
if ($subrow_count == 0) {
$lines .= '"' . $value . '"' . $separator;
} else {
for ($i = 1; $i <= $subrow_count; $i++) {
$lines .= '"' . $value . " " . $i . '"' . $separator;
}
}
}
$lines = substr($lines, 0, strlen($lines) - 1) . "\n";
//paging through results for memory issues
while ($entry_count > 0) {
$leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
foreach ($leads as $lead) {
foreach ($fields as $field_id) {
switch ($field_id) {
case "date_created":
$lead_gmt_time = mysql2date("G", $lead["date_created"]);
$lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
$value = date_i18n("Y-m-d H:i:s", $lead_local_time);
break;
default:
$long_text = "";
if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH - 10) {
$long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
}
$value = !empty($long_text) ? $long_text : $lead[$field_id];
break;
}
if (isset($field_rows[$field_id])) {
$list = empty($value) ? array() : unserialize($value);
foreach ($list as $row) {
$row_values = array_values($row);
$row_str = implode("|", $row_values);
$lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
}
//filling missing subrow columns (if any)
$missing_count = intval($field_rows[$field_id]) - count($list);
for ($i = 0; $i < $missing_count; $i++) {
$lines .= '""' . $separator;
}
} else {
$value = maybe_unserialize($value);
if (is_array($value)) {
$value = implode("|", $value);
}
$lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
}
}
$lines = substr($lines, 0, strlen($lines) - 1);
$lines .= "\n";
}
$offset += $page_size;
$entry_count -= $page_size;
if (!seems_utf8($lines)) {
$lines = utf8_encode($lines);
}
echo $lines;
$lines = "";
}
}
示例6: start_export
public static function start_export($form)
{
$form_id = $form["id"];
$fields = $_POST["export_field"];
$start_date = empty($_POST["export_date_start"]) ? "" : self::get_gmt_date($_POST["export_date_start"] . " 00:00");
$end_date = empty($_POST["export_date_end"]) ? "" : self::get_gmt_date($_POST["export_date_end"] . " 23:59:59");
GFCommon::log_debug("start date: {$start_date}");
GFCommon::log_debug("end date: {$end_date}");
$form = self::add_default_export_fields($form);
$entry_count = RGFormsModel::get_lead_count($form_id, "", null, null, $start_date, $end_date);
$page_size = 200;
$offset = 0;
//Adding BOM marker for UTF-8
$lines = chr(239) . chr(187) . chr(191);
// set the separater
$separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
$field_rows = self::get_field_row_count($form, $fields, $entry_count);
//writing header
foreach ($fields as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
$subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
if ($subrow_count == 0) {
$lines .= '"' . $value . '"' . $separator;
} else {
for ($i = 1; $i <= $subrow_count; $i++) {
$lines .= '"' . $value . " " . $i . '"' . $separator;
}
}
}
$lines = substr($lines, 0, strlen($lines) - 1) . "\n";
//paging through results for memory issues
while ($entry_count > 0) {
$leads = RGFormsModel::get_leads($form_id, "date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
foreach ($leads as $lead) {
foreach ($fields as $field_id) {
switch ($field_id) {
case "date_created":
$lead_gmt_time = mysql2date("G", $lead["date_created"]);
$lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
$value = date_i18n("Y-m-d H:i:s", $lead_local_time, true);
break;
default:
$long_text = "";
if (strlen($lead[$field_id]) >= GFORMS_MAX_FIELD_LENGTH - 10) {
$long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
}
$value = !empty($long_text) ? $long_text : $lead[$field_id];
$value = apply_filters("gform_export_field_value", $value, $form_id, $field_id, $lead);
break;
}
if (isset($field_rows[$field_id])) {
$list = empty($value) ? array() : unserialize($value);
foreach ($list as $row) {
$row_values = array_values($row);
$row_str = implode("|", $row_values);
$lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
}
//filling missing subrow columns (if any)
$missing_count = intval($field_rows[$field_id]) - count($list);
for ($i = 0; $i < $missing_count; $i++) {
$lines .= '""' . $separator;
}
} else {
$value = maybe_unserialize($value);
if (is_array($value)) {
$value = implode("|", $value);
}
$lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
}
}
$lines = substr($lines, 0, strlen($lines) - 1);
$lines .= "\n";
}
$offset += $page_size;
$entry_count -= $page_size;
if (!seems_utf8($lines)) {
$lines = utf8_encode($lines);
}
echo $lines;
$lines = "";
}
}
示例7: start_export
public static function start_export($form)
{
$form_id = $form["id"];
$fields = $_POST["export_field"];
$start_date = empty($_POST["export_date_start"]) ? "" : self::get_gmt_date($_POST["export_date_start"] . " 00:00:00");
$end_date = empty($_POST["export_date_end"]) ? "" : self::get_gmt_date($_POST["export_date_end"] . " 23:59:59");
$search_criteria["status"] = "active";
$search_criteria["field_filters"] = GFCommon::get_field_filters_from_post();
if (!empty($start_date)) {
$search_criteria["start_date"] = $start_date;
}
if (!empty($end_date)) {
$search_criteria["end_date"] = $end_date;
}
$sorting = array('key' => "date_created", 'direction' => "DESC", "type" => "info");
GFCommon::log_debug("start date: {$start_date}");
GFCommon::log_debug("end date: {$end_date}");
$form = self::add_default_export_fields($form);
$entry_count = GFAPI::count_entries($form_id, $search_criteria);
$page_size = 100;
$offset = 0;
//Adding BOM marker for UTF-8
$lines = chr(239) . chr(187) . chr(191);
// set the separater
$separator = apply_filters('gform_export_separator_' . $form_id, apply_filters('gform_export_separator', ',', $form_id), $form_id);
$field_rows = self::get_field_row_count($form, $fields, $entry_count);
//writing header
$headers = array();
foreach ($fields as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$value = str_replace('"', '""', GFCommon::get_label($field, $field_id));
GFCommon::log_debug("Header for field ID {$field_id}: {$value}");
$headers[$field_id] = $value;
$subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
if ($subrow_count == 0) {
$lines .= '"' . $value . '"' . $separator;
} else {
for ($i = 1; $i <= $subrow_count; $i++) {
$lines .= '"' . $value . " " . $i . '"' . $separator;
}
}
GFCommon::log_debug("Lines: {$lines}");
}
$lines = substr($lines, 0, strlen($lines) - 1) . "\n";
//paging through results for memory issues
while ($entry_count > 0) {
//$leads = RGFormsModel::get_leads($form_id,"date_created", "DESC", "", $offset, $page_size, null, null, false, $start_date, $end_date);
$paging = array('offset' => $offset, 'page_size' => $page_size);
$leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
$leads = apply_filters("gform_leads_before_export_{$form_id}", apply_filters("gform_leads_before_export", $leads, $form, $paging), $form, $paging);
foreach ($leads as $lead) {
foreach ($fields as $field_id) {
switch ($field_id) {
case "date_created":
$lead_gmt_time = mysql2date("G", $lead["date_created"]);
$lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
$value = date_i18n("Y-m-d H:i:s", $lead_local_time, true);
break;
default:
$long_text = "";
if (strlen(rgar($lead, $field_id)) >= GFORMS_MAX_FIELD_LENGTH - 10) {
$long_text = RGFormsModel::get_field_value_long($lead, $field_id, $form);
}
$value = !empty($long_text) ? $long_text : rgar($lead, $field_id);
$field = RGFormsModel::get_field($form, $field_id);
$input_type = RGFormsModel::get_input_type($field);
if ($input_type == "checkbox") {
$value = GFFormsModel::is_checkbox_checked($field_id, $headers[$field_id], $lead, $form);
if ($value === false) {
$value = "";
}
} else {
if ($input_type == "fileupload" && rgar($field, "multipleFiles")) {
$value = !empty($value) ? implode(" , ", json_decode($value, true)) : "";
}
}
$value = apply_filters("gform_export_field_value", $value, $form_id, $field_id, $lead);
GFCommon::log_debug("Value for field ID {$field_id}: {$value}");
break;
}
if (isset($field_rows[$field_id])) {
$list = empty($value) ? array() : unserialize($value);
foreach ($list as $row) {
$row_values = array_values($row);
$row_str = implode("|", $row_values);
$lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
}
//filling missing subrow columns (if any)
$missing_count = intval($field_rows[$field_id]) - count($list);
for ($i = 0; $i < $missing_count; $i++) {
$lines .= '""' . $separator;
}
} else {
$value = maybe_unserialize($value);
if (is_array($value)) {
$value = implode("|", $value);
}
$lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
}
}
//.........这里部分代码省略.........
示例8: build_lead_array
private static function build_lead_array($results, $use_long_values = false)
{
$leads = array();
$lead = array();
if (is_array($results) && sizeof($results) > 0) {
$lead = array("id" => $results[0]->id, "form_id" => $results[0]->form_id, "date_created" => $results[0]->date_created, "is_starred" => intval($results[0]->is_starred), "is_read" => intval($results[0]->is_read), "ip" => $results[0]->ip, "source_url" => $results[0]->source_url, "post_id" => $results[0]->post_id, "currency" => $results[0]->currency, "payment_status" => $results[0]->payment_status, "payment_date" => $results[0]->payment_date, "transaction_id" => $results[0]->transaction_id, "payment_amount" => $results[0]->payment_amount, "is_fulfilled" => $results[0]->is_fulfilled, "created_by" => $results[0]->created_by, "transaction_type" => $results[0]->transaction_type);
}
$prev_lead_id = 0;
foreach ($results as $result) {
if ($prev_lead_id != $result->id && $prev_lead_id > 0) {
array_push($leads, $lead);
$lead = array("id" => $result->id, "form_id" => $result->form_id, "date_created" => $result->date_created, "is_starred" => intval($result->is_starred), "is_read" => intval($result->is_read), "ip" => $result->ip, "source_url" => $result->source_url, "post_id" => $result->post_id, "currency" => $result->currency, "payment_status" => $result->payment_status, "payment_date" => $result->payment_date, "transaction_id" => $result->transaction_id, "payment_amount" => $result->payment_amount, "is_fulfilled" => $result->is_fulfilled, "created_by" => $result->created_by, "transaction_type" => $result->transaction_type);
}
$field_value = $result->value;
//using long values if specified
if ($use_long_values && strlen($field_value) >= GFORMS_MAX_FIELD_LENGTH) {
$long_text = RGFormsModel::get_field_value_long($lead["id"], $result->field_number);
$field_value = !empty($long_text) ? $long_text : $field_value;
}
$lead[$result->field_number] = $field_value;
$prev_lead_id = $result->id;
}
//adding last lead.
if (sizeof($lead) > 0) {
array_push($leads, $lead);
}
return $leads;
}
示例9: get_gf_field_value_long
function get_gf_field_value_long($leadid, $fieldid, $form = array(), $apply_filter = true)
{
return RGFormsModel::get_field_value_long($leadid, $fieldid, $form, $apply_filter);
}