public function view() { if (!is_numeric($this->_context[0])) { $this->_status = 400; $this->_Result = json_encode(array('error' => __('Invalid section ID.'))); } else { if (!($section = SectionManager::fetch((int) $this->_context[0]) && is_numeric($this->_context[0]))) { $this->_status = 404; $this->_Result = json_encode(array('error' => __('The section specified does not exist.'))); } else { $fields = array(array('id' => '0', 'title' => 'Use Entry ID Number')); foreach (ApiPage::getFieldObjects($this->_context[0]) as $field) { $fields[] = array('id' => $field->get('id'), 'title' => $field->get('label')); } $this->_Result = json_encode($fields); } } }