All the libraries, when it is required, now are using the message helper

This commit is contained in:
bison-paolo
2016-10-07 14:13:58 +02:00
parent 1fed18dd9b
commit 3588047989
7 changed files with 155 additions and 246 deletions
+20 -18
View File
@@ -1,31 +1,33 @@
<?php
/** ---------------------------------------------------------------
* General Error
/**
* Success
*
* @return array
*/
function success($retval, $message = null)
function success($retval, $code = null, $msg_indx_prefix = 'fhc_')
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->fhcCode = $message;
if (!is_null($message)) $return->msg = lang('fhc_' . $message);
$return->retval = $retval;
return $return;
$success = new stdClass();
$success->error = EXIT_SUCCESS;
$success->fhcCode = $code;
if (!is_null($code)) $success->msg = lang($msg_indx_prefix . $code);
$success->retval = $retval;
return $success;
}
/** ---------------------------------------------------------------
* General Error
/**
* Error
*
* @return array
*/
function error($retval = '', $message = null)
function error($retval = '', $code = null, $msg_indx_prefix = 'fhc_')
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->fhcCode = $message;
if (!is_null($message)) $return->msg = lang('fhc_' . $message);
$return->retval = $retval;
return $return;
$error = new stdClass();
$error->error = EXIT_ERROR;
$error->fhcCode = $code;
if (!is_null($code)) $error->msg = lang($msg_indx_prefix . $code);
$error->retval = $retval;
return $error;
}
+31 -54
View File
@@ -1,6 +1,6 @@
<?php
if (! defined("BASEPATH")) exit("No direct script access allowed");
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
@@ -8,7 +8,7 @@ if (! defined("BASEPATH")) exit("No direct script access allowed");
class DmsLib
{
//
const FILE_CONTENT_PROPERTY = "file_content";
const FILE_CONTENT_PROPERTY = 'file_content';
/**
* Object initialization
@@ -17,10 +17,13 @@ class DmsLib
{
$this->ci =& get_instance();
$this->ci->load->model("crm/Akte_model", "AkteModel");
$this->ci->load->model("content/Dms_model", "DmsModel");
$this->ci->load->model("content/DmsVersion_model", "DmsVersionModel");
$this->ci->load->model("content/DmsFS_model", "DmsFSModel");
$this->ci->load->model('crm/Akte_model', 'AkteModel');
$this->ci->load->model('content/Dms_model', 'DmsModel');
$this->ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
$this->ci->load->model('content/DmsFS_model', 'DmsFSModel');
// Loads helper message to manage returning messages
$this->ci->load->helper('message');
}
/**
@@ -32,8 +35,8 @@ class DmsLib
if (isset($dms_id))
{
$this->ci->DmsModel->addJoin("campus.tbl_dms_version", "dms_id");
$this->ci->DmsModel->addOrder("version", "DESC");
$this->ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id');
$this->ci->DmsModel->addOrder('version', 'DESC');
$this->ci->DmsModel->addLimit(1);
if (!isset($version))
@@ -42,7 +45,7 @@ class DmsLib
}
else
{
$result = $this->ci->DmsModel->loadWhere(array("dms_id" => $dms_id, "version" => $version));
$result = $this->ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version));
}
}
@@ -70,19 +73,19 @@ class DmsLib
{
$result = null;
if(isset($dms["new"]) && $dms["new"] == true)
if(isset($dms['new']) && $dms['new'] == true)
{
// Remove new parameter to avoid DB insert errors
unset($dms["new"]);
unset($dms['new']);
$result = $this->_saveFileOnInsert($dms);
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
$filename = $result->retval;
if(isset($dms["dms_id"]) && $dms["dms_id"] != "")
if(isset($dms['dms_id']) && $dms['dms_id'] != '')
{
$result = $this->ci->DmsVersionModel->insert(
$this->ci->DmsVersionModel->filterFields($dms, $dms["dms_id"], $filename)
$this->ci->DmsVersionModel->filterFields($dms, $dms['dms_id'], $filename)
);
}
else
@@ -102,13 +105,13 @@ class DmsLib
$result = $this->_saveFileOnUpdate($dms);
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
$result = $this->ci->DmsModel->update($dms["dms_id"], $this->ci->DmsModel->filterFields($dms));
$result = $this->ci->DmsModel->update($dms['dms_id'], $this->ci->DmsModel->filterFields($dms));
if ($result->error == EXIT_SUCCESS)
{
$result = $this->ci->DmsVersionModel->update(
array(
$dms["dms_id"],
$dms["version"]
$dms['dms_id'],
$dms['version']
),
$this->ci->DmsVersionModel->filterFields($dms)
);
@@ -133,7 +136,7 @@ class DmsLib
$this->ci->db->trans_start(false);
// Get akte_id from table tbl_akte
$result = $this->ci->AkteModel->loadWhere(array("person_id" => $person_id, "dms_id" => $dms_id));
$result = $this->ci->AkteModel->loadWhere(array('person_id' => $person_id, 'dms_id' => $dms_id));
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
// Delete all entries in tbl_akte
@@ -143,11 +146,11 @@ class DmsLib
}
// Get all filenames related to this dms
$resultFileNames = $this->ci->DmsVersionModel->loadWhere(array("dms_id" => $dms_id));
$resultFileNames = $this->ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id));
if (is_object($resultFileNames) && $resultFileNames->error == EXIT_SUCCESS)
{
// Delete from tbl_dms_version
$result = $this->ci->DmsVersionModel->delete(array("dms_id" => $dms_id));
$result = $this->ci->DmsVersionModel->delete(array('dms_id' => $dms_id));
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
// Delete from tbl_dms
@@ -163,12 +166,12 @@ class DmsLib
if ($this->ci->db->trans_status() === false || (is_object($result) && $result->error != EXIT_SUCCESS))
{
$this->ci->db->trans_rollback();
$result = $this->_error($result->msg, EXIT_ERROR);
$result = error($result->msg, EXIT_ERROR);
}
else
{
$this->ci->db->trans_commit();
$result = $this->_success("Dms successfully removed from DB");
$result = success('Dms successfully removed from DB');
}
// If everything is ok
@@ -183,7 +186,7 @@ class DmsLib
}
else
{
$result = $this->_error("Invalid parameters");
$result = error('Invalid parameters');
}
return $result;
@@ -194,9 +197,9 @@ class DmsLib
*/
private function _saveFileOnInsert($dms)
{
$filename = uniqid() . "." . pathinfo($dms["name"], PATHINFO_EXTENSION);
$filename = uniqid() . '.' . pathinfo($dms['name'], PATHINFO_EXTENSION);
$result = $this->ci->DmsFSModel->write($filename, $dms["file_content"]);
$result = $this->ci->DmsFSModel->write($filename, $dms['file_content']);
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
$result->retval = $filename;
@@ -212,42 +215,16 @@ class DmsLib
{
$result = null;
if(isset($dms["version"]))
if(isset($dms['version']))
{
$result = $this->read($dms["dms_id"], $dms["version"]);
$result = $this->read($dms['dms_id'], $dms['version']);
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
{
$result = $this->ci->DmsFSModel->write($result->retval[0]->filename, $dms["file_content"]);
$result = $this->ci->DmsFSModel->write($result->retval[0]->filename, $dms['file_content']);
}
}
return $result;
}
/**
* Success
*/
private function _success($retval, $message = FHC_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $message;
$return->msg = lang("message_" . $message);
$return->retval = $retval;
return $return;
}
/**
* Error
*/
private function _error($retval = "", $message = FHC_ERROR)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $message;
$return->msg = lang("message_" . $message);
$return->retval = $retval;
return $return;
}
}
}
+20 -20
View File
@@ -1,20 +1,20 @@
<?php
if (! defined("BASEPATH")) exit("No direct script access allowed");
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Utility class to be used in the database migration process
* Library usefull for logging!
*/
class LogLib
{
const DEBUG = "debug";
const ERROR = "error";
const INFO = "info";
const DEBUG = 'debug';
const ERROR = 'error';
const INFO = 'info';
const CALLER_PREFIX = "[";
const CALLER_POSTFIX = "]";
const CLASS_POSTFIX = "->";
const LINE_SEPARATOR = ":";
const CALLER_PREFIX = '[';
const CALLER_POSTFIX = ']';
const CLASS_POSTFIX = '->';
const LINE_SEPARATOR = ':';
/**
* Object initialization
@@ -25,12 +25,12 @@ class LogLib
{
$formatted = LogLib::CALLER_PREFIX;
if (!is_null($class) && $class != "")
if (!is_null($class) && $class != '')
{
$formatted .= $class . LogLib::CLASS_POSTFIX;
}
$formatted .= $function . LogLib::LINE_SEPARATOR . $line . LogLib::CALLER_POSTFIX . " ";
$formatted .= $function . LogLib::LINE_SEPARATOR . $line . LogLib::CALLER_POSTFIX . ' ';
return $formatted;
}
@@ -40,23 +40,23 @@ class LogLib
$classIndex = 3;
$functionIndex = 3;
$lineIndex = 2;
$class = "";
$function = "";
$line = "";
$class = '';
$function = '';
$line = '';
if (isset(debug_backtrace()[$classIndex]["class"]) && debug_backtrace()[$classIndex]["class"] != "")
if (isset(debug_backtrace()[$classIndex]['class']) && debug_backtrace()[$classIndex]['class'] != '')
{
$class = debug_backtrace()[$classIndex]["class"];
$class = debug_backtrace()[$classIndex]['class'];
}
if (isset(debug_backtrace()[$functionIndex]["function"]) && debug_backtrace()[$functionIndex]["function"] != "")
if (isset(debug_backtrace()[$functionIndex]['function']) && debug_backtrace()[$functionIndex]['function'] != '')
{
$function = debug_backtrace()[$functionIndex]["function"];
$function = debug_backtrace()[$functionIndex]['function'];
}
if (isset(debug_backtrace()[$lineIndex]["line"]) && debug_backtrace()[$lineIndex]["line"] != "")
if (isset(debug_backtrace()[$lineIndex]['line']) && debug_backtrace()[$lineIndex]['line'] != '')
{
$line = debug_backtrace()[$lineIndex]["line"];
$line = debug_backtrace()[$lineIndex]['line'];
}
return $this->format($class, $function, $line);
+21 -32
View File
@@ -7,6 +7,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class MessageLib
{
const MSG_INDX_PREFIX = 'message_';
public function __construct()
{
// Get code igniter instance
@@ -32,6 +34,8 @@ class MessageLib
// Loads fhc helper
$this->ci->load->helper('fhc');
// Loads helper message to manage returning messages
$this->ci->load->helper('message');
// Loads phrases
$this->ci->lang->load('message');
@@ -757,38 +761,7 @@ class MessageLib
// ------------------------------------------------------------------------
// Private Functions from here out!
// ------------------------------------------------------------------------
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $code = MSG_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $code;
$return->msg = lang('message_' . $code);
$return->retval = $retval;
return $return;
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval = '', $code = MSG_ERROR)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $code;
$return->msg = lang('message_' . $code);
$return->retval = $retval;
return $return;
}
/**
* Update the table tbl_message_recipient
*/
@@ -896,4 +869,20 @@ class MessageLib
return false;
}
/**
* Wrapper for function error
*/
private function _error($retval = '', $code = null)
{
return error($retval, $code, MessageLib::MSG_INDX_PREFIX);
}
/**
* Wrapper for function success
*/
private function _success($retval = '', $code = null)
{
return success($retval, $code, MessageLib::MSG_INDX_PREFIX);
}
}
+44 -60
View File
@@ -1,26 +1,26 @@
<?php
if (! defined("BASEPATH")) exit("No direct script access allowed");
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class PCRMLib
{
const RESOURCE_PARAMETER = "resource";
const FUNCTION_PARAMETER = "function";
const REG_SPLIT_EXPR = "/\//";
const LIB_PREFIX = "Lib";
const LIB_FILE_EXTENSION = ".php";
const LIBS_PATH = "libraries";
const MODEL_PREFIX = "_model";
const RESOURCE_PARAMETER = 'resource';
const FUNCTION_PARAMETER = 'function';
const REG_SPLIT_EXPR = '/\//';
const LIB_PREFIX = 'Lib';
const LIB_FILE_EXTENSION = '.php';
const LIBS_PATH = 'libraries';
const MODEL_PREFIX = '_model';
// Black list of resources that are no allowed to be used
private static $RESOURCES_BLACK_LIST = array(
"PCRMLib", // disabled self loading
"LogLib", // hardly usefull and virtually dangerous
"MigrationLib", // virtually dangerous, DB manipulation
"FilesystemLib" // virtually dangerous, direct access to file system
'PCRMLib', // disabled self loading
'LogLib', // hardly usefull and virtually dangerous
'MigrationLib', // virtually dangerous, DB manipulation
'FilesystemLib' // virtually dangerous, direct access to file system
);
/**
@@ -32,9 +32,9 @@ class PCRMLib
$this->ci =& get_instance();
// Loads helper message to manage returning messages
$this->ci->load->helper("message");
$this->ci->load->helper('message');
$this->ci->load->library("PermissionLib");
$this->ci->load->library('PermissionLib');
}
/**
@@ -99,7 +99,7 @@ class PCRMLib
// Wrong selection!
else
{
$result = $this->_error("Neither a lib nor model: " . $parameters->resourcePath . $parameters->resourceName);
$result = error('Neither a lib nor model: ' . $parameters->resourcePath . $parameters->resourceName);
}
// If the resource was found and loaded
@@ -137,7 +137,7 @@ class PCRMLib
// Separates the resource path from the resource name
$splittedResource = preg_split(PCRMLib::REG_SPLIT_EXPR, $parameterValue);
$parameters->resourceName = $splittedResource[count($splittedResource) - 1];
$parameters->resourcePath = str_replace($parameters->resourceName, "", $parameterValue);
$parameters->resourcePath = str_replace($parameters->resourceName, '', $parameterValue);
}
// The name of the function
else if ($parameterName == PCRMLib::FUNCTION_PARAMETER)
@@ -163,30 +163,30 @@ class PCRMLib
{
if (!is_object($parameters))
{
return $this->_error("Parameter is not an object");
return error('Parameter is not an object');
}
if (!isset($parameters->resourcePath))
{
return $this->_error("Resource path is not specified");
return error('Resource path is not specified');
}
if (!isset($parameters->resourceName))
{
return $this->_error("Resource name is not specified");
return error('Resource name is not specified');
}
if (!isset($parameters->function))
{
return $this->_error("Function is not specified");
return error('Function is not specified');
}
if (!is_array($parameters->parameters))
{
return $this->_error("Parameters are not specified");
return error('Parameters are not specified');
}
if (in_array($parameters->resourceName, PCRMLib::$RESOURCES_BLACK_LIST))
{
return $this->_error("You are trying to access to unauthorized resources");
return error('You are trying to access to unauthorized resources');
}
return $this->_success("Input data are valid");
return success('Input data are valid');
}
/**
@@ -206,12 +206,12 @@ class PCRMLib
catch (Exception $e)
{
// Errors while loading the model
$result = $this->_error("Errors while loading the model: " . $e->getMessage());
$result = error('Errors while loading the model: ' . $e->getMessage());
}
if (!is_null($loaded))
{
$result = $this->_success($loaded);
$result = success($loaded);
}
return $result;
@@ -220,22 +220,22 @@ class PCRMLib
private function checkLibraryPermission($resourcePath, $resourceName, $function, $permissionType)
{
$result = null;
$permissionPath = "";
$permissionPath = '';
if ($resourcePath != "")
if ($resourcePath != '')
{
$permissionPath = $resourcePath;
}
$permissionPath .= $resourceName . "." . $function;
$permissionPath .= $resourceName . '.' . $function;
if ($this->ci->permissionlib->hasPermission($permissionPath, $permissionType) === false)
{
$result = $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$permissionPath, FHC_NORIGHT);
$result = error(lang('fhc_'.FHC_NORIGHT).' -> '.$permissionPath, FHC_NORIGHT);
}
else
{
$result = $this->_success("Has permission");
$result = success('Has permission');
}
return $result;
@@ -244,11 +244,11 @@ class PCRMLib
/**
* Loads a library using the given path and name
*
* The method "library" of the class CI_Loader provided by CI has some limitations,
* The method 'library' of the class CI_Loader provided by CI has some limitations,
* so to be able to check errors was used a workaround.
* It consists in:
* - Checking if the file (identified by parameters $resourcePath and $resourceName) exists
* - If exists it will be loaded using the method "file" from CI_Loader
* - If exists it will be loaded using the method 'file' from CI_Loader
* - Checks if the loaded file contains a class identified by parameter $resourceName
*
* If one of the previous tests fails, it will be returned a null value
@@ -283,25 +283,25 @@ class PCRMLib
{
$loaded = null;
// Same phrase error as load->model() provided by CI
$result = $this->_error($found . " exists, but doesn't declare class " . $resourceName);
$result = error($found . ' exists, but doesn\'t declare class ' . $resourceName);
}
}
else
{
$loaded = null;
// Same phrase error as load->model() provided by CI
$result = $this->_error("Unable to load the requested class: " . $resourceName);
$result = error('Unable to load the requested class: ' . $resourceName);
}
}
catch (Exception $e)
{
// Errors while loading the library
$result = $this->_error("Errors while loading the library: " . $e->getMessage());
$result = error('Errors while loading the library: ' . $e->getMessage());
}
if (!is_null($loaded))
{
$result = $this->_success($loaded);
$result = success($loaded);
}
return $result;
@@ -329,7 +329,7 @@ class PCRMLib
// If the function is static
if ($reflectionMethod->isStatic() === true)
{
$classMethod = $resourceName . "::" . $function;
$classMethod = $resourceName . '::' . $function;
}
// If the function is not static
else
@@ -349,48 +349,32 @@ class PCRMLib
// it will be recognized like a running error. A little bit tricky ;)
if ($resultCall === false)
{
$result = $this->_error("Error running " . $resourceName . "->" . $function . "()");
$result = error('Error running ' . $resourceName . '->' . $function . '()');
}
// Returns the result of resource->function()
else
{
$result = $this->_success($resultCall);
$result = success($resultCall);
}
}
else
{
$result = $this->_error($resourceName . "->" . $function . "() is not callable!");
$result = error($resourceName . '->' . $function . '() is not callable!');
}
}
else
{
$result = $this->_error(
"Number of required parameters: " . $reflectionMethod->getNumberOfRequiredParameters() .
". Given: " . count($parameters)
$result = error(
'Number of required parameters: ' . $reflectionMethod->getNumberOfRequiredParameters() .
'. Given: ' . count($parameters)
);
}
}
catch (Exception $e)
{
$result = $this->_error($e->getMessage());
$result = error($e->getMessage());
}
return $result;
}
/*
*
*/
private function _error($retval = '', $message = EXIT_ERROR)
{
return error($retval, $message);
}
/*
*
*/
private function _success($retval, $message = EXIT_SUCCESS)
{
return success($retval, $message);
}
}
+11 -25
View File
@@ -26,7 +26,9 @@ class PhrasesLib
$this->ci->load->model('system/Phrasentext_model', 'PhrasentextModel');
$this->ci->load->helper('language');
$this->ci->load->helper('Message');
// Loads helper message to manage returning messages
$this->ci->load->helper('message');
//$this->ci->lang->load('fhcomplete');
}
@@ -39,7 +41,7 @@ class PhrasesLib
function getPhrase($phrase_id)
{
if (empty($phrase_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
return error(MSG_ERR_INVALID_MSG_ID);
$phrase = $this->ci->PhraseModel->load($phrase_id);
return $phrase;
@@ -60,7 +62,7 @@ class PhrasesLib
function getPhraseInhalt($phrase_id)
{
if (empty($phrase_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
return error(MSG_ERR_INVALID_MSG_ID);
$phrasentext = $this->ci->PhrasentextModel->loadWhere(array('phrase_id' => $phrase_id));
return $phrasentext;
@@ -69,7 +71,7 @@ class PhrasesLib
function delPhrasentext($phrasentext_id)
{
if (empty($phrasentext_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
return error(MSG_ERR_INVALID_MSG_ID);
$phrasentext = $this->ci->PhrasentextModel->delete(array('phrasentext_id' => $phrasentext_id));
return $phrasentext;
@@ -84,7 +86,7 @@ class PhrasesLib
function savePhrase($phrase_id, $data)
{
if (empty($data))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
return error(MSG_ERR_INVALID_MSG_ID);
$phrase = $this->ci->PhraseModel->update($phrase_id, $data);
return $phrase;
@@ -100,7 +102,7 @@ class PhrasesLib
function getPhrasentextById($phrasentext_id)
{
if (empty($phrasentext_id))
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
$phrasentext = $this->ci->PhrasentextModel->load($phrasentext_id);
return $phrasentext;
@@ -141,7 +143,7 @@ class PhrasesLib
}
else
{
$result = $this->_error('app and sprache parameters are required');
$result = error('app and sprache parameters are required');
}
return $result;
@@ -193,24 +195,8 @@ class PhrasesLib
function parseVorlagetext($text, $data = array())
{
if (empty($text))
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
$text = $this->ci->parser->parse_string($text, $data, TRUE);
return $text;
}
/*
*
*/
protected function _error($retval = '', $message = EXIT_ERROR)
{
return error($retval, $message);
}
/*
*
*/
protected function _success($retval, $message = EXIT_SUCCESS)
{
return success($retval, $message);
}
}
}
+8 -37
View File
@@ -24,6 +24,8 @@ class VorlageLib
$this->ci->load->model('system/Vorlagestudiengang_model', 'VorlageStudiengangModel');
$this->ci->load->helper('language');
// Loads helper message to manage returning messages
$this->ci->load->helper('message');
//$this->ci->lang->load('fhcomplete');
}
@@ -36,7 +38,7 @@ class VorlageLib
function getVorlage($vorlage_kurzbz)
{
if (empty($vorlage_kurzbz))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
return error(MSG_ERR_INVALID_MSG_ID);
$vorlage = $this->ci->VorlageModel->load($vorlage_kurzbz);
return $vorlage;
@@ -64,7 +66,7 @@ class VorlageLib
function saveVorlage($vorlage_kurzbz, $data)
{
if (empty($data))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
return error(MSG_ERR_INVALID_MSG_ID);
$vorlage = $this->ci->VorlageModel->update($vorlage_kurzbz, $data);
return $vorlage;
@@ -80,7 +82,7 @@ class VorlageLib
function getVorlagetextByVorlage($vorlage_kurzbz)
{
if (empty($vorlage_kurzbz))
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
$vorlage = $this->ci->VorlageStudiengangModel->loadWhere(array('vorlage_kurzbz' =>$vorlage_kurzbz));
return $vorlage;
@@ -98,7 +100,7 @@ class VorlageLib
function loadVorlagetext($vorlage_kurzbz, $oe_kurzbz = null, $orgform_kurzbz = null, $sprache = null)
{
if (empty($vorlage_kurzbz))
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
// Builds where clause
$where = "vorlage_kurzbz=".$this->ci->VorlageModel->escape($vorlage_kurzbz);
@@ -205,39 +207,8 @@ class VorlageLib
function parseVorlagetext($text, $data = array())
{
if (empty($text))
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
$text = $this->ci->parser->parse_string($text, $data, TRUE);
return $text;
}
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $message = EXIT_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval = '', $message = EXIT_ERROR)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
}
}