public static function makeHtmlList($array, $depth = 0, $key_map = FALSE) { $whitespace = str_repeat("\t", $depth * 2); //Base case: an empty array produces no list if (empty($array)) { return ''; } if (is_array($array)) { //Recursive Step: make a list with child lists $output = "{$whitespace}<ul>\n"; foreach ($array as $key => $subArray) { $subList = Com_Icodeecono_Api_ResponseFormatter_HTMLApiResponseFormatter::makeHtmlList($subArray, $depth + 1, $key_map); if ($key_map and $key_map[$key]) { $key = $key_map[$key]; } if ($subList) { $output .= "{$whitespace}\t<li>" . $key . "\n" . $subList . "{$whitespace}\t</li>\n"; } else { $output .= "{$whitespace}\t<li>" . $key . $subList . "</li>\n"; } } $output .= "{$whitespace}</ul>\n"; } else { $output .= " => " . $array; } return $output; }
private function packageAndOutputData() { if (!empty($this->_rawReturnData)) { if (is_array($this->_rawReturnData)) { switch ($this->_contentType) { case Com_Icodeecono_Api_ApiContentTypes::CONTENT_TYPE_XML: echo Com_Icodeecono_Api_ResponseFormatter_XMLApiResponseFormatter::formatResponse($this->_rawReturnData); break; case Com_Icodeecono_Api_ApiContentTypes::CONTENT_TYPE_CSV: echo Com_Icodeecono_Api_ResponseFormatter_CSVApiResponseFormatter::formatResponse($this->_rawReturnData); break; case Com_Icodeecono_Api_ApiContentTypes::CONTENT_TYPE_JSON: echo Com_Icodeecono_Api_ResponseFormatter_JSONApiResponseFormatter::formatResponse($this->_rawReturnData); break; case Com_Icodeecono_Api_ApiContentTypes::CONTENT_TYPE_HTML: echo Com_Icodeecono_Api_ResponseFormatter_HTMLApiResponseFormatter::formatResponse($this->_rawReturnData); break; default: foreach ($this->_rawReturnData as $dataKey => $dataval) { echo $dataKey . " => " . $dataval . ";"; } break; } } else { echo $this->_rawReturnData; } } }