diff --git a/application/controllers/api/frontend/v1/Ampeln.php b/application/controllers/api/frontend/v1/Ampeln.php index debdb917d..19f465a11 100644 --- a/application/controllers/api/frontend/v1/Ampeln.php +++ b/application/controllers/api/frontend/v1/Ampeln.php @@ -91,7 +91,7 @@ class Ampeln extends FHCAPI_Controller $zugeteilt = $this->getDataOrTerminateWithError($zugeteilt); - if($zugeteilt) $userAmpeln[] = $this->translateAmpel($ampel); + if($zugeteilt) $userAmpeln[] = $ampel; } } @@ -150,33 +150,7 @@ class Ampeln extends FHCAPI_Controller } - //------------------------------------------------------------------------------------------------------------------ - // Private methods - - /** - * translate ampel description and button text - * @access private - * - */ - public function translateAmpel($ampel){ - // fetch user language - $userLanguage = getUserLanguage(); - - $userLanguage = $this->SpracheModel->loadWhere(["sprache" => $userLanguage]); - - $userLanguage = $this->getDataOrTerminateWithError($userLanguage)[0]->index - 1; // why does the index start at 1? - - // translate the ampel description and button text - if(isset($ampel->beschreibung) && count($ampel->beschreibung)>=($userLanguage+1)) - $ampel->beschreibung = $ampel->beschreibung[$userLanguage]; - - if(isset($ampel->buttontext) && count($ampel->buttontext)>=($userLanguage+1)) - $ampel->buttontext = $ampel->buttontext[$userLanguage]; - - return $ampel; - - } } diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php index 901587893..86f8f57b2 100755 --- a/application/core/DB_Model.php +++ b/application/core/DB_Model.php @@ -94,6 +94,8 @@ class DB_Model extends CI_Model $this->load->library('UDFLib'); // Loads the logs library $this->load->library('LogLib'); + + } // ------------------------------------------------------------------------------------------ diff --git a/application/models/content/Ampel_model.php b/application/models/content/Ampel_model.php index 7c3bf1900..dfdbc668e 100755 --- a/application/models/content/Ampel_model.php +++ b/application/models/content/Ampel_model.php @@ -20,9 +20,12 @@ class Ampel_model extends DB_Model */ public function active($email = false) { + + $userLanguage = getUserLanguage(); + $parametersArray = null; $query = ' - SELECT * + SELECT *, beschreibung[('.$this->getLanguageIndex($this->escape($userLanguage)).')], buttontext[('. $this->getLanguageIndex($this->escape($userLanguage)).')] FROM public.tbl_ampel WHERE'; @@ -142,6 +145,7 @@ class Ampel_model extends DB_Model function alleAmpeln($uid){ + $userLanguage = getUserLanguage(); $zugeteile_ampeln = []; @@ -154,7 +158,7 @@ class Ampel_model extends DB_Model $benutzerStartDate = $datum->mktime_fromdate(date(current(getData($benutzerStartDate))->insertamum)); $allAmpeln = $this->execReadOnlyQuery(" - SELECT * FROM + SELECT *, beschreibung[('.$this->getLanguageIndex($userLanguage).')], buttontext[('.$this->getLanguageIndex($userLanguage).')] FROM public.tbl_ampel"); if(isError($allAmpeln)) return error(getError($allAmpeln)); @@ -202,4 +206,12 @@ class Ampel_model extends DB_Model return success($zugeteile_ampeln); } + private function getLanguageIndex($userLanguage) + { + return " + SELECT index + FROM public.tbl_sprache + WHERE sprache = " . $userLanguage; + } + }