fieldtype = "setUploadPanel";
$this->hasSaveField = true;
$this->AbortGlobalSave = false;
$this->classSubActions = array('UpdateFileInfos', 'DeleteFile', 'UploadFile', 'test', 'getPostChildsFiles');
}
public function saveField($post_id, $key, $meta_marker, $data, $field) {
global$current_user;
/* var_dump($_POST);
var_dump($_FILES);
exit; */
}
public function test() {
global$current_user;
}
public function UploadFile() {
global$current_user, $oThis;
// bug when upload multiple file
// var_dump($_FILES);
//var_dump($_POST);
// echo "
init name first " . $_FILES['apm_fileupload']['name'];
$newfile = self::addImageFromLocal($_FILES, $_POST);
$posttitle = $_POST['title'];
$newfilename = $newfile['name']; // $_POST['filename'];
if ($posttitle == "") {
$posttitle = $newfilename;
}
$files = $this->getPostChildsFiles($newfile['newid']);
$f = $files[0];
$thumb = "";
$key = $_POST['key'];
if (isset($oThis->default_fields[$key]['is_image']) and $oThis->default_fields[$key]['is_image'] == true) {
if (isset($oThis->default_fields[$key]['image_resize'])) {
if (isset($oThis->default_fields[$key]['image_resize']['thumb'])) {
$thumbar = explode('.', $f->guid);
$ext = $thumbar[count($thumbar) - 1];
$thumb = str_replace("." . $ext, "_thumb." . $ext, $f->guid);
} else if (isset($oThis->default_fields[$key]['image_resize']['minithumb'])) {
$thumbar = explode('.', $f->guid);
$ext = $thumbar[count($thumbar) - 1];
$thumb = str_replace("." . $ext, "_minithumb." . $ext, $f->guid);
} else if (isset($oThis->default_fields[$key]['image_resize']['medium'])) {
$thumbar = explode('.', $f->guid);
$ext = $thumbar[count($thumbar) - 1];
$thumb = str_replace("." . $ext, "_medium." . $ext, $f->guid);
} else {
$thumb = $f->guid;
}
}
}
$size = size_format($_FILES['apm_fileupload']['size']);
/* $type = $_FILES['apm_fileupload']['type'];
$date = date('Y-m-d H:i:s');
$path_filename = wp_upload_dir();
$fileobj = (object) array();
$fileobj->date = $f->post_date;
$fileobj->ID = $f->ID;
$fileobj->name = $f->post_title;
$fileobj->url = $f->guid;
// $fileobj->caption = $f->post_excerpt;
// $fileobj->description = $f->post_content;
$fileobj->type = $f->post_mime_type; */
//echo $_FILES['apm_fileupload'];
////COMMENT: Here we can use ID's attributes without issue because this is loaded in an iFrame totally separated from the main page.
echo "" . $_POST['filenb'] . "";
echo "
" . $_POST['postid'] . "";
echo "
" . $f->post_title . "";
echo "
" . $f->post_mime_type . "";
echo "
" . $f->guid . "";
echo "
" . $thumb . "";
echo "
" . $size . "";
echo "
" . $f->post_date . "";
echo "
" . $_POST['filename'] . "";
echo "
" . $newfilename . "";
echo "
" . $newfile['res_status'] . "";
echo "
" . $newfile['error'] . "";
echo "
" . $newfile['newid'] . "";
//var_dump($oThis);
}
public function DeleteFile() {
global $wpdb, $current_user;
}
public function UpdateFileInfos() {
global $wpdb, $current_user;
}
public function GetFileInfos() {
global $wpdb, $current_user;
}
public function getPostChildsFiles($download_id_arr) {
global $current_user, $post_id, $oThis;
if (!is_array($download_id_arr)) {
$download_id_arr = explode(',', $download_id_arr);
}
if (count($download_id_arr) > 0) {
$args = array(
'orderby' => 'post_date',
'order' => 'DESC',
'include' => implode(',', $download_id_arr),
'post_parent' => $post_id,
'post_type' => 'attachment',
'suppress_filters' => true);
$posts_array = get_posts($args);
} else {
$posts_array = array();
}
return $posts_array;
}
public function getField($oThis, $config, $post, $meta_marker) {
global $current_user, $post_id;
$this->init($oThis, $config, $post, $meta_marker);
wp_get_current_user();
$curuse = strval($current_user->ID) . ',' . $current_user->display_name;
// var_dump($config);
$str = "";
$custom = get_post_custom($this->post->ID);
$download_id = get_post_meta($this->post->ID, $config['field'] . $this->meta_marker, true);
// echo "---".$this->post->ID."-".$config['field'];
$download_id_arr = false;
if (strpos($download_id, '*****') > -1) {
$download_id_arr = explode('*****', $download_id);
} else {
$download_id_arr = array();
}
$files_list = $this->getPostChildsFiles($download_id_arr);
$max_multi_files = '0';
if (isset($config['max_multi_files'])) {
$max_multi_files = $config['max_multi_files'];
}
// $cur_files_count = count($download_id_arr);
//var_dump($files_list);
$cur_files_count = count($files_list);
$str.= "