Skip to content

Commit

Permalink
Generate fresh foler.php file
Browse files Browse the repository at this point in the history
  • Loading branch information
serkin committed May 19, 2015
1 parent ea13a1f commit d98cdb5
Showing 1 changed file with 22 additions and 18 deletions.
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 d98cdb5

Please sign in to comment.