Subversion Repositories SmartDukaan

Rev

Rev 11811 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11805 anikendra 1
<?php
2
if (!defined('BASEPATH'))
3
	exit('No direct script access allowed');
4
 
5
 
6
/*
7
 * Model for home
8
 */ 
9
 
10
Class Privatedeal_model extends CI_Model {
11
 
12
	var $url = '';
13
	var $parser_model;
14
	var $parser;
15
 
16
	function __construct() {
17
 
18
		// Call the Model constructor
19
		parent::__construct();
20
		//load appropriate parser
21
		$current_client =$this -> config -> item('current_client');
22
		$model = $current_client.'_model';
23
		$this->load->model($model);
24
		$this->parser = $this-> $model;
25
 
26
 
27
	}
28
/*
29
	function index($get=array(),$post=array(),$module=array())
30
	{
31
 
32
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
33
		$this->curlURL('privatedeals/1','get',$get);
34
		$responses = $this->mcurl->execute();
35
		$responses = $this->parser->parse_response($responses);
36
		return $responses;
37
	}
38
*/
11845 anikendra 39
	function getProducts($get=array(),$post=array(),$module=array(), $userId,$page=1)
11805 anikendra 40
	{
41
		$output =array();
42
		if(isset($module) and !empty($module))
43
		{
44
			if(isset($module['header']) and !empty($module['header']))
45
			{
46
				foreach($module['header'] as $header)
47
				{
48
 
49
					$this->curlURL($header,'get');
50
				}
51
			}
52
			if(isset($module['footer']) and !empty($module['footer']))
53
			{
54
				foreach($module['footer'] as $footer)
55
				{
56
					$this->curlURL($footer,'get');
57
				}
58
			}
59
			if(isset($module['response']) and !empty($module['response']))
60
			{
61
				foreach($module['response'] as $response)
62
				{
63
 
64
					if(isset($post) and !empty($post))
65
					{
66
						if($this->current_client=='magento' )
67
						$this->curlURL($response,'get',$post);
68
					else
69
						$this->curlURL($response,'get',$post);
70
 
71
					}
72
					else
73
					{
74
 
11845 anikendra 75
						$this->curlURL($response,'get',$get,$userId,$page);
11805 anikendra 76
					}
77
				}
78
			}
79
 
80
 
81
		}
82
 
83
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
84
		//$this->curlURL('products','get',$get);
85
		$responses = $this->mcurl->execute();
86
		if(isset($responses) and !empty($responses))
87
		$responses = $this->parser->parse_response($responses,$module);
88
 
89
 
90
		return $responses;
91
	}
11811 anikendra 92
 
11845 anikendra 93
	function curlURL($configurl=null,$methodtype='get',$parameter=array(),$userId=null,$page=1)	{		
11805 anikendra 94
		$params ='';
95
		$display='';
96
		$url = $this->config->item('curl_base_url');
97
		$productsurl =$this->config->item($configurl);
98
		if(isset($productsurl['url']) and !empty($productsurl['url']))
11811 anikendra 99
		{
100
			$url .=$productsurl['url'];
101
			if($productsurl['display']) {
102
				$display=$productsurl['display'];
103
			}
104
			if(empty($parameter)) {
105
				$parameter=$productsurl['params'];
106
			}			
107
			/*
108
			if(isset($parameter) and !empty($parameter) and $methodtype=='get')
11805 anikendra 109
			{
11811 anikendra 110
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
11805 anikendra 111
 
11811 anikendra 112
			}
113
			if(isset($parameter) and !empty($parameter) and $methodtype=='post')
114
			{
115
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
116
				$methodtype ='post';
117
			}
118
			if(!isset($parameter) || empty($parameter))
119
				{$params =$this->parser->prepareParams('',$display,$configurl);}
120
			*/
121
			if(isset($userId) && $userId != null){
11845 anikendra 122
				$url .= '/'.$page.'/?isLoggedIn=true&userId='.$userId;
11811 anikendra 123
			}
124
			/*
125
			if(isset($query) && $query != null){
126
				$params = $query;
127
			}		
128
			return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
129
			*/
130
			return $this->mcurl->add_call($configurl,$methodtype,$url);
131
		} else {
132
			return '';
11805 anikendra 133
		}
134
	}
135
}