mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
Merge branch 'master' into permissions
This commit is contained in:
@@ -15,12 +15,17 @@ class ExtensionsLib
|
||||
const EXTENSION_JSON_NAME = 'extension.json'; // file that contains extension data
|
||||
const EXTENSIONS_DIR_NAME = 'extensions'; // name of the directories where will be created the symlinks
|
||||
|
||||
private $_ci;
|
||||
|
||||
private $ARCHIVE_EXTENSIONS = array('.tgz', '.tbz2'); // accepted file extensions for an uploaded extension
|
||||
private $UPLOAD_PATH; // temporary directory to store the upload file and checks the archive
|
||||
private $EXTENSIONS_PATH; // directory where all the extensions are
|
||||
|
||||
// Directories that are part of the extension archive
|
||||
private $SOFTLINK_TARGET_DIRECTORIES = array('config', 'controllers', 'helpers', 'hooks', 'libraries', 'models', 'views', 'widgets');
|
||||
private $SOFTLINK_TARGET_DIRECTORIES = array(
|
||||
APPPATH => array('config', 'controllers', 'helpers', 'hooks', 'libraries', 'models', 'views', 'widgets'),
|
||||
DOC_ROOT => array('public')
|
||||
);
|
||||
|
||||
private $_errorOccurred; // boolean, true if an error occurred while installing an extension
|
||||
private $_currentInstalledExtensionVersion; // contains the version of the current installation of an extension
|
||||
@@ -33,16 +38,16 @@ class ExtensionsLib
|
||||
$this->UPLOAD_PATH = APPPATH.'tmp/';
|
||||
$this->EXTENSIONS_PATH = APPPATH.'extensions/';
|
||||
// Get code igniter instance
|
||||
$this->ci =& get_instance();
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
// Loads message configurationx
|
||||
$this->ci->config->load('message');
|
||||
$this->_ci->config->load('message');
|
||||
|
||||
// Loads EPrintfLib
|
||||
$this->ci->load->library('EPrintfLib');
|
||||
$this->_ci->load->library('EPrintfLib');
|
||||
|
||||
// Loading models
|
||||
$this->ci->load->model('system/Extensions_model', 'ExtensionsModel');
|
||||
$this->_ci->load->model('system/Extensions_model', 'ExtensionsModel');
|
||||
|
||||
// Set default values fot class properties
|
||||
$this->_errorOccurred = false;
|
||||
@@ -153,7 +158,7 @@ class ExtensionsLib
|
||||
$delExtension = false;
|
||||
|
||||
// Loads data about this extension from the DB
|
||||
$result = $this->ci->ExtensionsModel->load($extensionId);
|
||||
$result = $this->_ci->ExtensionsModel->load($extensionId);
|
||||
if (hasData($result)) // if something was found
|
||||
{
|
||||
$extensionName = $result->retval[0]->name; // extension name
|
||||
@@ -162,15 +167,15 @@ class ExtensionsLib
|
||||
$delExtension = $this->_rrm($this->EXTENSIONS_PATH.$extensionName);
|
||||
|
||||
// Select all the version of this extension
|
||||
$this->ci->ExtensionsModel->addSelect('extension_id');
|
||||
$result = $this->ci->ExtensionsModel->loadWhere(array('name' => $extensionName));
|
||||
$this->_ci->ExtensionsModel->addSelect('extension_id');
|
||||
$result = $this->_ci->ExtensionsModel->loadWhere(array('name' => $extensionName));
|
||||
if (hasData($result)) // if something was found
|
||||
{
|
||||
$extsArray = array();
|
||||
foreach ($result->retval as $key => $extension) // loops on them
|
||||
{
|
||||
// Remove them all
|
||||
$result = $this->ci->ExtensionsModel->delete($extension->extension_id);
|
||||
$result = $this->_ci->ExtensionsModel->delete($extension->extension_id);
|
||||
if (isSuccess($result))
|
||||
{
|
||||
$delExtension = true;
|
||||
@@ -187,7 +192,7 @@ class ExtensionsLib
|
||||
*/
|
||||
public function getInstalledExtensions()
|
||||
{
|
||||
return $this->ci->ExtensionsModel->getInstalledExtensions();
|
||||
return $this->_ci->ExtensionsModel->getInstalledExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +219,7 @@ class ExtensionsLib
|
||||
*/
|
||||
private function _loadUploadLibrary()
|
||||
{
|
||||
$this->ci->load->library(
|
||||
$this->_ci->load->library(
|
||||
'upload',
|
||||
array(
|
||||
'upload_path' => $this->UPLOAD_PATH,
|
||||
@@ -234,9 +239,9 @@ class ExtensionsLib
|
||||
$this->_printStart('Uploading extension');
|
||||
|
||||
// If the upload was a success
|
||||
if ($this->ci->upload->do_upload(ExtensionsLib::FILE_INPUT_NAME))
|
||||
if ($this->_ci->upload->do_upload(ExtensionsLib::FILE_INPUT_NAME))
|
||||
{
|
||||
$uploadData = $this->ci->upload->data(); // retrives data about the uploaded file
|
||||
$uploadData = $this->_ci->upload->data(); // retrives data about the uploaded file
|
||||
// Checks the file extension
|
||||
$uploadedFileExtension = '.'.pathinfo($uploadData['full_path'], PATHINFO_EXTENSION);
|
||||
if (!in_array($uploadedFileExtension, $this->ARCHIVE_EXTENSIONS))
|
||||
@@ -259,7 +264,7 @@ class ExtensionsLib
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_printFailure($this->ci->upload->display_errors('', ''));
|
||||
$this->_printFailure($this->_ci->upload->display_errors('', ''));
|
||||
}
|
||||
|
||||
$this->_printSuccess($_uploadExtension != null);
|
||||
@@ -309,9 +314,9 @@ class ExtensionsLib
|
||||
$this->_printStart('Loads any previous installation data');
|
||||
|
||||
// Loads the last version of the previous installation of this extension
|
||||
$this->ci->ExtensionsModel->addOrder('version', 'DESC');
|
||||
$this->ci->ExtensionsModel->addLimit(1);
|
||||
$result = $this->ci->ExtensionsModel->loadWhere(array('name' => $extensionName));
|
||||
$this->_ci->ExtensionsModel->addOrder('version', 'DESC');
|
||||
$this->_ci->ExtensionsModel->addLimit(1);
|
||||
$result = $this->_ci->ExtensionsModel->loadWhere(array('name' => $extensionName));
|
||||
if (isError($result))
|
||||
{
|
||||
$this->_errorOccurred = true;
|
||||
@@ -428,7 +433,7 @@ class ExtensionsLib
|
||||
&& count($extensionJson->dependencies) > 0)
|
||||
{
|
||||
// Gets the required dependencies
|
||||
$result = $this->ci->ExtensionsModel->getDependencies($extensionJson->dependencies);
|
||||
$result = $this->_ci->ExtensionsModel->getDependencies($extensionJson->dependencies);
|
||||
// If they are matcheds
|
||||
if (hasData($result) && count($result->retval) == count($extensionJson->dependencies))
|
||||
{
|
||||
@@ -525,7 +530,7 @@ class ExtensionsLib
|
||||
{
|
||||
$this->_printStart('Adding new entry in the DB');
|
||||
|
||||
$result = $this->ci->ExtensionsModel->insert(
|
||||
$result = $this->_ci->ExtensionsModel->insert(
|
||||
array(
|
||||
'name' => $extensionJson->name,
|
||||
'description' => isset($extensionJson->description) ? $extensionJson->description : null,
|
||||
@@ -581,7 +586,7 @@ class ExtensionsLib
|
||||
$this->_printMessage($sql);
|
||||
|
||||
// Try to execute that
|
||||
if (!isSuccess($result = @$this->ci->ExtensionsModel->executeQuery($sql)))
|
||||
if (!isSuccess($result = @$this->_ci->ExtensionsModel->executeQuery($sql)))
|
||||
{
|
||||
$this->_errorOccurred = true;
|
||||
$this->_printFailure(' error occurred while executing the query');
|
||||
@@ -592,7 +597,7 @@ class ExtensionsLib
|
||||
{
|
||||
$this->_printMessage('Query result:');
|
||||
var_dump($result->retval); // KEEP IT!!!
|
||||
$this->ci->eprintflib->printEOL();
|
||||
$this->_ci->eprintflib->printEOL();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -654,11 +659,14 @@ class ExtensionsLib
|
||||
{
|
||||
$_delSoftLinks = false;
|
||||
|
||||
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $key => $targetDirectory)
|
||||
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $rootPath => $targetDirectories)
|
||||
{
|
||||
if (file_exists(APPPATH.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
|
||||
foreach ($targetDirectories as $key => $targetDirectory)
|
||||
{
|
||||
$_delSoftLinks = unlink(APPPATH.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName);
|
||||
if (file_exists($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
|
||||
{
|
||||
$_delSoftLinks = unlink($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,25 +713,29 @@ class ExtensionsLib
|
||||
$extensionPath = $this->EXTENSIONS_PATH.$extensionName.'/';
|
||||
|
||||
// For every target directory
|
||||
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $key => $targetDirectory)
|
||||
foreach ($this->SOFTLINK_TARGET_DIRECTORIES as $rootPath => $targetDirectories)
|
||||
{
|
||||
// If destination of the symlink does not exist
|
||||
if (!file_exists(APPPATH.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
|
||||
foreach ($targetDirectories as $key => $targetDirectory)
|
||||
{
|
||||
// If the target directory does not exist than creates that
|
||||
if (!is_dir($extensionPath.$targetDirectory))
|
||||
// If destination of the symlink does not exist
|
||||
if (!file_exists($rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName))
|
||||
{
|
||||
mkdir($extensionPath.$targetDirectory);
|
||||
}
|
||||
// If the target directory does not exist than creates that
|
||||
if (!is_dir($extensionPath.$targetDirectory))
|
||||
{
|
||||
mkdir($extensionPath.$targetDirectory);
|
||||
}
|
||||
|
||||
// Create the symlink
|
||||
$_addSoftLinks = symlink(
|
||||
$extensionPath.$targetDirectory,
|
||||
APPPATH.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName
|
||||
);
|
||||
if (!$_addSoftLinks)
|
||||
{
|
||||
break;
|
||||
// Create the symlink
|
||||
$_addSoftLinks = symlink(
|
||||
$extensionPath.$targetDirectory,
|
||||
$rootPath.$targetDirectory.'/'.ExtensionsLib::EXTENSIONS_DIR_NAME.'/'.$extensionName
|
||||
);
|
||||
if (!$_addSoftLinks)
|
||||
{
|
||||
log_message('error','Failed to create Symlink to '.$extensionPath.$targetDirectory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -757,13 +769,13 @@ class ExtensionsLib
|
||||
if ($uploadData != null && isset($uploadData->extensionName) && $extensionDB == null)
|
||||
{
|
||||
// Loads all the previous installations of this extension
|
||||
$this->ci->ExtensionsModel->addOrder('version', 'DESC');
|
||||
$this->ci->ExtensionsModel->addLimit(1);
|
||||
$result = $this->ci->ExtensionsModel->loadWhere(array('name' => $uploadData->extensionName));
|
||||
$this->_ci->ExtensionsModel->addOrder('version', 'DESC');
|
||||
$this->_ci->ExtensionsModel->addLimit(1);
|
||||
$result = $this->_ci->ExtensionsModel->loadWhere(array('name' => $uploadData->extensionName));
|
||||
if (hasData($result)) // if found
|
||||
{
|
||||
// Remove them all from file system and DB
|
||||
$this->_printMessage('Removing entries in the DB related to this extension');
|
||||
$this->_printMessage('Removing entries in the DB related to this extension and from extensions directory');
|
||||
$this->delExtension($result->retval[0]->extension_id);
|
||||
}
|
||||
}
|
||||
@@ -772,7 +784,7 @@ class ExtensionsLib
|
||||
// Remove them all only from DB
|
||||
if ($extensionJson != null && isset($extensionJson->extension_id))
|
||||
{
|
||||
$this->ci->ExtensionsModel->delete($extensionJson->extension_id);
|
||||
$this->_ci->ExtensionsModel->delete($extensionJson->extension_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,7 +801,7 @@ class ExtensionsLib
|
||||
$_toggleExtension = false;
|
||||
|
||||
// Loads data from DB about the given extension
|
||||
$result = $this->ci->ExtensionsModel->load($extensionId);
|
||||
$result = $this->_ci->ExtensionsModel->load($extensionId);
|
||||
if (hasData($result))
|
||||
{
|
||||
$extensionName = $result->retval[0]->name; // extension name
|
||||
@@ -809,7 +821,7 @@ class ExtensionsLib
|
||||
if ($_toggleExtension) // if is a success
|
||||
{
|
||||
// Updates DB
|
||||
$result = $this->ci->ExtensionsModel->update($extensionId, array('enabled' => $enabled));
|
||||
$result = $this->_ci->ExtensionsModel->update($extensionId, array('enabled' => $enabled));
|
||||
if (isSuccess($result))
|
||||
{
|
||||
$_toggleExtension = true;
|
||||
@@ -829,7 +841,7 @@ class ExtensionsLib
|
||||
*/
|
||||
private function _printError($error)
|
||||
{
|
||||
$this->ci->eprintflib->printError($error);
|
||||
$this->_ci->eprintflib->printError($error);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -845,7 +857,7 @@ class ExtensionsLib
|
||||
*/
|
||||
private function _printMessage($message)
|
||||
{
|
||||
$this->ci->eprintflib->printMessage($message);
|
||||
$this->_ci->eprintflib->printMessage($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -864,7 +876,7 @@ class ExtensionsLib
|
||||
*/
|
||||
private function _printInfo($info)
|
||||
{
|
||||
$this->ci->eprintflib->printInfo($info);
|
||||
$this->_ci->eprintflib->printInfo($info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,38 +4,40 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class PhrasesLib
|
||||
{
|
||||
private $_ci; // Code igniter instance
|
||||
private $_phrases; // Contains the retrived phrases
|
||||
|
||||
/**
|
||||
* Loads parser library
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//require_once APPPATH.'config/message.php';
|
||||
$this->_ci =& get_instance();
|
||||
|
||||
$this->ci =& get_instance();
|
||||
// CI parser
|
||||
$this->_ci->load->library('parser');
|
||||
|
||||
// Loads message configuration
|
||||
$this->ci->config->load('message');
|
||||
|
||||
$this->ci->load->library('parser');
|
||||
|
||||
$this->ci->load->model('system/Phrase_model', 'PhraseModel');
|
||||
$this->ci->load->model('system/Phrasentext_model', 'PhrasentextModel');
|
||||
$this->_ci->load->model('system/Phrase_model', 'PhraseModel');
|
||||
$this->_ci->load->model('system/Phrasentext_model', 'PhrasentextModel');
|
||||
|
||||
$this->ci->load->helper('language');
|
||||
// Loads helper message to manage returning messages
|
||||
$this->ci->load->helper('message');
|
||||
$this->_ci->load->helper('message');
|
||||
|
||||
// Workaround to use more parameters in the construct since PHP doesn't support many constructors
|
||||
$this->_extend_construct(func_get_args());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* getPhrase() - will load a spezific Phrase
|
||||
* getPhrase() - loads a specific Phrase
|
||||
*/
|
||||
public function getPhrase($phrase_id)
|
||||
{
|
||||
if (empty($phrase_id))
|
||||
return error(MSG_ERR_INVALID_MSG_ID);
|
||||
if (empty($phrase_id)) return error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$phrase = $this->ci->PhraseModel->load($phrase_id);
|
||||
return $phrase;
|
||||
return $this->_ci->PhraseModel->load($phrase_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,8 +45,7 @@ class PhrasesLib
|
||||
*/
|
||||
public function getPhraseByApp($app = null)
|
||||
{
|
||||
$phrases = $this->ci->PhraseModel->loadWhere(array('app' => $app));
|
||||
return $phrases;
|
||||
return $this->_ci->PhraseModel->loadWhere(array('app' => $app));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,11 +53,9 @@ class PhrasesLib
|
||||
*/
|
||||
public function getPhraseInhalt($phrase_id)
|
||||
{
|
||||
if (empty($phrase_id))
|
||||
return error(MSG_ERR_INVALID_MSG_ID);
|
||||
if (empty($phrase_id)) return error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$phrasentext = $this->ci->PhrasentextModel->loadWhere(array('phrase_id' => $phrase_id));
|
||||
return $phrasentext;
|
||||
return $this->_ci->PhrasentextModel->loadWhere(array('phrase_id' => $phrase_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,11 +63,9 @@ class PhrasesLib
|
||||
*/
|
||||
public function delPhrasentext($phrasentext_id)
|
||||
{
|
||||
if (empty($phrasentext_id))
|
||||
return error(MSG_ERR_INVALID_MSG_ID);
|
||||
if (empty($phrasentext_id)) return error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$phrasentext = $this->ci->PhrasentextModel->delete(array('phrasentext_id' => $phrasentext_id));
|
||||
return $phrasentext;
|
||||
return $this->_ci->PhrasentextModel->delete(array('phrasentext_id' => $phrasentext_id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,11 +73,9 @@ class PhrasesLib
|
||||
*/
|
||||
public function savePhrase($phrase_id, $data)
|
||||
{
|
||||
if (empty($data))
|
||||
return error(MSG_ERR_INVALID_MSG_ID);
|
||||
if (empty($data)) return error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$phrase = $this->ci->PhraseModel->update($phrase_id, $data);
|
||||
return $phrase;
|
||||
return $this->_ci->PhraseModel->update($phrase_id, $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,32 +85,33 @@ class PhrasesLib
|
||||
public function getPhrasentextById($phrasentext_id)
|
||||
{
|
||||
if (empty($phrasentext_id))
|
||||
return 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;
|
||||
return $this->_ci->PhrasentextModel->load($phrasentext_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* getPhrases()
|
||||
* getPhrases() - Retrives phrases from the DB
|
||||
* The given parameter are the same needed to read from the table system.tb_phrase
|
||||
*/
|
||||
public function getPhrases($app, $sprache, $phrase = null, $orgeinheit_kurzbz = null, $orgform_kurzbz = null, $blockTags = null)
|
||||
{
|
||||
if (isset($app) && isset($sprache))
|
||||
{
|
||||
$result = $this->ci->PhraseModel->getPhrases($app, $sprache, $phrase, $orgeinheit_kurzbz, $orgform_kurzbz);
|
||||
|
||||
$result = $this->_ci->PhraseModel->getPhrases($app, $sprache, $phrase, $orgeinheit_kurzbz, $orgform_kurzbz);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$parser = new \Netcarver\Textile\Parser();
|
||||
|
||||
// Textile parser
|
||||
$textileParser = new \Netcarver\Textile\Parser();
|
||||
|
||||
for ($i = 0; $i < count($result->retval); $i++)
|
||||
{
|
||||
// If no <p> tags required
|
||||
if ($blockTags == 'no')
|
||||
{
|
||||
$tmpText = $parser->textileThis($result->retval[$i]->text); // Parse
|
||||
|
||||
$tmpText = $textileParser->textileThis($result->retval[$i]->text); // Parse
|
||||
|
||||
// Removes tags <p> and </p> from the beginning and from the end of the string if they are present
|
||||
// NOTE: Those tags are usually, but not always, added by the textile parser
|
||||
if (strlen($tmpText) >= 7)
|
||||
@@ -129,12 +125,12 @@ class PhrasesLib
|
||||
$tmpText = substr($tmpText, 0, strlen($tmpText) - 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result->retval[$i]->text = $tmpText;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result->retval[$i]->text = $parser->textileThis($result->retval[$i]->text);
|
||||
$result->retval[$i]->text = $textileParser->textileThis($result->retval[$i]->text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,8 +148,7 @@ class PhrasesLib
|
||||
*/
|
||||
public function insertPhraseinhalt($data)
|
||||
{
|
||||
$phrasentext = $this->ci->PhrasentextModel->insert($data);
|
||||
return $phrasentext;
|
||||
return $this->_ci->PhrasentextModel->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,8 +156,7 @@ class PhrasesLib
|
||||
*/
|
||||
public function getVorlagetextById($vorlagestudiengang_id)
|
||||
{
|
||||
$vorlagetext = $this->ci->VorlageStudiengangModel->load($vorlagestudiengang_id);
|
||||
return $vorlagetext;
|
||||
return $this->_ci->VorlageStudiengangModel->load($vorlagestudiengang_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,8 +164,7 @@ class PhrasesLib
|
||||
*/
|
||||
public function updatePhraseInhalt($phrasentext_id, $data)
|
||||
{
|
||||
$phrasentext = $this->ci->PhrasentextModel->update($phrasentext_id, $data);
|
||||
return $phrasentext;
|
||||
return $this->_ci->PhrasentextModel->update($phrasentext_id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,8 +173,84 @@ class PhrasesLib
|
||||
public function parseVorlagetext($text, $data = array())
|
||||
{
|
||||
if (empty($text))
|
||||
return error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
|
||||
$text = $this->ci->parser->parse_string($text, $data, true);
|
||||
return $text;
|
||||
return error($this->_ci->lang->line('fhc_'.FHC_INVALIDID, false));
|
||||
|
||||
return $this->_ci->parser->parse_string($text, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function t($category, $phrase, $parameters = array(), $orgeinheit_kurzbz = null, $orgform_kurzbz = null)
|
||||
{
|
||||
if (isset($this->_phrases) && is_array($this->_phrases))
|
||||
{
|
||||
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();
|
||||
|
||||
echo $this->_ci->parser->parse_string($_phrase->text, $parameters, true)."\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Extends the functionalities of the constructor of this class
|
||||
* This is a workaround to use more parameters in the construct since PHP doesn't support many constructors
|
||||
* The new accepted parameters are:
|
||||
* - categories: could be a string or an array of strings. These are the categories used to load phrases
|
||||
* - language: optional parameter must be a string. It's used to load phrases
|
||||
*/
|
||||
private function _extend_construct($params)
|
||||
{
|
||||
// Checks if the $params is an array with at least one element
|
||||
if (is_array($params) && count($params) > 0)
|
||||
{
|
||||
$parameters = $params[0]; // temporary variable
|
||||
|
||||
// If there are parameters
|
||||
if (is_array($parameters) && count($parameters) > 0)
|
||||
{
|
||||
$categories = $parameters[0]; // categories is always the first parameter
|
||||
if (!is_array($categories)) // if it is not an array, then convert into one
|
||||
{
|
||||
$categories = array($categories);
|
||||
}
|
||||
|
||||
// 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]))
|
||||
{
|
||||
$language = $parameters[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_ci->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
$language = $this->_ci->PersonModel->getLanguage(getAuthUID());
|
||||
}
|
||||
|
||||
// Loads phrases
|
||||
$phrases = $this->_ci->PhraseModel->getPhrasesByCategoryAndLanguage($categories, $language);
|
||||
|
||||
// If there are phrases loaded then store them in the property _phrases
|
||||
if (hasData($phrases))
|
||||
{
|
||||
$this->_phrases = $phrases->retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,8 @@ class VorlageLib
|
||||
$queryParameters["sprache"] = $sprache;
|
||||
}
|
||||
|
||||
$this->ci->VorlageStudiengangModel->addOrder('version', 'DESC');
|
||||
|
||||
$vorlage = $this->ci->VorlageStudiengangModel->loadWhere($queryParameters);
|
||||
// If the searched template was not found
|
||||
if (!hasData($vorlage))
|
||||
|
||||
Reference in New Issue
Block a user