Subversion Repositories SmartDukaan

Rev

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
Class Faq_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
 
30
  function index($get=array(),$post=array(),$module=array())
31
  {
32
 
33
    //add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
34
    $this->curlURL('products','get',$get);
35
    $responses = $this->mcurl->execute();
36
    $responses = $this->parser->parse_response($responses);
37
    return $responses;
38
  }
39
 
40
  function getHome($get=array(),$post=array(),$module=array())
41
  {
42
 
43
    $output =array();
44
    if(isset($module) and !empty($module))
45
    {
46
      if(isset($module['header']) and !empty($module['header']))
47
      {
48
        foreach($module['header'] as $header)
49
        {
50
 
51
          $this->curlURL($header,'get');
52
        }
53
      }
54
      if(isset($module['footer']) and !empty($module['footer']))
55
      {
56
        foreach($module['footer'] as $footer)
57
        {
58
          $this->curlURL($footer,'get');
59
        }
60
      }
61
      if(isset($module['response']) and !empty($module['response']))
62
      {
63
        foreach($module['response'] as $response)
64
        {
65
          $this->curlURL($response,'get',$get);
66
        }
67
      }
68
 
69
 
70
    }
71
 
72
    //add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
73
    //$this->curlURL('products','get',$get);
74
    $responses = $this->mcurl->execute();
75
    //print_r($responses);
76
    if(isset($responses) and !empty($responses))
77
    $responses = $this->parser->parse_response($responses,$module);
78
 
79
 
80
    return $responses;
81
  }
82
function curlURL($configurl=null,$methodtype='get',$parameter=array())
83
{
84
 
85
    $params ='';
86
    $display='';
87
    $url = $this->config->item('curl_base_url');
88
    $productsurl =$this->config->item($configurl);
89
    if(isset($productsurl['url']) and !empty($productsurl['url']))
90
      {
91
        $url .=$productsurl['url'];
92
        if($productsurl['display'])
93
        {$display=$productsurl['display'];}
94
      if(empty($parameter)){$parameter=$productsurl['params'];}
95
 
96
 
97
    if(isset($parameter) and !empty($parameter) and $methodtype=='get')
98
    {
99
      $params = $this->parser->prepareParams($parameter,$display);
100
 
101
    }
102
    if(isset($parameter) and !empty($parameter) and $methodtype=='post')
103
    {
104
      $params = $this->parser->prepareParams($parameter,$display);
105
      $methodtype ='post';
106
    }
107
    if(!isset($parameter) || empty($parameter))
108
      {$params =$this->parser->prepareParams('',$display);}
109
    if($configurl == 'recommended_accessories'){
110
      $mobileBuild = $this->session->userdata('mobileBuild');
111
        if(isset($mobileBuild) && !empty($mobileBuild)){
112
          $url = $url.rawurlencode($mobileBuild);
113
        }else{
114
          $url = '';
115
        }
116
    }
117
    return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
118
  }
119
  else
120
    {return '';}
121
 
122
}
123
 
124
}