mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
remove controllers, views and libraries for CisHmvc since not used
This commit is contained in:
@@ -1,319 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
use \DOMDocument as DOMDocument;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CisHmvc extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'basis/cis:r'
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->model('content/Content_model', 'ContentModel');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _remap($method)
|
||||
{
|
||||
$this->index();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// TODO(chris): CI can't handle empty ("//") parameters
|
||||
$path = explode('/', uri_string());
|
||||
array_shift($path); // NOTE(chris): remove cis4/
|
||||
|
||||
$menu = $this->ContentModel->getMenu(6739, getAuthUID());
|
||||
if (isError($menu)) {
|
||||
// TODO(chris): Error Handling
|
||||
return $this->load->view('CisHmvc/Error', ['error' => getError($menu)]);
|
||||
}
|
||||
$menu = getData($menu) ?? (object)['childs' => []];
|
||||
|
||||
$menu = $this->convertMenu($menu->childs, $path, APP_ROOT . 'index.ci.php/CisHmvc');
|
||||
$current = ['childs' => $menu];
|
||||
$params = $path;
|
||||
|
||||
foreach ($path as $key) {
|
||||
if (!isset($current['childs'][$key])) {
|
||||
if ($current['childs'] == $menu)
|
||||
$current = null;
|
||||
break;
|
||||
}
|
||||
$current = $current['childs'][$key];
|
||||
array_shift($params);
|
||||
}
|
||||
if (!$current) {
|
||||
return $this->notfound();
|
||||
}
|
||||
if (!$path)
|
||||
{
|
||||
$controller = 'CisHmvc/Dashboard';
|
||||
$action = 'index';
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ($current['orig']->template_kurzbz) {
|
||||
case 'redirect':
|
||||
list ($url, $target) = $this->getRedirectUrlAndTarget($current['orig']->content);
|
||||
if (substr($url, 0, 1) == '#')
|
||||
{
|
||||
$controller = 'CisHmvc';
|
||||
$action = 'notfound';
|
||||
break;
|
||||
}
|
||||
if ($target)
|
||||
{
|
||||
$controller = 'CisHmvc';
|
||||
$action = 'redirect';
|
||||
array_unshift($params, $url);
|
||||
break;
|
||||
}
|
||||
if (preg_match('/^(\.\.\/|\.\/)*index\.ci\.php\/(.*)$/', $url, $matches))
|
||||
{
|
||||
list ($controller, $action, $p) = $this->getControllerMethodAndParamsFromUrl($matches[2]);
|
||||
if (!$controller)
|
||||
{
|
||||
$controller = 'CisHmvc';
|
||||
$action = 'notfound';
|
||||
}
|
||||
else
|
||||
{
|
||||
while (count($p))
|
||||
array_unshift($params, array_pop($p));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (preg_match('/^(\.\.\/|\.\/)*cms\/news\.php(.*)$/', $url, $matches))
|
||||
{
|
||||
$controller = 'CisHmvc/Cms';
|
||||
$action = 'news';
|
||||
$p = parse_url($url . '?infoscreen=0', PHP_URL_QUERY);
|
||||
if ($p)
|
||||
{
|
||||
parse_str($p, $p);
|
||||
$params += array_values(array_merge([
|
||||
'infoscreen' => false,
|
||||
'studiengang_kz' => null,
|
||||
'semester' => null,
|
||||
'mischen' => true,
|
||||
'titel' => '',
|
||||
'edit' => false,
|
||||
'sichtbar' => true
|
||||
], $p));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (preg_match('/^(\.\.\/|\.\/)*(addons|cms|cis)\/(.*)$/', $url, $matches))
|
||||
{
|
||||
$controller = 'CisHmvc/Cms';
|
||||
$action = 'legacy';
|
||||
array_unshift($params, $matches[2] . "/" . $matches[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
$controller = 'CisHmvc/cms';
|
||||
$action = 'debug';
|
||||
array_unshift($params, $current['orig']);
|
||||
break;
|
||||
case 'contentohnetitel':
|
||||
case 'contentmittitel':
|
||||
$controller = 'CisHmvc/Cms';
|
||||
$action = 'content';
|
||||
array_unshift($params, $current['orig']->content_id);
|
||||
break;
|
||||
default:
|
||||
$controller = 'CisHmvc/Cms';
|
||||
$action = 'debug';
|
||||
array_unshift($params, $current['orig']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$className = ucfirst(basename($controller));
|
||||
$path = APPPATH . 'controllers/' . dirname($controller) . '/' . $className . '.php';
|
||||
|
||||
#var_dump(is_loaded());
|
||||
require_once $path;
|
||||
foreach (is_loaded() as $k => $v)
|
||||
if (!in_array($k, ['benchmark','hooks','config','log','utf8','uri','router','output','security','input','lang','loader']))
|
||||
unset(is_loaded()[$k]);
|
||||
|
||||
$this->router->directory = dirname($controller) . '/';
|
||||
$this->router->class = $className;
|
||||
$this->router->method = $action;
|
||||
|
||||
#var_dump($this->router->method);
|
||||
$controller = new $className();
|
||||
// NOTE(chris): this is needed because we loaded it in this controller and it can't be loaded twice
|
||||
$controller->ContentModel = $this->ContentModel;
|
||||
|
||||
$this->load->library('CisHmvc/Loader', [$menu, $this->load], 'Cis4Loader');
|
||||
$controller->load = $controller->Cis4Loader;
|
||||
call_user_func_array(array(&$controller, $action), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function notfound()
|
||||
{
|
||||
set_status_header(404);
|
||||
$this->load->view('CisHmvc/Error', ['error' => '404: Site Not Found']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri_string $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirect($url)
|
||||
{
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Protected methods (move to lib?)
|
||||
|
||||
protected function getControllerMethodAndParamsFromUrl($url)
|
||||
{
|
||||
$segments = explode('/', $url);
|
||||
$path = '';
|
||||
while ($possibleController = array_shift($segments)) {
|
||||
if (file_exists(APPPATH . 'controllers/' . $path . ucfirst($possibleController) . '.php'))
|
||||
return [$path . $possibleController, array_shift($segments) ?: 'index', $segments];
|
||||
$path .= $possibleController . '/';
|
||||
}
|
||||
return [null, null, null];
|
||||
}
|
||||
|
||||
protected function getRedirectUrlAndTarget($content)
|
||||
{
|
||||
if (!$content)
|
||||
return ['#', ''];
|
||||
|
||||
$url = '';
|
||||
$target = '';
|
||||
|
||||
$xml = new DOMDocument();
|
||||
$xml->loadXML($content);
|
||||
if ($xml->getElementsByTagName('url')->item(0))
|
||||
$url = $xml->getElementsByTagName('url')->item(0)->nodeValue;
|
||||
// TODO(chris): get params
|
||||
/*if (strpos($url, '$') !== FALSE)
|
||||
var_dump($url);*/
|
||||
if (isset($params) && is_array($params))
|
||||
foreach ($params as $key => $value)
|
||||
$url = str_replace('$' . $key, addslashes($value), $url);
|
||||
if ($xml->getElementsByTagName('target')->item(0))
|
||||
$target = $xml->getElementsByTagName('target')->item(0)->nodeValue;
|
||||
|
||||
if (!$url)
|
||||
$url = '#';
|
||||
|
||||
if (substr($url, 0, 1) == '#')
|
||||
$target = '';
|
||||
|
||||
if ($target == 'content' || $target == '_self')
|
||||
$target = '';
|
||||
|
||||
return [$url, $target];
|
||||
}
|
||||
|
||||
protected function convertMenu($items, $path, $path_prefix)
|
||||
{
|
||||
$menu = [];
|
||||
$current_path = array_shift($path);
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$entry = [];
|
||||
$entry['template_kurzbz'] = 'cis';
|
||||
$entry['content_id'] = $item->content_id;
|
||||
$entry['titel'] = $item->titel;
|
||||
|
||||
$slug = $this->createSlug($item->titel);
|
||||
|
||||
$entry['active'] = ($slug == $current_path);
|
||||
$entry['menu_open'] = $entry['active'];
|
||||
$entry['url'] = $path_prefix . '/' . $slug;
|
||||
$entry['target'] = '';
|
||||
|
||||
$entry['childs'] = $this->convertMenu($item->childs, $path, $entry['url']);
|
||||
|
||||
if ($entry['active'])
|
||||
$entry['orig'] = $item;
|
||||
|
||||
// TODO(chris): rewrite external and hash urls
|
||||
if ($item->template_kurzbz == 'redirect')
|
||||
{
|
||||
list ($url, $target) = $this->getRedirectUrlAndTarget($item->content);
|
||||
|
||||
if (substr($url, 0, 1) == '#')
|
||||
{
|
||||
$entry['url'] = $url;
|
||||
}
|
||||
elseif ($target)
|
||||
{
|
||||
$entry['url'] = $url;
|
||||
$entry['target'] = $target;
|
||||
}
|
||||
/*elseif (substr($url, 0, 7) != '../cis/' && substr($url, 0, 7) != '../cms/' && substr($url, 0, 10) != '../addons/' && substr($url, 0, 16) != '../index.ci.php/' && substr($url, 0, 1) != '?')
|
||||
{
|
||||
var_dump($entry['url']);
|
||||
}*/
|
||||
}
|
||||
|
||||
$menu[$slug] = $entry;
|
||||
}
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to create a slug associated to an "ugly" string.
|
||||
*
|
||||
* @param string $text the string to transform.
|
||||
*
|
||||
* @return string the resulting slug.
|
||||
*/
|
||||
protected function createSlug($text)
|
||||
{
|
||||
$table = [
|
||||
'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
|
||||
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'Ae', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
|
||||
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
|
||||
'Õ'=>'O', 'Ö'=>'Oe', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'Ue', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss',
|
||||
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'ae', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e',
|
||||
'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o',
|
||||
'ô'=>'o', 'õ'=>'o', 'ö'=>'oe', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ü'=>'ue', /*'ý'=>'y', duplicate? => see quality check*/'ý'=>'y', 'þ'=>'b',
|
||||
'ÿ'=>'y', 'Ŕ'=>'R', 'ŕ'=>'r', '/' => '-', ' ' => '-'
|
||||
];
|
||||
$text = preg_replace(['/\s{2,}/', '/[\t\n]/'], ' ', $text);
|
||||
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
|
||||
$text = strtr($text, $table);
|
||||
$text = preg_replace('~^[^a-z]~i', '', $text);
|
||||
return strtolower($text);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Cms extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'debug' => 'user:r',
|
||||
'legacy' => 'user:r',
|
||||
'content' => 'user:r',
|
||||
'news' => 'user:r'
|
||||
)
|
||||
);
|
||||
|
||||
// Loads WidgetLib
|
||||
$this->load->library('CmsLib');
|
||||
#$this->load->library('WidgetLib');
|
||||
|
||||
// Loads phrases system
|
||||
$this->loadPhrases([
|
||||
'global'
|
||||
]);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @param stdClass $content
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function debug($content)
|
||||
{
|
||||
$msg = $content->template_kurzbz . ' not yet implemented';
|
||||
if ($content->template_kurzbz == 'redirect') {
|
||||
$msg .= '<pre class="card p-1 mt-3">' . htmlentities($content->content) . '</pre>';
|
||||
}
|
||||
$this->load->view('CisHmvc/Error', ['error' => $msg]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function legacy($url)
|
||||
{
|
||||
$this->load->view('CisHmvc/Cms/Legacy', ['url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $content_id
|
||||
* @param int $version
|
||||
* @param string $sprache
|
||||
* @param boolean $sichtbar
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function content($content_id, $version = null, $sprache = null, $sichtbar = true)
|
||||
{
|
||||
// return early if the content_id for the content is missing
|
||||
if(!isset($content_id))
|
||||
$this->terminateWithError("content_id is missing");
|
||||
|
||||
$content = $this->ContentModel->load($content_id);
|
||||
if (isError($content))
|
||||
$this->terminateWithError(getError($content));
|
||||
|
||||
$content = getData($content);
|
||||
if(NULL === $content)
|
||||
$this->terminateWithError("Content not found");
|
||||
|
||||
$content = current($content);
|
||||
|
||||
$this->load->view('CisVue/Cms/Content', ['content_id' => $content_id, 'template_kurzbz'=>$content->template_kurzbz , 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* @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 news($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true)
|
||||
{
|
||||
$this->load->view('CisHmvc/Cms/Content', ['infoscreen' => $infoscreen, 'studiengang_kz' => $studiengang_kz, 'semester' => $semester, 'mischen' => $mischen, 'titel' => $titel, 'edit' => $edit, 'sichtbar' => $sichtbar, "template_kurzbz"=>"news"]);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Dashboard extends Auth_Controller
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'dashboard/benutzer:r'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('CisHmvc/Dashboard.php');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user