コード例 #1
0
 /**
  * Export to CSV
  * @since 2.0.19
  */
 public static function csv($form_id = false, $search = '', $fid = '')
 {
     FrmAppHelper::permission_check('frm_view_entries');
     if (!$form_id) {
         $form_id = FrmAppHelper::get_param('form', '', 'get', 'sanitize_text_field');
         $search = FrmAppHelper::get_param(isset($_REQUEST['s']) ? 's' : 'search', '', 'get', 'sanitize_text_field');
         $fid = FrmAppHelper::get_param('fid', '', 'get', 'sanitize_text_field');
     }
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
         //Remove time limit to execute this function
         $mem_limit = str_replace('M', '', ini_get('memory_limit'));
         if ((int) $mem_limit < 256) {
             ini_set('memory_limit', '256M');
         }
     }
     global $wpdb;
     $form = FrmForm::getOne($form_id);
     $form_id = $form->id;
     $form_cols = self::get_fields_for_csv_export($form_id, $form);
     $item_id = FrmAppHelper::get_param('item_id', 0, 'get', 'sanitize_text_field');
     if (!empty($item_id)) {
         $item_id = explode(',', $item_id);
     }
     $query = array('form_id' => $form_id);
     if ($item_id) {
         $query['id'] = $item_id;
     }
     /**
      * Allows the query to be changed for fetching the entry ids to include in the export
      *
      * $query is the array of options to be filtered. It includes form_id, and maybe id (array of entry ids),
      * and the search query. This should return an array, but it can be handled as a string as well.
      */
     $query = apply_filters('frm_csv_where', $query, compact('form_id', 'search', 'fid', 'item_id'));
     $entry_ids = FrmDb::get_col($wpdb->prefix . 'frm_items it', $query);
     unset($query);
     if (empty($entry_ids)) {
         esc_html_e('There are no entries for that form.', 'formidable');
     } else {
         FrmCSVExportHelper::generate_csv(compact('form', 'entry_ids', 'form_cols'));
     }
     wp_die();
 }
コード例 #2
0
ファイル: import_form.php プロジェクト: tshdvs/GooseMobile
?>
                        </select>

                        <ul class="frm_hidden csv_opts export-filters">
                            <li>
                            <label for="csv_format"><?php 
_e('Format', 'formidable');
?>
:</label>
							<span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php 
esc_attr_e('If your CSV special characters are not working correctly, try a different formatting option.', 'formidable');
?>
"></span>
                            <select name="csv_format">
								<?php 
foreach (FrmCSVExportHelper::csv_format_options() as $format) {
    ?>
								<option value="<?php 
    echo esc_attr($format);
    ?>
"><?php 
    echo esc_html($format);
    ?>
</option>
								<?php 
}
?>
                            </select>
                            </li>

                            <li><label for="csv_col_sep"><?php 
コード例 #3
0
 private static function prepare_next_csv_rows($next_set)
 {
     // order by parent_item_id so children will be first
     $entries = FrmEntry::getAll(array('or' => 1, 'id' => $next_set, 'parent_item_id' => $next_set), ' ORDER BY parent_item_id DESC', '', true, false);
     foreach ($entries as $k => $entry) {
         self::$entry = $entry;
         unset($entry);
         if (self::$entry->form_id != self::$form_id) {
             self::add_repeat_field_values_to_csv($entries);
         } else {
             self::prepare_csv_row();
         }
     }
 }