- Added function isEmptyString to fhc_helper

- Added function isEmptyArray to fhc_helper
- Adapted the code in application/* to use as much as possible this two new functions
- Removed the php function empty almost everywhere
This commit is contained in:
Paolo
2018-06-27 15:06:04 +02:00
parent d04b0450da
commit 25e66bf9dd
23 changed files with 214 additions and 200 deletions
+9 -9
View File
@@ -34,7 +34,7 @@ class PhrasesLib
*/
public function getPhrase($phrase_id)
{
if (empty($phrase_id)) return error(MSG_ERR_INVALID_MSG_ID);
if (isEmptyString($phrase_id)) return error(MSG_ERR_INVALID_MSG_ID);
return $this->_ci->PhraseModel->load($phrase_id);
}
@@ -52,7 +52,7 @@ class PhrasesLib
*/
public function getPhraseInhalt($phrase_id)
{
if (empty($phrase_id)) return error(MSG_ERR_INVALID_MSG_ID);
if (isEmptyString($phrase_id)) return error(MSG_ERR_INVALID_MSG_ID);
return $this->_ci->PhrasentextModel->loadWhere(array('phrase_id' => $phrase_id));
}
@@ -62,7 +62,7 @@ class PhrasesLib
*/
public function delPhrasentext($phrasentext_id)
{
if (empty($phrasentext_id)) return error(MSG_ERR_INVALID_MSG_ID);
if (isEmptyString($phrasentext_id)) return error(MSG_ERR_INVALID_MSG_ID);
return $this->_ci->PhrasentextModel->delete(array('phrasentext_id' => $phrasentext_id));
}
@@ -72,7 +72,7 @@ class PhrasesLib
*/
public function savePhrase($phrase_id, $data)
{
if (empty($data)) return error(MSG_ERR_INVALID_MSG_ID);
if (isEmptyString($data)) return error(MSG_ERR_INVALID_MSG_ID);
return $this->_ci->PhraseModel->update($phrase_id, $data);
}
@@ -82,7 +82,7 @@ class PhrasesLib
*/
public function getPhrasentextById($phrasentext_id)
{
if (empty($phrasentext_id))
if (isEmptyString($phrasentext_id))
return error($this->_ci->lang->line('fhc_'.FHC_INVALIDID, false));
return $this->_ci->PhrasentextModel->load($phrasentext_id);
@@ -170,7 +170,7 @@ class PhrasesLib
*/
public function parseVorlagetext($text, $data = array())
{
if (empty($text))
if (isEmptyString($text))
return error($this->_ci->lang->line('fhc_'.FHC_INVALIDID, false));
return $this->_ci->parser->parse_string($text, $data, true);
@@ -193,13 +193,13 @@ class PhrasesLib
for ($i = 0; $i < count($this->_phrases); $i++)
{
$_phrase = $this->_phrases[$i]; // single phrase
$trimed = trim($_phrase->text);
// If the single phrase match the given parameters and is not an empty string
if ($_phrase->category == $category
&& $_phrase->phrase == $phrase
&& $_phrase->orgeinheit_kurzbz == $orgeinheit_kurzbz
&& $_phrase->orgform_kurzbz == $orgform_kurzbz
&& (!empty($trimed)))
&& !isEmptyString($_phrase->text))
{
if (!is_array($parameters)) $parameters = array(); // if params is not an array
@@ -243,7 +243,7 @@ class PhrasesLib
// Use the given language if present, otherwise retrives the language for the logged user
$language = DEFAULT_LANGUAGE;
if (count($parameters) == 2 && !empty($parameters[1]) && is_string($parameters[1]))
if (count($parameters) == 2 && !isEmptyString($parameters[1]) && is_string($parameters[1]))
{
$language = $parameters[1];
}