/** * Get a list of locations * * @param array $where Key->value array of the set of filters to apply * @return string JSON/XML string with the location data */ private function _get_locations($where = array()) { // Fetch the location items $items = Location_Model::get_locations($where, $this->list_limit); //No record found. if ($items->count() == 0) { return $this->response(4); } // Counter $i = 0; // To hold the json data $json_locations = array(); foreach ($items as $item) { // Needs different treatment depending on the output if ($this->response_type == 'json') { $json_locations[] = array("location" => $item); } else { $json_locations['location' . $i] = array("location" => $item); $this->replar[] = 'location' . $i; } $i++; } // Array to be converted to either JSON or xml $data = array("payload" => array("domain" => $this->domain, "locations" => $json_locations), "error" => $this->api_service->get_error_msg(0)); return $this->response_type == 'json' ? $this->array_as_json($data) : $this->array_as_xml($data, $this->replar); }