diff --git a/apps/Files/config.php b/apps/Files/config.php index 85f7714..3338f6c 100755 --- a/apps/Files/config.php +++ b/apps/Files/config.php @@ -7,3 +7,5 @@ $_CONF['mod_desc'] = 'Ein Modul zum Anzeigen & Uploaden von Dateien'; $_CONF['menu_top'] = ' '.$GLOBALS['lang']->get('files_title'); $_CONF['menu'] = ['menu_top' => 'index.php']; $_CONF['type'] = 'none'; + +$_CONF['css'] = ['css/files.css']; \ No newline at end of file diff --git a/apps/SimplePages/backend/dashboard.php b/apps/SimplePages/backend/dashboard.php index 025e4db..7917d7d 100755 --- a/apps/SimplePages/backend/dashboard.php +++ b/apps/SimplePages/backend/dashboard.php @@ -1,11 +1,11 @@ set('Seiten zum Freischalten', 'sp_pages_confirm', 'de'); + $lang->set('Seiten zum Freischalten', 'sp_edit_pages_to_confirm', 'de'); $lang->set('Seiten, die Sie editieren dürfen', 'sp_edit_pages_to_edit', 'de'); - $lang->set('Seiten zum Freischalten', 'sp_pages_confirm', 'en'); - $lang->set('Seiten, die Sie editieren dürfen', 'sp_edit_pages_to_edit', 'en'); + $lang->set('Pages pending confirmation', 'sp_edit_pages_to_confirm', 'en'); + $lang->set('Pages you can edit', 'sp_edit_pages_to_edit', 'en'); //If pages are available for confirmation, show them $config = parse_ini_file('../apps/SimplePages/backend/confirm.ini'); diff --git a/apps/SimplePages/lang/lang.de.php b/apps/SimplePages/lang/lang.de.php index d0d2b2e..5d00c46 100755 --- a/apps/SimplePages/lang/lang.de.php +++ b/apps/SimplePages/lang/lang.de.php @@ -18,7 +18,7 @@ $lang['sp_manage_permissions'] = 'Berechtigungen verwalten'; $lang['sp_create_new'] = 'Neue Seite erstellen'; $lang['sp_confirm'] = 'Ă„nderungen Freischalten'; -$lang['sp_edit_pages_to_edit'] = 'Seiten, die Sie editieren dürfen'; +$lang['sp_edit_pages_to_edit'] = 'Pages you can edit'; $lang['sp_edit_pages_to_confirm'] = 'Seiten zum Freischalten'; //Manage Pages diff --git a/apps/SimplePages/lang/lang.en.php b/apps/SimplePages/lang/lang.en.php index 6db334a..a402312 100755 --- a/apps/SimplePages/lang/lang.en.php +++ b/apps/SimplePages/lang/lang.en.php @@ -19,7 +19,7 @@ $lang['sp_create_new'] = 'Create New Page'; $lang['sp_confirm'] = 'Confirm Changes'; $lang['sp_edit_pages_to_edit'] = 'Pages you can edit'; -$lang['sp_edit_pages_to_confirm'] = 'Pages to confirm'; +$lang['sp_edit_pages_to_confirm'] = 'Pages pending confirmation'; //Manage Pages $lang['sp_page'] = 'Page'; diff --git a/apps/testing/config.php b/apps/testing/config.php new file mode 100644 index 0000000..9c953b8 --- /dev/null +++ b/apps/testing/config.php @@ -0,0 +1,9 @@ + 'test.php', 'watr-andres' => 'test.php']; + +$_CONF['domain'] = 'sub.mowie'; \ No newline at end of file diff --git a/apps/testing/test.php b/apps/testing/test.php new file mode 100644 index 0000000..50fdff8 --- /dev/null +++ b/apps/testing/test.php @@ -0,0 +1,4 @@ +setResponseCode(200); +$page->setContent('Hallo Welr'); +$page->setTitle('tset'); \ No newline at end of file diff --git a/content/template.tpl b/content/template.tpl index 561cd0b..749c0f0 100755 --- a/content/template.tpl +++ b/content/template.tpl @@ -13,7 +13,7 @@ {$menu}
{$sidebar} - {$inhalt} + {$content} {$test} {$test2}
diff --git a/inc/apps.php b/inc/apps.php new file mode 100644 index 0000000..07c6c45 --- /dev/null +++ b/inc/apps.php @@ -0,0 +1,52 @@ +apps[$app] = $_CONF; + //print_r($_CONF); + $_CONF = []; + } + } + } + closedir($handle); + } + } + + public function getApps() + { + return $this->apps; + } +} \ No newline at end of file diff --git a/inc/autoload.php b/inc/autoload.php index be8f446..6e0dfca 100755 --- a/inc/autoload.php +++ b/inc/autoload.php @@ -26,6 +26,10 @@ if(file_exists($path.'lang/') && is_dir($path.'lang/')) $lang->setLangFolder( $path.'lang/'); } +//init Apps +require_once $path.'../../inc/apps.php'; +$apps = new apps(); + //Require appsConfig require_once $path.'config.php'; diff --git a/inc/autoload_adm.php b/inc/autoload_adm.php index b1ecfbf..a2c180d 100755 --- a/inc/autoload_adm.php +++ b/inc/autoload_adm.php @@ -7,4 +7,8 @@ require_once '../inc/config.php'; //$lang = new lang(); $lang->setLangFolder('lang/'); +//init Apps +require_once '../inc/apps.php'; +$apps = new apps(); + require_once '../inc/libs/functions.php'; \ No newline at end of file diff --git a/inc/libs/functions.php b/inc/libs/functions.php index 59fe348..be621ac 100755 --- a/inc/libs/functions.php +++ b/inc/libs/functions.php @@ -207,6 +207,43 @@ function printHeader($title) } } else { + //Get Apps, build app-menu (We're building the menu here and output it later because we want the name of the current app to use ist for App-CSS) + $appmenu = ''; + $apps = $GLOBALS['apps']->getApps(); + $appCurr = ''; + foreach ($apps as $app => $appconf) + { + if (isset($appconf['menu_top']) && $appconf['menu_top'] !== '') + { + $now = ''; + if (strpos($_SERVER['REQUEST_URI'], $app) !== false) + { + $now = ' class="active"'; + $appCurr = $app; + } + + if (array_key_exists('menu_top', $appconf['menu'])) + { + $appmenu .= "\n" . '' . $appconf['menu_top'] . '' . "\n"; + } else + { + $first_itm = array_keys($appconf['menu']); + $appmenu .= "\n" . '' . $appconf['menu_top'] . '' . "\n" . '' . "\n"; + } + $appconf['menu_top'] = ''; + } + } + // echo ' @@ -224,6 +261,19 @@ function printHeader($title) + +'; + + //Get App-CSS and output it + if(isset($apps[$appCurr]['css'])) + { + foreach ($apps[$appCurr]['css'] as $style) + { + echo ' '; + } + } + +echo ' '; if (is_loggedin()) @@ -295,62 +345,9 @@ function printHeader($title) ' . $_CONF['menu_top'] . '' . "\n"; - } else - { - $first_itm = array_keys($_CONF['menu']); - echo "\n" . '' . $_CONF['menu_top'] . '' . "\n" . '
    '; - foreach ($_CONF['menu'] as $mod_name_anz => $mod_name_url) - { - $now = ''; - if (strpos($_SERVER['REQUEST_URI'], $mod_name_url) !== false && strpos($_SERVER['REQUEST_URI'], $mod) !== false) - { - $now = ' class="active"'; - } - echo '' . $mod_name_anz . '' . "\n"; - } - echo '
