mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
phrases system
This commit is contained in:
@@ -23,7 +23,7 @@ $config['migration_enabled'] = TRUE;
|
||||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 009;
|
||||
$config['migration_version'] = '009';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Phrases extends FHC_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('PhrasesLib');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('system/phrases.php');
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$phrases = $this->phraseslib->getPhraseByApp('aufnahme');
|
||||
if ($phrases->error)
|
||||
show_error($phrases->retval);
|
||||
//var_dump($vorlage);
|
||||
|
||||
$data = array
|
||||
(
|
||||
'app' => 'aufnahme',
|
||||
'phrases' => $phrases->retval
|
||||
);
|
||||
$v = $this->load->view('system/phrasesList.php', $data);
|
||||
}
|
||||
|
||||
public function view($phrase_id = null)
|
||||
{
|
||||
if (empty($phrase_id))
|
||||
exit;
|
||||
$phrase_inhalt = $this->phraseslib->getPhraseInhalt($phrase_id);
|
||||
if ($phrase_inhalt->error)
|
||||
show_error($phrase_inhalt->retval);
|
||||
//var_dump($vorlage);
|
||||
|
||||
$data = array
|
||||
(
|
||||
'phrase_id' => $phrase_id,
|
||||
'phrase_inhalt' => $phrase_inhalt->retval
|
||||
);
|
||||
$v = $this->load->view('system/phrasesinhaltList.php', $data);
|
||||
}
|
||||
|
||||
public function edit($vorlage_kurzbz = null)
|
||||
{
|
||||
if (empty($vorlage_kurzbz))
|
||||
exit;
|
||||
$vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz);
|
||||
//var_dump($vorlage);
|
||||
if ($vorlage->error)
|
||||
show_error($vorlage->retval);
|
||||
if (count($vorlage->retval) != 1)
|
||||
show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz);
|
||||
|
||||
$data = array
|
||||
(
|
||||
'vorlage' => $vorlage->retval[0]
|
||||
);
|
||||
//var_dump($data['message']);
|
||||
$v = $this->load->view('system/templatesEdit', $data);
|
||||
}
|
||||
|
||||
public function write($vorlage_kurzbz = null)
|
||||
{
|
||||
$data = array
|
||||
(
|
||||
'subject' => 'TestSubject',
|
||||
'body' => 'TestDevelopmentBodyText'
|
||||
);
|
||||
$v = $this->load->view('system/messageWrite', $data);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE);
|
||||
$data['bezeichnung'] = $this->input->post('bezeichnung', TRUE);
|
||||
$data['anmerkung'] = $this->input->post('anmerkung', TRUE);
|
||||
$data['mimetype'] = $this->input->post('mimetype', TRUE);
|
||||
$data['attribute'] = $this->input->post('attribute', TRUE);
|
||||
$vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data);
|
||||
if ($vorlage->error)
|
||||
show_error($vorlage->retval);
|
||||
$vorlage_kurzbz = $vorlage->retval;
|
||||
|
||||
redirect('/system/Templates/edit/'.$vorlage_kurzbz);
|
||||
}
|
||||
|
||||
public function newText()
|
||||
{
|
||||
$vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE);
|
||||
$data = array
|
||||
(
|
||||
'vorlage_kurzbz' => $vorlage_kurzbz,
|
||||
'studiengang_kz' => 0,
|
||||
'version' => 1,
|
||||
'oe_kurzbz' => 'etw'
|
||||
);
|
||||
$vorlagetext = $this->vorlagelib->insertVorlagetext($data);
|
||||
if ($vorlagetext->error)
|
||||
show_error($vorlagetext->retval);
|
||||
$vorlagestudiengang_id = $vorlagetext->retval;
|
||||
|
||||
redirect('/system/Templates/editText/'.$vorlagestudiengang_id);
|
||||
}
|
||||
|
||||
public function editText($vorlagestudiengang_id)
|
||||
{
|
||||
$vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id);
|
||||
if ($vorlagetext->error)
|
||||
show_error($vorlagetext->retval);
|
||||
$data = $vorlagetext->retval[0];
|
||||
|
||||
// Preview-Data
|
||||
$schema = $this->vorlagelib->getVorlage($data->vorlage_kurzbz);
|
||||
$data->schema = $schema->retval[0]->attribute;
|
||||
|
||||
$this->load->view('system/templatetextEdit', $data);
|
||||
}
|
||||
|
||||
public function saveText()
|
||||
{
|
||||
$vorlagestudiengang_id = $this->input->post('vorlagestudiengang_id', TRUE);
|
||||
$data['studiengang_kz'] = $this->input->post('studiengang_kz', TRUE);
|
||||
$data['version'] = $this->input->post('version', TRUE);
|
||||
$data['oe_kurzbz'] = $this->input->post('oe_kurzbz', TRUE);
|
||||
$data['text'] = $this->input->post('text', TRUE);
|
||||
$data['aktiv'] = $this->input->post('aktiv', TRUE);
|
||||
$vorlagetext = $this->vorlagelib->updateVorlagetext($vorlagestudiengang_id, $data);
|
||||
if ($vorlagetext->error)
|
||||
show_error($vorlagetext->retval);
|
||||
$data['vorlagestudiengang_id'] = $vorlagestudiengang_id;
|
||||
redirect('/system/Templates/editText/'.$vorlagestudiengang_id);
|
||||
//$this->load->view('system/templatetextEdit', $data);
|
||||
}
|
||||
|
||||
public function preview($vorlagestudiengang_id)
|
||||
{
|
||||
$formdata = $this->input->post('formdata', FALSE);
|
||||
$daten = json_decode($formdata, TRUE);
|
||||
$vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id);
|
||||
if ($vorlagetext->error)
|
||||
show_error($vorlagetext->retval);
|
||||
$data = array
|
||||
(
|
||||
'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $daten)
|
||||
);
|
||||
$this->load->view('system/templatetextPreview', $data);
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,20 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class FHC_Controller extends CI_Controller
|
||||
{
|
||||
public $uid;
|
||||
|
||||
function __construct()
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('session');
|
||||
//$this->load->helper('language');
|
||||
|
||||
|
||||
// look if User is logged in and set uid
|
||||
if (isset($_SERVER['PHP_AUTH_USER']))
|
||||
$this->uid = $_SERVER['PHP_AUTH_USER'];
|
||||
if (isset($_SESSION['uid']))
|
||||
$this->uid = $_SESSION['uid'];
|
||||
$this->session->set_userdata('uid', 'pam');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
if (! defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
/**
|
||||
* Name: Messaging Library for FH-Complete
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class PhrasesLib
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//require_once APPPATH.'config/message.php';
|
||||
|
||||
$this->ci =& get_instance();
|
||||
$this->ci->load->library('parser');
|
||||
$this->ci->load->model('system/Phrase_model', 'PhraseModel');
|
||||
$this->ci->load->model('system/Phrase_inhalt_model', 'PhraseInhaltModel');
|
||||
$this->ci->load->helper('language');
|
||||
//$this->ci->lang->load('fhcomplete');
|
||||
}
|
||||
|
||||
/**
|
||||
* getPhrase() - will load a spezific Phrase
|
||||
*
|
||||
* @param integer $vorlage_kurzbz REQUIRED
|
||||
* @return struct
|
||||
*/
|
||||
function getPhrase($phrase_id)
|
||||
{
|
||||
if (empty($vorlage_kurzbz))
|
||||
return $this->_error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$Phrase = $this->ci->PhraseModel->load($phrase_id);
|
||||
return $phrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSubMessages() - will return all Messages subordinated from a specified message.
|
||||
*
|
||||
* @param integer $msg_id REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
function getPhraseByApp($app = null)
|
||||
{
|
||||
$phrases = $this->ci->PhraseModel->loadWhere(array('app' => $app));
|
||||
return $phrases;
|
||||
}
|
||||
|
||||
function getPhraseInhalt($phrase_id)
|
||||
{
|
||||
if (empty($phrase_id))
|
||||
return $this->_error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$phrase_inhalt = $this->ci->PhraseInhaltModel->loadWhere(array('phrase_id' => $phrase_id));
|
||||
return $phrase_inhalt;
|
||||
}
|
||||
|
||||
/**
|
||||
* saveVorlage() - will save a spezific Template.
|
||||
*
|
||||
* @param array $data REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
function saveVorlage($vorlage_kurzbz, $data)
|
||||
{
|
||||
if (empty($data))
|
||||
return $this->_error(MSG_ERR_INVALID_MSG_ID);
|
||||
|
||||
$vorlage = $this->ci->VorlageModel->update($vorlage_kurzbz, $data);
|
||||
return $vorlage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getVorlagetextByVorlage() - will load tbl_vorlagestudiengang for a spezific Template.
|
||||
*
|
||||
* @param string $vorlage_kurzbz REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
function getVorlagetextByVorlage($vorlage_kurzbz)
|
||||
{
|
||||
if (empty($vorlage_kurzbz))
|
||||
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
|
||||
|
||||
$vorlage = $this->ci->VorlageStudiengangModel->loadWhere(array('vorlage_kurzbz' =>$vorlage_kurzbz));
|
||||
return $vorlage;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadVorlagetext() - will load the best fitting Template.
|
||||
*
|
||||
* @param string $vorlage_kurzbz REQUIRED
|
||||
* @param string $oe_kurzbz OPTIONAL
|
||||
* @param string $orgform_kurzbz OPTIONAL
|
||||
* @return array
|
||||
*/
|
||||
function loadVorlagetext($vorlage_kurzbz, $oe_kurzbz=null, $orgform_kurzbz=null)
|
||||
{
|
||||
if (empty($vorlage_kurzbz))
|
||||
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
|
||||
|
||||
$vorlage = $this->ci->VorlageStudiengangModel->getVorlageStudiengang($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz);
|
||||
return $vorlage;
|
||||
}
|
||||
|
||||
/**
|
||||
* insertVorlagetext() - will load tbl_vorlagestudiengang for a spezific Template.
|
||||
*
|
||||
* @param string $vorlage_kurzbz REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
function insertVorlagetext($data)
|
||||
{
|
||||
$vorlagetext = $this->ci->VorlageStudiengangModel->insert($data);
|
||||
return $vorlagetext;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadVorlagetext() - will load tbl_vorlagestudiengang for a spezific Template.
|
||||
*
|
||||
* @param string $vorlage_kurzbz REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
function getVorlagetextById($vorlagestudiengang_id)
|
||||
{
|
||||
$vorlagetext = $this->ci->VorlageStudiengangModel->load($vorlagestudiengang_id);
|
||||
return $vorlagetext;
|
||||
}
|
||||
|
||||
/**
|
||||
* saveVorlagetext() - will load tbl_vorlagestudiengang for a spezific Template.
|
||||
*
|
||||
* @param string $vorlage_kurzbz REQUIRED
|
||||
* @return array
|
||||
*/
|
||||
function updateVorlagetext($vorlagestudiengang_id, $data)
|
||||
{
|
||||
$vorlagetext = $this->ci->VorlageStudiengangModel->update($vorlagestudiengang_id, $data);
|
||||
return $vorlagetext;
|
||||
}
|
||||
|
||||
/**
|
||||
* parseVorlagetext() - will parse a Vorlagetext.
|
||||
*
|
||||
* @param string $text REQUIRED
|
||||
* @param array $data REQUIRED
|
||||
* @return string
|
||||
*/
|
||||
function parseVorlagetext($text, $data = array())
|
||||
{
|
||||
if (empty($text))
|
||||
return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false));
|
||||
$text = $this->ci->parser->parse_string($text, $data, TRUE);
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
@@ -54,4 +54,3 @@ class Migration_Add_apikey extends CI_Migration {
|
||||
$this->dbforge->drop_table('ci_apikey');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,10 @@ class Migration_Phrase extends CI_Migration {
|
||||
phrase_inhalt_id serial,
|
||||
phrase_id bigint NOT NULL,
|
||||
sprache varchar(32) NOT NULL,
|
||||
orgeinheit_kurzbz varchar(32) NOT NULL,
|
||||
orgform_kurzbz varchar(32) NOT NULL,
|
||||
orgeinheit_kurzbz varchar(32),
|
||||
orgform_kurzbz varchar(32),
|
||||
text text,
|
||||
description text,
|
||||
insertamum timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
insertvon varchar(32),
|
||||
PRIMARY KEY (phrase_inhalt_id)
|
||||
@@ -64,7 +65,7 @@ class Migration_Phrase extends CI_Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function down()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
class Phrase_inhalt_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_phrase_inhalt';
|
||||
$this->pk = 'phrase_inhalt_id';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
class Phrase_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'public.tbl_phrase';
|
||||
$this->pk = 'phrase_id';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
|
||||
<html lang="de_AT">
|
||||
|
||||
<head>
|
||||
<title>VileSci - Phrasen</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
|
||||
<frameset rows="30%,*">
|
||||
<frame src="Phrases/table" id="PhrasesTop" name="PhrasesTop" frameborder="0" />
|
||||
<frame src="Phrases/edit" id="PhrasesBottom" name="PhrasesBottom" frameborder="0" />
|
||||
<noframes>
|
||||
<body bgcolor="#FFFFFF">
|
||||
This application works only with a frames-enabled browser.<br />
|
||||
<a href="PhrasesList">Use without frames</a>
|
||||
</body>
|
||||
</noframes>
|
||||
</frameset>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
$this->load->view('templates/header', array('title' => 'PhrasesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '2:{sorter:false}'));
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<h2>Phrasen</h2>
|
||||
<!--
|
||||
<form method="post" action="">
|
||||
App: aufnahme
|
||||
<?php
|
||||
// This is an example to show that you can load stuff from inside the template file
|
||||
//echo $this->templatelib->widget("mimetype_widget", array('mimetype' => $mimetype));
|
||||
?>
|
||||
<button type="submit">Filter</button>
|
||||
</form>
|
||||
-->
|
||||
<table id="t1" class="tablesorter">
|
||||
<thead>
|
||||
<tr><th class='table-sortable:default'>ID</th>
|
||||
<th class='table-sortable:default'>Phrase</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($phrases as $p): ?>
|
||||
<tr><td><a href="edit/<?php echo $p->phrase_id; ?>" target="PhrasesBottom"><?php echo $p->phrase_id; ?></a></td>
|
||||
<td><?php echo $p->phrase; ?></td>
|
||||
<td><a href="view/<?php echo $p->phrase_id; ?>" target="PhrasesBottom">View</a></td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
$this->load->view('templates/header', array('title' => 'PhrasenInhaltList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '5:{sorter:false}'));
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="span4">
|
||||
<h2>Phrase Inhalt - <?php echo $phrase_id; ?></h2>
|
||||
<form method="post" action="../newtext" target="TemplatesBottom">
|
||||
<input type="hidden" name="phrase_id" value="<?php echo $phrase_id; ?>"/>
|
||||
<button type="submit">Neu</button>
|
||||
</form>
|
||||
|
||||
<table id="t1" class="tablesorter">
|
||||
<thead>
|
||||
<tr><th class='table-sortable:default'>ID</th>
|
||||
<th class='table-sortable:default'>Sprache</th>
|
||||
<th class='table-sortable:default'>OrgEinheit</th>
|
||||
<th class='table-sortable:default'>OrgForm</th>
|
||||
<th class='table-sortable:default'>Text</th>
|
||||
<th>Beschreibung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($phrase_inhalt as $v): ?>
|
||||
<tr><td><a href="../edittext/<?php echo $v->phrase_inhalt_id; ?>" target="PhrasesBottom"><?php echo $v->phrase_inhalt_id; ?></a></td>
|
||||
<td><?php echo $v->sprache; ?></td>
|
||||
<td><?php echo $v->orgeinheit_kurzbz; ?></td>
|
||||
<td><?php echo $v->orgform_kurzbz; ?></td>
|
||||
<td><?php echo $v->text; ?></td>
|
||||
<td><?php echo $v->description; ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$this->load->view('templates/footer');
|
||||
?>
|
||||
+8
-5
@@ -347,10 +347,13 @@ if (isset($assign_to_config) && is_array($assign_to_config))
|
||||
*/
|
||||
$LANG =& load_class('Lang', 'core');
|
||||
|
||||
define('FHC_INTEGER',1);
|
||||
define('FHC_STRING',2);
|
||||
define('FHC_BOOLEAN',3);
|
||||
define('FHC_LANG_ARRAY',4);
|
||||
if (!defined('FHC_INTEGER'))
|
||||
{
|
||||
define('FHC_INTEGER',1);
|
||||
define('FHC_STRING',2);
|
||||
define('FHC_BOOLEAN',3);
|
||||
define('FHC_LANG_ARRAY',4);
|
||||
}
|
||||
|
||||
function &get_instance()
|
||||
{
|
||||
@@ -369,4 +372,4 @@ require_once(dirname(__FILE__).'/application/core/FHC_Model.php');
|
||||
$model=new CI_Model();
|
||||
|
||||
// Traits
|
||||
require_once(dirname(__FILE__).'/ci_db_extra.php');
|
||||
require_once(dirname(__FILE__).'/ci_db_extra.php');
|
||||
|
||||
Reference in New Issue
Block a user