public function upload() { /** import upload library **/ _wpl_import('assets.packages.ajax_uploader.UploadHandler'); $kind = wpl_request::getVar('kind', 0); $params = array(); $params['accept_ext'] = wpl_flex::get_field_options(301); $extentions = explode(',', $params['accept_ext']['ext_file']); $ext_str = ''; foreach ($extentions as $extention) { $ext_str .= $extention . '|'; } // remove last | $ext_str = substr($ext_str, 0, -1); $ext_str = rtrim($ext_str, ';'); $custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null); $upload_handler = new UploadHandler($custom_op); $response = json_decode($upload_handler->json_response); if (isset($response->files[0]->error)) { return; } $attachment_categories = wpl_items::get_item_categories('attachment', $kind); // get item category with first index $item_cat = reset($attachment_categories)->category_name; $index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0; $item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index); wpl_items::save($item); }
<div id="progress" class="progress progress-success progress-striped"> <div class="bar"></div> </div> </div> <div class="error_uploaded_message" id="error_ajax_att"> </div> <!-- The container for the uploaded files --> <div id="attaches" class="attachment-wp wpl_files_container"> <ul class="ui-sortable" id="ajax_att_sortable"> <?php // get uploaded attachments and show them $att_items = wpl_items::get_items($item_id, 'attachment', $this->kind, '', ''); $att_folder = wpl_items::get_folder($item_id, $this->kind); $attachment_categories = wpl_items::get_item_categories('attachment', $this->kind); $max_index_att = 0; foreach ($att_items as $attachment) { $attachment->index = intval($attachment->index); if ($max_index_att < $attachment->index) { $max_index_att = $attachment->index; } ?> <li class="ui-state-default" id="ajax_attachment<?php echo $attachment->index; ?> "> <input type="hidden" class="att_name" value="<?php echo $attachment->item_name; ?> "/>
<!-- The global progress bar --> <div id="progress_vid"> <div id="progress" class="progress progress-success progress-striped"> <div class="bar"></div> </div> </div> <div class="error_uploaded_message" id="error_ajax_vid"> </div> <!-- The container for the uploaded files --> <div id="video" class="video-list-wp wpl_files_container"> <ul class="ui-sortable" id="ajax_vid_sortable"> <?php // get uploaded videos and show them $vid_items = wpl_items::get_items($item_id, 'video', $this->kind, 'video', ''); $vid_folder = wpl_items::get_folder($item_id, $this->kind); $video_categories = wpl_items::get_item_categories('addon_video', $this->kind); $max_index_vid = 0; foreach ($vid_items as $video) { $video->index = intval($video->index); if ($max_index_vid < $video->index) { $max_index_vid = $video->index; } ?> <li class="ui-state-default" id="ajax_video<?php echo $video->index; ?> "> <input type="hidden" class="vid_name" value="<?php echo $video->item_name; ?> "/>
<div class="bar"></div> </div> </div> <div class="error_uploaded_message" id="error_ajax_img"> </div> <!-- The container for the uploaded files --> <div id="files" class="gallary-images-wp wpl_files_container"> <ul class="ui-sortable" id="ajax_gal_sortable"> <?php // get uploaded images and show them $gall_items = wpl_items::get_items($item_id, 'gallery', $this->kind, '', ''); $image_folder = wpl_items::get_folder($item_id, $this->kind); $image_path = wpl_items::get_path($item_id, $this->kind); $image_categories = wpl_items::get_item_categories('gallery', $this->kind); $max_img_index = 0; foreach ($gall_items as $image) { $image->index = intval($image->index); if ($max_img_index < $image->index) { $max_img_index = $image->index; } /** set resize method parameters **/ $params = array(); $params['image_name'] = $image->item_name; $params['image_parentid'] = $image->parent_id; $params['image_parentkind'] = $image->parent_kind; $params['image_source'] = $image_path . $image->item_name; $image_thumbnail_url = wpl_images::create_gallary_image(80, 60, $params, 1, 0); if ($image->item_cat == 'external') { $image_thumbnail_url = $image->item_extra3;