' . "\n"; - } - $_CONF['menu_top'] = ''; - } - } - } - closedir($handle); - } echo '
© 2016 Mowie
'; //Lang @@ -528,7 +525,7 @@ function hasPerm($permkey, $scope = '') if ($scope == 'System') $scopeUri .= '../admin/'; - //echo $moduluri; + //echo $appuri; if (file_exists($scopeUri . 'permissions.json')) { diff --git a/inc/page.php b/inc/page.php index 1322808..7a51bc2 100755 --- a/inc/page.php +++ b/inc/page.php @@ -9,6 +9,7 @@ class page extends Smarty private $title; private $tplAssign = []; private $templateFile; + private $domain; //url fkt public function setUrl($url) @@ -115,4 +116,10 @@ class page extends Smarty echo preg_replace_callback('/{[A-Za-z0-9_:,\-\|]+}/', 'page_key', $tplFile); } + + public function getDomain() + { + $this->domain = $_SERVER['HTTP_HOST']; + return $this->domain; + } } \ No newline at end of file diff --git a/index.php b/index.php index fc17403..806476d 100755 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ setResponseCode(404); + $apps = new apps(); //Search apps and execute them if necessary - $appdir = 'apps/'; - if ($handle = opendir($appdir)) + foreach ($apps->getApps() as $app => $appconf) { - while (false !== ($app = readdir($handle))) + $appUri = 'apps/'.$app.'/'; + //If the App should run from one domain only + if((isset($appconf['domain']) && $page->getDomain() == $appconf['domain']) || !isset($appconf['domain']) || (isset($appconf['domain']) && $appconf['domain'] === '')) { - if ($app != "." && $app != ".." && !is_file($appdir . $app)) + //If we have an alias which equals the current url, execute it + if(isset($appconf['alias'])) + { + if(array_key_exists($page->getUrl(), $appconf['alias'])) { - $appUri = $appdir.$app; - if (file_exists($appUri.'/config.php')) - { - require $appUri.'/config.php'; - if(isset($_CONF['type']))//typ vorhanden? - { - if($_CONF['type'] == 'page')//Seite, die inhalte ausgibt - { - if(isset($_CONF['base_url_file'])) - { - if($_CONF['base_url'] == $page->getUrl()) - { - require $appUri.'/' . $_CONF['base_url_file']; - } - } - if(isset($_CONF['base_url']) && file_exists($appUri.'/' . $_CONF['base_file'])) - { - if($_CONF['base_url'] == $page->getBaseUrl()) - { - require $appUri.'/' . $_CONF['base_file']; - } - } - } - if($_CONF['type'] == 'static' && isset($_CONF['base_file']) && file_exists($appUri.'/'.$_CONF['base_file'])) - { - require $appUri.'/'.$_CONF['base_file']; - } - } - $_CONF = []; - } + require $appUri. $appconf['alias'][$page->getUrl()]; } } - closedir($handle); + + //If we have a type + if(isset($appconf['type'])) + { + //Page for (more or less) dynamic content + if($appconf['type'] == 'page') + { + //If we have a base_url_file and the current url equals base_url, execute base_url_file + if(isset($appconf['base_url_file'])) + { + if($appconf['base_url'] == $page->getUrl()) + { + require $appUri . $appconf['base_url_file']; + } + } + + //if we have a base_url and a base_file which exists and the current baseUrl equals base_url, execute base_file + if(isset($appconf['base_url']) && file_exists($appUri.'/' . $appconf['base_file'])) + { + if($appconf['base_url'] == $page->getBaseUrl()) + { + require $appUri. $appconf['base_file']; + } + } + } + + //Static + if($appconf['type'] == 'static' && isset($appconf['base_file']) && file_exists($appUri.'/'.$appconf['base_file'])) + { + require $appUri.$appconf['base_file']; + } + } + + //If the App should run from one domain only + /*if(isset($appconf['domain']) && $page->getDomain() == $appconf['domain']) + { + echo 'ff';*/ + } + + $appconf = []; } if($page->getResponseCode() == 404) @@ -89,7 +106,7 @@ if (file_exists('inc/config.yml')) $page->assign('copyright', $copy); // dat ganze ausgeben - http_response_code($page->getresponseCode()); + http_response_code($page->getResponseCode()); $page->assign($MCONF['tpl_title'], $page->getTitle(). ' | ' . $MCONF['title']); $page->assign($MCONF['tpl_content'], $page->getContent()); $page->assign($MCONF['tpl_webUri'], $MCONF['web_uri']);