JsonView::render($revisions); }); /** * SETTINGS COLLECTION */ $app->map("/{$v}/settings(/:id)/?", function ($id = null) use($acl, $ZendDb, $params, $requestPayload, $app) { $Settings = new DirectusSettingsTableGateway($acl, $ZendDb); switch ($app->request()->getMethod()) { case "POST": case "PUT": $data = $requestPayload; unset($data['id']); $Settings->setValues($id, $data); break; } $settings_new = $Settings->fetchAll(); $get_new = is_null($id) ? $settings_new : $settings_new[$id]; JsonView::render($get_new); })->via('GET', 'POST', 'PUT'); // GET and PUT table details $app->map("/{$v}/tables/:table/?", function ($table) use($ZendDb, $acl, $params, $requestPayload, $app) { $TableGateway = new TableGateway($acl, 'directus_tables', $ZendDb, null, null, null, 'table_name'); $ColumnsTableGateway = new TableGateway($acl, 'directus_columns', $ZendDb); /* PUT updates the table */ if ($app->request()->isPut()) { $data = $requestPayload; $table_settings = array('table_name' => $data['table_name'], 'hidden' => (int) $data['hidden'], 'single' => (int) $data['single'], 'is_junction_table' => (int) $data['is_junction_table'], 'footer' => (int) $data['footer'], 'primary_column' => array_key_exists('primary_column', $data) ? $data['primary_column'] : ''); //@TODO: Possibly pretty this up so not doing direct inserts/updates $set = $TableGateway->select(array('table_name' => $table))->toArray(); //If item exists, update, else insert if (count($set) > 0) {
function getSettings() { global $ZendDb, $acl; $settings = new DirectusSettingsTableGateway($acl, $ZendDb); $items = []; foreach ($settings->fetchAll() as $key => $value) { if ($key == 'global') { $value['max_file_size'] = get_max_upload_size(); } $value['id'] = $key; $items[] = $value; } return $items; }
function getSettings() { global $ZendDb, $acl; $settings = new DirectusSettingsTableGateway($acl, $ZendDb); $items = array(); foreach ($settings->fetchAll() as $key => $value) { $value['id'] = $key; $items[] = $value; } return $items; }
JsonView::render($revisions); }); /** * SETTINGS COLLECTION */ $app->map("/{$v}/settings(/:id)/?", function ($id = null) use($acl, $ZendDb, $params, $requestPayload, $app) { $Settings = new DirectusSettingsTableGateway($acl, $ZendDb); switch ($app->request()->getMethod()) { case 'POST': case 'PUT': $data = $requestPayload; unset($data['id']); $Settings->setValues($id, $data); break; } $response = $Settings->fetchAll(); if (!is_null($id)) { $response = array_key_exists($id, $response) ? $response[$id] : null; } if (!$response) { $response = ['message' => __t('unable_to_find_setting_collection_x', ['collection' => $id]), 'success' => false]; } JsonView::render($response); })->via('GET', 'POST', 'PUT'); /** * /tables * List of viewable tables for the authenticated user group * * return list of objects with the name of the table * Ex. [{name: 'articles'}, {name: 'projects'}] */