3 Versions

This commit is contained in:
cgfhtw
2022-12-15 09:42:28 +01:00
parent 266ba7523f
commit c56b774d1d
48 changed files with 2909 additions and 430 deletions
+420
View File
@@ -0,0 +1,420 @@
<?php
defined('BASEPATH') || exit('No direct script access allowed');
/**
* Description of Cis4Loader
*
* @author chris
*/
class Loader extends CI_Loader
{
const OVERWRITE_PARAMS = [
'vue3' => true,
'bootstrap5' => true,
'bootstrap3' => false,
'fontawesome6' => true,
'fontawesome4' => false,
'axios027' => true,
'customJSModules' => [
'public/js/apps/Cis.js'
],
'customCSSs' => [
'public/css/Cis4/Cis.css'
]
];
protected $coreOptions = null;
protected $loader = null;
public function __construct($params)
{
$this->loader = $params[1];
$this->coreOptions = ['menu' => $params[0]];
}
/**
* View Loader
*
* Loads "view" files.
*
* @param string $view View name
* @param array $vars An associative array of data
* to be extracted for use in the view
* @param bool $return Whether to return the view output
* or leave it to the Output class
* @return object|string
*/
public function view($view, $vars = array(), $return = FALSE)
{
if ($view == 'templates/FHC-Header' || $view == 'templates/FHC-Footer')
{
$overwrittenParams = array_merge($vars, self::OVERWRITE_PARAMS);
foreach (['customJSModules', 'customCSSs'] as $key)
if (isset($vars[$key]))
$overwrittenParams[$key] = array_merge(self::OVERWRITE_PARAMS[$key], $vars[$key]);
if ($view == 'templates/FHC-Header')
{
$view1 = $view;
$param1 = $overwrittenParams;
$view2 = 'templates/CISHMVC-Header';
$param2 = $this->coreOptions;
}
else
{
$view1 = 'templates/CISHMVC-Footer';
$param1 = $this->coreOptions;
$view2 = $view;
$param2 = $overwrittenParams;
}
if ($return)
return $this->loader->view($view1, $param1, $return) . $this->loader->view($view2, $param2, $return);
$this->loader->view($view1, $param1, $return);
$this->loader->view($view2, $param2, $return);
}
else
{
return $this->loader->view($view, $vars, $return);
}
}
/**
* Initializer
*
* @todo Figure out a way to move this to the constructor
* without breaking *package_path*() methods.
* @uses CI_Loader::_ci_autoloader()
* @used-by CI_Controller::__construct()
* @return void
*/
public function initialize()
{
$this->loader->initialize();
}
// --------------------------------------------------------------------
/**
* Is Loaded
*
* A utility method to test if a class is in the self::$_ci_classes array.
*
* @used-by Mainly used by Form Helper function _get_validation_object().
*
* @param string $class Class name to check for
* @return string|bool Class object name if loaded or FALSE
*/
public function is_loaded($class)
{
return $this->loader->is_loaded($class);
}
// --------------------------------------------------------------------
/**
* Library Loader
*
* Loads and instantiates libraries.
* Designed to be called from application controllers.
*
* @param mixed $library Library name
* @param array $params Optional parameters to pass to the library class constructor
* @param string $object_name An optional object name to assign to
* @return object
*/
public function library($library, $params = NULL, $object_name = NULL)
{
$this->loader->library($library, $params, $object_name);
return $this;
}
// --------------------------------------------------------------------
/**
* Model Loader
*
* Loads and instantiates models.
*
* @param mixed $model Model name
* @param string $name An optional object name to assign to
* @param bool $db_conn An optional database connection configuration to initialize
* @return object
*/
public function model($model, $name = '', $db_conn = FALSE)
{
$this->loader->model($model, $name, $db_conn);
return $this;
}
// --------------------------------------------------------------------
/**
* Database Loader
*
* @param mixed $params Database configuration options
* @param bool $return Whether to return the database object
* @param bool $query_builder Whether to enable Query Builder
* (overrides the configuration setting)
*
* @return object|bool Database object if $return is set to TRUE,
* FALSE on failure, CI_Loader instance in any other case
*/
public function database($params = '', $return = FALSE, $query_builder = NULL)
{
$res = $this->loader->database($params, $return, $query_builder);
return $res == $this->loader ? $this : $res;
}
// --------------------------------------------------------------------
/**
* Load the Database Utilities Class
*
* @param object $db Database object
* @param bool $return Whether to return the DB Utilities class object or not
* @return object
*/
public function dbutil($db = NULL, $return = FALSE)
{
$res = $this->loader->dbutil($db, $return);
return $res === $this->loader ? $this : $res;
}
// --------------------------------------------------------------------
/**
* Load the Database Forge Class
*
* @param object $db Database object
* @param bool $return Whether to return the DB Forge class object or not
* @return object
*/
public function dbforge($db = NULL, $return = FALSE)
{
$res = $this->loader->dbforge($db, $return);
return $res === $this->loader ? $this : $res;
}
// --------------------------------------------------------------------
/**
* Generic File Loader
*
* @param string $path File path
* @param bool $return Whether to return the file output
* @return object|string
*/
public function file($path, $return = FALSE)
{
$res = $this->loader->file($path, $return);
return $res === $this->loader ? $this : $res;
}
// --------------------------------------------------------------------
/**
* Set Variables
*
* Once variables are set they become available within
* the controller class and its "view" files.
*
* @param array|object|string $vars
* An associative array or object containing values
* to be set, or a value's name if string
* @param string $val Value to set, only used if $vars is a string
* @return object
*/
public function vars($vars, $val = '')
{
$res = $this->loader->vars($vars, $val);
return $res === $this->loader ? $this : $res;
}
// --------------------------------------------------------------------
/**
* Clear Cached Variables
*
* Clears the cached variables.
*
* @return CI_Loader
*/
public function clear_vars()
{
$this->loader->clear_vars();
return $this;
}
// --------------------------------------------------------------------
/**
* Get Variable
*
* Check if a variable is set and retrieve it.
*
* @param string $key Variable name
* @return mixed The variable or NULL if not found
*/
public function get_var($key)
{
return $this->loader->get_var($key);
}
// --------------------------------------------------------------------
/**
* Get Variables
*
* Retrieves all loaded variables.
*
* @return array
*/
public function get_vars()
{
return $this->loader->get_vars();
}
// --------------------------------------------------------------------
/**
* Helper Loader
*
* @param string|string[] $helpers Helper name(s)
* @return object
*/
public function helper($helpers = array())
{
$this->loader->helper($helpers);
return $this;
}
// --------------------------------------------------------------------
/**
* Load Helpers
*
* An alias for the helper() method in case the developer has
* written the plural form of it.
*
* @uses CI_Loader::helper()
* @param string|string[] $helpers Helper name(s)
* @return object
*/
public function helpers($helpers = array())
{
return $this->helper($helpers);
}
// --------------------------------------------------------------------
/**
* Language Loader
*
* Loads language files.
*
* @param string|string[] $files List of language file names to load
* @param string Language name
* @return object
*/
public function language($files, $lang = '')
{
$this->loader->language($files, $lang);
return $this;
}
// --------------------------------------------------------------------
/**
* Config Loader
*
* Loads a config file (an alias for CI_Config::load()).
*
* @uses CI_Config::load()
* @param string $file Configuration file name
* @param bool $use_sections Whether configuration values should be loaded into their own section
* @param bool $fail_gracefully Whether to just return FALSE or display an error message
* @return bool TRUE if the file was loaded correctly or FALSE on failure
*/
public function config($file, $use_sections = FALSE, $fail_gracefully = FALSE)
{
return $this->loader->config($file, $use_sections, $fail_gracefully);
}
// --------------------------------------------------------------------
/**
* Driver Loader
*
* Loads a driver library.
*
* @param string|string[] $library Driver name(s)
* @param array $params Optional parameters to pass to the driver
* @param string $object_name An optional object name to assign to
*
* @return object|bool Object or FALSE on failure if $library is a string
* and $object_name is set. CI_Loader instance otherwise.
*/
public function driver($library, $params = NULL, $object_name = NULL)
{
$res = $this->loader->driver($library, $params, $object_name);
return $res === $this->loader ? $this : $res;
}
// --------------------------------------------------------------------
/**
* Add Package Path
*
* Prepends a parent path to the library, model, helper and config
* path arrays.
*
* @see CI_Loader::$_ci_library_paths
* @see CI_Loader::$_ci_model_paths
* @see CI_Loader::$_ci_helper_paths
* @see CI_Config::$_config_paths
*
* @param string $path Path to add
* @param bool $view_cascade (default: TRUE)
* @return object
*/
public function add_package_path($path, $view_cascade = TRUE)
{
$this->loader->add_package_path($path, $view_cascade);
return $this;
}
// --------------------------------------------------------------------
/**
* Get Package Paths
*
* Return a list of all package paths.
*
* @param bool $include_base Whether to include BASEPATH (default: FALSE)
* @return array
*/
public function get_package_paths($include_base = FALSE)
{
return $this->loader->get_package_paths($include_base);
}
// --------------------------------------------------------------------
/**
* Remove Package Path
*
* Remove a path from the library, model, helper and/or config
* path arrays if it exists. If no path is provided, the most recently
* added path will be removed removed.
*
* @param string $path Path to remove
* @return object
*/
public function remove_package_path($path = '')
{
$this->remove_package_path($path);
return $this;
}
}
+275
View File
@@ -0,0 +1,275 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* TODO(chris): NEWS: edit & delete button links and confirm
* TODO(chris): NEWS: news_infoscreen xlst
*/
class CmsLib
{
/**
* @var object
*/
protected $ci;
/**
* Constructor
*/
public function __construct()
{
$this->ci =& get_instance();
// Load Models
$this->ci->load->model('content/Content_model', 'ContentModel');
$this->ci->load->model('content/Contentgruppe_model', 'ContentgruppeModel');
$this->ci->load->model('content/Template_model', 'TemplateModel');
if (defined('LOG_CONTENT') && LOG_CONTENT)
$this->ci->load->model('system/Webservicelog_model', 'WebservicelogModel');
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* @param int $content_id
* @param int $version
* @param string $sprache
* @param boolean $sichtbar
*
* @return void
*/
public function getContent($content_id, $version = null, $sprache = null, $sichtbar = true)
{
if(!is_numeric($content_id))
return error('ContentID ist ungueltig');
if ($sprache === null)
$sprache = getUserLanguage();
$islocked = $this->ci->ContentgruppeModel->loadWhere(['content_id' => $content_id]);
if (isError($islocked))
return $islocked;
if (getData($islocked)) {
$uid = getAuthUID();
$isberechtigt = $this->ci->ContentgruppeModel->berechtigt($content_id, $uid);
if (isError($isberechtigt))
return $isberechtigt;
if (!getData($isberechtigt))
return error('global/keineBerechtigungFuerDieseSeite');
}
#$this->load->model('content/Content_model', 'ContentModel');
$content = $this->ci->ContentModel->getContent($content_id, $sprache, $version, $sichtbar, true);
if (isError($content))
return $content;
// Legt einen Logeintrag für die Klickstatistik an
if (defined('LOG_CONTENT') && LOG_CONTENT)
{
// Nur eingeloggte User werden geloggt, das sonst auch alle Infoscreenaufrufe und dgl. mitgeloggt werden
if (isLogged())
{
$request_data = 'content_id=' . $content_id;
if ($version !== null)
$request_data .= '&version=' . $version;
if ($sichtbar !== true)
$request_data .= '&sichtbar=' . $sichtbar;
$this->ci->WebservicelogModel->insert([
'webservicetyp_kurzbz' => 'content',
'request_id' => $content_id,
'beschreibung' => 'content',
'request_data' => $request_data . '&sprache=' . $sprache,
'execute_time' => 'now()',
'execute_user' => getAuthUID()
]);
}
}
$content = getData($content);
//XSLT Vorlage laden
$template = $this->ci->TemplateModel->load($content->template_kurzbz);
if (isError($template))
return $template;
$template = current(getData($template));
$XML = new \DOMDocument();
$XML->loadXML($content->content);
$xsltemplate = new \DOMDocument();
$xsltemplate->loadXML($template->xslt_xhtml_c4);
//Transformation
$processor = new \XSLTProcessor();
$processor->importStylesheet($xsltemplate);
$content = $processor->transformToXML($XML);
$content = str_replace('dms.php', APP_ROOT . 'cms/dms.php', $content);
return success($content);
}
/**
* @param stdClass $stg_obj
*
* @return stdClass
*/
protected function getNewsExtras($stg_obj, $semester)
{
$this->ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
$stg_ltg = $this->ci->StudiengangModel->getLeitungDetailed($stg_obj->studiengang_kz);
if (isError($stg_ltg))
return $stg_ltg;
$stg_ltg = getData($stg_ltg) ?: [];
$gf_ltg = $this->ci->BenutzerfunktionModel->getBenutzerFunktionenDetailed('gLtg', $stg_obj->oe_kurzbz);
if (isError($gf_ltg))
return $gf_ltg;
$gf_ltg = getData($gf_ltg) ?: [];
$stv_ltg = $this->ci->BenutzerfunktionModel->getBenutzerFunktionenDetailed('stvLtg', $stg_obj->oe_kurzbz);
if (isError($stv_ltg))
return $stv_ltg;
$stv_ltg = getData($stv_ltg) ?: [];
$ass = $this->ci->BenutzerfunktionModel->getBenutzerFunktionenDetailed('ass', $stg_obj->oe_kurzbz);
if (isError($ass))
return $ass;
$ass = getData($ass) ?: [];
$hochschulvertr = $this->ci->BenutzerfunktionModel->getBenutzerFunktionenDetailed('hsv');
if (isError($hochschulvertr))
return $hochschulvertr;
$hochschulvertr = getData($hochschulvertr) ?: [];
$stdv = $this->ci->BenutzerfunktionModel->getBenutzerFunktionenDetailed('stdv', $stg_obj->oe_kurzbz);
if (isError($stdv))
return $stdv;
$stdv = getData($stdv) ?: [];
$jahrgangsvertr = $this->ci->BenutzerfunktionModel->getBenutzerFunktionenDetailed('jgv', $stg_obj->oe_kurzbz, $semester);
if (isError($jahrgangsvertr))
return $jahrgangsvertr;
$jahrgangsvertr = getData($jahrgangsvertr) ?: [];
return success($this->ci->load->view('Cis/Cms/News/Xml/NewsExtras', [
'studiengang' => $stg_obj,
'semester' => $semester,
'stg_ltg' => $stg_ltg,
'gf_ltg' => $gf_ltg,
'stv_ltg' => $stv_ltg,
'ass' => $ass,
'hochschulvertr' => $hochschulvertr,
'stdv' => $stdv,
'jahrgangsvertr' => $jahrgangsvertr
], true));
}
/**
* @param boolean $infoscreen
* @param string | null $studiengang_kz
* @param int | null $semester
* @param boolean $mischen
* @param string $titel
* @param boolean $edit
* @param boolean $sichtbar
*
* @return void
*/
public function getNews($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true)
{
$this->ci->load->model('crm/Student_model', 'StudentModel');
$this->ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
if (!$infoscreen && ($studiengang_kz === null || $semester === null))
{
//Zum anzeigen der Studiengang-Details neben den News
$student = $this->ci->StudentModel->loadWhere(['student_uid' => get_uid()]);
if (isError($student))
return $student;
if (getData($student)) {
$student = current(getData($student));
if ($studiengang_kz === null)
$studiengang_kz = $student->studiengang_kz;
if ($semester === null)
$semester = $student->semester;
}
}
$all = $edit;
$xml = '<?xml version="1.0" encoding="UTF-8"?><content>';
$this->ci->load->model('content/News_model', 'NewsModel');
$news = $this->ci->NewsModel->getNewsWithContent(getSprache(), $studiengang_kz, $semester, null, $sichtbar, 0, 0, $all, $mischen);
if (isError($news))
return $news;
$news = getData($news);
foreach ($news as $newsobj) {
if ($studiengang_kz && $edit && !$newsobj->studiengang_kz)
continue;
$date = new \DateTime($newsobj->datum);
$datum = '<datum><![CDATA[' . $date->format('d.m.Y') . ']]></datum>';
$datum .= '<datumdetail><![CDATA[' . $date->format('Y-m-d H:i') . ']]></datumdetail>';
$id = $edit ? '<news_id><![CDATA[' . $newsobj->news_id . ']]></news_id>' : '';
$xml .= "<newswrapper>" . $newsobj->content . $datum . $id . "</newswrapper>";
}
if ($studiengang_kz != 0)
{
$stg_obj = $this->ci->StudiengangModel->load($studiengang_kz);
if (isError($stg_obj))
return $stg_obj;
$stg_obj = current(getData($stg_obj) ?: []);
if ($stg_obj)
{
if (!$edit && !$infoscreen)
{
$extras = $this->getNewsExtras($stg_obj, $semester);
if (isError($extras))
return $extras;
$xml .= getData($extras);
}
$xml .= '<studiengang_bezeichnung><![CDATA[' . $stg_obj->bezeichnung . ']]></studiengang_bezeichnung>';
}
}
if ($titel != '')
{
$xml .= '<news_titel>' . $titel . '</news_titel>';
}
$xml .= '</content>';
//XSLT Vorlage laden
$template = $this->ci->TemplateModel->load($infoscreen ? 'news_infoscreen' : 'news');
if (isError($template))
return $template;
$template = current(getData($template));
$XML = new \DOMDocument();
$XML->loadXML($xml);
$xsltemplate = new \DOMDocument();
$xsltemplate->loadXML($template->xslt_xhtml_c4);
//Transformation
$processor = new \XSLTProcessor();
$processor->importStylesheet($xsltemplate);
$content = $processor->transformToDoc($XML);
$content->formatOutput = true;
$content = $content->saveHTML();
$content = str_replace('dms.php', APP_ROOT . 'cms/dms.php', $content);
return success($content);
}
}