60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
if (!isset($vueViewName)) die("vueViewName is not set");
|
|
if (!isset($mfLayoutPackage)) die("mfLayoutPackage is not set");
|
|
|
|
$additionalCSS = $additionalCSS ?? [];
|
|
$additionalJS = $additionalJS ?? [];
|
|
$vueViewPath = BASEDIR . "/public/js/pages/$vueViewName";
|
|
$additionalJS = ["bundler.php", ...$additionalJS];
|
|
|
|
if (is_dir($vueViewPath)) {
|
|
foreach (scandir($vueViewPath) as $file) {
|
|
if ($file === '.' || $file === '..') continue;
|
|
|
|
$fileExtension = pathinfo($file, PATHINFO_EXTENSION);
|
|
if ($fileExtension === 'css') $additionalCSS[] = "js/pages/$vueViewName/$file";
|
|
else if ($fileExtension === 'js') $additionalJS[] = "js/pages/$vueViewName/$file";
|
|
}
|
|
}
|
|
|
|
$additionalCSS = [
|
|
...$additionalCSS,
|
|
'plugins/daterangepicker/daterangepicker.css',
|
|
'plugins/vue/tt-components/css/tt-table.css',
|
|
'plugins/vue/tt-components/css/tt-loader.css',
|
|
'plugins/vue/tt-components/css/tt-position-manager.css',
|
|
];
|
|
|
|
/**
|
|
* Convert PascalCase to snake_case (e.g. PascalCase to pascal-case)
|
|
* @param string $str PascalCase string
|
|
* @return string snake-case string
|
|
*/
|
|
function pascalToSnakeCase(string $str): string {
|
|
return strtolower(preg_replace('/(?<!^)([A-Z])/', '-$1', $str));
|
|
}
|
|
|
|
$vueTagName = pascalToSnakeCase($vueViewName);
|
|
|
|
$vueHeaderPath = realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/vueHeader.php";
|
|
if (!file_exists($vueHeaderPath))
|
|
$vueHeaderPath = realpath(dirname(__FILE__) . "/../../default") . "/vueHeader.php";
|
|
|
|
include($vueHeaderPath); ?>
|
|
|
|
<div id="app">
|
|
<tt-page-title
|
|
v-if="window['TT_CONFIG'] && window['TT_CONFIG']['PAGE_TITLE'] && window['TT_CONFIG']['PATH']"
|
|
:title="window['TT_CONFIG']['PAGE_TITLE']"
|
|
:path="window['TT_CONFIG']['PATH']">
|
|
</tt-page-title>
|
|
|
|
<<?php echo $vueTagName; ?>>
|
|
</<?php echo $vueTagName; ?>>
|
|
</div>
|
|
<script>
|
|
const view = new Vue({el: '#app', data: {window: window}});
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|