diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php
index 99b73732b..1194e769c 100644
--- a/application/libraries/PhrasesLib.php
+++ b/application/libraries/PhrasesLib.php
@@ -187,22 +187,67 @@ class PhrasesLib
{
for ($i = 0; $i < count($this->_phrases); $i++)
{
+
$_phrase = $this->_phrases[$i];
-
+
if ($_phrase->category == $category
&& $_phrase->phrase == $phrase
&& $_phrase->orgeinheit_kurzbz == $orgeinheit_kurzbz
- && $_phrase->orgform_kurzbz== $orgform_kurzbz)
- {
- if ($parameters == null) $parameters = array();
+ && $_phrase->orgform_kurzbz== $orgform_kurzbz
+ && (!empty($_phrase->text)))
+ {
+ if ($parameters == null)
+ $parameters = array();
+
+ return $this->_ci->parser->parse_string($_phrase->text, $parameters, true);
+ }
+ }
+
+ //fallback 1: if phrase not found in phrases-array, try with default language
+ $default_language = DEFAULT_LANGUAGE;
+ $categories = $this->_ci->PhraseModel->getCategories();
+
+ if (hasData($categories))
+ {
+ $categories = $categories->retval;
+ foreach($categories as $cat)
+ $all_categories[] = $cat->category;
+ }
+
+ $phrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndLanguage($all_categories, $default_language);
+
+ if (hasData($phrases))
+ {
+ $default_phrases = $phrases->retval;
+ }
- echo $this->_ci->parser->parse_string($_phrase->text, $parameters, true)."\n";
- break;
+ if (isset($default_phrases) && is_array($default_phrases))
+ {
+ for ($i = 0; $i < count($default_phrases); $i++)
+ {
+ $_phrase = $default_phrases[$i];
+// var_dump($_phrase);
+
+// echo $phrase . "
";
+// echo $_phrase->phrase . "
";
+
+ if ($_phrase->category == $category
+ && $_phrase->phrase == $phrase
+ && $_phrase->orgeinheit_kurzbz == $orgeinheit_kurzbz
+ && $_phrase->orgform_kurzbz== $orgform_kurzbz)
+ {
+ if ($parameters == null)
+ $parameters = array();
+ return $this->_ci->parser->parse_string($_phrase->text, $parameters, true);
+ }
}
}
- }
+
+ //fallback 2: if phrase not found at all, return phrasename
+ $phrase = '<< PHRASE ' . $phrase . ' >>';
+ return $this->_ci->parser->parse_string($phrase, $parameters, true);
+ }
}
-
// -----------------------------------------------------------------------------------------------------------------
// Private methods
diff --git a/application/models/system/Phrase_model.php b/application/models/system/Phrase_model.php
index a0363eb5a..dff8bebaf 100644
--- a/application/models/system/Phrase_model.php
+++ b/application/models/system/Phrase_model.php
@@ -77,4 +77,15 @@ class Phrase_model extends DB_Model
return $this->execQuery($query, array($categories, $language));
}
-}
+
+ /**
+ * Loads all categories
+ */
+ public function getCategories()
+ {
+ $query = 'SELECT DISTINCT category
+ FROM system.tbl_phrase';
+
+ return $this->execQuery($query);
+ }
+}
\ No newline at end of file