From 5754d4551a55927c5b468630602fb66122f87378 Mon Sep 17 00:00:00 2001 From: "shawn@snowbank.ca" Date: Tue, 3 Dec 2019 12:09:01 -0500 Subject: [PATCH] namespace WorldlandDict #12 --- controllers/ToolController.php | 2 +- controllers/WordListController.php | 2 +- index.php | 2 +- models/Request.php | 2 +- models/Word.php | 2 +- models/WordList.php | 4 ++-- src/App.php | 21 ++++++++++++++---- src/config.php | 34 ------------------------------ src/request.php | 6 ++---- 9 files changed, 26 insertions(+), 49 deletions(-) delete mode 100644 src/config.php diff --git a/controllers/ToolController.php b/controllers/ToolController.php index 0fd9539..aa22014 100644 --- a/controllers/ToolController.php +++ b/controllers/ToolController.php @@ -1,5 +1,5 @@ list as $wordIndex=>$entry) { // var_dump($entry->get()); - if (is_a($entry, 'GlobasaDictionary\Word')) { + if (is_a($entry, 'WorldlangDict\Word')) { if ($this->listLang != "glb") { $result .='

'.sprintf($this->app->getTrans('Entry for'),$wordIndex,$this->listLang).'

'; } diff --git a/src/App.php b/src/App.php index ae5404c..7709d4a 100644 --- a/src/App.php +++ b/src/App.php @@ -1,18 +1,31 @@ startTime = microtime(true); } - public function setLang($lang) { - $this->lang = $lang; + public function setLang($lang, $aux=null) { + $this->lang = strtolower($lang); $this->langCap = ucfirst($lang); + if (!is_null($aux)) { + $this->defaultLang = strtolower($aux); + $this->defaultLangCap = ucfirst($aux); + } } + public function setTemplate($name, $folder=null) { + $this->template = $name; + if (!is_null($folder)) { + $this->templatesFolder = $folder; + } + + $this->templatePath = "./".$this->templatesFolder.'/'.$this->template.'/'; + $this->templateUri = $this->siteUri.$this->templatesFolder.'/'.$this->template.'/'; + } public function setPageTitle($title) { $this->page->title = $title . ' - ' . $this->siteName; } diff --git a/src/config.php b/src/config.php deleted file mode 100644 index 6e231f2..0000000 --- a/src/config.php +++ /dev/null @@ -1,34 +0,0 @@ -siteUri = 'http://leksi.globasa.net/'; -$app->siteName = 'Globasa Dictionary'; -$app->template = 'photon'; -$app->lang = $app->defaultLang = "glb"; -$app->langCap = $app->defaultLangCap = "Glb"; -$app->auxLang = "eng"; -$app->auxLangCap = "Eng"; - -/* App configurations (leave these alone) */ -$app->templatesFolder = 'templates'; -$app->templatePath = "./".$app->templatesFolder.'/'.$app->template.'/'; -$app->templateUri = $app->siteUri.$app->templatesFolder.'/'.$app->template.'/'; - -$app->dictionaryFile = '/home/globasa/api.globasa.net/dictionary.yaml'; -$app->languagesFile = '/home/globasa/api.globasa.net/languages.yaml'; -$app->internationalizationFile = '/home/globasa/api.globasa.net/internationalization.yaml'; - -$app->dictionary = yaml_parse_file($app->dictionaryFile); -$app->languages = yaml_parse_file($app->languagesFile); -$app->trans = yaml_parse_file($app->internationalizationFile); \ No newline at end of file diff --git a/src/request.php b/src/request.php index e61c4c7..00906c1 100644 --- a/src/request.php +++ b/src/request.php @@ -1,5 +1,5 @@ page->options as $option=>$value) { switch ($option) { case 'template': - $app->template = $value; - $app->templatePath = "./".$app->templatesFolder.'/'.$app->template.'/'; - $app->templateUri = $app->siteUri.$app->templatesFolder.'/'.$app->template.'/'; + $app->setTemplate($value); case 'full': }