当前位置: 首页>>代码示例>>PHP>>正文


PHP RGFormsModel::get_temp_filename方法代码示例

本文整理汇总了PHP中RGFormsModel::get_temp_filename方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_temp_filename方法的具体用法?PHP RGFormsModel::get_temp_filename怎么用?PHP RGFormsModel::get_temp_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RGFormsModel的用法示例。


在下文中一共展示了RGFormsModel::get_temp_filename方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_field_input

 public function get_field_input($form, $value = '', $entry = null)
 {
     $form_id = $form['id'];
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $is_admin = $is_entry_detail || $is_form_editor;
     $id = (int) $this->id;
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $value = esc_attr($value);
     $size = $this->size;
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $class = $size . $class_suffix;
     $disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
     $title = esc_attr(rgget($this->id . '.1', $value));
     $caption = esc_attr(rgget($this->id . '.4', $value));
     $description = esc_attr(rgget($this->id . '.7', $value));
     //hidding meta fields for admin
     $hidden_style = "style='display:none;'";
     $title_style = !$this->displayTitle && $is_admin ? $hidden_style : '';
     $caption_style = !$this->displayCaption && $is_admin ? $hidden_style : '';
     $description_style = !$this->displayDescription && $is_admin ? $hidden_style : '';
     $file_label_style = $is_admin && !($this->displayTitle || $this->displayCaption || $this->displayDescription) ? $hidden_style : '';
     $hidden_class = $preview = '';
     $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
     if ($file_info) {
         $hidden_class = ' gform_hidden';
         $file_label_style = $hidden_style;
         $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info['uploaded_filename']) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __('delete', 'gravityforms') . '</a></span>';
     }
     //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
     $file_label = $is_admin || $this->displayTitle || $this->displayCaption || $this->displayDescription ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters('gform_postimage_file', __('File', 'gravityforms'), $form_id), $form_id) . '</label>' : '';
     $tabindex = $this->get_tabindex();
     $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
     $tabindex = $this->get_tabindex();
     $title_field = $this->displayTitle || $is_admin ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters('gform_postimage_title', __('Title', 'gravityforms'), $form_id), $form_id) . '</label></span>', $id, $field_id, $title, $disabled_text, $field_id) : '';
     $tabindex = $this->get_tabindex();
     $caption_field = $this->displayCaption || $is_admin ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s_4' value='%s' {$tabindex} %s/><label for='%s_4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters('gform_postimage_caption', __('Caption', 'gravityforms'), $form_id), $form_id) . '</label></span>', $id, $field_id, $caption, $disabled_text, $field_id) : '';
     $tabindex = $this->get_tabindex();
     $description_field = $this->displayDescription || $is_admin ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s_7' value='%s' {$tabindex} %s/><label for='%s_7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters('gform_postimage_description', __('Description', 'gravityforms'), $form_id), $form_id) . '</label></span>', $id, $field_id, $description, $disabled_text, $field_id) : '';
     return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . '</div>';
 }
开发者ID:healthcommcore,项目名称:osnap,代码行数:41,代码来源:class-gf-field-post-image.php

示例2: load_save

 public function load_save($form, $page, $source)
 {
     //print_r($form);
     $target_path = RGFormsModel::get_upload_path($form["id"]) . "/tmp/";
     $str_start = strpos($target_path, '/wp-content/');
     $gform = new DevonSample\GFormManager();
     $gform->develop();
     $path = substr($target_path, $str_start);
     if (isset($form['fields'])) {
         foreach ($form['fields'] as $field) {
             if (isset($field['type']) && $field['type'] == 'fileupload') {
                 $input_name = 'input_' . $field['id'];
                 $key = isset($field['adminLabel']) && $field['adminLabel'] != "" ? $field['adminLabel'] : strtolower($field['label']);
                 $key = $gform->formatAsKey($key);
                 $file = RGFormsModel::get_temp_filename($form["id"], $input_name);
                 if ($file["temp_filename"] && file_exists($target_path . $file["temp_filename"])) {
                     $gform->field($key, $path . $file["temp_filename"]);
                 }
             }
         }
         $gform->snapshot();
     }
 }
开发者ID:bluefission,项目名称:store_gform_data,代码行数:23,代码来源:pluginsample.php

