Blame | Last modification | View Log | RSS feed
<?phpif (!defined('BASEPATH'))exit('No direct script access allowed');/** Model for home*/Class Cart_model extends CI_Model {var $url = '';var $parser_model;var $parser;function __construct() {// Call the Model constructorparent::__construct();//load appropriate parser$this->current_client =$this -> config -> item('current_client');$model = $this->current_client.'_model';$this->load->model($model);$this->parser = $this-> $model;}function getCart($get=array(),$post=array(),$module=array(), $cartId=null){$output =array();if(isset($module) and !empty($module)){if(isset($module['header']) and !empty($module['header'])){foreach($module['header'] as $header){$cache = getFileCache($header);if(isset($cache) && !empty($cache)){$head['header'][$header] = $cache;}else{$this->curlURL($header,'get');}}}if(isset($module['footer']) and !empty($module['footer'])){foreach($module['footer'] as $footer){$cache = getFileCache($footer);if(isset($cache) && !empty($cache)){$foot['footer'][$footer] = $cache;}else{$this->curlURL($footer,'get');}}}if(isset($module['response']) and !empty($module['response'])){foreach($module['response'] as $response){if(isset($post) and !empty($post)){if($this->current_client=='magento' )$this->curlURL($response,'post',$post,$cartId);else$this->curlURL($response,'post',$post,$cartId);}else{$this->curlURL($response,'get',$get,$cartId);}}}}//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )//$this->curlURL('products','get',$get);$responses = $this->mcurl->execute();if(isset($responses) and !empty($responses))$responses = $this->parser->parse_response($responses,$module);if(isset($head) && !empty($head)){foreach($head['header'] as $key=>$value){$responses['header'][$key] = $value;}}if(isset($foot) && !empty($foot)){foreach($foot['footer'] as $key=>$value){$responses['footer'][$key] = $value;}}return $responses;}function curlURL($configurl=null,$methodtype='get',$parameter=array(), $cartId=null){$params ='';$display='';$url = $this->config->item('curl_base_url');$productsurl =$this->config->item($configurl);if(isset($productsurl['url']) and !empty($productsurl['url'])){if($configurl == 'cartcoupon' || $configurl == 'cartcouponclear'){$url .= 'cart/'.$cartId.'/'.$productsurl['url'];}else{$url .=$productsurl['url'];}if($productsurl['display']){$display=$productsurl['display'];}if(empty($parameter)){$parameter=$productsurl['params'];}if(isset($parameter) and !empty($parameter) and $methodtype=='get'){$params = $this->parser->prepareParams($parameter,$display,$configurl);}if(isset($parameter) and !empty($parameter) and $methodtype=='post'){$params = $this->parser->prepareParams($parameter,$display,$configurl);$methodtype ='post';}if(!isset($parameter) || empty($parameter)){$params =$this->parser->prepareParams('',$display,$configurl);}if($configurl == 'carts'){$methodtype = 'get';$productsparams =$this->config->item($configurl);$productsparams = $productsparams['params'];$i = 0;$newparams = array();foreach($productsparams as $key => $value){if (array_key_exists($value,$params)){$newparams[$value] = $params[$value];$i++;}}$params = $newparams;}if(isset($cartId) && $cartId != null && $configurl != 'cartcoupon' && $configurl != 'cartcouponclear'){$url .= '/'.$cartId;}return $this->mcurl->add_call($configurl,$methodtype,$url,$params);}else{return '';}}}