18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page.inc';
33 protected $_res = Array();
37 private $_response_headers = Array(
46 protected $_extra_replacements = Array();
57 $this->_ser_attrs = TRUE;
58 parent::__construct($assetid);
72 return parent::printFrontend();
94 $GLOBALS[
'SQ_SYSTEM']->setGlobalDefine(
'SQ_REPLACE_MYSOURCE_LEVEL_KEYWORDS', $this->
attr(
'allow_global_replace'));
96 if (!empty($this->_res[
'responses'])) {
97 if ($this->
attr(
'send_headers')) {
98 foreach ($this->_response_headers as $h) {
99 if (isset($this->_res[
'response'][
'headers'][$h])) {
100 header(
"$h: " . $this->_res[
'response'][
'headers'][$h]);
107 foreach ($this->_res[
'responses'] as &$resp) {
108 if ($resp[
'info'][
'http_code'] >= 400) {
109 echo $this->
attr(
'error_response');
128 if (($this->
attr(
'allow_multiple_runs')) || (empty($this->_res[
'responses']))) {
131 $http_attr->setKeywordReplacements($this->_extra_replacements);
134 $available_keywords = parent::getAvailableKeywords();
135 foreach ($available_keywords as $keyword => $val) {
139 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
140 $metadata_fields = $mm->getMetadata($this->
id);
141 foreach($metadata_fields as $schema_fieldid => $field_data) {
142 foreach ($field_data as $item) {
143 $available_keywords[
'asset_metadata_'.$item[
'name']] = $item[
'value'];
147 $http_attr->setKeywordReplacements($available_keywords);
149 $this->_res =& $http_attr->run();
152 $GLOBALS[
'SQ_SYSTEM']->broadcastTriggerEvent(
'trigger_event_rest_response_received', $this, $this->_res);
171 return ob_get_clean();
186 if (substr($keyword, 0, strlen(
'asset_rest_contents')) ==
'asset_rest_contents') {
188 $params = substr($keyword, strlen(
'asset_rest_contents') + 1);
189 $params = explode(
'_', $params);
192 foreach ($params as $p) {
193 $this->_extra_replacements[
"rest_param_$i"] = $p;
198 }
else if (substr($keyword, 0, strlen(
'rest')) ==
'rest') {
204 return parent::getKeywordReplacement($keyword);
226 if (isset($array[$keyword]))
return $array[$keyword];
229 $parts = explode(
'_', $keyword);
230 $part = array_shift($parts);
232 if (isset($array[$part])) {