0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
marketting
/
system
/
application
/
controllers
/
[
Home
]
File: products.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | COPYRIGHT NOTICE | Copyright 2008 JROX Technologies, Inc. All Rights Reserved. | ------------------------------------------------------------------------- | This script may be only used and modified in accordance to the license | agreement attached (license.txt) except where expressly noted within | commented areas of the code body. This copyright notice and the | comments above and below must remain intact at all times. By using this | code you agree to indemnify JROX Technologies, Inc, its corporate agents | and affiliates from any liability that might arise from its use. | | Selling the code for this program without prior written consent is | expressly forbidden and in violation of Domestic and International | copyright laws. | | ------------------------------------------------------------------------- | FILENAME - Products.php | ------------------------------------------------------------------------- | | This controller file is used to generate product categories | */ class Products extends Public_Controller { function __construct() { parent::Public_Controller(); //load css body style $this->config->set_item('css_body', 'jroxProducts'); //load required models $this->load->model('init_model', 'init'); $this->load->model('products_model', 'prod'); //create pagination links $this->config->set_item('uri', $this->config->item('base_folder_path') . '/' . $this->uri->segment(1)); $this->config->set_item('uri_string', str_replace('/', ':', trim_slashes($this->uri->uri_string()))); } // ------------------------------------------------------------------------ function index() { //redirect to default view redirect(); } // ------------------------------------------------------------------------ function category() { //set data array $data = $this->security_model->_load_config('public'); //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } $data['lang_products'] = $this->lang->line('product_s'); $data['lang_more_info'] = $this->lang->line('more_info'); $data['lang_sort_products_by'] = $this->lang->line('sort_products_by'); $data['lang_alphabetically'] = $this->lang->line('alphabetically'); $data['lang_price_high_to_low'] = $this->lang->line('price_high_to_low'); $data['lang_price_low_to_high'] = $this->lang->line('price_low_to_high'); $data['lang_sub_categories'] = $this->lang->line('sub_categories'); $data['lang_select_category'] = $this->lang->line('select_category'); //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } //set the category ID $data['product_title_url'] = $this->uri->segment(4); $data['cat_id'] = (int)$this->uri->segment(3, 1); //get the category details $filter = $this->db_validation_model->_get_details('products_categories', '*', 'category_id', $data['cat_id']); $data['product_category_name'] = $filter[0]['category_name']; $data['product_category_description'] = $filter[0]['category_description']; //set up the breadcrumbs $cat_path_array = $this->prod_cat->_get_all_product_categories(); $data['breadcrumbs_path'] = $this->prod_cat->_get_path($data['cat_id'], $data['product_category_name'], $filter[0]['parent_id'], $cat_path_array, true); $data['product_category_image'] = ''; if (!empty($filter[0]['category_image'])) { $data['product_category_image'] = '<img src="' . base_url() . 'images/' . $data['images_product_categories_dir'] . '/' . $filter[0]['category_image'] . '" id="jroxProductCategoryImage_' . $data['cat_id'] . '" class="jroxProductCategoryImage"/>'; } //set the meta tags $data['page_title'] = $data['layout_design_header_tag_line'] . ' - ' . $data['product_category_name']; $data['meta_keywords'] = $data['sts_store_default_keywords'] . ', ' . $filter[0]['category_keywords']; $data['meta_description'] = $data['sts_store_description'] . ' - ' . $data['product_category_name']; $data['images_products_dir'] = $data['images_products_dir']; //set the products per page if ($this->session->userdata('user_products_per_page_set')) { $data['products_per_page'] = $this->session->userdata('user_products_per_page_set'); } else { $data['products_per_page'] = $data['sts_products_per_page']; } $uri = $data['uri'] . '/category/' . $data['cat_id'] . '/' . $this->uri->segment(4); $data['offset'] = $this->uri->segment(5, 0); $data['sort_column'] = $this->uri->segment(7, 0); $data['sort_order'] = $this->uri->segment(6, 0); $data['next_sort_order'] = $this->uri->segment(6) == 'DESC' ? 'ASC' : 'DESC'; //get currency options $num_options = get_default_currency($this->config->item('sts_store_default_currency')); //get any subcategories $cdata = $this->prod_cat->_get_sub_categories($data['cat_id']); $data['no_sub_categories'] = '1'; if (!empty($cdata)) { $data['sub_categories'] = array(); foreach ($cdata as $row) { $row['category_name_url'] = $row['category_id'] . '/' . url_title($row['category_name']); array_push($data['sub_categories'] , $row); } $data['no_sub_categories'] = '0'; } //get products $sdata = $this->prod->_get_products_per_category($data['cat_id'], $data['products_per_page'], $data['offset'], $data['sort_column'], $data['sort_order'], $num_options); if (empty($sdata['rows'])) { $data['products'] = array(); $data['pagination_rows'] = ''; $data['no_products'] = '1'; $data['lang_no_products_found'] = $this->lang->line('no_products_found'); $data['total_products'] = '0'; } else { //add the data to the array $data['products'] = $sdata['rows']; $data['total_products'] = $sdata['total_rows']; $data['no_products'] = '0'; //check for discounts $data['show_discount_amount'] = ''; //set pagination $pagination = $this->db_validation_model->_set_pagination($uri, 'products_categories', $data['products_per_page'], 5, $data['sort_order'], $data['sort_column'], $sdata['total_rows'], '', '', 'public'); $data['pagination_rows'] = $pagination['rows']; $data['num_pages'] = $pagination['num_pages']; $data['no_pages'] = $data['num_pages'] > 1 ? 1 : 0; } //check grid or list $data['lang_switch_view'] = $this->lang->line('switch_product_view'); $data['lang_view_grid'] = $this->lang->line('view_grid'); $data['lang_view_list'] = $this->lang->line('view_list'); if ($this->session->userdata('user_products_grid_set') == 'grid') { $template = 'tpl_products_grid'; } else { $template = 'tpl_products'; } $this->parser->_JROX_load_view($template, 'store', $data); } // ------------------------------------------------------------------------ function search() { //set data array $data = $this->security_model->_load_config('public'); //set the search query $data['query_string'] = $this->uri->segment(3); if (empty($data['query_string'])) { redirect(); } else { //load convert library $this->load->library('convert'); $uri = $data['uri'] . '/search/' . $data['query_string']; $data['query_string'] = base64_decode($this->convert->HexToAscii($data['query_string'])); } //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } $data['lang_products'] = $this->lang->line('products'); $data['lang_search_term'] = $this->lang->line('search_term'); $data['lang_more_info'] = $this->lang->line('more_info'); $data['lang_search'] = $this->lang->line('search'); //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } //set the meta tags $data['page_title'] = $data['layout_design_header_tag_line'] . ' - ' . $this->lang->line('search'); $data['meta_keywords'] = $data['sts_store_default_keywords'] . ', ' . $data['query_string']; $data['meta_description'] = $data['sts_store_description'] . ' - ' . $data['query_string']; $data['images_products_dir'] = $data['images_products_dir']; //set the products per page if ($this->session->userdata('user_products_per_page_set')) { $data['products_per_page'] = $this->session->userdata('user_products_per_page_set'); } else { $data['products_per_page'] = $data['sts_products_per_page']; } $data['offset'] = $this->uri->segment(4, 0); $data['sort_column'] = $this->uri->segment(6, 0); $data['sort_order'] = $this->uri->segment(5, 0); $data['next_sort_order'] = $this->uri->segment(5) == 'DESC' ? 'ASC' : 'DESC'; //get products $num_options = get_default_currency($this->config->item('sts_store_default_currency')); $sdata = $this->prod->_get_products_per_category($data['query_string'], $data['products_per_page'], $data['offset'], $data['sort_column'], $data['sort_order'], $num_options, 'search'); if (empty($sdata['rows'])) { $data['products'] = array(); $data['pagination_rows'] = ''; $data['no_products'] = '1'; $data['lang_no_products_found'] = $this->lang->line('no_products_found'); $data['total_products'] = '0'; } else { //add the data to the array $data['products'] = $sdata['rows']; $data['total_products'] = $sdata['total_rows']; $data['no_products'] = '0'; //check for discounts $data['show_discount_amount'] = ''; //set pagination $pagination = $this->db_validation_model->_set_pagination($uri, 'search', $data['products_per_page'], 4, $data['sort_order'], $data['sort_column'], $sdata['total_rows'], '', '', 'public'); $data['pagination_rows'] = $pagination['rows']; $data['num_pages'] = $pagination['num_pages']; $data['no_pages'] = $data['num_pages'] > 1 ? 1 : 0; } if ($this->session->userdata('user_products_grid_set') == 'grid') { $template = 'tpl_search_products_grid'; } else { $template = 'tpl_search_products'; } $this->parser->_JROX_load_view($template, 'store', $data); } // ------------------------------------------------------------------------ function new_products() { //set data array $data = $this->security_model->_load_config('public'); $uri = $data['uri'] . '/new_products'; //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } $data['lang_products'] = $this->lang->line('products'); $data['lang_new_products'] = $this->lang->line('new_products'); $data['lang_more_info'] = $this->lang->line('more_info'); $data['lang_sort_products_by'] = $this->lang->line('sort_products_by'); $data['lang_alphabetically'] = $this->lang->line('alphabetically'); $data['lang_price_high_to_low'] = $this->lang->line('price_high_to_low'); $data['lang_price_low_to_high'] = $this->lang->line('price_low_to_high'); //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } //set the meta tags $data['page_title'] = $data['layout_design_header_tag_line'] . ' - ' . $this->lang->line('new_products'); $data['meta_keywords'] = $data['sts_store_default_keywords'] . ', ' . $this->lang->line('new_products'); $data['meta_description'] = $data['sts_store_description'] . ' - ' . $this->lang->line('new_products'); $data['images_products_dir'] = $data['images_products_dir']; //set the products per page if ($this->session->userdata('user_products_per_page_set')) { $data['products_per_page'] = $this->session->userdata('user_products_per_page_set'); } else { $data['products_per_page'] = $data['sts_products_per_page']; } $data['offset'] = $this->uri->segment(3, 0); $data['sort_column'] = $this->uri->segment(5, 0); $data['sort_order'] = $this->uri->segment(4, 0); $data['next_sort_order'] = $this->uri->segment(4) == 'DESC' ? 'ASC' : 'DESC'; //get products $num_options = get_default_currency($this->config->item('sts_store_default_currency')); $sdata = $this->prod->_get_products_per_category('new', $data['products_per_page'], $data['offset'], $data['sort_column'], $data['sort_order'], $num_options, 'new'); if (empty($sdata['rows'])) { $data['products'] = array(); $data['pagination_rows'] = ''; $data['no_products'] = '1'; $data['lang_no_products_found'] = $this->lang->line('no_products_found'); $data['total_products'] = '0'; } else { //add the data to the array $data['products'] = $sdata['rows']; $data['total_products'] = $sdata['total_rows']; $data['no_products'] = '0'; //check for discounts $data['show_discount_amount'] = ''; //set pagination $pagination = $this->db_validation_model->_set_pagination($uri, 'new_products', $data['products_per_page'], 3, $data['sort_order'], $data['sort_column'], $sdata['total_rows'], '', '', 'public'); $data['pagination_rows'] = $pagination['rows']; $data['num_pages'] = $pagination['num_pages']; $data['no_pages'] = $data['num_pages'] > 1 ? 1 : 0; } //check grid or list $data['lang_switch_view'] = $this->lang->line('switch_product_view'); $data['lang_view_grid'] = $this->lang->line('view_grid'); $data['lang_view_list'] = $this->lang->line('view_list'); if ($this->session->userdata('user_products_grid_set') == 'grid') { $template = 'tpl_new_products_grid'; } else { $template = 'tpl_new_products'; } $this->parser->_JROX_load_view($template, 'store', $data); } // ------------------------------------------------------------------------ function manufacturer() { //set data array $data = $this->security_model->_load_config('public'); $uri = $data['uri'] . '/manufacturer'; $data['manufacturer_id'] = (int)$this->uri->segment(3, 1); //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } $data['lang_products'] = $this->lang->line('products'); $data['lang_manufacturers'] = $this->config->item('sts_products_manufacturer_category_name'); $data['lang_more_info'] = $this->lang->line('more_info'); $data['lang_sort_products_by'] = $this->lang->line('sort_products_by'); $data['lang_alphabetically'] = $this->lang->line('alphabetically'); $data['lang_price_high_to_low'] = $this->lang->line('price_high_to_low'); $data['lang_price_low_to_high'] = $this->lang->line('price_low_to_high'); //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } $data['product_title_url'] = $this->uri->segment(4); //get the category details $filter = $this->db_validation_model->_get_details('manufacturers', '*', 'manufacturer_id', $data['manufacturer_id']); $data['manufacturer_name'] = $filter[0]['manufacturer_name']; $data['manufacturer_description'] = $filter[0]['manufacturer_description']; //set the meta tags $data['page_title'] = $data['layout_design_header_tag_line'] . ' - ' . $data['manufacturer_name']; $data['meta_keywords'] = $data['sts_store_default_keywords'] . ', ' . $filter[0]['manufacturer_meta_keywords']; $data['meta_description'] = $data['sts_store_description'] . ' - ' . $filter[0]['manufacturer_meta_description']; $data['images_manufacturers_dir'] = $data['images_manufacturers_dir']; //set the products per page if ($this->session->userdata('user_products_per_page_set')) { $data['products_per_page'] = $this->session->userdata('user_products_per_page_set'); } else { $data['products_per_page'] = $data['sts_products_per_page']; } $uri = $data['uri'] . '/manufacturer/' . $data['manufacturer_id'] . '/' . $this->uri->segment(4); $data['offset'] = $this->uri->segment(5, 0); $data['sort_column'] = $this->uri->segment(7, 0); $data['sort_order'] = $this->uri->segment(6, 0); $data['next_sort_order'] = $this->uri->segment(6) == 'DESC' ? 'ASC' : 'DESC'; //get products $num_options = get_default_currency($this->config->item('sts_store_default_currency')); $sdata = $this->prod->_get_products_per_category($data['manufacturer_id'], $data['products_per_page'], $data['offset'], $data['sort_column'], $data['sort_order'], $num_options, 'manufacturer'); if (empty($sdata['rows'])) { $data['products'] = array(); $data['pagination_rows'] = ''; $data['no_products'] = '1'; $data['lang_no_products_found'] = $this->lang->line('no_products_found'); $data['total_products'] = '0'; } else { //add the data to the array $data['products'] = $sdata['rows']; $data['total_products'] = $sdata['total_rows']; $data['no_products'] = '0'; //check for discounts $data['show_discount_amount'] = ''; //set pagination $pagination = $this->db_validation_model->_set_pagination($uri, 'manufacturers', $data['products_per_page'], 5, $data['sort_order'], $data['sort_column'], $sdata['total_rows'], '', '', 'public'); $data['pagination_rows'] = $pagination['rows']; $data['num_pages'] = $pagination['num_pages']; $data['no_pages'] = $data['num_pages'] > 1 ? 1 : 0; } //check grid or list $data['lang_switch_view'] = $this->lang->line('switch_product_view'); $data['lang_view_grid'] = $this->lang->line('view_grid'); $data['lang_view_list'] = $this->lang->line('view_list'); if ($this->session->userdata('user_products_grid_set') == 'grid') { $template = 'tpl_manufacturer_products_grid'; } else { $template = 'tpl_manufacturer_products'; } $this->parser->_JROX_load_view($template, 'store', $data); } // ------------------------------------------------------------------------ function details() { //set data array $data = $this->security_model->_load_config('public'); //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } //set the category ID $data['product_title_url'] = $this->uri->segment(4); $data['s_product_id'] = (int)$this->uri->segment(3, 1); $num_options = get_default_currency($this->config->item('sts_store_default_currency')); $sdata = $this->prod->_get_product_info($data['s_product_id']); if (empty($sdata['info'])) { redirect_301(); } //merge the product data foreach ($sdata['info'] as $k => $v) { $data[$k] = $v; } $data['lang_inventory'] = ''; $data['no_inventory'] = 0; //check inventory system if ($this->config->item('sts_products_enable_inventory') == 1) { if ($data['product_type'] == 'physical' && $data['enable_product_inventory'] != '0') { if (empty($data['product_inventory'])) { $data['lang_inventory'] = $this->lang->line('out_of_stock'); $data['no_inventory'] = 1; $data['lang_add_to_cart'] = $this->lang->line('out_of_stock'); } else { $data['lang_inventory'] = $this->lang->line('in_stock'); } } } //format pricing $data['product_price'] = format_amounts($data['product_price'], $num_options); $data['product_trial_price'] = format_amounts($data['product_trial_price'], $num_options); //check for trial membership pricing if ($data['product_type'] == 'membership' && $data['enable_product_trial'] == 1 && !empty($data['product_trial_price'])) { $data['product_price'] = $data['product_trial_price']; } if ($data['login_for_price'] == 1) { if (!$this->session->userdata('userid')) { $data['product_price'] = $this->lang->line('login_for_price'); } } if ($data['add_cart_for_price'] == 1) { $data['product_price'] = $this->lang->line('add_cart_for_price'); } //format add to cart links if ($data['product_type'] == 'membership') { $data['submit_url'] = $data['checkout_url'] . $this->config->slash_item('checkout_index_page') . 'membership/registration/' . $data['pid'] . '/' . $this->config->item('enc_id'); $data['add_to_cart'] = $this->lang->line('buy_now'); $data['add_to_cart_css'] = 'jroxButtonBuyNowBig'; } else { $data['submit_url'] = 'cart/add/' . $data['pid']; $data['add_to_cart'] = $this->lang->line('add_to_cart'); $data['add_to_cart_css'] = 'jroxButtonAddToCartBig'; } //check reviews if (!empty($data['average_review'])) { $data['ratings'] = _show_ratings($data['average_review']); $data['lang_rating'] = $this->lang->line('ratings') . ':'; } else { $data['ratings'] = ''; $data['lang_rating'] = ''; } //format the photos //check if there are any videos $sdata['no_photos'] = !empty($sdata['photos']) ? '0' : '1'; $i=0; if (!empty($sdata['photos'])) { foreach ($sdata['photos'] as $k => $v) { $sdata['photos'][$i]['image_id'] = $v['photo_id']; if (empty($v['photo_file_name'])) { $sdata['photos'][$i]['image_file'] = '<img src="' . base_url(). 'themes/main/' . $this->config->item('layout_design_site_theme') . '/images/no_photo.png" />'; } else { $sdata['photos'][$i]['image_file'] = _check_image_thumbnail($this->config->item('images_products_dir'), $v, $v['image_resized'], $height = '', $width = ''); } $i++; } } else { $sdata['photos'][0]['image_file'] = '<img src="' . base_url(). 'themes/main/' . $this->config->item('layout_design_site_theme') . '/images/no_photo_large.png" />'; } //format videos if ($this->session->userdata('m_username')) { $data['s_product_aff_link'] = _get_aff_product_link($this->session->userdata('m_username'), $data['uri_string']); } else { $data['s_product_aff_link'] = $data['sts_video_player_default_link']; } $i=0; $this->load->plugin('flv_player'); if (!empty($sdata['videos'])) { $width = $this->config->item('sts_video_player_width') + '40'; $height = $this->config->item('sts_video_player_height') + '40'; foreach ($sdata['videos'] as $k => $v) { $sdata['videos'][$i]['video_url'] = '<a href="javascript:void(window.open(\''. base_url() . PRODUCTS_ROUTE . '/view_video/' . $v['id'] . '\', \'popup\', \'width=' . $width . ',height=' . $height . ', location=no, menubar=no, status=no,toolbar=no, scrollbars=yes, resizable=yes\'))">' . $v['video_name'] . '</a>'; if ($sdata['videos'][$i]['use_external_embed'] == 0) { $sdata['videos'][$i]['video_embed_code'] = htmlentities(Flash_Player($sdata['videos'][$i]['video_code'], $data['s_product_aff_link'], 'jroxMainVideo')); } else { $sdata['videos'][$i]['video_embed_code'] = $sdata['videos'][$i]['video_code']; } $i++; } } $data = array_merge($data, $sdata); //set the meta tags $data['page_title'] = $data['layout_design_header_tag_line'] . ' - ' . $sdata['info']['product_name']; $data['meta_keywords'] = $data['sts_store_default_keywords'] . ', ' . $sdata['info']['product_keywords']; $data['meta_description'] = $data['sts_store_description'] . ' - ' . $sdata['info']['product_name']; $data['lang_products'] = $this->lang->line('products'); //check if there are any videos $data['no_videos'] = !empty($data['videos']) ? '0' : '1'; if ($data['use_video_default'] == 1) { if ($data['videos'][0]['use_external_embed'] == 0) { $data['code'] = Flash_Player(html_entity_decode($data['videos'][0]['video_code']), $data['s_product_aff_link'], 'jroxMainVideo'); } else { $data['code'] = html_entity_decode($data['videos'][0]['video_code']); } } else { if (empty($data['photos'][0]['photo_file_name'])) { $data['code'] = '<img src="' . base_url(). 'themes/main/' . $this->config->item('layout_design_site_theme') . '/images/no_photo.png " class="jroxMainPhoto"/>'; } else { $data['code'] = '<img src="' . base_url() . 'images/' . $data['images_products_dir'] . '/' . $data['photos'][0]['photo_file_name'] . '" class="jroxMainPhoto"/>'; } } $data['lang_overview'] = $this->lang->line('overview'); $data['lang_videos'] = $this->lang->line('videos'); $data['lang_photos'] = $this->lang->line('photos'); $data['lang_click_image_view'] = $this->lang->line('click_image_view'); $data['lang_click_view_videos'] = $this->lang->line('click_view_videos'); $data['lang_description_1'] = $data['sts_products_description_1_name']; $data['lang_description_2'] = $data['sts_products_description_2_name']; $data['lang_similar_products'] = $this->lang->line('similar_products'); $data['lang_tell_friend'] = $this->lang->line('tell_a_friend'); $data['lang_required'] = $this->lang->line('required'); $data['lang_subtotal'] = $this->lang->line('subtotal'); $data['lang_no_items_in_cart'] = $this->lang->line('no_items_in_cart'); //check for discounts $data['show_discount_amount'] = ''; if ($this->session->userdata('m_discount_group') && $data['product_type'] != 'membership') { $custom_discount = $this->prod->_get_custom_product_discount($data['s_product_id'], $this->session->userdata('m_discount_group')); $custom_amount = !empty($custom_discount) ? $custom_discount['amount'] : ''; $data['show_discount_amount'] = $this->prod->_get_product_discounts($this->session->userdata('m_discount_group'), $num_options, false, $custom_amount); } //check if we are showing similar products if ($this->config->item('sts_products_show_similar_products_details_page') == 1) { $data['show_similar'] = 1; $data['similar_products'] = $this->prod->_get_similar_products($data['product_keywords'], $data['s_product_id'], $num_options); if (empty($data['similar_products'])) { $data['show_similar'] = 0; } } else { $data['show_similar'] = 0; } //get attributes if any $attributes = $this->attrib->_get_product_attributes($data['s_product_id']); $data['show_attributes'] = 0; if (!empty($attributes)) { $data['show_attributes'] = 1; $data['product_attributes'] = array(); foreach ($attributes as $k => $v) { $new_attrib = $this->attrib->_format_attribute($v); array_push($data['product_attributes'], $new_attrib); } } $data['lang_product_options'] = $this->lang->line('product_options'); $data['lang_quantity'] = $this->lang->line('quantity'); $data['lang_your_cart_contents'] = $this->lang->line('your_cart_contents'); $data['lang_embed_code'] = $this->lang->line('embed_code'); $data['lang_links'] = $this->lang->line('links'); //get reviews $data['show_reviews'] = 0; if ($this->config->item('sts_products_enable_reviews') == 1) { $data['show_reviews'] = 1; $data['lang_reviews'] = $this->lang->line('reviews'); $data['lang_add_review'] = $this->lang->line('add_review'); $this->load->model('reviews_model'); $reviews = $this->reviews_model->_get_product_reviews('25', '0', $this->config->item('pub_dbs_rev_column'), $this->config->item('pub_dbs_rev_order'), 'product_id', $data['s_product_id'], true); if (empty($reviews)) { $data['product_reviews'][0] = array('username' => '', 'comment' => 'be the first to write a review for this product', 'review_ratings' => '', 'review_date' => ''); $data['lang_reviewed_by'] = $this->lang->line('write_a_review'); } else { $data['lang_reviewed_by'] = $this->lang->line('reviewed_by'); $data['product_reviews'] = array(); foreach ($reviews as $v) { $v['review_date'] = _show_date($v['date']); $v['review_id'] = $v['id']; $v['review_ratings'] = _show_ratings($v['ratings']); array_push($data['product_reviews'], $v); } } //generate review box if ($this->session->userdata('userid')) { $atts = array( 'width' => '500', 'height' => '500', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '20', 'screeny' => '20' ); $url = anchor_popup(base_url() . PRODUCTS_ROUTE . '/add_review/' . $data['s_product_id'], $this->lang->line('add_review'), $atts); $data['lang_write_review'] = $url; $data['lang_click_to_register'] = ''; $data['lang_click_to_login'] = ''; } else { $data['lang_write_review'] = '<a href="' . base_url() . 'login">' . $this->lang->line('login_to_review') . '</a>'; $data['lang_click_to_register'] = $this->lang->line('click_to_register'); $data['lang_click_to_login'] = $this->lang->line('click_to_login'); } } //check for social marketing code $data['tell_friend_code'] = base64_decode($data['sts_store_refer_friend_code']); $data['bookmarks_code'] = base64_decode($data['sts_products_bookmarks_code']); //check for affiliate marketing and direct link codes $data['show_aff_links'] = 0; if ($data['sts_affiliate_enable_affiliate_marketing'] == 1 && $data['sts_affiliate_enable_direct_product_code'] == 1) { if ($this->session->userdata('userid')) { $data['show_aff_links'] = 1; $data['product_aff_link_code'] = $data['s_product_aff_link']; $data['lang_link_to_product'] = $this->lang->line('link_to_product'); } } if ($this->session->userdata('m_username')) { $aff_product_link = _get_aff_product_link($this->session->userdata('m_username'), $data['uri_string']); $data['tell_friend_code'] = str_replace('{affiliate_link}', '\'' . $aff_product_link . '\'', $data['tell_friend_code']); $data['bookmarks_code'] = str_replace('{affiliate_link}', '\'' . $aff_product_link . '\'', $data['bookmarks_code']); } elseif ($this->session->userdata('jrox_site_referral_regular')) { $aff_username = _get_session_aff($this->session->userdata('jrox_site_referral_regular')); $aff_product_link = _get_aff_product_link($aff_username, $data['uri_string']); $data['tell_friend_code'] = str_replace('{affiliate_link}', '\'' . $aff_product_link . '\'', $data['tell_friend_code']); $data['bookmarks_code'] = str_replace('{affiliate_link}', '\'' . $aff_product_link . '\'', $data['bookmarks_code']); } else { $data['tell_friend_code'] = str_replace('{affiliate_link}', 'window.location', $data['tell_friend_code']); $data['bookmarks_code'] = str_replace('{affiliate_link}', base_url(), $data['bookmarks_code']); } //get shopping cart contents $cart_items = $this->cart->_get_cart_items($num_options); $data['total_conversion'] = ''; if (empty($cart_items['items'])) { $data['cart_contents'] = $this->lang->line('cart_is_empty'); $data['checkout_items'] = array(); $data['subtotal_cart_price'] = ''; $data['show_cart_contents'] = 0; } else { $i=0; foreach ($cart_items['items'] as $item) { $cart_items['items'][$i]['s_product_name'] = limit_chars($cart_items['items'][$i]['product_name'], 20); $i++; } $data['checkout_items'] = $cart_items['items']; $data['subtotal_cart_price'] = format_amounts($cart_items['subtotal_cart_price'], $num_options); $data['show_cart_contents'] = 1; //check for currency total conversion $site_currency = get_site_currency(); if ($this->config->item('sts_store_default_currency') != $site_currency['settings_value']) { $default_num = get_default_currency($site_currency['settings_value']); $data['total_conversion'] = '(' . format_amounts($cart_items['subtotal_cart_price'], $default_num) . ')'; } } //check min quantity $data['min_quantity'] = !empty($data['min_quantity_ordered']) ? $data['min_quantity_ordered'] : '1'; //check recommended $data['show_recommended'] = 0; if ($data['sts_affiliate_enable_recommended_profile'] == 1 && $this->session->userdata('userid')) { $data['lang_add_to_profile_recommended'] = $this->lang->line('add_to_profile_recommended'); $data['lang_recommend_this'] = $this->lang->line('recommend_this'); $data['show_recommended'] = 1; } $data['show_message'] = ''; if ($this->session->flashdata('user_error')) { $data['show_message'] = '<div class="errorMessage">' . $this->session->flashdata('user_error') . '</div>'; } //update the product view totals $this->prod->_update_product_views($data['s_product_id']); if (file_exists($data['base_physical_path'] . '/themes/main/' . $data['layout_design_site_theme'] . '/custom_templates/tpl_product_details_' . $data['s_product_id'] . '.php')) { $this->parser->_JROX_load_view('tpl_product_details_' . $data['s_product_id'] , 'product_details', $data, true, true, true); } else { $this->parser->_JROX_load_view('tpl_product_details', 'product_details', $data, true, true, true); } } // ------------------------------------------------------------------------ function add_review() { //set data array $data = $this->security_model->_load_config('public'); $this->load->model('reviews_model'); //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } //set the ID $data['product_id'] = (int)$this->uri->segment(3); //first check if user is logged in if (!$this->session->userdata('userid')) { show_error($this->lang->line('login_to_review')); exit(); } $data['lang_submit_product_review'] = $this->lang->line('submit_a_review'); //get product name $name = $this->db_validation_model->_get_details('products', 'product_name', 'product_id', $data['product_id']); if (empty($name)) { show_error($this->lang->line('invalid_product')); exit(); } $data['product_name'] = $name[0]['product_name']; $data['product_name_url'] = url_title($data['product_name']); $data['lang_stars'] = $this->lang->line('stars'); $data['lang_star'] = $this->lang->line('star'); $data['lang_rating'] = $this->lang->line('rating'); $data['lang_close'] = $this->lang->line('close'); $data['page_title'] = $data['layout_design_header_tag_line']; $data['meta_keywords'] = $data['sts_store_default_keywords']; $data['meta_description'] = $data['sts_store_description']; $data['close_button'] = 'javascript:window.close()'; $data['show_message'] = ''; if ($this->_check_review() == false) { $this->load->helper('captcha'); $captcha = _generate_captcha(); $data = array_merge($data, $captcha); $data['lang_show_error'] = ''; $data['comment'] = ''; if (!empty($_POST)) { $data['show_message'] = '<div class="errorMessage">' . $this->validation->error_string . '</div>'; $data['comment'] = $this->validation->comment; } if ($this->session->flashdata('user_success_review')) { $data['show_message'] = '<div class="successMessage">' . $this->lang->line('review_waiting_moderation') . '</div>'; } echo $this->parser->_JROX_parse('tpl_review_product', APPPATH . 'views/main', $data, true); } else { if ($this->reviews_model->_add_review($data['product_id'])) { //send notifications out to admins $admins = $this->db_validation_model->_get_details('admin_users', '*', 'alert_admin_product_review', '1'); if (!empty($admins)) { $this->load->model('emailing_model'); foreach ($admins as $k => $v) { $v['review_comment'] = $this->validation->comment; $v['product_id'] = $data['product_id']; $v['product_url'] = base_url(). PRODUCTS_ROUTE . '/details/' . $data['product_id'] . '/' . $data['product_name_url']; if ($this->emailing_model->_send_template_email('admin', $v, 'admin_alert_product_review_template', true)) { //log success log_message('info', 'Admin Alert on Product Review Sent to ' . $v['primary_email']); } else { show_error($this->lang->line('could_not_send_email') . '. ' . $this->lang->line('check_email_settings')); log_message('error', 'Could not send email to ' . $v['primary_email'] . '. Check email settings.'); } } } $this->session->set_flashdata('user_success_review', true); redirect(PRODUCTS_ROUTE .'/add_review/' . $this->uri->segment(3)); } } } // ------------------------------------------------------------------------ function view_video() { //set data array $data = $this->security_model->_load_config('public'); //initialize site with required db config $sdata = $this->init->_initialize(__CLASS__, __FUNCTION__); //set up the languages array $data['languages'] = $sdata['languages']; //set all text foreach ($sdata['text'] as $key => $val) { $data[$key] = $val; } //set referral info foreach ($sdata['aff_cfg'] as $key => $val) { $data[$key] = $val; } //set the video ID $data['video_id'] = (int)$this->uri->segment(3); $video = $this->prod->_view_video($data['video_id']); if ($this->session->userdata('m_username')) { $data['s_product_aff_link'] = _get_aff_product_link($this->session->userdata('m_username'), $data['uri_string']); } else { $data['s_product_aff_link'] = $data['sts_video_player_default_link']; } $this->load->plugin('flv_player'); if ($video[0]['use_external_embed'] == 0) { $data['code'] = Flash_Player(html_entity_decode($video[0]['video_code']), $data['s_product_aff_link'], 'jroxMainVideo'); } else { $data['code'] = html_entity_decode($video[0]['video_code']); } echo $this->parser->_JROX_parse('tpl_view_video', APPPATH . 'views/main', $data, true); } // ------------------------------------------------------------------------ function recommend() { //recommend this product on member's profile page $product_id = (int)$this->uri->segment(3); if ($this->session->userdata('userid') && $this->session->userdata('m_username')) { if ($this->uri->segment(4) == 'delete') { if ($this->prod->_delete_recommended_product($product_id) == true) { redirect(PROFILE_ROUTE . '/' . $this->session->userdata('m_username')); exit(); } } else { if ($this->prod->_insert_recommended_product($product_id, $this->session->userdata('userid')) == true) { redirect(PROFILE_ROUTE . '/' . $this->session->userdata('m_username')); exit(); } } } redirect_301(); } // ------------------------------------------------------------------------ function switch_per_page() { if ($this->uri->segment('4')) { $this->session->set_userdata('user_products_per_page_set', (int)$this->uri->segment(4)); } if ($this->uri->segment('3')) { $data = explode(':', $this->uri->segment('3')); $refer = $data[0] . '/' . $data[1]; //$refer = referer_redirect('main', $this->uri->segment('3'), $sep = '_'); $refer .= !empty($data[2]) ? '/' . $data[2] : ''; $refer .= !empty($data[3]) ? '/' . $data[3] : ''; redirect_301($refer, false, false); //redirect_301($refer, false, false); } else { redirect_301(); } } // ------------------------------------------------------------------------ function switch_product_layout() { if ($this->uri->segment('4')) { $this->session->set_userdata('user_products_grid_set', $this->uri->segment('4')); } if ($this->uri->segment('3')) { $refer = referer_redirect('main', $this->uri->segment('3'), $sep = ':'); redirect_301($refer, false, false); } else { redirect_301(); } } // ------------------------------------------------------------------------ /* | ------------------------------------------------------------------------- | supporting functions - these are used to support the main functions above | ------------------------------------------------------------------------- */ // ------------------------------------------------------------------------ function _check_review() { $rules['comment'] = 'trim|required|min_length[2]'; if ($this->config->item('sts_sec_enable_captcha') == 1) { $rules['jroxVerifyField'] = 'trim|required|callback__check_captcha'; } $this->validation->set_rules($rules); //repopulate form $fields['comment'] = $this->lang->line('comment'); $fields['jroxVerifyField'] = $this->lang->line('verification_code'); $this->validation->set_fields($fields); if ($this->validation->run() == FALSE) { return false; } return true; } // ------------------------------------------------------------------------ function _check_captcha() { if ($this->session->userdata('user_captcha_set') != $this->validation->jroxVerifyField) { $this->validation->set_message('_check_captcha', $this->lang->line('invalid_verification_code')); return false; } } } ?>