Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
serkin committed May 19, 2015
2 parents 52f171a + d98cdb5 commit 72b9e8b
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 37 deletions.
6 changes: 3 additions & 3 deletions classes/general/Foler.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ public function getTranslation($idProject, $code = null){

$languages = $this->getLanguagesFromProject($idProject);

$dbRecords = !is_null($code) ? $this->getCodeTranslation($idProject, $code) : [];
$dbRecords = !is_null($code) ? $this->getCodeTranslation($idProject, $code) : array();


$returnValue = array();
$returnValue['code'] = $code;

foreach ($languages as $lang):
$returnValue['translations'][] = [
$returnValue['translations'][] = array(
'language' => $lang,
'translation' => !empty($dbRecords[$lang]) ? $dbRecords[$lang] : ''
];
);
endforeach;

return $returnValue;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"require": {
"php": ">=5.3",
"ext-pdo": "*"
"ext-pdo_mysql": "*"
},
"require-dev": {
"phpunit/phpunit": "4.6.*"
Expand Down
5 changes: 3 additions & 2 deletions controllers/code/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
$errorMsg = $app['i18n']['errors']['empty_code'];
else:
$result = $app['foler']->deleteCode($idProject, $code);
$errorMsg = $app['foler']->getError()[2];
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;


if($result):
Response::responseWithSuccess([], $app['i18n']['foler']['code_removed']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['code_removed']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down
2 changes: 1 addition & 1 deletion controllers/code/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
$idProject = !empty($request['id_project']) ? (int)$request['id_project'] : null;

$codes = $app['foler']->getAllCodes($idProject, $keyword);
Response::responseWithSuccess(['codes' => $codes]);
Response::responseWithSuccess(array('codes' => $codes));

};
5 changes: 3 additions & 2 deletions controllers/project/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
$errorMsg = $app['i18n']['errors']['empty_id_project'];
else:
$result = $app['foler']->deleteProject($idProject);
$errorMsg = $app['foler']->getError()[2];
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;


if($result):
Response::responseWithSuccess([], $app['i18n']['foler']['project_removed']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['project_removed']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down
4 changes: 2 additions & 2 deletions controllers/project/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


$idProject = !empty($request['id_project']) ? (int)$request['id_project'] : null;
$type = (!empty($request['type']) && in_array($request['type'], ['php','yaml'])) ? $request['type'] : 'php';
$type = (!empty($request['type']) && in_array($request['type'], array('php','yaml'))) ? $request['type'] : 'php';


$project = $app['foler']->getProjectById($idProject);
Expand Down Expand Up @@ -61,7 +61,7 @@


if($result === true):
Response::responseWithSuccess([], $app['i18n']['foler']['project_exported']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['project_exported']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down
2 changes: 1 addition & 1 deletion controllers/project/getall.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
$app['controllers']['project/getall'] = function ($app, $request){

$projects = $app['foler']->getAllProjects();
Response::responseWithSuccess(['projects' => $projects]);
Response::responseWithSuccess(array('projects' => $projects));

};
2 changes: 1 addition & 1 deletion controllers/project/getone.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

if(!is_null($idProject)):
$project = $app['foler']->getProjectByID($idProject);
Response::responseWithSuccess(['project' => $project]);
Response::responseWithSuccess(array('project' => $project));
else:
Response::responseWithError($app['i18n']['errors']['empty_id_project']);
endif;
Expand Down
7 changes: 4 additions & 3 deletions controllers/project/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
$result = false;
$errorMsg = $app['i18n']['errors']['empty_project_name'];
else:
$result = $app['foler']->saveProject($form, $idProject);
$errorMsg = $app['foler']->getError()[2];
$result = $app['foler']->saveProject($form, $idProject);
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;

if($result):
Response::responseWithSuccess(['id_project' => $result], $app['i18n']['foler']['project_saved']);
Response::responseWithSuccess(array('id_project' => $result), $app['i18n']['foler']['project_saved']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down
7 changes: 4 additions & 3 deletions controllers/transaltion/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$idProject = !empty($form['id_project']) ? $form['id_project'] : null;
$code = !empty($form['code']) ? $form['code'] : null;
$arr = !empty($form['translation']) ? $form['translation'] : [];
$arr = !empty($form['translation']) ? $form['translation'] : array();

if(empty($idProject)):
$result = false;
Expand All @@ -23,11 +23,12 @@
$errorMsg = $app['i18n']['errors']['not_valid_project_code'];
else:
$result = $app['foler']->saveTranslation($idProject, $code, $arr);
$errorMsg = $app['foler']->getError()[2];
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;

if($result):
Response::responseWithSuccess([], $app['i18n']['foler']['translation_saved']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['translation_saved']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down
40 changes: 22 additions & 18 deletions foler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1197,17 +1197,17 @@ public function getTranslation($idProject, $code = null){

$languages = $this->getLanguagesFromProject($idProject);

$dbRecords = !is_null($code) ? $this->getCodeTranslation($idProject, $code) : [];
$dbRecords = !is_null($code) ? $this->getCodeTranslation($idProject, $code) : array();


$returnValue = array();
$returnValue['code'] = $code;

foreach ($languages as $lang):
$returnValue['translations'][] = [
$returnValue['translations'][] = array(
'language' => $lang,
'translation' => !empty($dbRecords[$lang]) ? $dbRecords[$lang] : ''
];
);
endforeach;

return $returnValue;
Expand Down Expand Up @@ -1484,12 +1484,13 @@ public static function responseWithSuccess($arr, $statusMessage = ''){
$errorMsg = $app['i18n']['errors']['empty_code'];
else:
$result = $app['foler']->deleteCode($idProject, $code);
$errorMsg = $app['foler']->getError()[2];
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;


if($result):
Response::responseWithSuccess([], $app['i18n']['foler']['code_removed']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['code_removed']);
else:
Response::responseWithError($errorMsg);
endif;
Expand All @@ -1507,7 +1508,7 @@ public static function responseWithSuccess($arr, $statusMessage = ''){
$idProject = !empty($request['id_project']) ? (int)$request['id_project'] : null;

$codes = $app['foler']->getAllCodes($idProject, $keyword);
Response::responseWithSuccess(['codes' => $codes]);
Response::responseWithSuccess(array('codes' => $codes));

};

Expand All @@ -1527,12 +1528,13 @@ public static function responseWithSuccess($arr, $statusMessage = ''){
$errorMsg = $app['i18n']['errors']['empty_id_project'];
else:
$result = $app['foler']->deleteProject($idProject);
$errorMsg = $app['foler']->getError()[2];
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;


if($result):
Response::responseWithSuccess([], $app['i18n']['foler']['project_removed']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['project_removed']);
else:
Response::responseWithError($errorMsg);
endif;
Expand All @@ -1547,7 +1549,7 @@ public static function responseWithSuccess($arr, $statusMessage = ''){


$idProject = !empty($request['id_project']) ? (int)$request['id_project'] : null;
$type = (!empty($request['type']) && in_array($request['type'], ['php','yaml'])) ? $request['type'] : 'php';
$type = (!empty($request['type']) && in_array($request['type'], array('php','yaml'))) ? $request['type'] : 'php';


$project = $app['foler']->getProjectById($idProject);
Expand Down Expand Up @@ -1603,7 +1605,7 @@ public static function responseWithSuccess($arr, $statusMessage = ''){


if($result === true):
Response::responseWithSuccess([], $app['i18n']['foler']['project_exported']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['project_exported']);
else:
Response::responseWithError($errorMsg);
endif;
Expand All @@ -1617,7 +1619,7 @@ public static function responseWithSuccess($arr, $statusMessage = ''){
$app['controllers']['project/getall'] = function ($app, $request){

$projects = $app['foler']->getAllProjects();
Response::responseWithSuccess(['projects' => $projects]);
Response::responseWithSuccess(array('projects' => $projects));

};

Expand All @@ -1632,7 +1634,7 @@ public static function responseWithSuccess($arr, $statusMessage = ''){

if(!is_null($idProject)):
$project = $app['foler']->getProjectByID($idProject);
Response::responseWithSuccess(['project' => $project]);
Response::responseWithSuccess(array('project' => $project));
else:
Response::responseWithError($app['i18n']['errors']['empty_id_project']);
endif;
Expand Down Expand Up @@ -1680,12 +1682,13 @@ public static function responseWithSuccess($arr, $statusMessage = ''){
$result = false;
$errorMsg = $app['i18n']['errors']['empty_project_name'];
else:
$result = $app['foler']->saveProject($form, $idProject);
$errorMsg = $app['foler']->getError()[2];
$result = $app['foler']->saveProject($form, $idProject);
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;

if($result):
Response::responseWithSuccess(['id_project' => $result], $app['i18n']['foler']['project_saved']);
Response::responseWithSuccess(array('id_project' => $result), $app['i18n']['foler']['project_saved']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down Expand Up @@ -1724,7 +1727,7 @@ public static function responseWithSuccess($arr, $statusMessage = ''){

$idProject = !empty($form['id_project']) ? $form['id_project'] : null;
$code = !empty($form['code']) ? $form['code'] : null;
$arr = !empty($form['translation']) ? $form['translation'] : [];
$arr = !empty($form['translation']) ? $form['translation'] : array();

if(empty($idProject)):
$result = false;
Expand All @@ -1734,11 +1737,12 @@ public static function responseWithSuccess($arr, $statusMessage = ''){
$errorMsg = $app['i18n']['errors']['not_valid_project_code'];
else:
$result = $app['foler']->saveTranslation($idProject, $code, $arr);
$errorMsg = $app['foler']->getError()[2];
$error = $app['foler']->getError();
$errorMsg = $error[2];
endif;

if($result):
Response::responseWithSuccess([], $app['i18n']['foler']['translation_saved']);
Response::responseWithSuccess(array(), $app['i18n']['foler']['translation_saved']);
else:
Response::responseWithError($errorMsg);
endif;
Expand Down

0 comments on commit 72b9e8b

Please sign in to comment.