public static function init() { if (REST_API::getOutputFormat() == 'csv') { REST_API::sendError(sprintf('%s output format not supported.', strtoupper(REST_API::getOutputFormat())), 401, 'xml'); } $request_uri = REST_API::getRequestURI(); $section_reference = $request_uri[0]; $sections = NULL; if (is_null($section_reference)) { $sections = SectionManager::fetch(); } elseif (is_numeric($section_reference)) { $sections = SectionManager::fetch($section_reference); } else { $section_id = SectionManager::fetchIDFromHandle($section_reference); if ($section_id) { $sections = SectionManager::fetch($section_id); } } if (!is_array($sections)) { $sections = array($sections); } if (!reset($sections) instanceof Section) { REST_API::sendError(sprintf("Section '%s' not found.", $section_reference), 404); } self::$_sections = $sections; }
public static function init() { if (REST_API::getOutputFormat() == 'csv' && !REST_API::getHTTPMethod() == 'get') { REST_API::sendError(sprintf('%s output format not supported for %s requests.', strtoupper(REST_API::getOutputFormat()), strtoupper(REST_API::getHTTPMethod())), 401, 'xml'); } $request_uri = REST_API::getRequestURI(); self::$_section_handle = $request_uri[0]; self::$_entry_id = $request_uri[1]; $section_id = SectionManager::fetchIDFromHandle(self::$_section_handle); if (!$section_id) { REST_API::sendError('Section not found.', 404); } self::$_section_id = $section_id; self::setDatasourceParam('included_elements', $_REQUEST['fields']); self::setDatasourceParam('limit', $_REQUEST['limit']); self::setDatasourceParam('page', $_REQUEST['page']); self::setDatasourceParam('sort', $_REQUEST['sort']); self::setDatasourceParam('order', $_REQUEST['order']); self::setDatasourceParam('groupby', $_REQUEST['groupby']); $filters = $_REQUEST['filter']; if (!is_null($filters) && !is_array($filters)) { $filters = array($filters); } self::setDatasourceParam('filters', $filters); }
public static function init() { if (REST_API::getOutputFormat() == 'csv') { REST_API::sendError(sprintf('%s output format not supported.', strtoupper(REST_API::getOutputFormat())), 401, 'xml'); } }