Example #1
0
 public function index($id = 0, $color = 0, $design_id = '')
 {
     $id = (int) $id;
     $data = array();
     $data['color'] = (string) $color;
     $data['design_id'] = $design_id;
     $this->load->model('settings_m');
     $setting = $this->settings_m->getSetting();
     $data['setting'] = json_decode($setting->settings);
     $langFile = ROOTPATH . DS . 'media' . DS . 'data' . DS . 'lang.ini';
     $data['lang'] = parse_ini_file($langFile);
     // get product default or product id
     if ($id > 0) {
         $fields = array('id' => $id, 'published' => 1);
     } else {
         $fields = array('published' => 1);
     }
     $this->load->model('product_m');
     $rows = $this->product_m->getProduct($fields);
     if ($rows != false) {
         $product = $rows[0];
         // get product design
         $design = $this->product_m->getProductDesign($product->id);
         if ($design == false) {
             $product = false;
         } else {
             $this->load->helper('product');
             $help_design = new helperProduct();
             $product->design = $help_design->getDesign($design);
             // attribute
             $attribute = $this->product_m->getAttribute($product->id);
             if (count($attribute)) {
                 $product->attribute = $help_design->displayAttributes($attribute);
             } else {
                 $product->attribute = '';
             }
             $product->attribute = $help_design->quantity($product->min_order) . $product->attribute;
             $this->load->model('categories_m');
             $product->categories = $this->categories_m->getCategories('product');
         }
         $data['product'] = $product;
     } else {
         $data['product'] = false;
     }
     $data['user'] = $this->session->userdata('user');
     // check user admin
     $is_admin = true;
     if (empty($data['user']['id'])) {
         $is_admin = false;
     } else {
         //$this->load->model('users_m');
         //$is_admin	= $this->users_m->userPermission('art');
     }
     $data['is_admin'] = $is_admin;
     $designer = $this->load->view('components/design/designer', $data, true);
     $this->data['meta'] = '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1, minimum-scale=0.5, maximum-scale=1.0"/>';
     $this->data['content'] = $designer;
     $this->data['subview'] = $this->load->view('layouts/design/default', array(), true);
     $this->theme($this->data, 'design');
 }
Example #2
0
File: api.php Project: Nnamso/tbox
 function image($product_id = 0, $view = 'front', $index = 0)
 {
     $product_id = (int) $product_id;
     $index = (int) $index;
     if ($product_id == 0) {
         return false;
     }
     $this->load->driver('cache');
     if ($this->cache->file->get('product-img-' . $product_id . '-' . $view . '-' . $index) == false) {
         // load product design
         $this->load->model('product_m');
         $product = $this->product_m->getProductDesign($product_id);
         if (count($product)) {
             $this->load->helper('product');
             $help_product = new helperProduct();
             $design = $help_product->getDesign($product);
         } else {
             return false;
         }
         $design = json_decode(json_encode($design), true);
         if (empty($design[$view][$index])) {
             return false;
         }
         $string = str_replace("'", '"', $design[$view][$index]);
         $string = str_replace('px"', '"', $string);
         $img = new Imagick();
         $img->newImage(500, 500, new ImagickPixel('transparent'));
         $img->setImageFormat('png');
         $design = json_decode($string, true);
         $n = count($design) - 1;
         for ($i = $n; $i >= 0; $i--) {
             $image = $design[$i];
             if ($image['id'] == 'area-design') {
                 continue;
             }
             $file = ROOTPATH . DS . str_replace('/', DS, $image['img']);
             $newfile = new Imagick($file);
             $newfile->resizeImage($image['width'], $image['height'], Imagick::FILTER_LANCZOS, 1);
             $img->compositeImage($newfile, Imagick::COMPOSITE_DEFAULT, $image['left'], $image['top']);
         }
         $thumbnail = $img->getImageBlob();
         $this->cache->file->save('product-img-' . $product_id . '-' . $view . '-' . $index, base64_encode($thumbnail), 300000);
     } else {
         $img = $this->cache->file->get('product-img-' . $product_id . '-' . $view . '-' . $index);
         $thumbnail = base64_decode($img);
     }
     header("Content-Type: image/png");
     echo $thumbnail;
 }
