コード例 #1
0
 public function get_languages()
 {
     $records = array();
     foreach (lang_get_all() as $l) {
         $records[] = array('id' => $l['id'], 'text' => $l['name']);
     }
     return array(EXT_JSON_READER_ROOT => $records);
 }
コード例 #2
0
 /**
  * Save the manufacturer
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     $this->load->library('upload');
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //editing or adding the manufacturer
     if (is_numeric($id)) {
         $this->db->update('manufacturers', array('manufacturers_name' => $data['name'], 'last_modified' => date('Y-m-d H:i:s')), array('manufacturers_id' => $id));
     } else {
         $this->db->insert('manufacturers', array('manufacturers_name' => $data['name'], 'date_added' => date('Y-m-d H:i:s')));
     }
     //check transaction status and then upload the manufacturer image
     if ($this->db->trans_status() === TRUE) {
         $manufacturers_id = $id ? $id : $this->db->insert_id();
         $config['upload_path'] = ROOTPATH . 'images/manufacturers/';
         $config['allowed_types'] = 'gif|jpg|png';
         $this->upload->initialize($config);
         if ($this->upload->do_upload($data['image'])) {
             $this->db->update('manufacturers', array('manufacturers_image' => $this->upload->data('file_name')), array('manufacturers_id' => $manufacturers_id));
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
             }
         }
     } else {
         $error = TRUE;
     }
     //process languages
     if ($error === FALSE) {
         foreach (lang_get_all() as $l) {
             $manufacturers_info = array('manufacturers_url' => $data['url'][$l['id']], 'manufacturers_friendly_url' => $data['friendly_url'][$l['id']], 'manufacturers_page_title' => $data['page_title'][$l['id']], 'manufacturers_meta_keywords' => $data['meta_keywords'][$l['id']], 'manufacturers_meta_description' => $data['meta_description'][$l['id']]);
             //editing or adding the manufacturer
             if (is_numeric($id)) {
                 $this->db->update('manufacturers_info', $manufacturers_info, array('manufacturers_id' => $manufacturers_id, 'languages_id' => $l['id']));
             } else {
                 $manufacturers_info['manufacturers_id'] = $manufacturers_id;
                 $manufacturers_info['languages_id'] = $l['id'];
                 $this->db->insert('manufacturers_info', $manufacturers_info);
             }
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
                 break;
             }
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #3
0
 /**
  * Save slide image
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     //load upload library
     $this->load->library('upload');
     $this->upload->initialize(array('upload_path' => ROOTPATH . 'images/', 'allowed_types' => 'gif|jpg|jpeg|png'));
     //start transaction
     $this->db->trans_start();
     if (is_numeric($id)) {
         foreach (lang_get_all() as $l) {
             $image_data = array('description' => $data['description'][$l['id']], 'image_url' => $data['image_url'][$l['id']], 'sort_order' => $data['sort_order'], 'group' => $data['group'], 'status' => $data['status']);
             //if new image is uploaded to override the old one
             if ($this->upload->do_upload('image' . $l['id'])) {
                 $file = $this->upload->data();
                 //delete image
                 $result = $this->db->select('image')->from('slide_images')->where(array('image_id' => $id, 'language_id' => $l['id']))->get();
                 if ($result->num_rows() > 0) {
                     $image = $result->row_array();
                     if (!empty($image)) {
                         @unlink($image_path . $image['image']);
                     }
                 }
                 //update image
                 $image_data['image'] = $file['file_name'];
             }
             $this->db->update('slide_images', $image_data, array('language_id' => $l['id'], 'image_id' => $id));
         }
     } else {
         //get insert image id
         $insert_id = 1;
         $result = $this->db->select_max('image_id')->get('slide_images');
         if ($result->num_rows() > 0) {
             $row = $result->row_array();
             $insert_id = $row['image_id'] + 1;
         }
         //insert image for each language
         foreach (lang_get_all() as $l) {
             if ($this->upload->do_upload('image' . $l['id'])) {
                 $image = $this->upload->data();
                 $this->db->insert('slide_images', array('image_id' => $insert_id, 'language_id' => $l['id'], 'description' => $data['description'][$l['id']], 'image' => $image['file_name'], 'image_url' => $data['image_url'][$l['id']], 'sort_order' => $data['sort_order'], 'group' => $data['group'], 'status' => $data['status']));
             }
         }
     }
     //complete transaction
     $this->db->trans_complete();
     //check transaction status
     if ($this->db->trans_status() === FALSE) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #4
0
 /**
  * Save the weight class
  *
  * @access public
  * @param $id
  * @param $data
  * @param $default
  * @return boolean
  */
 public function save($id = NULL, $data, $default = FALSE)
 {
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //editing or adding the weight class
     if (is_numeric($id)) {
         $weight_class_id = $id;
     } else {
         $result = $this->db->select_max('weight_class_id')->from('weight_classes')->get();
         $max_weight_class = $result->row_array();
         $result->free_result();
         $weight_class_id = $max_weight_class['weight_class_id'] + 1;
     }
     //languages
     foreach (lang_get_all() as $l) {
         //editing or adding the weight class
         if (is_numeric($id)) {
             $this->db->update('weight_classes', array('weight_class_key' => $data['key'][$l['id']], 'weight_class_title' => $data['name'][$l['id']]), array('weight_class_id' => $weight_class_id, 'language_id' => $l['id']));
         } else {
             $this->db->insert('weight_classes', array('weight_class_id' => $weight_class_id, 'language_id' => $l['id'], 'weight_class_key' => $data['key'][$l['id']], 'weight_class_title' => $data['name'][$l['id']]));
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
             break;
         }
     }
     //process weiht class rules
     if ($error === FALSE) {
         //editing or adding the weight class
         if (is_numeric($id)) {
             $result = $this->db->select('weight_class_to_id')->from('weight_classes_rules')->where(array('weight_class_from_id' => $weight_class_id, 'weight_class_to_id !=' => $weight_class_id))->get();
             if ($result->num_rows() > 0) {
                 foreach ($result->result_array() as $rule) {
                     $this->db->update('weight_classes_rules', array('weight_class_rule' => $data['rules'][$rule['weight_class_to_id']]), array('weight_class_from_id' => $weight_class_id, 'weight_class_to_id' => $rule['weight_class_to_id']));
                     //check transaction status
                     if ($this->db->trans_status() === FALSE) {
                         $error = TRUE;
                         break;
                     }
                 }
             }
             $result->free_result();
         } else {
             $result = $this->db->select('weight_class_id')->from('weight_classes')->where(array('weight_class_id !=' => $weight_class_id, 'language_id' => lang_id()))->get();
             if ($result->num_rows() > 0) {
                 foreach ($result->result_array() as $class) {
                     $this->db->insert('weight_classes_rules', array('weight_class_from_id' => $class['weight_class_id'], 'weight_class_to_id' => $weight_class_id, 'weight_class_rule' => '1'));
                     //check transaction status
                     if ($this->db->trans_status() === FALSE) {
                         $error = TRUE;
                         break;
                     }
                     if ($error === FALSE) {
                         $this->db->insert('weight_classes_rules', array('weight_class_from_id' => $weight_class_id, 'weight_class_to_id' => $class['weight_class_id'], 'weight_class_rule' => $data['rules'][$class['weight_class_id']]));
                         //check transaction status
                         if ($this->db->trans_status() === FALSE) {
                             $error = TRUE;
                             break;
                         }
                     }
                 }
             }
             $result->free_result();
         }
     }
     //handle configuration
     if ($error === FALSE) {
         if ($default === TRUE) {
             $this->db->update('configuration', array('configuration_value' => $weight_class_id), array('configuration_key' => 'SHIPPING_WEIGHT_UNIT'));
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
             }
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #5
0
 public function get_data($id)
 {
     $Qcategories = $this->db->get_where('categories', array('categories_id' => $id));
     $data = $Qcategories->row_array();
     $Qcategories->free_result();
     foreach (lang_get_all() as $l) {
         $Qcategories_descriptions = $this->db->select('categories_name, categories_url, categories_page_title, categories_meta_keywords, categories_meta_description')->from('categories_description')->where(array('categories_id' => $id, 'language_id' => $l['id']))->get();
         $description = $Qcategories_descriptions->row_array();
         $data['categories_name[' . $l['id'] . ']'] = $description['categories_name'];
         $data['page_title[' . $l['id'] . ']'] = $description['categories_page_title'];
         $data['meta_keywords[' . $l['id'] . ']'] = $description['categories_meta_keywords'];
         $data['meta_description[' . $l['id'] . ']'] = $description['categories_meta_description'];
         $data['categories_url[' . $l['id'] . ']'] = $description['categories_url'];
         $Qcategories_descriptions->free_result();
     }
     if (empty($data)) {
         return FALSE;
     }
     $data['childs_count'] = sizeof($this->category_tree->get_children($id, $dummy = array()));
     $data['products_count'] = $this->category_tree->get_number_of_products($id);
     $cPath = explode('_', $this->category_tree->get_full_cpath($id));
     array_pop($cPath);
     $data['parent_category_id'] = !empty($cPath) ? implode('_', $cPath) : 0;
     $Qcategories->free_result();
     return $data;
 }
コード例 #6
0
 /**
  * Save the image group
  *
  * @access public
  * @param $id
  * @param $data
  * @param $default
  * @return boolean
  */
 public function save($id = NULL, $data, $default = FALSE)
 {
     //editing or adding the products images groups
     if (is_numeric($id)) {
         $group_id = $id;
     } else {
         $result = $this->db->select_max('id')->from('products_images_groups')->get();
         $group = $result->row_array();
         $group_id = $group['id'] + 1;
         $result->free_result();
     }
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //process languages
     foreach (lang_get_all() as $l) {
         $image_group = $data;
         $image_group['title'] = $data['title'][$l['id']];
         $image_group['force_size'] = $data['force_size'] === TRUE ? 1 : 0;
         if (is_numeric($id)) {
             $this->db->update('products_images_groups', $image_group, array('id' => $id, 'language_id' => $l['id']));
         } else {
             $image_group['id'] = $group_id;
             $image_group['language_id'] = $l['id'];
             $this->db->insert('products_images_groups', $image_group);
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
             break;
         }
     }
     if ($error === FALSE) {
         //update the default image group
         if ($default === TRUE) {
             $this->db->update('configuration', array('configuration_value' => $group_id), array('configuration_key' => 'DEFAULT_IMAGE_GROUP_ID'));
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
             }
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #7
0
 /**
  * Save the quantity unit classes
  *
  * @access public
  * @param $id
  * @param $data
  * @param $default
  * @return boolean
  */
 public function save($id = NULL, $data, $default = FALSE)
 {
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //editing or adding the unit class
     if (is_numeric($id)) {
         $unit_class_id = $id;
     } else {
         $result = $this->db->select_max('quantity_unit_class_id')->from('quantity_unit_classes')->get();
         $max_unit = $result->row_array();
         $result->free_result();
         $unit_class_id = $max_unit['quantity_unit_class_id'] + 1;
     }
     //languages
     foreach (lang_get_all() as $l) {
         //editing or adding the unit class
         if (is_numeric($id)) {
             $this->db->update('quantity_unit_classes', array('quantity_unit_class_title' => $data['unit_class_title'][$l['id']]), array('quantity_unit_class_id' => $unit_class_id, 'language_id' => $l['id']));
         } else {
             $this->db->insert('quantity_unit_classes', array('quantity_unit_class_id' => $unit_class_id, 'language_id' => $l['id'], 'quantity_unit_class_title' => $data['unit_class_title'][$l['id']]));
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
             break;
         }
     }
     if ($error === FALSE) {
         if ($default === TRUE) {
             $this->db->update('configuration', array('configuration_value' => $unit_class_id), array('configuration_key' => 'DEFAULT_UNIT_CLASSES'));
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #8
0
 /**
  * Insert or update an article category
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     $category_id = '';
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //article category
     $article_category = array('articles_categories_order' => $data['articles_order'], 'articles_categories_status' => $data['status']);
     if (is_numeric($id)) {
         $this->db->update('articles_categories', $article_category, array('articles_categories_id' => $id));
     } else {
         $this->db->insert('articles_categories', $article_category);
     }
     if ($this->db->trans_status() === TRUE) {
         $articles_category_id = is_numeric($id) ? $id : $this->db->insert_id();
         //languages
         foreach (lang_get_all() as $l) {
             $articles_category_description = array('articles_categories_name' => $data['name'][$l['id']], 'articles_categories_url' => $data['url'][$l['id']] == '' ? $data['name'][$l['id']] : $data['url'][$l['id']], 'articles_categories_page_title' => $data['page_title'][$l['id']], 'articles_categories_meta_keywords' => $data['meta_keywords'][$l['id']], 'articles_categories_meta_description' => $data['meta_description'][$l['id']]);
             if (is_numeric($id)) {
                 $this->db->update('articles_categories_description', $articles_category_description, array('articles_categories_id' => $articles_category_id, 'language_id' => $l['id']));
             } else {
                 $articles_category_description['articles_categories_id'] = $articles_category_id;
                 $articles_category_description['language_id'] = $l['id'];
                 $this->db->insert('articles_categories_description', $articles_category_description);
             }
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
                 break;
             }
         }
     }
     if ($error === FALSE) {
         //commit transaction
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #9
0
 public function save($id = NULL, $data)
 {
     $this->db->trans_begin();
     //products
     $products_data = array('products_type' => $data['products_type'], 'products_sku' => $data['products_sku'], 'products_model' => $data['products_model'], 'products_price' => $data['price'], 'products_quantity' => $data['quantity'], 'products_moq' => $data['products_moq'], 'products_max_order_quantity' => $data['products_max_order_quantity'], 'order_increment' => $data['order_increment'], 'products_weight' => $data['weight'], 'products_weight_class' => $data['weight_class'], 'products_status' => $data['status'], 'products_tax_class_id' => $data['tax_class_id'], 'manufacturers_id' => $data['manufacturers_id'], 'quantity_discount_groups_id' => $data['quantity_discount_groups_id'], 'quantity_unit_class' => $data['quantity_unit_class'], 'products_last_modified' => date('Y-m-d'));
     if (date('Y-m-d') < $data['date_available']) {
         $products_data['products_date_available'] = $data['date_available'];
     } else {
         $products_data['products_date_available'] = NULL;
     }
     if (is_numeric($id)) {
         $products_data['products_last_modified'] = date('Y-m-d');
         $Qproducts = $this->db->where('products_id', $id)->update('products', $products_data);
     } else {
         $products_data['products_date_added'] = date('Y-m-d');
         $Qproducts = $this->db->insert('products', $products_data);
     }
     if ($this->db->trans_status() === TRUE) {
         if (is_numeric($id)) {
             $products_id = $id;
         } else {
             $products_id = $this->db->insert_id();
         }
         //products_to_categories
         $Qcategories = $this->db->delete('products_to_categories', array('products_id' => $products_id));
         if (isset($data['categories']) && !empty($data['categories'])) {
             foreach ($data['categories'] as $category_id) {
                 $products_to_categories = array('products_id' => $products_id, 'categories_id' => $category_id);
                 $Qp2c = $this->db->insert('products_to_categories', $products_to_categories);
             }
         }
     }
     //products_accessories
     if ($this->db->trans_status() === TRUE) {
         if (is_numeric($id)) {
             $Qdelete = $this->db->delete('products_accessories', array('products_id' => $products_id));
         }
         if (isset($data['accessories_ids']) && sizeof($data['accessories_ids']) > 0) {
             foreach ($data['accessories_ids'] as $accessories_id) {
                 $accessory_data = array('products_id' => $products_id, 'accessories_id' => $accessories_id);
                 $this->db->insert('products_accessories', $accessory_data);
             }
         }
     }
     //products_description
     if ($this->db->trans_status() === TRUE) {
         foreach (lang_get_all() as $l) {
             $products_description_data = array('products_name' => $data['products_name'][$l['id']], 'products_short_description' => $data['products_short_description'][$l['id']], 'products_description' => $data['products_description'][$l['id']], 'products_tags' => $data['products_tags'][$l['id']], 'products_url' => $data['products_url'][$l['id']], 'products_friendly_url' => $data['products_friendly_url'][$l['id']], 'products_page_title' => $data['products_page_title'][$l['id']], 'products_meta_keywords' => $data['products_meta_keywords'][$l['id']], 'products_meta_description' => $data['products_meta_description'][$l['id']]);
             if (is_numeric($id)) {
                 $this->db->update('products_description', $products_description_data, array('products_id' => $products_id, 'language_id' => $l['id']));
             } else {
                 $products_description_data['language_id'] = $l['id'];
                 $this->db->insert('products_description', $products_description_data);
             }
         }
     }
     //BEGIN: products images
     if ($this->db->trans_status() === TRUE) {
         $images = array();
         $image_path = ROOTPATH . 'images/products/_upload/' . $this->session->userdata('session_id') . '/';
         foreach ($this->directory_listing->getFiles() as $file) {
             @copy($image_path . $file['name'], ROOTPATH . 'images/products/originals/' . $file['name']);
             @unlink($image_path . $file['name']);
             $images[$file['name']] = -1;
         }
         delete_files($image_path);
         $default_flag = 1;
         $images_keys = array_keys($images);
         foreach ($images_keys as $image) {
             $image_data = array('products_id' => $products_id, 'default_flag' => $default_flag, 'sort_order' => 0, 'image' => '', 'date_added' => date('Y-m-d'));
             $this->db->insert('products_images', $image_data);
             $image_id = $this->db->insert_id();
             $images[$image] = $image_id;
             $new_image_name = $products_id . '_' . $image_id . '_' . $image;
             @rename(ROOTPATH . 'images/products/originals/' . $image, ROOTPATH . 'images/products/originals/' . $new_image_name);
             $this->db->update('products_images', array('image' => $new_image_name), array('id' => $image_id));
             foreach ($this->admin_image->getGroups() as $group) {
                 if ($group['id'] != '1') {
                     $this->admin_image->resize($new_image_name, $group['id'], 'products');
                 }
             }
             $default_flag = 0;
         }
     }
     //END: products images
     //BEGIN: products variants
     if ($this->db->trans_status() === TRUE) {
         //if edit product, delete variant first
         if (is_numeric($id)) {
             $Qvariants = $this->db->select('*')->from('products_variants')->where('products_id', $id)->order_by('products_variants_id')->get();
             $records = array();
             if ($Qvariants->num_rows() > 0) {
                 foreach ($Qvariants->result_array() as $product_variant) {
                     $Qentries = $this->db->select('products_variants_id, products_variants_groups_id, products_variants_values_id')->from('products_variants_entries')->where('products_variants_id', $product_variant['products_variants_id'])->order_by('products_variants_groups_id', 'products_variants_values_id')->get();
                     $variants_values = array();
                     if ($Qentries->num_rows() > 0) {
                         foreach ($Qentries->result_array() as $entry) {
                             $variants_values[] = $entry['products_variants_groups_id'] . '_' . $entry['products_variants_values_id'];
                         }
                     }
                     $variant = implode('-', $variants_values);
                     if (!isset($data['products_variants_id'][$variant])) {
                         //delete variants
                         $this->db->delete('products_variants', array('products_variants_id' => $product_variant['products_variants_id']));
                         //delete variants entries
                         if ($this->db->trans_status() === TRUE) {
                             $this->db->delete('products_variants_entries', array('products_variants_id' => $product_variant['products_variants_id']));
                         }
                     }
                 }
             }
         }
         $products_quantity = 0;
         //insert or update variant
         if (isset($data['products_variants_id']) && is_array($data['products_variants_id'])) {
             foreach ($data['products_variants_id'] as $key => $variants_id) {
                 $product_variants_data = array('is_default' => $data['variants_default'][$key], 'products_price' => $data['variants_price'][$key], 'products_sku' => $data['variants_sku'][$key], 'products_model' => $data['variants_model'][$key], 'products_quantity' => $data['variants_quantity'][$key], 'products_weight' => $data['variants_weight'][$key], 'products_status' => $data['variants_status'][$key], 'filename' => '', 'cache_filename' => '');
                 $products_images_id = is_numeric($data['variants_image'][$key]) ? $data['variants_image'][$key] : $images[$data['variants_image'][$key]];
                 $product_variants_data['products_images_id'] = $products_images_id;
                 if ($variants_id > 0) {
                     $this->db->update('products_variants', $product_variants_data, array('products_variants_id' => $variants_id));
                 } else {
                     $product_variants_data['products_id'] = $products_id;
                     $this->db->insert('products_variants', $product_variants_data);
                 }
                 if ($this->db->trans_status() === FALSE) {
                     break;
                 } else {
                     if (is_numeric($variants_id) && $variants_id > 0) {
                         $products_variants_id = $variants_id;
                     } else {
                         $products_variants_id = $this->db->insert_id();
                     }
                     $products_quantity += $data['variants_quantity'][$key];
                 }
                 //variant entries
                 if ($this->db->trans_status() === TRUE && $variants_id == '-1') {
                     $assigned_variants = explode('-', $key);
                     for ($i = 0; $i < sizeof($assigned_variants); $i++) {
                         $assigned_variant = explode('_', $assigned_variants[$i]);
                         $entries_data = array('products_variants_id' => $products_variants_id, 'products_variants_groups_id' => $assigned_variant[0], 'products_variants_values_id' => $assigned_variant[1]);
                         $this->db->insert('products_variants_entries', $entries_data);
                         if ($this->db->trans_status() === FALSE) {
                             break;
                         }
                     }
                 }
             }
             if ($this->db->trans_status() === TRUE) {
                 $this->db->update('products', array('products_quantity' => $products_quantity), array('products_id' => $products_id));
             }
         }
     }
     //END: products variants
     //BEGIN: xsell products
     if ($this->db->trans_status() === TRUE) {
         if (is_numeric($id)) {
             $this->db->delete('products_xsell', array('products_id' => $id));
         }
         if ($this->db->trans_status() === TRUE) {
             if (isset($data['xsell_id_array']) && !empty($data['xsell_id_array'])) {
                 foreach ($data['xsell_id_array'] as $xsell_products_id) {
                     $this->db->insert('products_xsell', array('products_id' => $products_id, 'xsell_products_id' => $xsell_products_id));
                     if ($this->db->trans_status() === FALSE) {
                         break;
                     }
                 }
             }
         }
     }
     //END: xsell products
     if ($this->db->trans_status() === TRUE) {
         $this->db->trans_commit();
         return $products_id;
     } else {
         $this->db->trans_rollback();
         return FALSE;
     }
 }
コード例 #10
0
 /**
  * Save an article
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     //load libraries
     $this->load->library(array('image', 'upload'));
     //load helpers
     $this->load->helper(array('html_output', 'directory'));
     //flag to check errors
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //article information
     $article_info = array('articles_status' => $data['articles_status'], 'articles_order' => $data['articles_order'], 'articles_categories_id' => $data['articles_categories']);
     //editing article
     if (is_numeric($id)) {
         $article_info['articles_last_modified'] = date('Y-m-d H:i:s');
         $this->db->update('articles', $article_info, array('articles_id' => $id));
     } else {
         $article_info['articles_date_added'] = date('Y-m-d H:i:s');
         $article_info['articles_last_modified'] = date('Y-m-d H:i:s');
         $this->db->insert('articles', $article_info);
     }
     if ($this->db->trans_status() === FALSE) {
         $error = TRUE;
     } else {
         //get the article id as inserting the new article
         $articles_id = is_numeric($id) ? $id : $this->db->insert_id();
     }
     //articles images
     if ($error === FALSE && $data['delimage'] == 1) {
         $this->image->delete_articles_image($articles_id);
         $this->db->update('articles', array('articles_image' => NULL), array('articles_id' => $articles_id));
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
         }
     }
     //upload article image
     if ($error === FALSE) {
         //create the directory to store articles images
         if (!is_dir(ROOTPATH . 'images/articles')) {
             directory_make(ROOTPATH . 'images/articles');
             directory_make(ROOTPATH . 'images/articles/originals');
         }
         //check whether the uploaded image is existed
         if (isset($_FILES[$data['articles_image']]) && isset($_FILES[$data['articles_image']]['tmp_name']) && !empty($_FILES[$data['articles_image']]['tmp_name']) && is_uploaded_file($_FILES[$data['articles_image']]['tmp_name'])) {
             $config['upload_path'] = ROOTPATH . 'images/articles/originals';
             //only the gif, jpg, png, jpeg are allowed to be uploaded
             $config['allowed_types'] = 'gif|jpg|png|jpeg';
             $this->upload->initialize($config);
             //upload the image now
             if ($this->upload->do_upload($data['articles_image'])) {
                 //upload the articles image field in the database
                 $this->db->update('articles', array('articles_image' => $this->upload->data('file_name')), array('articles_id' => $articles_id));
                 if ($this->db->trans_status() === FALSE) {
                     $error = TRUE;
                 } else {
                     //resize the image for each image group
                     foreach ($this->image->get_groups() as $group) {
                         if ($group['id'] !== 1) {
                             $this->image->resize($this->upload->data('file_name'), $group['id'], 'articles');
                         }
                     }
                 }
             } else {
                 $error = TRUE;
             }
         }
     }
     //Process articles description for each language
     if ($error === FALSE) {
         foreach (lang_get_all() as $l) {
             $articles_description = array('articles_name' => $data['articles_name'][$l['id']], 'articles_url' => $data['articles_url'][$l['id']], 'articles_description' => $data['articles_description'][$l['id']], 'articles_page_title' => $data['page_title'][$l['id']], 'articles_meta_keywords' => $data['meta_keywords'][$l['id']], 'articles_meta_description' => $data['meta_description'][$l['id']]);
             //editing article
             if (is_numeric($id)) {
                 $this->db->update('articles_description', $articles_description, array('articles_id' => $articles_id, 'language_id' => $l['id']));
             } else {
                 $articles_description['articles_id'] = $articles_id;
                 $articles_description['language_id'] = $l['id'];
                 $this->db->insert('articles_description', $articles_description);
             }
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
                 break;
             }
         }
     }
     if ($error === FALSE) {
         //commit transaction
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #11
0
 /**
  * Save the orders_status
  *
  * @access public
  * @param $id
  * @param $data
  * @param $default
  * @return boolean
  */
 public function save($id = NULL, $data, $default = FALSE)
 {
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //editing or adding the order status
     if (is_numeric($id)) {
         $orders_status_id = $id;
     } else {
         $result = $this->db->select_max('orders_status_id')->from('orders_status')->get();
         $status = $result->row_array();
         $orders_status_id = $status['orders_status_id'] + 1;
         $result->free_result();
     }
     //languages
     foreach (lang_get_all() as $l) {
         //editing or adding the order status
         if (is_numeric($id)) {
             $this->db->update('orders_status', array('orders_status_name' => $data['name'][$l['id']], 'public_flag' => $data['public_flag']), array('orders_status_id' => $orders_status_id, 'language_id' => $l['id']));
         } else {
             $this->db->insert('orders_status', array('orders_status_id' => $orders_status_id, 'language_id' => $l['id'], 'orders_status_name' => $data['name'][$l['id']], 'public_flag' => $data['public_flag']));
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
             break;
         }
     }
     if ($error === FALSE) {
         if ($default === TRUE) {
             $this->db->update('configuration', array('configuration_value' => $orders_status_id), array('configuration_key' => 'DEFAULT_ORDERS_STATUS_ID'));
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
             }
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #12
0
 /**
  * save the variants group
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     $error = FALSE;
     //editing or adding the product variants group
     if (is_numeric($id)) {
         $group_id = $id;
     } else {
         $result = $this->db->select_max('products_variants_groups_id')->from('products_variants_groups')->get();
         $max_groups = $result->row_array();
         $result->free_result();
         $group_id = $max_groups['products_variants_groups_id'] + 1;
     }
     //start transaction
     $this->db->trans_begin();
     //process languages
     foreach (lang_get_all() as $l) {
         //editing or adding the product variants group
         if (is_numeric($id)) {
             $this->db->update('products_variants_groups', array('products_variants_groups_name' => $data['name'][$l['id']]), array('products_variants_groups_id' => $group_id, 'language_id' => $l['id']));
         } else {
             $this->db->insert('products_variants_groups', array('products_variants_groups_id' => $group_id, 'language_id' => $l['id'], 'products_variants_groups_name' => $data['name'][$l['id']]));
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
             break;
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #13
0
 /**
  * Get the data of home page
  *
  * @access public
  * @return array
  */
 public function get_data()
 {
     $data = array();
     //process homepage info for each language
     foreach (lang_get_all() as $l) {
         $name = $l['name'];
         $code = strtoupper($l['code']);
         //check page title for language
         if (!defined('HOME_PAGE_TITLE_' . $code)) {
             $this->db->insert('configuration', array('configuration_title' => 'Homepage Page Title For ' . $name, 'configuration_key' => 'HOME_PAGE_TITLE_' . $code, 'configuration_value' => '', 'configuration_description' => 'the page title for the front page', 'configuration_group_id' => '6', 'sort_order' => '0', 'date_added' => date('Y-m-d H:i:s')));
             define('HOME_PAGE_TITLE_' . $code, '');
         }
         //check meta keywords for language
         if (!defined('HOME_META_KEYWORD_' . $code)) {
             $this->db->insert('configuration', array('configuration_title' => 'Homepage Meta Keywords For ' . $name, 'configuration_key' => 'HOME_META_KEYWORD_' . $code, 'configuration_value' => '', 'configuration_description' => 'the meta keywords for the front page', 'configuration_group_id' => '6', 'sort_order' => '0', 'date_added' => date('Y-m-d H:i:s')));
             define('HOME_META_KEYWORD_' . $code, '');
         }
         //check meta description for language
         if (!defined('HOME_META_DESCRIPTION_' . $code)) {
             $this->db->insert('configuration', array('configuration_title' => 'Homepage Meta Description For ' . $name, 'configuration_key' => 'HOME_META_DESCRIPTION_' . $code, 'configuration_value' => '', 'configuration_description' => 'the meta description for the front page', 'configuration_group_id' => '6', 'sort_order' => '0', 'date_added' => date('Y-m-d H:i:s')));
             define('HOME_META_DESCRIPTION_' . $code, '');
         }
         //process the index text
         $result = $this->db->select('*')->from('languages_definitions')->where(array('definition_key' => 'index_text', 'languages_id' => $l['id']))->get();
         if ($result->num_rows() > 0) {
             foreach ($result->result_array() as $homepage) {
                 $data['index_text[' . $l['id'] . ']'] = $homepage['definition_value'];
             }
         }
         $data['HOME_PAGE_TITLE[' . $code . ']'] = constant('HOME_PAGE_TITLE_' . $code);
         $data['HOME_META_KEYWORD[' . $code . ']'] = constant('HOME_META_KEYWORD_' . $code);
         $data['HOME_META_DESCRIPTION[' . $code . ']'] = constant('HOME_META_DESCRIPTION_' . $code);
     }
     return $data;
 }
コード例 #14
0
 /**
  * Save an customer group
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //editing or adding the customer group
     if (is_numeric($id)) {
         $this->db->update('customers_groups', array('customers_groups_discount' => $data['customers_groups_discount'], 'is_default' => $data['is_default']), array('customers_groups_id' => $id));
     } else {
         $this->db->insert('customers_groups', array('customers_groups_discount' => $data['customers_groups_discount'], 'is_default' => $data['is_default']));
     }
     //check transaction status
     if ($this->db->trans_status() === FALSE) {
         $error = TRUE;
     } else {
         $group_id = is_numeric($id) ? $id : $this->db->insert_id();
     }
     if ($error === FALSE) {
         //process languages
         foreach (lang_get_all() as $l) {
             //editing or adding the customer group
             if (is_numeric($id)) {
                 $this->db->update('customers_groups_description', array('customers_groups_name' => $data['customers_groups_name'][$l['id']]), array('customers_groups_id' => $group_id, 'language_id' => $l['id']));
             } else {
                 $this->db->insert('customers_groups_description', array('customers_groups_id' => $group_id, 'language_id' => $l['id'], 'customers_groups_name' => $data['customers_groups_name'][$l['id']]));
             }
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
                 break;
             }
         }
     }
     if ($error === FALSE) {
         //set the customer group as the default group
         if ($data['is_default'] == 1) {
             $this->db->update('customers_groups', array('is_default' => 0));
             if ($this->db->trans_status() === TRUE) {
                 $this->db->update('customers_groups', array('is_default' => 1), array('customers_groups_id' => $group_id));
             }
         }
         //check transaction status
         if ($this->db->trans_status() === FALSE) {
             $error = TRUE;
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #15
0
 /**
  * Save the rating
  *
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data)
 {
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //editing or adding the rating
     if (is_numeric($id)) {
         $this->db->update('ratings', array('status' => $data['status']), array('ratings_id' => $id));
     } else {
         $this->db->insert('ratings', array('status' => $data['status']));
     }
     //check transaction status
     if ($this->db->trans_status() === TRUE) {
         $ratings_id = is_numeric($id) ? $id : $this->db->insert_id();
         //process languages
         foreach (lang_get_all() as $l) {
             //editing or adding the rating
             if (is_numeric($id)) {
                 $this->db->update('ratings_description', array('ratings_text' => $data['ratings_text'][$l['id']]), array('ratings_id' => $id, 'languages_id' => $l['id']));
             } else {
                 $this->db->insert('ratings_description', array('ratings_id' => $ratings_id, 'languages_id' => $l['id'], 'ratings_text' => $data['ratings_text'][$l['id']]));
             }
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
                 break;
             }
         }
     }
     if ($error === FALSE) {
         //commit
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }
コード例 #16
0
ファイル: languages.php プロジェクト: colonia/tomatocart-v2
 /**
  * Get the parent language
  *
  * @access public
  * @return string
  */
 public function get_parent_language()
 {
     $records = array(array('parent_id' => '0', 'text' => lang('none')));
     foreach (lang_get_all() as $l) {
         if ($l['id'] != $this->input->post('languages_id')) {
             $records[] = array('parent_id' => $l['id'], 'text' => $l['name'] . ' (' . $l['code'] . ')');
         }
     }
     $this->output->set_output(json_encode(array(EXT_JSON_READER_ROOT => $records)));
 }
コード例 #17
0
 /**
  * Load a slide image
  * 
  * @access public
  * @return string
  */
 public function load_slide_images()
 {
     $data = $this->slide_images_model->get_data($this->input->post('image_id'));
     if ($data !== NULL) {
         //languages
         $languages = lang_get_all();
         foreach ($languages as $l) {
             if (isset($data['slide_image' . $l['id']])) {
                 $image = $data['slide_image' . $l['id']];
                 list($orig_width, $orig_height) = getimagesize(ROOTPATH . 'images/' . $image);
                 $width = intval($orig_width * 80 / $orig_height);
                 $data['slide_image' . $l['id']] = '<img src="' . IMGHTTPPATH . $image . '" width="' . $width . '" height="80" style="margin-left: 112px" />';
             }
         }
     }
     $this->output->set_output(json_encode(array('success' => TRUE, 'data' => $data)));
 }
コード例 #18
0
ファイル: guest_book.php プロジェクト: colonia/tomatocart-v2
 /**
  * Get all the available languages
  * 
  * @access public
  * @return string
  */
 public function get_languages()
 {
     $languages = array();
     //languages
     foreach (lang_get_all() as $l) {
         $languages[] = array('id' => $l['id'], 'text' => $l['name']);
     }
     $this->output->set_output(json_encode(array(EXT_JSON_READER_ROOT => $languages)));
 }
コード例 #19
0
ファイル: login.php プロジェクト: colonia/tomatocart-v2
  <script type="text/javascript">
    Ext.onReady(function(){
      Ext.BLANK_IMAGE_URL = '<?php 
echo base_url();
?>
templates/base/web/images/s.gif';
      Ext.EventManager.onWindowResize(centerPanel);
      
      var loginPanel = Ext.get("x-login-panel");
      
      centerPanel();
      
      Ext.namespace("Toc");
      Toc.Languages = [];
      <?php 
foreach (lang_get_all() as $l) {
    echo 'Toc.Languages.push({"id" : "' . $l['code'] . '", "text" : "' . $l['name'] . '"});';
}
?>
      
      var cboLanguage = new Ext.form.ComboBox({
        store: new Ext.data.Store({
          fields: ['id', 'text'],
          data : Toc.Languages
        }),
        fieldLabel: '<?php 
echo lang("field_language");
?>
',
        name: 'language',
        hiddenName: 'language',
コード例 #20
0
ファイル: faqs_model.php プロジェクト: colonia/tomatocart-v2
 /**
  * Save the faq
  * 
  * @access public
  * @param $id
  * @param $data
  * @return boolean
  */
 public function save($id = NULL, $data = array())
 {
     $error = FALSE;
     //start transaction
     $this->db->trans_begin();
     //process faqs
     if (is_numeric($id)) {
         $this->db->update('faqs', array('faqs_status' => $data['faqs_status'], 'faqs_order' => $data['faqs_order'], 'faqs_last_modified' => date('Y-m-d H:i:s')), array('faqs_id' => $id));
     } else {
         $this->db->insert('faqs', array('faqs_status' => $data['faqs_status'], 'faqs_order' => $data['faqs_order'], 'faqs_date_added' => date('Y-m-d H:i:s')));
     }
     if ($this->db->trans_status() === FALSE) {
         $error = TRUE;
     } else {
         $faqs_id = is_numeric($id) ? $id : $this->db->insert_id();
     }
     //process faqs description
     if ($error === FALSE) {
         //languages
         foreach (lang_get_all() as $l) {
             $decription_data = array('faqs_question' => $data['faqs_question'][$l['id']], 'faqs_url' => $data['faqs_url'][$l['id']], 'faqs_answer' => $data['faqs_answer'][$l['id']]);
             if (is_numeric($id)) {
                 $this->db->update('faqs_description', $decription_data, array('faqs_id' => $faqs_id, 'language_id' => $l['id']));
             } else {
                 $decription_data['faqs_id'] = $faqs_id;
                 $decription_data['language_id'] = $l['id'];
                 $this->db->insert('faqs_description', $decription_data);
             }
             //check transaction status
             if ($this->db->trans_status() === FALSE) {
                 $error = TRUE;
                 break;
             }
         }
     }
     if ($error === FALSE) {
         //commit transaction
         $this->db->trans_commit();
         return TRUE;
     }
     //rollback
     $this->db->trans_rollback();
     return FALSE;
 }