From ca83b2f59dd362c9020949a5055ebe2547036295 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jun 2016 16:25:55 +0200 Subject: [PATCH] phrases system --- application/config/migration.php | 2 +- application/controllers/system/Phrases.php | 155 +++++++++++++++++ application/core/FHC_Controller.php | 8 +- application/libraries/PhrasesLib.php | 159 ++++++++++++++++++ application/migrations/003_add_apikey.php | 1 - application/migrations/009_phrase.php | 7 +- .../models/system/Phrase_inhalt_model.php | 15 ++ application/models/system/Phrase_model.php | 15 ++ application/views/system/phrases.php | 20 +++ application/views/system/phrasesList.php | 37 ++++ .../views/system/phrasesinhaltList.php | 40 +++++ ci_hack.php | 13 +- 12 files changed, 459 insertions(+), 13 deletions(-) create mode 100644 application/controllers/system/Phrases.php create mode 100644 application/libraries/PhrasesLib.php create mode 100644 application/models/system/Phrase_inhalt_model.php create mode 100644 application/models/system/Phrase_model.php create mode 100644 application/views/system/phrases.php create mode 100644 application/views/system/phrasesList.php create mode 100644 application/views/system/phrasesinhaltList.php diff --git a/application/config/migration.php b/application/config/migration.php index 65e90ad2e..102054bae 100755 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -23,7 +23,7 @@ $config['migration_enabled'] = TRUE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 009; +$config['migration_version'] = '009'; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/system/Phrases.php b/application/controllers/system/Phrases.php new file mode 100644 index 000000000..eedb4bb1e --- /dev/null +++ b/application/controllers/system/Phrases.php @@ -0,0 +1,155 @@ +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); + } +} diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php index 7921455cb..e3026dbb8 100644 --- a/application/core/FHC_Controller.php +++ b/application/core/FHC_Controller.php @@ -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'); + } + } diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php new file mode 100644 index 000000000..1fad64e56 --- /dev/null +++ b/application/libraries/PhrasesLib.php @@ -0,0 +1,159 @@ +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; + } +} diff --git a/application/migrations/003_add_apikey.php b/application/migrations/003_add_apikey.php index 06ea42d65..c7bc4b578 100644 --- a/application/migrations/003_add_apikey.php +++ b/application/migrations/003_add_apikey.php @@ -54,4 +54,3 @@ class Migration_Add_apikey extends CI_Migration { $this->dbforge->drop_table('ci_apikey'); } } - diff --git a/application/migrations/009_phrase.php b/application/migrations/009_phrase.php index 708f1e6b6..ea354b5f9 100755 --- a/application/migrations/009_phrase.php +++ b/application/migrations/009_phrase.php @@ -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 diff --git a/application/models/system/Phrase_inhalt_model.php b/application/models/system/Phrase_inhalt_model.php new file mode 100644 index 000000000..806915bca --- /dev/null +++ b/application/models/system/Phrase_inhalt_model.php @@ -0,0 +1,15 @@ +dbTable = 'public.tbl_phrase_inhalt'; + $this->pk = 'phrase_inhalt_id'; + } + +} diff --git a/application/models/system/Phrase_model.php b/application/models/system/Phrase_model.php new file mode 100644 index 000000000..051ef170c --- /dev/null +++ b/application/models/system/Phrase_model.php @@ -0,0 +1,15 @@ +dbTable = 'public.tbl_phrase'; + $this->pk = 'phrase_id'; + } + +} diff --git a/application/views/system/phrases.php b/application/views/system/phrases.php new file mode 100644 index 000000000..2409fcc83 --- /dev/null +++ b/application/views/system/phrases.php @@ -0,0 +1,20 @@ + + + + + VileSci - Phrasen + + + + + + + + <body bgcolor="#FFFFFF"> + This application works only with a frames-enabled browser.<br /> + <a href="PhrasesList">Use without frames</a> + </body> + + + + diff --git a/application/views/system/phrasesList.php b/application/views/system/phrasesList.php new file mode 100644 index 000000000..6cfa3d17c --- /dev/null +++ b/application/views/system/phrasesList.php @@ -0,0 +1,37 @@ +load->view('templates/header', array('title' => 'PhrasesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '2:{sorter:false}')); +?> +
+
+

Phrasen

+ + + + + + + + + + + + + + + + + +
IDPhrase
phrase_id; ?>phrase; ?>View
+
+
+ + diff --git a/application/views/system/phrasesinhaltList.php b/application/views/system/phrasesinhaltList.php new file mode 100644 index 000000000..4e6b5fe43 --- /dev/null +++ b/application/views/system/phrasesinhaltList.php @@ -0,0 +1,40 @@ +load->view('templates/header', array('title' => 'PhrasenInhaltList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '5:{sorter:false}')); +?> + +
+
+

Phrase Inhalt -

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + +
IDSpracheOrgEinheitOrgFormTextBeschreibung
phrase_inhalt_id; ?>sprache; ?>orgeinheit_kurzbz; ?>orgform_kurzbz; ?>text; ?>description; ?>
+
+
+ +load->view('templates/footer'); +?> diff --git a/ci_hack.php b/ci_hack.php index a7cfe5d02..dc1261eb8 100755 --- a/ci_hack.php +++ b/ci_hack.php @@ -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'); \ No newline at end of file +require_once(dirname(__FILE__).'/ci_db_extra.php');