Example #3
0
 function getDesign($id = '')
 {
     $data = array();
     if ($id == '') {
         $this->msgError();
     }
     $this->load->model('product_m');
     // get product info
     $fields = array('id' => $id, 'published' => 1);
     $rows = $this->product_m->getProduct($fields);
     // check product
     if ($rows == false) {
         $this->msgError();
     }
     $product = $rows[0];
     // product design
     $design = $this->product_m->getProductDesign($id);
     if (count($design) == 0) {
         $this->msgError();
     }
     $this->load->helper('product');
     $help_design = new helperProduct();
     $product->design = $help_design->getDesign($design);
     // get product attribute
     $attribute = $this->product_m->getAttribute($id);
     if (count($attribute)) {
         $product->attribute = $help_design->displayAttributes($attribute);
     } else {
         $product->attribute = '';
     }
     $product->attribute = $help_design->quantity($product->min_order) . $product->attribute;
     $data = array();
     $data['status'] = 1;
     $data['product'] = $product;
     echo json_encode($data);
     exit;
 }
Example #4
0
File: edit.php Project: Nnamso/tbox
</a>
											</td>
											
											<td class="center">
												<input type="hidden" id="right-products-design-<?php 
        echo $i;
        ?>
" value="<?php 
        echo $design->options[$i]['right'];
        ?>
" name="product[design][right][]">
												<img width="50" id="right-products-img-<?php 
        echo $i;
        ?>
" src="<?php 
        echo helperProduct::getImgage($design->options[$i]['right']);
        ?>
" alt=""> <br>
												<a onclick="dgUI.product.design(this, 'right')" href="javascript:void(0)"><?php 
        echo lang('configure');
        ?>
</a>
											</td>
											
											<td class="center"><input type="text" name="product[design][ordering][]" value="<?php 
        echo $design->options[$i]['ordering'];
        ?>
" class="input-small ordering"></td>
											
											<td class="center"><a onclick="dgUI.product.removeColor(this)" href="javascript:void(0)"><?php 
        echo lang('remove');
Example #5
0
 public function index($string = '', $color = '')
 {
     $id = (int) $string;
     // page not found
     $found = true;
     if ($id == 0) {
         $found = false;
     } else {
         // load product info
         $this->load->model('product_m');
         $row = $this->product_m->getProduct(array('id' => $id, 'published' => 1));
         if (empty($row[0]) || count($row[0]) == 0) {
             $found = false;
         }
     }
     $data = array();
     if ($found === false) {
         // load 404
         $data['subview'] = $this->load->view('layouts/404/404', array(), true);
     } else {
         $this->data = array();
         $product = $row[0];
         // get attributes
         $attribute = $this->product_m->getAttribute($id);
         if (count($attribute)) {
             $this->load->helper('product');
             $help_product = new helperProduct();
             $product->attributes = $help_product->displayAttributes($attribute);
         }
         // get product design
         $design = $this->product_m->getProductDesign($id);
         if (count($design)) {
             $product->design = $help_product->getDesign($design);
         }
         // product color
         $this->data['color_load'] = false;
         $this->data['index'] = '';
         if ($color != '') {
             $index = (int) $color;
             if (isset($product->design->color_hex[$index])) {
                 $this->data['index'] = $index;
                 $this->data['color_load'] = true;
                 $this->data['color_active'] = str_replace($index . '-', '', $color);
             }
         }
         $this->data['product_m'] = $this->product_m;
         $this->data['product'] = $product;
         // load Related
         $product_cate = $this->product_m->getProductCate($id);
         $cate_id = array();
         foreach ($product_cate as $cate) {
             $cate_id[] = $cate->cate_id;
         }
         $this->data['products'] = $this->product_m->getRelated($cate_id, $id);
         // load view data
         $content = $this->load->view('components/product/default', $this->data, true);
         $data['content'] = $content;
         // load layout of each product
         $this->load->model('layout_m');
         $layout = $this->layout_m->getProductPage($id);
         if ($layout == '') {
             $layout = $this->load->view('layouts/product/default', array(), true);
         }
         $data['subview'] = $layout;
         // load Meta
         if ($product->meta_title != '') {
             $data['title'] = $product->meta_title;
         }
         if ($product->meta_keywords != '') {
             $data['meta_keywords'] = $product->meta_keywords;
         }
         if ($product->meta_description != '') {
             $data['meta_description'] = $product->meta_description;
         }
     }
     $this->theme($data, 'product');
 }