public function display_field($field, $group_index = 1, $field_index = 1) { global $mf_domain; $field_style = ''; $imageThumbID = "img_thumb_" . $field['input_id']; if (!$field['input_value']) { $value = sprintf('%simages/noimage.jpg', MF_URL); $field_style = 'style="display:none;"'; } else { $MFthumb = MF_PATH . '/mf_front_end.php'; require_once $MFthumb; $value = aux_image($field['input_value'], "w=150&h=120&zc=1", 'image_alt'); // $value = sprintf("%s?src=%s%s&w=150&h=120&zc=1",PHPTHUMB,MF_FILES_URL,$field['input_value']); } $value = sprintf('<img src="%s" id="%s" />', $value, $imageThumbID); $out = '<div class="image_layout">'; $out .= '<div class="image_photo"><div class="image_wrap">'; $out .= $value; $out .= '</div>'; $out .= sprintf('<div id="photo_edit_link_%s" %s class="photo_edit_link">', $field['input_id'], $field_style); $out .= sprintf('<a href="%s" target="_blank" id="edit-%s" >%s</a> | ', MF_FILES_URL . $field['input_value'], $field['input_id'], __('View', $mf_domain)); $out .= sprintf('<a href="#remove" class="remove remove_photo_alt" alt="%s" id="remove-%s" >%s</a>', __('Are you sure?', $mf_domain), $field['input_id'], __('Delete', $mf_domain)); $out .= '</div>'; $out .= '</div>'; $out .= '<div class="image_input">'; $out .= '<div class="mf_custom_field">'; $out .= sprintf('<div id="response-%s" style="display:none;" ></div>', $field['input_id']); $out .= sprintf('<input type="hidden" value="%s" name="%s" id="%s" %s >', $field['input_value'], $field['input_name'], $field['input_id'], $field['input_validate']); $out .= '<input type="file" name="file" class="up_ajax" >'; $out .= '</div></div>'; $out .= '</div>'; return $out; }
public function display_field($field, $group_index = 1, $field_index = 1) { global $mf_domain; $field_style = ''; $imageThumbID = "img_thumb_" . $field['input_id']; $path_image_media = ''; $error = ''; if (!$field['input_value']) { $value = sprintf('%simages/noimage.jpg', MF_URL); $field_style = 'style="display:none;"'; } else { $MFFrontEnd = MF_PATH . '/mf_front_end.php'; require_once $MFFrontEnd; $info = wp_get_attachment_image_src($field['input_value'], 'original'); $path_image_media = $info[0]; $value = aux_image($path_image_media, "w=150&h=120&zc=1", 'image_media'); if (is_wp_error($value)) { $wp_error = $value; $field_style = 'style="display:none;"'; $value = sprintf('%simages/noimage.jpg', MF_URL); // $value = $path_image_media; $error = "<script type=\"text/javascript\">\n jQuery(document).ready(function(\$){\n show_error_image_field('" . $field['input_id'] . "','" . html_entity_decode($wp_error->get_error_message()) . "');\n });\n </script>"; } } $value = sprintf('<img src="%s" id="%s" />', $value, $imageThumbID); $out = '<div class="image_layout">'; $out .= '<div class="image_photo"><div class="image_wrap">'; $out .= $value; $out .= '</div>'; $out .= sprintf('<div id="photo_edit_link_%s" %s class="photo_edit_link">', $field['input_id'], $field_style); $out .= sprintf('<a href="%s" target="_blank" id="edit-%s" >%s</a> | ', $path_image_media, $field['input_id'], __('View', $mf_domain)); $out .= sprintf('<a href="#remove" class="remove remove_image_media" alt="%s" id="remove-%s" >%s</a>', __('Are you sure?', $mf_domain), $field['input_id'], __('Delete', $mf_domain)); $out .= '</div>'; $out .= '</div>'; $out .= '<div class="image_input">'; $out .= '<div class="mf_custom_field">'; $out .= sprintf('<div id="response-%s" style="display:none;" ></div>', $field['input_id']); $out .= sprintf('<input type="hidden" value="%s" name="%s" id="%s" %s >', $field['input_value'], $field['input_name'], $field['input_id'], $field['input_validate']); $link = sprintf('media-upload.php?post_id=0&type=image&TB_iframe=1'); $out .= sprintf('<a class="button thickbox update_field_media_upload" id="thumb_%s" href="%s">%s</a>', $field['input_id'], $link, __('Set Image', $mf_domain)); $out .= '</div></div>'; $out .= '</div>'; $out .= $error; return $out; }
public function display_field($field, $group_index = 1, $field_index = 1) { global $mf_domain; $field_style = ''; $imageThumbID = "img_thumb_" . $field['input_id']; $error = ''; if (!$field['input_value']) { $value = sprintf('%simages/noimage.jpg', MF_URL); $field_style = 'style="display:none;"'; } else { // $value = sprintf("%s?src=%s%s&w=150&h=120&zc=1",PHPTHUMB,MF_FILES_URL,$field['input_value']); $MFFrontEnd = MF_PATH . '/mf_front_end.php'; require_once $MFFrontEnd; $value = aux_image($field['input_value'], "w=150&h=120&zc=1", 'image'); if (is_wp_error($value)) { $wp_error = $value; $field_style = 'style="display:none;"'; $value = sprintf('%simages/noimage.jpg', MF_URL); // $value = $path_image_media; $error = "<script type=\"text/javascript\">\n jQuery(document).ready(function(\$){\n show_error_image_field('" . $field['input_id'] . "','" . html_entity_decode($wp_error->get_error_message()) . "');\n });\n </script>"; } } $value = sprintf('<img src="%s" id="%s" />', $value, $imageThumbID); $out = '<div class="image_layout">'; $out .= '<div class="image_photo"><div class="image_wrap">'; $out .= $value; $out .= '</div>'; $out .= sprintf('<div id="photo_edit_link_%s" %s class="photo_edit_link">', $field['input_id'], $field_style); $out .= sprintf('<a href="%s" target="_blank" id="edit-%s" >%s</a> | ', MF_FILES_URL . $field['input_value'], $field['input_id'], __('View', $mf_domain)); $out .= sprintf('<a href="#remove" class="remove remove_photo" alt="%s" id="remove-%s" >%s</a>', __('Are you sure?', $mf_domain), $field['input_id'], __('Delete', $mf_domain)); $out .= '</div>'; $out .= '</div>'; $out .= '<div class="image_input">'; $out .= '<div class="mf_custom_field">'; $out .= sprintf('<div id="response-%s" style="display:none;" ></div>', $field['input_id']); $out .= sprintf('<input type="hidden" value="%s" name="%s" id="%s" %s >', $field['input_value'], $field['input_name'], $field['input_id'], $field['input_validate']); $out .= $this->upload($field['input_id'], 'image', 'mf_image_callback_upload'); $out .= '</div></div>'; $out .= '</div>'; $out .= $error; return $out; }
function _processed_value($value, $type, $options = array(), $image_array = 0) { if (is_serialized($options)) { $options = unserialize($options); } $result = ''; switch ($type) { case 'audio': case 'file': if (!empty($value)) { $result = MF_FILES_URL . $value; } break; case 'image': if ($image_array) { if (!empty($value)) { unset($options['css_class']); $options = _processed_params($options); $result['original'] = MF_FILES_URL . $value; if (empty($options)) { $result['thumb'] = $result['original']; } else { $result['thumb'] = aux_image($value, $options, $type); } } } else { if (!empty($value)) { $result = MF_FILES_URL . $value; } } break; case 'checkbox': if ($value == '1') { $result = 1; } else { $result = 0; } break; case 'datepicker': if (!empty($value)) { $result = date($options['format'], strtotime($value)); } break; case 'dropdown': $result = $options['multiple'] == '0' ? $value[0] : $value; break; case 'image_media': if ($image_array) { if (!empty($value)) { unset($options['css_class']); $options = _processed_params($options); $data = wp_get_attachment_image_src($value, 'original'); $result['original'] = $data[0]; if (empty($options)) { $result['thumb'] = $result['original']; } else { $result['thumb'] = aux_image($result['original'], $options, $type); } } } else { if (!empty($value)) { $data = wp_get_attachment_image_src($value, 'original'); $result = $data[0]; } } break; case 'multiline': $result = apply_filters('the_content', $value); break; default: $result = $value; break; } return $result; }
function get_field_duplicate($fieldName, $groupIndex = 1, $post_id = NULL) { global $wpdb, $post, $FIELD_TYPES; if (!$post_id) { $post_id = $post->ID; } $sql = "SELECT \t\tpm.field_name, cf.type, pm_wp.meta_value, pm.order_id, pm.field_count, cf.id, fp.properties \n\t\t\tFROM \t\t" . MF_TABLE_POST_META . " pm, " . MF_TABLE_PANEL_GROUPS . " g, {$wpdb->postmeta} pm_wp,\n\t\t\t\t\t\t" . MF_TABLE_GROUP_FIELDS . " cf \n\t\t\tLEFT JOIN " . MF_TABLE_CUSTOM_FIELD_PROPERTIES . " fp ON fp.custom_field_id = cf.id\n\t\t\tWHERE \t\tpm_wp.post_id = {$post_id} AND cf.name = pm.field_name AND cf.group_id=g.id AND\n\t\t\t\t\t\tpm_wp.meta_id=pm.id AND pm.field_name='{$fieldName}' AND pm.group_count = {$groupIndex}\n\t\t\t\t\t\tAND pm_wp.meta_value <> '' \n\t\t\tORDER BY \tpm.order_id, cf.display_order, pm.field_count"; $data_fields = $wpdb->get_results($sql); $info = null; foreach ($data_fields as $data) { switch ($data->type) { case $FIELD_TYPES["textbox"]: case $FIELD_TYPES["radiobutton_list"]: case $FIELD_TYPES["dropdown_list"]: case $FIELD_TYPES["color_picker"]: case $FIELD_TYPES["slider"]: $info[$data->field_count] = $data->meta_value; break; case $FIELD_TYPES['multiline_textbox']: $info[$data->field_count] = apply_filters('the_content', $data->meta_value); break; case $FIELD_TYPES["checkbox"]: if ($data->meta_value == 'true') { $fieldValue = 1; } else { $fieldValue = 0; } $info[$data->field_count] = $fieldValue; break; case $FIELD_TYPES["checkbox_list"]: case $FIELD_TYPES["listbox"]: $info[$data->field_count] = unserialize($data->meta_value); break; case $FIELD_TYPES["audio"]: case $FIELD_TYPES["file"]: if ($data->meta_value != "") { $fieldValue = MF_FILES_URI . $data->meta_value; } else { $fieldValue = null; } $info[$data->field_count] = $fieldValue; break; case $FIELD_TYPES['image']: if ($data->meta_value != "") { $format = unserialize($data->properties); if ($format) { $info[$data->field_count]['t'] = aux_image($data->meta_value, $format['params']); } $info[$data->field_count]['o'] = MF_FILES_URI . $data->meta_value; } break; case $FIELD_TYPES['date']: $format = unserialize($data->properties); $fieldValue = GetProcessedFieldValue($data->meta_value, $data->type, $format); $info[$data->field_count] = $fieldValue; break; } } return $info; }
function get_clean_field_duplicate($fieldName, $groupIndex = 1, $post_id = NULL) { global $wpdb, $post, $FIELD_TYPES; if (!$post_id) { $post_id = $post->ID; } $cache_name = $post_id . '/_fduplicates-' . $fieldName . '--' . $groupIndex . '.txt'; $data_fields = unserialize(MF_get_cached_data($cache_name, FALSE)); // When field is set, but it's empty, it gets a NULL value, but still this value is cached // therefore: if !is_null condition if (!$data_fields && !is_null($data_fields)) { $sql = $wpdb->prepare("SELECT pm.field_name, cf.type, pm_wp.meta_value, pm.order_id, pm.field_count, cf.id, fp.properties \n\t\t\t\tFROM \t\t" . MF_TABLE_POST_META . " pm, " . MF_TABLE_PANEL_GROUPS . " g, {$wpdb->postmeta} pm_wp,\n\t\t\t\t\t\t\t" . MF_TABLE_GROUP_FIELDS . " cf \n\t\t\t\tLEFT JOIN " . MF_TABLE_CUSTOM_FIELD_PROPERTIES . " fp ON fp.custom_field_id = cf.id\n\t\t\t\tWHERE \t\tpm_wp.post_id = %d AND cf.name = pm.field_name AND cf.group_id = g.id AND\n\t\t\t\t\t\t\tpm_wp.meta_id = pm.id AND pm.field_name = %s AND pm.group_count = %d\n\t\t\t\t\t\t\tAND pm_wp.meta_value <> '' \n\t\t\t\tORDER BY \tpm.order_id, cf.display_order, pm.field_count", array($post_id, $fieldName, $groupIndex)); $data_fields = $wpdb->get_results($sql); MF_put_cached_data($cache_name, serialize($data_fields)); } $info = null; foreach ($data_fields as $data) { switch ($data->type) { case $FIELD_TYPES["textbox"]: case $FIELD_TYPES["radiobutton_list"]: case $FIELD_TYPES["dropdown_list"]: case $FIELD_TYPES["color_picker"]: case $FIELD_TYPES["slider"]: case $FIELD_TYPES["related_type"]: case $FIELD_TYPES['markdown_textbox']: $info[$data->field_count] = $data->meta_value; break; case $FIELD_TYPES['multiline_textbox']: $info[$data->field_count] = $data->meta_value; break; case $FIELD_TYPES["checkbox"]: if ($data->meta_value == 'true') { $fieldValue = 1; } else { $fieldValue = 0; } $info[$data->field_count] = $fieldValue; break; case $FIELD_TYPES["checkbox_list"]: case $FIELD_TYPES["listbox"]: $info[$data->field_count] = unserialize($data->meta_value); break; case $FIELD_TYPES["audio"]: case $FIELD_TYPES["file"]: if ($data->meta_value != "") { $fieldValue = MF_FILES_URI . $data->meta_value; } else { $fieldValue = null; } $info[$data->field_count] = $fieldValue; break; case $FIELD_TYPES['image']: if ($data->meta_value != "") { $format = unserialize($data->properties); if ($format) { $info[$data->field_count]['t'] = aux_image($data->meta_value, $format['params']); } $info[$data->field_count]['o'] = MF_FILES_URI . $data->meta_value; } break; case $FIELD_TYPES['date']: $format = unserialize($data->properties); $fieldValue = GetProcessedFieldValue($data->meta_value, $data->type, $format); $info[$data->field_count] = $fieldValue; break; case $FIELD_TYPES['Image (Upload Media)']: if ($data->meta_value != "") { $format = unserialize($data->properties); $image = wp_get_attachment_image_src($data->meta_value, 'original'); if ($format) { $info[$data->order_id][$data->field_name][$data->field_count]['t'] = aux_image($image[0], $format['params'], $data->type); } $info[$data->order_id][$data->field_name][$data->field_count]['o'] = $image[0]; } break; } } return $info; }
public function get_thumb($data) { require_once ABSPATH . "/wp-admin/includes/image.php"; require_once ABSPATH . "/wp-includes/media.php"; // remove text aditional in attachment $image_id = preg_replace('/del_attachment_/', '', $data['image_id']); $info = wp_get_attachment_image_src($image_id, 'original'); $field_value = $info[0]; $thumb = aux_image($field_value, "w=150&h=120&zc=1", 'image_media'); $field_id = preg_replace('/thumb_/', '', $data['field_id']); if (count($info)) { $image_thumb = PHPTHUMB . '?&w=150&h=120&src=' . $info[0]; $data = array('image' => $image_thumb, 'field_id' => $field_id, 'image_value' => $image_id, 'image_path' => $info[0], 'thumb' => $thumb); echo json_encode($data); } }
} } par.getElementById("<?php echo $idField; ?> ").value = "<?php echo $filename; ?> "; //Set image <?php //$newImagePath = PHPTHUMB.'?&w=150&h=120&src='.MF_FILES_URI.$filename; if ($acceptedExts == "image") { $newImagePath = aux_image($filename, 'w=150&h=120&zc=1'); } else { $newImagePath = ""; } if (isset($_POST['imageThumbID'])) { ?> if( par.getElementById('<?php echo $_POST['imageThumbID']; ?> ') ) { par.getElementById('<?php echo $_POST['imageThumbID']; ?> ').src = "<?php echo $newImagePath;
<?php if (isset($_POST['fileframe'])) { $resp = array('error' => true, 'field_id' => $_POST['input_name'], 'msg' => __("Upload Unsuccessful", $mf_domain)); if (isset($_FILES['file']) && !empty($_FILES['file']['tmp_name'])) { if ($_FILES['file']['error'] == UPLOAD_ERR_OK) { if (valid_mime($_FILES['file']['type'], $_POST['type'])) { if (!wp_verify_nonce($_POST['checking'], 'nonce_upload_file')) { $resp['msg'] = __('Sorry, your nonce did not verify.', $mf_domain); } else { $special_chars = array(' ', '`', '"', '\'', '\\', '/', " ", "#", "\$", "%", "^", "&", "*", "!", "~", "‘", "\"", "’", "'", "=", "?", "/", "[", "]", "(", ")", "|", "<", ">", ";", "\\", ",", "+", "-"); $filename = str_replace($special_chars, '', $_FILES['file']['name']); $filename = time() . $filename; @move_uploaded_file($_FILES['file']['tmp_name'], MF_FILES_DIR . $filename); @chmod(MF_FILES_DIR . $filename, 0644); $info = pathinfo(MF_FILES_DIR . $filename); $thumb = $_GET['type'] == 'image' ? aux_image($filename, "w=150&h=120&zc=1", 'image_alt') : ""; $resp = array('error' => false, 'name' => $filename, 'ext' => $info['extension'], 'field_id' => $_POST['input_name'], 'file_path' => MF_FILES_DIR . $filename, 'file_url' => MF_FILES_URL . $filename, 'encode_file_url' => urlencode(MF_FILES_URL . $filename), 'phpthumb' => PHPTHUMB, 'msg' => __("Successful upload", $mf_domain)); if (is_wp_error($thumb)) { $resp['error'] = true; $resp['msg'] = html_entity_decode($thumb->get_error_message()); } } } else { $resp['msg'] = __("Failed to upload the file!", $mf_domain); } } elseif ($_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE) { $resp['msg'] = __('The uploaded file exceeds the maximum upload limit!', $mf_domain); } else { $resp['msg'] = __("Upload Unsuccessful", $mf_domain); } }
public static function PhotoInterface($customField, $inputName, $groupCounter, $fieldCounter) { global $mf_domain; $idField = RCCWP_WritePostPage::changeNameInput($inputName); $mf_post_id = apply_filters('mf_source_post_data', @$_REQUEST['post']); if (!empty($mf_post_id)) { $hidValue = RCCWP_CustomField::GetCustomFieldValues(true, $mf_post_id, $customField->name, $groupCounter, $fieldCounter); } else { $hidValue = ''; } $filepath = $inputName . '_filepath'; //The Image is required? $requiredClass = ""; if ($customField->required_field) { $requiredClass = "field_required"; } $imageThumbID = "img_thumb_" . $idField; $value = "<img src='" . MF_URI . "images/noimage.jpg' id='{$imageThumbID}'/>"; if (!empty($hidValue)) { $value = aux_image($hidValue, 'w=150&h=120&zc=1'); $value = "<img src='{$value}' id='{$imageThumbID}'/>"; } ?> <p class="error_msg_txt upload-msg" id="upload_progress_<?php echo $idField; ?> " style="display:none;"> </p> <div class="image_layout"> <div class="image_photo"> <div class="image_wrap"> <?php echo $value; ?> </div> <div id="photo_edit_link_<?php echo $idField; ?> " class="photo_edit_link"> <?php if (isset($mf_post_id)) { echo '<a href="' . MF_FILES_URI . $hidValue . '" target="_blank">View</a> | <strong><a href="#remove" class="remove" id="remove-' . $idField . '">' . __("Delete", $mf_domain) . '</a></strong>'; } ?> </div> </div> <div class="image_input"> <?php if (empty($requiredClass)) { $requiredClass = ''; } ?> <div class="mf_custom_field"> <input tabindex="3" id="<?php echo $idField; ?> " name="<?php echo $inputName; ?> " type="hidden" class="<?php echo $requiredClass; ?> " size="46" value="<?php echo $hidValue; ?> " <?php if ($customField->required_field) { echo 'validate="required:true"'; } ?> /> <?php include_once "RCCWP_SWFUpload.php"; RCCWP_SWFUpload::Body($inputName, 1, 0, false); ?> </div> </div> </div> <!-- /.image_layout --> <div style="clear: both; height: 1px;"> </div> <?php if ($customField->required_field) { ?> <div class="mf_message_error"><label for="<?php echo $inputName; ?> " class="error_magicfields error"><?php _e("This field is required", $mf_domain); ?> </label></div> <?php } ?> <?php }
<?php if (isset($_POST['fileframe'])) { $resp = array('error' => true, 'field_id' => $_POST['input_name'], 'msg' => __("Upload Unsuccessful", $mf_domain)); if (isset($_FILES['file']) && !empty($_FILES['file']['tmp_name'])) { if ($_FILES['file']['error'] == UPLOAD_ERR_OK) { if (valid_mime($_FILES['file']['type'], $_POST['type'])) { if (!wp_verify_nonce($_POST['checking'], 'nonce_upload_file')) { $resp['msg'] = __('Sorry, your nonce did not verify.', $mf_domain); } else { $special_chars = array(' ', '`', '"', '\'', '\\', '/', " ", "#", "\$", "%", "^", "&", "*", "!", "~", "‘", "\"", "’", "'", "=", "?", "/", "[", "]", "(", ")", "|", "<", ">", ";", "\\", ",", "+", "-"); $filename = str_replace($special_chars, '', $_FILES['file']['name']); $filename = time() . $filename; @move_uploaded_file($_FILES['file']['tmp_name'], MF_FILES_DIR . $filename); @chmod(MF_FILES_DIR . $filename, 0644); $info = pathinfo(MF_FILES_DIR . $filename); $thumb = aux_image($filename, "w=150&h=120&zc=1", 'image_alt'); $resp = array('error' => false, 'name' => $filename, 'ext' => $info['extension'], 'field_id' => $_POST['input_name'], 'file_path' => MF_FILES_DIR . $filename, 'file_url' => MF_FILES_URL . $filename, 'encode_file_url' => urlencode(MF_FILES_URL . $filename), 'phpthumb' => PHPTHUMB, 'msg' => __("Successful upload", $mf_domain)); if (is_wp_error($thumb)) { $resp['error'] = true; $resp['msg'] = html_entity_decode($thumb->get_error_message()); } } } else { $resp['msg'] = __("Failed to upload the file!", $mf_domain); } } elseif ($_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE) { $resp['msg'] = __('The uploaded file exceeds the maximum upload limit!', $mf_domain); } else { $resp['msg'] = __("Upload Unsuccessful", $mf_domain); } }