[1055] | 1 | <?php |
---|
| 2 | if(!session_id()) session_start(); |
---|
| 3 | |
---|
| 4 | $action=$_POST["action"]; |
---|
| 5 | |
---|
| 6 | switch ($action) { |
---|
| 7 | case 'getModuleInfo': |
---|
| 8 | getModuleInfo($_POST["module"]); |
---|
| 9 | break; |
---|
| 10 | case 'getModuleLayout': |
---|
| 11 | getModuleLayout($_POST["id"], $_POST["filename"]); |
---|
| 12 | break; |
---|
| 13 | |
---|
| 14 | case 'getModuleList': |
---|
| 15 | getModuleList(); |
---|
| 16 | break; |
---|
| 17 | |
---|
| 18 | default: |
---|
| 19 | # code... |
---|
| 20 | break; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | function getModuleList(){ |
---|
| 24 | header('Content-type: application/json'); |
---|
| 25 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
---|
| 26 | header("Cache-Control: post-check=0, pre-check=0", false); |
---|
| 27 | header("Pragma: no-cache"); |
---|
| 28 | |
---|
| 29 | $modules=array_diff(scandir("modules"), array('..', '.')); |
---|
| 30 | echo(json_encode($modules)); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | function getModuleInfo($module){ |
---|
| 34 | header('Content-type: application/json'); |
---|
| 35 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
---|
| 36 | header("Cache-Control: post-check=0, pre-check=0", false); |
---|
| 37 | header("Pragma: no-cache"); |
---|
| 38 | |
---|
| 39 | $moduleInfo=array(); |
---|
| 40 | $moduleInfo['info']=$_SESSION['modules'][$module]; |
---|
| 41 | |
---|
| 42 | // Reading css files list |
---|
| 43 | $styles=array_diff(scandir("modules/$module/src/css"), array('..', '.')); |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | foreach ($styles as $key=>$value) |
---|
| 47 | $styles[$key]="modules/$module/src/css/$value"; |
---|
| 48 | |
---|
| 49 | $moduleInfo['styles']=$styles; |
---|
| 50 | |
---|
| 51 | // Reading js files list |
---|
| 52 | $scripts=array_diff(scandir("modules/$module/src/js"), array('..', '.')); |
---|
| 53 | foreach ($scripts as $key=>$value) |
---|
| 54 | $scripts[$key]="modules/$module/src/js/$value"; |
---|
| 55 | |
---|
| 56 | $moduleInfo['scripts']=$scripts; |
---|
| 57 | |
---|
| 58 | echo(json_encode($moduleInfo)); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | function getModuleLayout($id, $filename){ |
---|
| 62 | header('Content-type: text/html'); |
---|
| 63 | header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
---|
| 64 | header("Cache-Control: post-check=0, pre-check=0", false); |
---|
| 65 | header("Pragma: no-cache"); |
---|
| 66 | |
---|
| 67 | echo "<div class='moduleWindow' id='$id'>"; |
---|
| 68 | require($filename); |
---|
| 69 | echo "</div>"; |
---|
| 70 | }; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | //require("modules/$module/src/main.html"); |
---|
| 74 | // Adding submodules |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | /* |
---|
| 79 | function importModuleContent($modules, $components){ |
---|
| 80 | |
---|
| 81 | echo "<div class='moduleWindow' id='info' style='display: block'>"; |
---|
| 82 | require("info.php"); |
---|
| 83 | echo "</div>"; |
---|
| 84 | |
---|
| 85 | foreach ($modules as $module){ |
---|
| 86 | echo "<div class='moduleWindow' id='$module'>"; |
---|
| 87 | //require("modules/$module/src/main.html"); |
---|
| 88 | // LOADMODULE |
---|
| 89 | echo "</div>"; |
---|
| 90 | // Loading components in module |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | foreach ($components as $component){ |
---|
| 94 | echo "<div class='moduleWindow' id='$component[0]'>"; |
---|
| 95 | //require($component['1']); |
---|
| 96 | |
---|
| 97 | echo "</div>"; |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | */ |
---|
| 101 | ?> |
---|