Subversion Repositories SmartDukaan

Rev

Rev 12700 | Go to most recent revision | Details | 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
					{
115
						if($this->current_client=='prestashop' || $this->current_client=='magento' )
116
						$this->curlURL($response,'post',$post);
117
					else
118
						$this->curlURL($response,'post',$post);
119
 
120
					}
121
				}
122
			}
123
 
124
 
125
		}
126
 
127
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
128
		//$this->curlURL('products','get',$get);
129
		$responses = $this->mcurl->execute();
130
		if(isset($responses) and !empty($responses))
131
		$responses = $this->parser->parse_response($responses,$module);
132
		// if(isset($head) && !empty($head)){
133
		// 	foreach($head['header'] as $key=>$value){
134
		// 		$responses['header'][$key] = $value;
135
		// 	}
136
		// }
137
		// if(isset($foot) && !empty($foot)){
138
		// 	foreach($foot['footer'] as $key=>$value){
139
		// 		$responses['footer'][$key] = $value;
140
		// 	}
141
		// }
142
		return $responses;
143
	}
144
 
145
 
146
	function getDashboard($get=array(),$post=array(),$module=array()) {
147
		$output =array();
148
		if(isset($module) and !empty($module))	{
149
		  if(isset($module['header']) and !empty($module['header'])) {
150
		    foreach($module['header'] as $header) {
151
		      $this->curlURL($header,'get');
152
		    }
153
		  }
154
		  if(isset($module['footer']) and !empty($module['footer'])) {
155
		    foreach($module['footer'] as $footer) {
156
		      $this->curlURL($footer,'get');
157
		    }
158
		  }
159
		  if(isset($module['response']) and !empty($module['response'])) {
160
		    foreach($module['response'] as $response) {
161
		      $this->curlURL($response,'get',$get);
162
		    }
163
		  }      
164
		}
165
 
166
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
167
		//$this->curlURL('products','get',$get);
168
		$responses = $this->mcurl->execute();
169
		//print_r($responses);
170
		if(isset($responses) and !empty($responses))
171
		$responses = $this->parser->parse_response($responses,$module);    
172
		return $responses;
173
	}
174
 
175
	function curlURL($configurl=null,$methodtype='get',$parameter=array()) {		
176
		$params ='';
177
		$display='';
178
		$url = $this->config->item('curl_base_url');
179
		$productsurl =$this->config->item($configurl);
180
		if(isset($productsurl['url']) and !empty($productsurl['url'])) {
181
			$url .=$productsurl['url'];
182
			if($productsurl['display'])	{
183
				$display=$productsurl['display'];
184
			}
185
			if(empty($parameter)){$parameter=$productsurl['params'];}
186
 
187
 
188
			if(isset($parameter) and !empty($parameter) and $methodtype=='get')
189
			{
190
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
191
 
192
			}
193
			if(isset($parameter) and !empty($parameter) and $methodtype=='post')
194
			{
195
				$params = $this->parser->prepareParams($parameter,$display,$configurl);
196
				$methodtype ='post';
197
			}
198
			if(!isset($parameter) || empty($parameter))
199
				{$params =$this->parser->prepareParams('',$display,$configurl);}
200
			//$methodtype = 'post';
201
			return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
202
		} else {
203
			return '';
204
		}
205
	}
206
}