Skip to content

Commit e3d8573

Browse files
authored
Merge pull request #442 from tdt/development
Development
2 parents d800368 + ffd32e3 commit e3d8573

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2471
-645
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ app/config/workbench.php
1717
public/packages
1818
workbench
1919
node_modules/
20+
app/storage/app
2021

2122
# IDE dependant
2223
.idea

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: php
22
services: mysql
33
php:
4-
- "5.4"
54
- "5.6"
5+
- "7.0"
66
env:
77
- DB=mysql
88
before_script:

app/Tdt/Core/ContentNegotiator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ public static function getResponse($data, $extension = null)
5757
$formatter_class = 'Tdt\\Core\\Formatters\\' . $extension . 'Formatter';
5858

5959
// Exception for XML, only XML or HTML is allowed
60-
if ($data->definition['source_type'] == 'XmlDefinition' && !empty($extension) && $data->source_definition['geo_formatted'] != 1) {
61-
if ($extension != "XML" && $extension != "HTML" && $extension != "PHP") {
62-
\App::abort(406, "XML only allows to be formatted in XML, HTML or PHP serialization.");
63-
} elseif ($extension == "XML") {
64-
return self::createXmlResponse($data->data);
65-
}
66-
}
60+
// if ($data->definition['source_type'] == 'XmlDefinition' && !empty($extension) && $data->source_definition['geo_formatted'] != 1) {
61+
// if ($extension != "XML" && $extension != "HTML" && $extension != "PHP") {
62+
// \App::abort(406, "XML only allows to be formatted in XML, HTML or PHP serialization.");
63+
// } elseif ($extension == "XML") {
64+
// return self::createXmlResponse($data->data);
65+
// }
66+
// }
6767

6868
if (empty($extension)) {
6969
$negotiator = new FormatNegotiator();

app/Tdt/Core/DataControllers/ELASTICSEARCHController.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
use Tdt\Core\Datasets\Data;
66
use Tdt\Core\Pager;
77
use Elastica\Client;
8-
use Elastica\Document;
9-
use Elastica\Query\Term;
108
use Elastica\Search;
119
use Elastica\Query;
12-
use Elastica\Exception\ResponseException;
1310
use Elastica\Query\SimpleQueryString;
1411
use Elastica\Query\MatchAll;
1512

@@ -82,9 +79,9 @@ public function readData($source_definition, $rest_parameters = [])
8279
public static function getParameters()
8380
{
8481
$query_params = [
85-
"query" => [
86-
"required" => false,
87-
"description" => "A value that will be used to perform a full text-search on the data."
82+
'query' => [
83+
'required' => false,
84+
'description' => 'A value that will be used to perform a full text-search on the data.'
8885
]
8986
];
9087

app/Tdt/Core/DataControllers/MYSQLController.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function readData($source_definition, $rest_parameters = array())
3737
}
3838

3939
// Disregard the paging when rest parameters are given
40-
if (!empty($rest_parameters)) {
40+
if (! empty($rest_parameters)) {
4141
$limit = 500;
4242
$offset = 0;
4343
}
@@ -54,32 +54,32 @@ public function readData($source_definition, $rest_parameters = array())
5454
$geo[$geo_prop['property']] = $geo_prop['path'];
5555
}
5656

57-
if (!$columns) {
57+
if (! $columns) {
5858
// 500 error because this shouldn't happen in normal conditions
5959
// Columns are parsed upon adding a CSV resource and are always present
60-
\App::abort(500, "Cannot find the columns of the MySQL table file, this might be due to a corrupted database or a broken configuration.");
60+
\App::abort(500, 'Cannot find the columns of the MySQL table file, this might be due to a corrupted database or a broken configuration.');
6161
}
6262

6363
// Create aliases for the columns
6464
$aliases = $this->columnsRepo->getColumnAliases($source_definition['id'], 'MysqlDefinition');
6565
$pk = null;
6666

6767
foreach ($columns as $column) {
68-
69-
if (!empty($column['is_pk'])) {
68+
if (! empty($column['is_pk'])) {
7069
$pk = $column['column_name_alias'];
7170
}
7271
}
7372

7473
// Connect to the database
7574
$db_config = array(
76-
'driver' => 'mysql',
77-
'host' => $source_definition['host'],
78-
'database' => $source_definition['database'],
79-
'username' => $source_definition['username'],
80-
'password' => $source_definition['password'],
8175
'charset' => 'utf8',
8276
'collation' => $source_definition['collation'],
77+
'database' => $source_definition['database'],
78+
'driver' => 'mysql',
79+
'host' => $source_definition['mysql_host'],
80+
'password' => $source_definition['mysql_password'],
81+
'port' => $source_definition['mysql_port'],
82+
'username' => $source_definition['mysql_username'],
8383
);
8484

8585
// Configure a connection
@@ -92,7 +92,7 @@ public function readData($source_definition, $rest_parameters = array())
9292
$query = $source_definition['query'];
9393

9494
// Get the total amount of records for the query for pagination
95-
preg_match("/select.*?(from.*)/msi", $query, $matches);
95+
preg_match('/select.*?(from.*)/msi', $query, $matches);
9696

9797
if (empty($matches[1])) {
9898
\App::abort(400, 'Failed to make a count statement, make sure the SQL query is valid.');
@@ -104,20 +104,19 @@ public function readData($source_definition, $rest_parameters = array())
104104

105105
$total_rows = $count_result[0]->count;
106106

107-
if (!$limitInQuery) {
108-
if (!empty($limit)) {
107+
if (! $limitInQuery) {
108+
if (! empty($limit)) {
109109
$query .= ' limit ' . $limit;
110110
}
111111

112-
if (!empty($offset)) {
112+
if (! empty($offset)) {
113113
$query .= ' offset ' . $offset;
114114
}
115115
}
116116

117117
$result = $db->select($query);
118-
119118
} catch (QueryException $ex) {
120-
\App::abort(400, "A bad query has been made, make sure all passed statements are SQL friendly. The error message was: " . $ex->getMessage());
119+
\App::abort(400, 'A bad query has been made, make sure all passed statements are SQL friendly. The error message was: ' . $ex->getMessage());
121120
}
122121

123122
// Get the paging headers

0 commit comments

Comments
 (0)