示例3: get_field_input

 public function get_field_input($form, $value = '', $entry = null)
 {
     $lead_id = absint(rgar($entry, 'id'));
     $form_id = absint($form['id']);
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $id = absint($this->id);
     $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
     $size = $this->size;
     $class_suffix = $is_entry_detail ? '_admin' : '';
     $class = $size . $class_suffix;
     $disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
     $tabindex = $this->get_tabindex();
     $multiple_files = $this->multipleFiles;
     $file_list_id = 'gform_preview_' . $form_id . '_' . $id;
     $is_entry_detail = $this->is_entry_detail();
     $is_form_editor = $this->is_form_editor();
     $is_admin = $is_entry_detail || $is_form_editor;
     $max_upload_size = !$is_admin && $this->maxFileSize > 0 ? $this->maxFileSize * 1048576 : wp_max_upload_size();
     $allowed_extensions = !empty($this->allowedExtensions) ? join(',', GFCommon::clean_extensions(explode(',', strtolower($this->allowedExtensions)))) : array();
     if (!empty($allowed_extensions)) {
         $extensions_message = esc_attr(sprintf(__('Accepted file types: %s.', 'gravityforms'), str_replace(',', ', ', $allowed_extensions)));
     } else {
         $extensions_message = '';
     }
     if ($multiple_files) {
         $upload_action_url = trailingslashit(site_url()) . '?gf_page=' . GFCommon::get_upload_page_slug();
         $max_files = $this->maxFiles > 0 ? $this->maxFiles : 0;
         $browse_button_id = 'gform_browse_button_' . $form_id . '_' . $id;
         $container_id = 'gform_multifile_upload_' . $form_id . '_' . $id;
         $drag_drop_id = 'gform_drag_drop_area_' . $form_id . '_' . $id;
         $messages_id = "gform_multifile_messages_{$form_id}_{$id}";
         if (empty($allowed_extensions)) {
             $allowed_extensions = '*';
         }
         $disallowed_extensions = GFCommon::get_disallowed_file_extensions();
         if (defined('DOING_AJAX') && DOING_AJAX && 'rg_change_input_type' === rgpost('action')) {
             $plupload_init = array();
         } else {
             $plupload_init = array('runtimes' => 'html5,flash,html4', 'browse_button' => $browse_button_id, 'container' => $container_id, 'drop_element' => $drag_drop_id, 'filelist' => $file_list_id, 'unique_names' => true, 'file_data_name' => 'file', 'url' => $upload_action_url, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array('mime_types' => array(array('title' => __('Allowed Files', 'gravityforms'), 'extensions' => $allowed_extensions)), 'max_file_size' => $max_upload_size . 'b'), 'multipart' => true, 'urlstream_upload' => false, 'multipart_params' => array('form_id' => $form_id, 'field_id' => $id), 'gf_vars' => array('max_files' => $max_files, 'message_id' => $messages_id, 'disallowed_extensions' => $disallowed_extensions));
             if (rgar($form, 'requireLogin')) {
                 $plupload_init['multipart_params']['_gform_file_upload_nonce_' . $form_id] = wp_create_nonce('gform_file_upload_' . $form_id, '_gform_file_upload_nonce_' . $form_id);
             }
             // plupload 2 was introduced in WordPress 3.9. Plupload 1 accepts a slightly different init array.
             if (version_compare(get_bloginfo('version'), '3.9-RC1', '<')) {
                 $plupload_init['max_file_size'] = $max_upload_size . 'b';
                 $plupload_init['filters'] = array(array('title' => __('Allowed Files', 'gravityforms'), 'extensions' => $allowed_extensions));
             }
         }
         $plupload_init = gf_apply_filters('gform_plupload_settings', $form_id, $plupload_init, $form_id, $this);
         $drop_files_here_text = esc_html__('Drop files here or', 'gravityforms');
         $select_files_text = esc_attr__('Select files', 'gravityforms');
         $plupload_init_json = htmlspecialchars(json_encode($plupload_init), ENT_QUOTES, 'UTF-8');
         $upload = "<div id='{$container_id}' data-settings='{$plupload_init_json}' class='gform_fileupload_multifile'>\n\t\t\t\t\t\t\t\t\t\t<div id='{$drag_drop_id}' class='gform_drop_area'>\n\t\t\t\t\t\t\t\t\t\t\t<span class='gform_drop_instructions'>{$drop_files_here_text} </span>\n\t\t\t\t\t\t\t\t\t\t\t<input id='{$browse_button_id}' type='button' value='{$select_files_text}' class='button gform_button_select_files' aria-describedby='extensions_message' {$tabindex} />\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>";
         if (!$is_admin) {
             $upload .= "<span id='extensions_message' class='screen-reader-text'>{$extensions_message}</span>";
             $upload .= "<div class='validation_message'>\n\t\t\t\t\t\t\t\t<ul id='{$messages_id}'>\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</div>";
         }
         if ($is_entry_detail) {
             $upload .= sprintf('<input type="hidden" name="input_%d" value=\'%s\' />', $id, esc_attr($value));
         }
     } else {
         $upload = '';
         if ($max_upload_size <= 2047 * 1048576) {
             //  MAX_FILE_SIZE > 2048MB fails. The file size is checked anyway once uploaded, so it's not necessary.
             $upload = sprintf("<input type='hidden' name='MAX_FILE_SIZE' value='%d' />", $max_upload_size);
         }
         $upload .= sprintf("<input name='input_%d' id='%s' type='file' class='%s' aria-describedby='extensions_message' {$tabindex} %s/>", $id, $field_id, esc_attr($class), $disabled_text);
         if (!$is_admin) {
             $upload .= "<span id='extensions_message' class='screen-reader-text'>{$extensions_message}</span>";
         }
     }
     if ($is_entry_detail && !empty($value)) {
         // edit entry
         $file_urls = $multiple_files ? json_decode($value) : array($value);
         $upload_display = $multiple_files ? '' : "style='display:none'";
         $preview = "<div id='upload_{$id}' {$upload_display}>{$upload}</div>";
         $preview .= sprintf("<div id='%s'></div>", $file_list_id);
         $preview .= sprintf("<div id='preview_existing_files_%d'>", $id);
         foreach ($file_urls as $file_index => $file_url) {
             if (GFCommon::is_ssl() && strpos($file_url, 'http:') !== false) {
                 $file_url = str_replace('http:', 'https:', $file_url);
             }
             $download_file_text = esc_attr__('Download file', 'gravityforms');
             $delete_file_text = esc_attr__('Delete file', 'gravityforms');
             $file_index = intval($file_index);
             $file_url = esc_attr($file_url);
             $display_file_url = GFCommon::truncate_url($file_url);
             $download_button_url = GFCommon::get_base_url() . '/images/download.png';
             $delete_button_url = GFCommon::get_base_url() . '/images/delete.png';
             $preview .= "<div id='preview_file_{$file_index}' class='ginput_preview'>\n\t\t\t\t\t\t\t\t<a href='{$file_url}' target='_blank' alt='{$file_url}' title='{$file_url}'>{$display_file_url}</a>\n\t\t\t\t\t\t\t\t<a href='{$file_url}' target='_blank' alt='{$download_file_text}' title='{$download_file_text}'>\n\t\t\t\t\t\t\t\t<img src='{$download_button_url}' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='{$delete_file_text}' title='{$delete_file_text}' onclick='DeleteFile({$lead_id},{$id},this);' ><img src='{$delete_button_url}' style='margin-left:10px;'/></a>\n\t\t\t\t\t\t\t</div>";
         }
         $preview .= '</div>';
         return $preview;
     } else {
         $input_name = "input_{$id}";
         $uploaded_files = isset(GFFormsModel::$uploaded_files[$form_id][$input_name]) ? GFFormsModel::$uploaded_files[$form_id][$input_name] : array();
         $file_infos = $multiple_files ? $uploaded_files : RGFormsModel::get_temp_filename($form_id, $input_name);
         if (!empty($file_infos)) {
             $preview = sprintf("<div id='%s'>", $file_list_id);
//.........这里部分代码省略.........
开发者ID:wesleykepke,项目名称:ARIA,代码行数:101,代码来源:class-gf-field-fileupload.php

示例4: is_empty

 public static function is_empty($field, $form_id = 0)
 {
     switch (RGFormsModel::get_input_type($field)) {
         case "post_image":
         case "fileupload":
             $input_name = "input_" . $field["id"];
             $file_info = RGFormsModel::get_temp_filename($form_id, $input_name);
             return !$file_info && empty($_FILES[$input_name]['name']);
         case "list":
             $value = rgpost("input_" . $field["id"]);
             if (is_array($value)) {
                 //empty if all inputs are empty (for inputs with the same name)
                 foreach ($value as $input) {
                     if (strlen(trim($input)) > 0) {
                         return false;
                     }
                 }
             }
             return true;
         case 'singleproduct':
             $value = rgpost("input_" . $field["id"]);
             $quantity_id = $field["id"] . ".3";
             $quantity = rgpost($quantity_id, $value);
     }
     if (is_array($field["inputs"])) {
         foreach ($field["inputs"] as $input) {
             $value = rgpost("input_" . str_replace('.', '_', $input["id"]));
             if (is_array($value) && !empty($value)) {
                 return false;
             }
             $strlen = strlen(trim($value));
             if (!is_array($value) && strlen(trim($value)) > 0) {
                 return false;
             }
         }
         return true;
     } else {
         $value = rgpost("input_" . $field["id"]);
         if (is_array($value)) {
             //empty if any of the inputs are empty (for inputs with the same name)
             foreach ($value as $input) {
                 if (strlen(trim($input)) <= 0) {
                     return true;
                 }
             }
             return false;
         } else {
             if ($field["enablePrice"]) {
                 list($label, $price) = explode("|", $value);
                 $is_empty = strlen(trim($price)) <= 0;
                 return $is_empty;
             } else {
                 $is_empty = strlen(trim($value)) <= 0 || $field["type"] == "post_category" && $value < 0;
                 return $is_empty;
             }
         }
     }
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:58,代码来源:form_display.php

示例5: upload_files

 private static function upload_files($form, $files)
 {
     $form_upload_path = GFFormsModel::get_upload_path($form['id']);
     //Creating temp folder if it does not exist
     $target_path = $form_upload_path . '/tmp/';
     wp_mkdir_p($target_path);
     GFCommon::recursive_add_index_file($form_upload_path);
     foreach ($form['fields'] as $field) {
         $input_name = "input_{$field->id}";
         //skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
         $input_type = RGFormsModel::get_input_type($field);
         if (!in_array($input_type, array('fileupload', 'post_image')) || $field->multipleFiles) {
             continue;
         }
         if ($field->failed_validation || empty($_FILES[$input_name]['name'])) {
             GFCommon::log_debug("GFFormDisplay::upload_files(): Skipping field: {$field->label}({$field->id} - {$field->type}).");
             continue;
         }
         $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
         GFCommon::log_debug('GFFormDisplay::upload_files(): Temp file info: ' . print_r($file_info, true));
         if ($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info['temp_filename'])) {
             GFFormsModel::set_permissions($target_path . $file_info['temp_filename']);
             $files[$input_name] = $file_info['uploaded_filename'];
             GFCommon::log_debug("GFFormDisplay::upload_files(): File uploaded successfully: {$file_info['uploaded_filename']}");
         } else {
             GFCommon::log_error("GFFormDisplay::upload_files(): File could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info['temp_filename']);
         }
     }
     return $files;
 }
开发者ID:timk85,项目名称:DIT,代码行数:30,代码来源:form_display.php

示例6: upload_files

 private static function upload_files($form, $files)
 {
     $form_upload_path = GFFormsModel::get_upload_path($form['id']);
     GFCommon::log_debug("GFFormDisplay::upload_files(): Upload path {$form_upload_path}");
     //Creating temp folder if it does not exist
     $target_path = $form_upload_path . '/tmp/';
     wp_mkdir_p($target_path);
     GFCommon::recursive_add_index_file($form_upload_path);
     foreach ($form['fields'] as $field) {
         $input_name = "input_{$field->id}";
         //skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
         $input_type = RGFormsModel::get_input_type($field);
         if (!in_array($input_type, array('fileupload', 'post_image')) || $field->multipleFiles) {
             continue;
         }
         /*if ( $field->failed_validation || empty( $_FILES[ $input_name ]['name'] ) ) {
         			GFCommon::log_debug( "GFFormDisplay::upload_files(): Skipping field: {$field->label}({$field->id} - {$field->type})." );
         			continue;
         		}*/
         if ($field->failed_validation) {
             GFCommon::log_debug("GFFormDisplay::upload_files(): Skipping field because it failed validation: {$field->label}({$field->id} - {$field->type}).");
             continue;
         }
         if (empty($_FILES[$input_name]['name'])) {
             GFCommon::log_debug("GFFormDisplay::upload_files(): Skipping field because " . $_FILES[$input_name]['name'] . " could not be found: {$field->label}({$field->id} - {$field->type}).");
             continue;
         }
         $file_name = $_FILES[$input_name]['name'];
         if (GFCommon::file_name_has_disallowed_extension($file_name)) {
             GFCommon::log_debug(__METHOD__ . "(): Illegal file extension: {$file_name}");
             continue;
         }
         $allowed_extensions = !empty($field->allowedExtensions) ? GFCommon::clean_extensions(explode(',', strtolower($field->allowedExtensions))) : array();
         if (!empty($allowed_extensions)) {
             if (!GFCommon::match_file_extension($file_name, $allowed_extensions)) {
                 GFCommon::log_debug(__METHOD__ . "(): The uploaded file type is not allowed: {$file_name}");
                 continue;
             }
         }
         /**
          * Allows the disabling of file upload whitelisting
          *
          * @param bool false Set to 'true' to disable whitelisting.  Defaults to 'false'.
          */
         $whitelisting_disabled = apply_filters('gform_file_upload_whitelisting_disabled', false);
         if (empty($allowed_extensions) && !$whitelisting_disabled) {
             // Whitelist the file type
             $valid_file_name = GFCommon::check_type_and_ext($_FILES[$input_name], $file_name);
             if (is_wp_error($valid_file_name)) {
                 GFCommon::log_debug(__METHOD__ . "(): The uploaded file type is not allowed: {$file_name}");
                 continue;
             }
         }
         $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
         GFCommon::log_debug('GFFormDisplay::upload_files(): Temp file info: ' . print_r($file_info, true));
         if ($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info['temp_filename'])) {
             GFFormsModel::set_permissions($target_path . $file_info['temp_filename']);
             $files[$input_name] = $file_info['uploaded_filename'];
             GFCommon::log_debug("GFFormDisplay::upload_files(): File uploaded successfully: {$file_info['uploaded_filename']}");
         } else {
             GFCommon::log_error("GFFormDisplay::upload_files(): File could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info['temp_filename']);
         }
     }
     return $files;
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:65,代码来源:form_display.php

示例7: is_new_file_upload

 public static function is_new_file_upload($form_id, $input_name)
 {
     $file_info = RGFormsModel::get_temp_filename($form_id, $input_name);
     $temp_filepath = RGFormsModel::get_upload_path($form_id) . "/tmp/" . $file_info["temp_filename"];
     // check if file has already been uploaded by previous step
     if ($file_info && file_exists($temp_filepath)) {
         return true;
     } else {
         if (!empty($_FILES[$input_name]["name"])) {
             return true;
         }
     }
     return false;
 }
开发者ID:Inteleck,项目名称:hwc,代码行数:14,代码来源:userregistration.php

示例8: preview_image_display

 public static function preview_image_display($field, $form, $value)
 {
     // need to get the tmp $file_info to retrieve real uploaded filename, otherwise will display ugly tmp name
     $input_name = "input_" . str_replace('.', '_', $field['id']);
     $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
     $file_path = $value;
     if (!empty($file_path)) {
         $file_path = esc_attr(str_replace(" ", "%20", $file_path));
         $value = "<a href='{$file_path}' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $file_info['uploaded_filename'] . "</a>";
     }
     return $value;
 }
开发者ID:quinntron,项目名称:tmad,代码行数:12,代码来源:functions.php

示例9: get_field_input


//.........这里部分代码省略.........
                 }
                 if (rgget("categoryInitialItemEnabled", $field)) {
                     $args["show_option_none"] = empty($field["categoryInitialItem"]) ? " " : $field["categoryInitialItem"];
                 }
                 return "<div class='ginput_container'>" . wp_dropdown_categories($args) . "</div>";
             } else {
                 $tabindex = self::get_tabindex();
                 if (is_array(rgar($field, "choices"))) {
                     usort($field["choices"], create_function('$a,$b', 'return strcmp($a["text"], $b["text"]);'));
                 }
                 $choices = self::get_select_choices($field, $value);
                 //Adding first option
                 if (rgget("categoryInitialItemEnabled", $field)) {
                     $selected = empty($value) ? "selected='selected'" : "";
                     $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                 }
                 return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
             }
             break;
         case "post_image":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $title = esc_attr(rgget($field["id"] . ".1", $value));
             $caption = esc_attr(rgget($field["id"] . ".4", $value));
             $description = esc_attr(rgget($field["id"] . ".7", $value));
             //hidding meta fields for admin
             $hidden_style = "style='display:none;'";
             $title_style = !rgget("displayTitle", $field) && IS_ADMIN ? $hidden_style : "";
             $caption_style = !rgget("displayCaption", $field) && IS_ADMIN ? $hidden_style : "";
             $description_style = !rgget("displayDescription", $field) && IS_ADMIN ? $hidden_style : "";
             $file_label_style = IS_ADMIN && !(rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field)) ? $hidden_style : "";
             $hidden_class = $preview = "";
             $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
             if ($file_info) {
                 $hidden_class = " gform_hidden";
                 $file_label_style = $hidden_style;
                 $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info["uploaded_filename"]) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
             }
             //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
             $file_label = IS_ADMIN || rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field) ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters("gform_postimage_file", __("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";
             $tabindex = self::get_tabindex();
             $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
             $tabindex = self::get_tabindex();
             $title_field = rgget("displayTitle", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters("gform_postimage_title", __("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $caption_field = rgget("displayCaption", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s_4' value='%s' {$tabindex} %s/><label for='%s_4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters("gform_postimage_caption", __("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $description_field = rgget("displayDescription", $field) || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s_7' value='%s' {$tabindex} %s/><label for='%s_7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters("gform_postimage_description", __("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";
             return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";
             break;
         case "multiselect":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $placeholder = rgar($field, "enableEnhancedUI") ? "data-placeholder='" . esc_attr(apply_filters("gform_multiselect_placeholder_{$form_id}", apply_filters("gform_multiselect_placeholder", __("Click to select...", "gravityforms"), $form_id), $form_id)) . "'" : "";
             $logic_event = self::get_logic_event($field, "keyup");
             $css_class = trim(esc_attr($class) . " gfield_select");
             $size = rgar($field, "multiSelectSize");
             if (empty($size)) {
                 $size = 7;
             }
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select multiple='multiple' {$placeholder} size='{$size}' name='input_%d[]' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
             break;
         case "select":
开发者ID:ipman3,项目名称:Mediassociates-wp,代码行数:67,代码来源:common.php

示例10: upload_files

    private static function upload_files($form, $files){

        //Creating temp folder if it does not exist
        $target_path = RGFormsModel::get_upload_path($form["id"]) . "/tmp/";
        wp_mkdir_p($target_path);

        foreach($form["fields"] as $field){
            $input_name = "input_{$field["id"]}";

            //skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
            $input_type = RGFormsModel::get_input_type($field);
            if(!in_array($input_type, array("fileupload", "post_image")) || $field["failed_validation"] || empty($_FILES[$input_name]["name"])){
                GFCommon::log_debug("upload_files() - skipping field: {$field["label"]}({$field["id"]} - {$field["type"]})");
                continue;
            }

            if(rgar($field,"multipleFiles"))
                continue;

            $file_info = RGFormsModel::get_temp_filename($form["id"], $input_name);
            GFCommon::log_debug("upload_files() - temp file info: " . print_r($file_info, true));

            if($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info["temp_filename"])){
                $files[$input_name] = $file_info["uploaded_filename"];
                GFCommon::log_debug("upload_files() - file uploaded successfully:  {$file_info["uploaded_filename"]}");
            }
            else{
                GFCommon::log_error("upload_files() - file could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info["temp_filename"]);
            }
        }

        return $files;
    }
开发者ID:bmontague,项目名称:sct,代码行数:33,代码来源:form_display.php

示例11: get_field_input


//.........这里部分代码省略.........
                 $args = array('echo' => 0, 'selected' => $selected, "class" => esc_attr($class) . " gfield_select", 'hide_empty' => 0, 'name' => "input_{$id}", 'orderby' => 'name', 'hierarchical' => true);
                 if (self::$tab_index > 0) {
                     $args["tab_index"] = self::$tab_index++;
                 }
                 if ($field["categoryInitialItemEnabled"]) {
                     $args["show_option_none"] = empty($field["categoryInitialItem"]) ? " " : $field["categoryInitialItem"];
                 }
                 return "<div class='ginput_container'>" . wp_dropdown_categories($args) . "</div>";
             } else {
                 $tabindex = self::get_tabindex();
                 $choices = self::get_select_choices($field, $value);
                 //Adding first option
                 if ($field["categoryInitialItemEnabled"]) {
                     $selected = empty($value) ? "selected='selected'" : "";
                     $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                 }
                 return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
             }
             break;
         case "post_image":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $title = esc_attr($value[$field["id"] . ".1"]);
             $caption = esc_attr($value[$field["id"] . ".4"]);
             $description = esc_attr($value[$field["id"] . ".7"]);
             //hidding meta fields for admin
             $hidden_style = "style='display:none;'";
             $title_style = !$field["displayTitle"] && IS_ADMIN ? $hidden_style : "";
             $caption_style = !$field["displayCaption"] && IS_ADMIN ? $hidden_style : "";
             $description_style = !$field["displayDescription"] && IS_ADMIN ? $hidden_style : "";
             $file_label_style = IS_ADMIN && !($field["displayTitle"] || $field["displayCaption"] || $field["displayDescription"]) ? $hidden_style : "";
             $hidden_class = "";
             $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
             if ($file_info) {
                 $hidden_class = " gform_hidden";
                 $file_label_style = $hidden_style;
                 $preview = "<span class='ginput_preview'><strong>{$file_info["uploaded_filename"]}</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
             }
             //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
             $file_label = IS_ADMIN || $field["displayTitle"] || $field["displayCaption"] || $field["displayDescription"] ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . apply_filters("gform_postimage_file_{$form_id}", apply_filters("gform_postimage_file", __("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";
             $tabindex = self::get_tabindex();
             $upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
             $tabindex = self::get_tabindex();
             $title_field = $field["displayTitle"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s.1' value='%s' {$tabindex} %s/><label for='%s.1'>" . apply_filters("gform_postimage_title_{$form_id}", apply_filters("gform_postimage_title", __("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $caption_field = $field["displayCaption"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s.4' value='%s' {$tabindex} %s/><label for='%s.4'>" . apply_filters("gform_postimage_caption_{$form_id}", apply_filters("gform_postimage_caption", __("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";
             $tabindex = self::get_tabindex();
             $description_field = $field["displayDescription"] || IS_ADMIN ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s.7' value='%s' {$tabindex} %s/><label for='%s.7'>" . apply_filters("gform_postimage_description_{$form_id}", apply_filters("gform_postimage_description", __("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";
             return "<div class='ginput_complex{$class_suffix} ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";
             break;
         case "select":
             if (!empty($post_link)) {
                 return $post_link;
             }
             $logic_event = empty($field["conditionalLogicFields"]) || IS_ADMIN ? "" : "onchange='gf_apply_rules(" . $field["formId"] . "," . GFCommon::json_encode($field["conditionalLogicFields"]) . ");'";
             $css_class = trim(esc_attr($class) . " gfield_select");
             $tabindex = self::get_tabindex();
             return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, $field_id, $css_class, $disabled_text, self::get_select_choices($field, $value));
         case "checkbox":
             return sprintf("<div class='ginput_container'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", $field_id, self::get_checkbox_choices($field, $value, $disabled_text));
         case "radio":
             if (!empty($post_link)) {
                 return $post_link;
             }
             return sprintf("<div class='ginput_container'><ul class='gfield_radio' id='%s'>%s</ul></div>", $field_id, self::get_radio_choices($field, $value, $disabled_text));
开发者ID:novuscory,项目名称:ACH,代码行数:67,代码来源:common.php

示例12: field_validation

 public function field_validation($valid, $value, $form, $field)
 {
     if (!empty($_FILES) && $valid['is_valid'] && in_array(RGFormsModel::get_input_type($field), array('fileupload', 'post_image'))) {
         $form_id = $form['id'];
         $input_name = 'input_' . $field['id'];
         $fileinfo = RGFormsModel::get_temp_filename($form_id, $input_name);
         $temp_filepath = RGFormsModel::get_upload_path($form_id) . "/tmp/" . $fileinfo["temp_filename"];
         if (isset($_FILES[$input_name]) && !empty($_FILES[$input_name])) {
             $bytes = $_FILES[$input_name]['size'];
             $dims = @getimagesize($_FILES[$input_name]['tmp_name']);
         } elseif (file_exists($temp_filepath)) {
             $bytes = filesize($temp_filepath);
             $dims = @getimagesize($temp_filepath);
         } else {
             return $valid;
         }
         //validate filesize
         if (isset($field['uprules_filesize_limit'])) {
             $multipliers = array('kb' => 1024, 'mb' => 1024 * 1024);
             $max_filesize_user = intval($field['uprules_filesize_limit']);
             $bytes_multiplier = $multipliers[$field['uprules_filesize_dim']];
             $max_filesize_bytes = $max_filesize_user * $bytes_multiplier;
         }
         if (isset($bytes) && $max_filesize_user > 0 && $max_filesize_bytes < $bytes) {
             $valid['is_valid'] = false;
             $valid['message'] = sprintf(__('Max file upload size (%s) exceeded.', 'gravityforms'), size_format($max_filesize_bytes, 2));
         }
         //validate image dimensions
         if ($valid['is_valid'] && is_array($dims) && isset($field['uprules_dims_ruletype']) && in_array($field['uprules_dims_ruletype'], array('exact', 'conditional'))) {
             list($up_width, $up_height) = $dims;
             $valid = self::validate_image_dimensions($field, $up_width, $up_height);
         }
         if (!$valid['is_valid']) {
             unset(RGFormsModel::$uploaded_files[$form_id][$input_name], $_FILES[$input_name]);
         }
     }
     return $valid;
 }
开发者ID:hansstam,项目名称:makerfaire,代码行数:38,代码来源:gforms-uploadrules.php

示例13: get_field_input


//.........这里部分代码省略.........
                else{
                    $tabindex = self::get_tabindex();
                    if(is_array(rgar($field, "choices")))
                        usort($field["choices"], create_function('$a,$b', 'return strcmp($a["text"], $b["text"]);'));

                    $choices = self::get_select_choices($field, $value);

                    //Adding first option
                    if(rgget("categoryInitialItemEnabled", $field)){
                        $selected = empty($value) ? "selected='selected'" : "";
                        $choices = "<option value='-1' {$selected}>{$field["categoryInitialItem"]}</option>" . $choices;
                    }

                    return sprintf("<div class='ginput_container'><select name='input_%d' id='%s' class='%s gfield_select' {$tabindex} %s>%s</select></div>", $id, $field_id, esc_attr($class), $disabled_text, $choices);
                }
            break;

            case "post_image" :
                if(!empty($post_link))
                    return $post_link;

                $title = esc_attr(rgget($field["id"] . ".1", $value));
                $caption = esc_attr(rgget($field["id"] . ".4", $value));
                $description = esc_attr(rgget($field["id"] . ".7", $value));

                //hidding meta fields for admin
                $hidden_style = "style='display:none;'";
                $title_style = !rgget("displayTitle", $field) && IS_ADMIN ? $hidden_style : "";
                $caption_style = !rgget("displayCaption", $field) && IS_ADMIN ? $hidden_style : "";
                $description_style = !rgget("displayDescription", $field) && IS_ADMIN ? $hidden_style : "";
                $file_label_style = IS_ADMIN && !(rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field)) ? $hidden_style : "";

                $hidden_class = $preview = "";
                $file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
                if($file_info){
                    $hidden_class = " gform_hidden";
                    $file_label_style = $hidden_style;
                    $preview = "<span class='ginput_preview'><strong>" . esc_html($file_info["uploaded_filename"]) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __("delete", "gravityforms") . "</a></span>";
                }

                //in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
                $file_label = (IS_ADMIN || rgget("displayTitle", $field) || rgget("displayCaption", $field) || rgget("displayDescription", $field)) ? "<label for='$field_id' class='ginput_post_image_file' $file_label_style>" . apply_filters("gform_postimage_file_{$form_id}",apply_filters("gform_postimage_file",__("File", "gravityforms"), $form_id), $form_id) . "</label>" : "";

                $tabindex = self::get_tabindex();
                $upload = sprintf("<span class='ginput_full$class_suffix'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' $tabindex %s/>$file_label</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);

                $tabindex = self::get_tabindex();
                $title_field = rgget("displayTitle", $field) || IS_ADMIN ? sprintf("<span class='ginput_full$class_suffix ginput_post_image_title' $title_style><input type='text' name='input_%d.1' id='%s_1' value='%s' $tabindex %s/><label for='%s_1'>" . apply_filters("gform_postimage_title_{$form_id}",apply_filters("gform_postimage_title",__("Title", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $title, $disabled_text, $field_id) : "";

                $tabindex = self::get_tabindex();
                $caption_field = rgget("displayCaption", $field) || IS_ADMIN ? sprintf("<span class='ginput_full$class_suffix ginput_post_image_caption' $caption_style><input type='text' name='input_%d.4' id='%s_4' value='%s' $tabindex %s/><label for='%s_4'>" . apply_filters("gform_postimage_caption_{$form_id}",apply_filters("gform_postimage_caption",__("Caption", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $caption, $disabled_text, $field_id) : "";

                $tabindex = self::get_tabindex();
                $description_field = rgget("displayDescription", $field) || IS_ADMIN? sprintf("<span class='ginput_full$class_suffix ginput_post_image_description' $description_style><input type='text' name='input_%d.7' id='%s_7' value='%s' $tabindex %s/><label for='%s_7'>" . apply_filters("gform_postimage_description_{$form_id}",apply_filters("gform_postimage_description",__("Description", "gravityforms"), $form_id), $form_id) . "</label></span>", $id, $field_id, $description, $disabled_text, $field_id) : "";

                return "<div class='ginput_complex$class_suffix ginput_container'>" . $upload . $title_field . $caption_field . $description_field . "</div>";

            break;

            case "multiselect" :
                if(!empty($post_link))
                    return $post_link;

                $placeholder = rgar($field, "enableEnhancedUI") ? "data-placeholder='" . esc_attr(apply_filters("gform_multiselect_placeholder_{$form_id}", apply_filters("gform_multiselect_placeholder", __("Click to select...", "gravityforms"), $form_id), $form_id)) . "'" : "";
                $logic_event = self::get_logic_event($field, "keyup");
                $css_class = trim(esc_attr($class) . " gfield_select");
开发者ID:bmontague,项目名称:sct,代码行数:67,代码来源:common.php


注:本文中的RGFormsModel::get_temp_filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。