123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
-
- namespace SCF\Core;
-
-
- class Languages
- {
-
- /**
- * @var Database
- */
- private $_db;
-
- /**
- * @var
- */
- private $language;
-
- /**
- * @var array
- */
- private $phrases = [];
-
- /**
- * Languages constructor.
- * @param Database $db
- * @param $langCode
- */
- public function __construct(Database $db, $langCode)
- {
- $this->_db = $db;
- $this->language = $langCode;
- $this->setLanguage();
- }
-
- /**
- * Create Language Array for the current language
- */
- private function setLanguage()
- {
- $this->_db->query("SELECT * FROM system_localization ORDER BY locaId ASC");
-
-
- $result = $this->_db->fetchArray();
-
- foreach ($result as $lang) {
- $this->phrases[$lang['locaVarname']] = $lang['locaString_'.$this->language];
- }
- }
-
- /**
- * @return array
- */
- public function postArray()
- {
- return $this->phrases;
- }
-
- /**
- * @param $phraseName
- * @return mixed
- */
- public function getPhrase($phraseName)
- {
- if (isset($this->phrases[$phraseName])) {
- return $this->phrases[$phraseName];
- } else {
- return $phraseName;
- }
- }
-
- }
|