示例#1
0
 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);
 }
示例#2
0
 public static function save_external_images()
 {
     $kind = wpl_request::getVar('kind', 0);
     $pid = wpl_request::getVar('pid');
     $links_str = wpl_request::getVar('links', '');
     $type = wpl_request::getVar('type', 'gallery');
     $category = wpl_request::getVar('category', 'external');
     $links_str = str_replace(";", '<-->', $links_str);
     $links_str = str_replace(",", '<-->', $links_str);
     $links_str = str_replace("\r\n", '<-->', $links_str);
     $links_str = str_replace("\n", '<-->', $links_str);
     $links = explode('<-->', $links_str);
     foreach ($links as $link) {
         $link = trim($link, ',; ');
         if (trim($link) == '') {
             continue;
         }
         // get item category with first index
         $index = floatval(wpl_items::get_maximum_index($pid, $type, $kind, $category)) + 1.0;
         $name = 'external_image' . $index;
         $item = array('parent_id' => $pid, 'parent_kind' => $kind, 'item_type' => $type, 'item_cat' => $category, 'item_name' => $name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index, 'item_extra3' => $link);
         $item_id = wpl_items::save($item);
     }
     exit;
 }
示例#3
0
 public static function save_room()
 {
     $pid = wpl_request::getVar('pid');
     $kind = wpl_request::getVar('kind');
     $room_name = wpl_request::getVar('room_name');
     $room_type_id = wpl_request::getVar('room_type_id');
     $x = wpl_request::getVar('x_param');
     $y = wpl_request::getVar('y_param');
     $index = floatval(wpl_items::get_maximum_index($pid, 'rooms', $kind)) + 1.0;
     $item = array('parent_id' => $pid, 'parent_kind' => $kind, 'item_type' => 'rooms', 'item_cat' => $room_type_id, 'item_name' => $room_name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index, 'item_extra1' => $x, 'item_extra2' => $y);
     $id = wpl_items::save($item);
     $res = (int) $id;
     $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = $id;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
示例#4
0
 private function item_save()
 {
     $kind = wpl_request::getVar('kind', 0);
     $parent_id = wpl_request::getVar('item_id', 0);
     $item_type = wpl_request::getVar('item_type', '');
     $item_cat = wpl_request::getVar('item_cat', '');
     $item_name = wpl_request::getVar('value', '');
     $item_extra1 = wpl_request::getVar('item_extra1', '');
     $item_extra2 = wpl_request::getVar('item_extra2', '');
     $item_extra3 = wpl_request::getVar('item_extra3', '');
     $query = "SELECT `id` FROM `#__wpl_items` WHERE `parent_kind`='{$kind}' AND `parent_id`='{$parent_id}' AND `item_type`='{$item_type}' AND `item_cat`='{$item_cat}'";
     $item_id = wpl_db::select($query, 'loadResult');
     $item = array('parent_id' => $parent_id, 'parent_kind' => $kind, 'item_type' => $item_type, 'item_cat' => $item_cat, 'item_name' => $item_name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => '1.00', 'item_extra1' => $item_extra1, 'item_extra2' => $item_extra2, 'item_extra3' => $item_extra3);
     wpl_items::save($item, $item_id);
     $res = 1;
     $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = NULL;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }