Subversion Repositories SmartDukaan

Rev

Rev 12694 | Go to most recent revision | 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
		}
68
 
69
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
70
		//$this->curlURL('products','get',$get);
71
		$responses = $this->mcurl->execute();
72
		if(isset($responses) and !empty($responses))
73
		$responses = $this->parser->parse_response($responses,$module);
74
		// if(isset($head) && !empty($head)){
75
		// 	foreach($head['header'] as $key=>$value){
76
		// 		$responses['header'][$key] = $value;
77
		// 	}
78
		// }
79
		// if(isset($foot) && !empty($foot)){
80
		// 	foreach($foot['footer'] as $key=>$value){
81
		// 		$responses['footer'][$key] = $value;
82
		// 	}
83
		// }
84
		return $responses;
85
	}
86
 
87
	function getSignup($get=array(),$post=array(),$module=array())
88
	{		
89
		$output =array();
90
		if(isset($module) and !empty($module))
91
		{
92
			if(isset($module['header']) and !empty($module['header']))
93
			{
94
				foreach($module['header'] as $header)
95
				{
96
					$this->curlURL($header,'get');	
97
 
98
				}
99
			}
100
			if(isset($module['footer']) and !empty($module['footer']))
101
			{
102
				foreach($module['footer'] as $footer)
103
				{
104
 
105
					$this->curlURL($footer,'get');	
106
 
107
				}
108
			}
109
			if(isset($module['response']) and !empty($module['response']))
110
			{
111
				foreach($module['response'] as $response)
112
				{
113
					if(isset($post) and !empty($post))
114
					{
12700 anikendra 115
						if($this->current_client=='prestashop' || $this->current_client=='magento' ) {
116
							$this->curlURL($response,'post',$post);
117
						}
118
						else{							
119
							$this->curlURL($response,'post',$post);
120
						}
12694 anikendra 121
					}
122
				}
12700 anikendra 123
			}			
12694 anikendra 124
		}
125
 
126
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
127
		//$this->curlURL('products','get',$get);
128
		$responses = $this->mcurl->execute();
129
		if(isset($responses) and !empty($responses))
130
		$responses = $this->parser->parse_response($responses,$module);
131
		// if(isset($head) && !empty($head)){
132
		// 	foreach($head['header'] as $key=>$value){
133
		// 		$responses['header'][$key] = $value;
134
		// 	}
135
		// }
136
		// if(isset($foot) && !empty($foot)){
137
		// 	foreach($foot['footer'] as $key=>$value){
138
		// 		$responses['footer'][$key] = $value;
139
		// 	}
140
		// }
141
		return $responses;
142
	}
143
 
144
 
145
	function getDashboard($get=array(),$post=array(),$module=array()) {
146
		$output =array();
147
		if(isset($module) and !empty($module))	{
148
		  if(isset($module['header']) and !empty($module['header'])) {
149
		    foreach($module['header'] as $header) {
150
		      $this->curlURL($header,'get');
151
		    }
152
		  }
153
		  if(isset($module['footer']) and !empty($module['footer'])) {
154
		    foreach($module['footer'] as $footer) {
155
		      $this->curlURL($footer,'get');
156
		    }
157
		  }
158
		  if(isset($module['response']) and !empty($module['response'])) {
159
		    foreach($module['response'] as $response) {
160
		      $this->curlURL($response,'get',$get);
161
		    }
162
		  }      
163
		}
164
 
165
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
166
		//$this->curlURL('products','get',$get);
167
		$responses = $this->mcurl->execute();
168
		//print_r($responses);
169
		if(isset($responses) and !empty($responses))
170
		$responses = $this->parser->parse_response($responses,$module);    
171
		return $responses;
172
	}
173
 
174
	function curlURL($configurl=null,$methodtype='get',$parameter=array()) {		
175
		$params ='';
176
		$display='';
177
		$url = $this->config->item('curl_base_url');
178
		$productsurl =$this->config->item($configurl);
179
		if(isset($productsurl['url']) and !empty($productsurl['url'])) {
180
			$url .=$productsurl['url'];
181
			if($productsurl['display'])	{
182
				$display=$productsurl['display'];
183
			}
184
			if(empty($parameter)){$parameter=$productsurl['params'];}
185
 
186
 
187
			if(isset($parameter) and !empty($parameter) and $methodtype=='get')
188
			{
189
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
190
 
191
			}
192
			if(isset($parameter) and !empty($parameter) and $methodtype=='post')
193
			{
194
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
195
				$methodtype ='post';
196
			}
197
			if(!isset($parameter) || empty($parameter))
198
				{$params =$this->parser->prepareParams('',$display,$configurl);}
199
			//$methodtype = 'post';
200
			return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
201
		} else {
202
			return '';
203
		}
204
	}
205
}