Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
funnelback_rest_search_page.inc
1 <?php
17 require_once SQ_PACKAGES_PATH.'/web_services/rest/page_templates/page_rest_resource/page_rest_resource.inc';
18 
29 {
30 
31  // These are the headers to be sent if send_headers is true.
32  // Only those with values found in the first response will be forwarded.
33  private $_response_headers = Array(
34  'Content-Type',
35  'Content-Length',
36  'Last-Modified',
37  'Cache-Control',
38  'Expires',
39  );
40 
41 
48  function __construct($assetid=0)
49  {
50  parent::__construct($assetid);
51 
52  }//end constructor
53 
54 
62  public function printHead()
63  {
64  // Run the request(s).
65  $this->_process();
66 
67  if (!empty($this->_res['responses'])) {
68  // Send the response. If there are multiple responses, send them all. This might
69  // seem odd, but occasionally you might be building a document from multiple fragments.
70  foreach ($this->_res['responses'] as &$resp) {
71  if ($resp['info']['http_code'] < 400) {
72  $body = $resp['body'];
73  if (strpos($body, '<!--rest-asset-head-body-separator-->') !== FALSE) {
74  $body_parts = explode('<!--rest-asset-head-body-separator-->', $body);
75  echo $body_parts[0];
76  }
77  }
78  }
79  }
80 
81  }//end printHead()
82 
83 
84  public function printBody()
85  {
86  // Run the request(s).
87  $this->_process();
88 
89  if (!empty($this->_res['responses'])) {
90  if ($this->attr('send_headers')) {
91  foreach ($this->_response_headers as $h) {
92  if (isset($this->_res['response']['headers'][$h])) {
93  header("$h: " . $this->_res['response']['headers'][$h]);
94  }
95  }
96  }
97 
98  // Send the response. If there are multiple responses, send them all. This might
99  // seem odd, but occasionally you might be building a document from multiple fragments.
100  foreach ($this->_res['responses'] as &$resp) {
101  if ($resp['info']['http_code'] >= 400) {
102  echo $this->attr('error_response');
103  } else {
104  $body = $resp['body'];
105  if (strpos($body, '<!--rest-asset-head-body-separator-->') !== FALSE) {
106  $body_parts = explode('<!--rest-asset-head-body-separator-->', $body);
107  echo $body_parts[1];
108  } else {
109  echo $resp['body'];
110  }
111  }
112  }
113  }
114 
115  }//end printBody()
116 
117 
118 }//end class
119 
120 ?>