Subversion Repositories SmartDukaan

Rev

Rev 12700 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 1
<?php
2
if (!defined('BASEPATH'))
3
	exit('No direct script access allowed');
4
 
5
 
6
/*
7
 * Model for home
8
 */ 
9
 
10
 
11
Class Fos_model extends CI_Model {
12
 
13
	var $url = '';
14
	var $parser_model;
15
	var $parser;
16
	var $current_client;
17
 
18
	function __construct() {
19
		// Call the Model constructor
20
		parent::__construct();
21
		//load appropriate parser
22
		$current_client =$this -> config -> item('current_client');
23
		$model = $current_client.'_model';
24
		$this->load->model($model);
25
		$this->parser = $this-> $model;
26
		$this->current_client=$this -> config -> item('current_client');
27
 
28
 
29
	}
30
 
31
 
32
	function getLogin($get=array(),$post=array(),$module=array())
33
	{	
34
		$output =array();
35
		if(isset($module) and !empty($module))
36
		{
37
			if(isset($module['header']) and !empty($module['header']))
38
			{
39
				foreach($module['header'] as $header)
40
				{
41
					$this->curlURL($header,'get');	
42
 
43
				}
44
			}
45
			if(isset($module['footer']) and !empty($module['footer']))
46
			{
47
				foreach($module['footer'] as $footer)
48
				{
49
 
50
					$this->curlURL($footer,'get');	
51
				}
52
			}
53
			if(isset($module['response']) and !empty($module['response']))
54
			{
55
				foreach($module['response'] as $response)
56
				{
57
					if(isset($post) and !empty($post))
58
					{
59
						if($this->current_client=='prestashop' || $this->current_client=='magento' ){
60
							$this->curlURL($response,'post',$post);
61
						} else{							
62
							$this->curlURL($response,'post',$post);
63
						}
64
					}
65
				}
66
			}			
67
		}
12732 anikendra 68
 
12694 anikendra 69
		$responses = $this->mcurl->execute();
70
		if(isset($responses) and !empty($responses))
71
		$responses = $this->parser->parse_response($responses,$module);
12732 anikendra 72
 
12694 anikendra 73
		return $responses;
74
	}
75
 
76
	function getSignup($get=array(),$post=array(),$module=array())
77
	{		
78
		$output =array();
79
		if(isset($module) and !empty($module))
80
		{
81
			if(isset($module['header']) and !empty($module['header']))
82
			{
83
				foreach($module['header'] as $header)
84
				{
85
					$this->curlURL($header,'get');	
86
 
87
				}
88
			}
89
			if(isset($module['footer']) and !empty($module['footer']))
90
			{
91
				foreach($module['footer'] as $footer)
92
				{
93
 
94
					$this->curlURL($footer,'get');	
95
 
96
				}
97
			}
98
			if(isset($module['response']) and !empty($module['response']))
99
			{
100
				foreach($module['response'] as $response)
101
				{
102
					if(isset($post) and !empty($post))
103
					{
12700 anikendra 104
						if($this->current_client=='prestashop' || $this->current_client=='magento' ) {
105
							$this->curlURL($response,'post',$post);
106
						}
107
						else{							
108
							$this->curlURL($response,'post',$post);
109
						}
12694 anikendra 110
					}
111
				}
12700 anikendra 112
			}			
12694 anikendra 113
		}
114
 
115
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
116
		//$this->curlURL('products','get',$get);
117
		$responses = $this->mcurl->execute();
118
		if(isset($responses) and !empty($responses))
119
		$responses = $this->parser->parse_response($responses,$module);
120
		// if(isset($head) && !empty($head)){
121
		// 	foreach($head['header'] as $key=>$value){
122
		// 		$responses['header'][$key] = $value;
123
		// 	}
124
		// }
125
		// if(isset($foot) && !empty($foot)){
126
		// 	foreach($foot['footer'] as $key=>$value){
127
		// 		$responses['footer'][$key] = $value;
128
		// 	}
129
		// }
130
		return $responses;
131
	}
132
 
133
 
134
	function getDashboard($get=array(),$post=array(),$module=array()) {
135
		$output =array();
136
		if(isset($module) and !empty($module))	{
137
		  if(isset($module['header']) and !empty($module['header'])) {
138
		    foreach($module['header'] as $header) {
139
		      $this->curlURL($header,'get');
140
		    }
141
		  }
142
		  if(isset($module['footer']) and !empty($module['footer'])) {
143
		    foreach($module['footer'] as $footer) {
144
		      $this->curlURL($footer,'get');
145
		    }
146
		  }
147
		  if(isset($module['response']) and !empty($module['response'])) {
148
		    foreach($module['response'] as $response) {
149
		      $this->curlURL($response,'get',$get);
150
		    }
151
		  }      
152
		}
153
 
154
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
155
		//$this->curlURL('products','get',$get);
156
		$responses = $this->mcurl->execute();
157
		//print_r($responses);
158
		if(isset($responses) and !empty($responses))
159
		$responses = $this->parser->parse_response($responses,$module);    
160
		return $responses;
161
	}
162
 
12732 anikendra 163
	function getSearch($get=array(),$post=array(),$module=array())
164
	{	
165
		$output =array();
166
		if(isset($module) and !empty($module))
167
		{
168
			if(isset($module['header']) and !empty($module['header']))
169
			{
170
				foreach($module['header'] as $header)
171
				{
172
					$this->curlURL($header,'get');	
173
 
174
				}
175
			}
176
			if(isset($module['footer']) and !empty($module['footer']))
177
			{
178
				foreach($module['footer'] as $footer)
179
				{
180
 
181
					$this->curlURL($footer,'get');	
182
				}
183
			}
184
			if(isset($module['response']) and !empty($module['response']))
185
			{
186
				foreach($module['response'] as $response)
187
				{
188
					if(isset($post) and !empty($post))
189
					{
190
						if($this->current_client=='prestashop' || $this->current_client=='magento' ){
191
							$this->curlURL($response,'get',$post);
192
						} else{							
193
							$this->curlURL($response,'get',$post);
194
						}
195
					}
196
				}
197
			}			
198
		}
199
 
200
		$responses = $this->mcurl->execute();		
201
		if(isset($responses) and !empty($responses))
202
		$responses = $this->parser->parse_response($responses,$module);
203
 
204
		return $responses;
205
	}
206
 
207
	function getUser($get=array(),$post=array(),$module=array())
208
	{			
209
		$output =array();
210
		if(isset($module) and !empty($module))
211
		{
212
			if(isset($module['header']) and !empty($module['header']))
213
			{
214
				foreach($module['header'] as $header)
215
				{
216
					$this->curlURL($header,'get');	
217
 
218
				}
219
			}
220
			if(isset($module['footer']) and !empty($module['footer']))
221
			{
222
				foreach($module['footer'] as $footer)
223
				{
224
 
225
					$this->curlURL($footer,'get');	
226
				}
227
			}
228
			if(isset($module['response']) and !empty($module['response']))
229
			{
230
				foreach($module['response'] as $response)
231
				{
232
					if(isset($post) and !empty($post))
233
					{
234
						if($this->current_client=='prestashop' || $this->current_client=='magento' ){							
235
							$this->curlURL($response,'get',$post);
236
						} else{							
237
							$this->curlURL($response,'get',$post);
238
						}
239
					}
240
				}
241
			}			
242
		}
243
 
244
		$responses = $this->mcurl->execute();		
245
		if(isset($responses) and !empty($responses))
246
		$responses = $this->parser->parse_response($responses,$module);
247
 
248
		return $responses;
249
	}
250
 
12694 anikendra 251
	function curlURL($configurl=null,$methodtype='get',$parameter=array()) {		
252
		$params ='';
253
		$display='';
254
		$url = $this->config->item('curl_base_url');
255
		$productsurl =$this->config->item($configurl);
256
		if(isset($productsurl['url']) and !empty($productsurl['url'])) {
257
			$url .=$productsurl['url'];
258
			if($productsurl['display'])	{
259
				$display=$productsurl['display'];
260
			}
261
			if(empty($parameter)){$parameter=$productsurl['params'];}
262
 
263
 
264
			if(isset($parameter) and !empty($parameter) and $methodtype=='get')
265
			{
266
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
267
 
268
			}
269
			if(isset($parameter) and !empty($parameter) and $methodtype=='post')
270
			{
271
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
272
				$methodtype ='post';
273
			}
274
			if(!isset($parameter) || empty($parameter))
275
				{$params =$this->parser->prepareParams('',$display,$configurl);}
276
			//$methodtype = 'post';
277
			return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
278
		} else {
279
			return '';
280
		}
281
	}
282
}