Skip to content

Commit

Permalink
- finish auto register modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpadgett committed Feb 26, 2024
1 parent d486d88 commit c36bc15
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ private function scanAndRegisterCustomModules(): void
$baseModuleDir = $GLOBALS['baseModDir'];
$customDir = $GLOBALS['customModDir'];
$zendModDir = $GLOBALS['zendModDir'];
$coreModules = ['Application', 'Acl', 'Installer', 'FHIR', 'PatientFlowBoard'];
$allModules = array();

$result = $this->getInstallerTable()->allModules();
$allModules = array();
foreach ($result as $dataArray) {
$mod = new InstModule();
$mod->exchangeArray($dataArray);
Expand All @@ -107,34 +108,44 @@ private function scanAndRegisterCustomModules(): void
$allModules[] = $mod;
}

$dpath = $GLOBALS['srcdir'] . "/../$baseModuleDir$customDir/";
$dp = opendir($dpath);
$inDir = array();
for ($i = 0; false != ($fname = readdir($dp)); $i++) {
if ($fname != "." && $fname != ".." && $fname != "Application" && is_dir($dpath . $fname)) {
$inDir[$i] = $fname;
$dir_path = $GLOBALS['srcdir'] . "/../$baseModuleDir$customDir/";
$dp = opendir($dir_path);
$inDirCustom = array();
for ($i = 0; false != ($file_name = readdir($dp)); $i++) {
if ($file_name != "." && $file_name != ".." && $file_name != "Application" && is_dir($dir_path . $file_name)) {
$inDirCustom[$i] = $file_name;
}
}
/* Laminas directory Unregistered scan */
$dir_path = $GLOBALS['srcdir'] . "/../$baseModuleDir$zendModDir/module";
$dp = opendir($dir_path);
$inDirLaminas = array();
for ($i = 0; false != ($file_name = readdir($dp)); $i++) {
if ($file_name != "." && $file_name != ".." && (!in_array($file_name, $coreModules)) && is_dir($dir_path . "/" . $file_name)) {
$inDirLaminas[$i] = $file_name;
}
}
// do not show registered modules in the unregistered list
if (sizeof($allModules) > 0) {
foreach ($allModules as $modules) {
$key = array_search($modules->modDirectory, $inDir);
$key = array_search($modules->modDirectory, $inDirLaminas);
if ($key !== false) {
unset($inDir[$key]);
unset($inDirLaminas[$key]);
continue;
}
$key = array_search($modules->modDirectory, $inDirCustom);
if ($key !== false) {
unset($inDirCustom[$key]);
}
}
}
foreach ($inDir as $fname) {
$form_title_file = @file($GLOBALS['srcdir'] . "/../$baseModuleDir$customDir/$fname/info.txt");
if ($form_title_file) {
$form_title = trim($form_title_file[0]);
} else {
$form_title = $fname;
}
$rel_path = $fname . "/index.php";
if ($this->getInstallerTable()->register($fname, $rel_path)) {
$status = true;
}
foreach ($inDirLaminas as $file_name) {
$rel_path = $file_name . "/index.php";
$status = $this->getInstallerTable()->register($file_name, $rel_path, 0, $zendModDir);
}
foreach ($inDirCustom as $file_name) {
$rel_path = $file_name . "/index.php";
$status = $this->getInstallerTable()->register($file_name, $rel_path);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Warning : PoC code
// TBD - Must handle modules in external namespaces
Use OpenEMR\Modules;
use OpenEMR\Modules;

$listener = $this->listenerObject;
$hangers = $this->hangers;
Expand Down Expand Up @@ -199,18 +199,15 @@ if (count($TabSettings ?? []) > 0) { ?>
// TBD : clsOeModule
$rs_mod = sqlQuery('select * from modules where `mod_id` = ?', [$mod_id]);
$fConfig = dirname(realpath('.')) . '/custom_modules/' . $rs_mod['mod_directory'] . '/moduleConfig.php';
if (($rs_mod['type'] == 0) && file_exists($fConfig)) {
?>
if (($rs_mod['type'] == 0) && file_exists($fConfig)) { ?>
<div class="container-xl" id="tab<?php echo $this->escapeHtml($mod_id); ?>" style="height:100vh;">
<iframe src="<?php echo dirname($this->basePath(), 2) . '/custom_modules/' . $rs_mod['mod_directory'] . '/moduleConfig.php'; ?>"
style="width:100%;height:100%;border:0">
<iframe src="<?php echo dirname($this->basePath(), 2) . '/custom_modules/' . $rs_mod['mod_directory'] . '/moduleConfig.php'; ?>" style="width:100%;height:100%;border:0">
</iframe>
</div>
<?php
} else { ?>
<div class="easyui-tabs container" id="tab<?php echo $this->escapeHtml($mod_id); ?>" style="height:auto;">
<?php echo $listener->z_xlt('No Configuration Defined for this Module'); ?>
</div>
<?php
}
<?php }
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $coreModules = $this->coreModules ?? [];

table {
font-family: Arial, Helvetica, sans-serif;
font-size: 1rem;
}

.fa-2x {
Expand All @@ -65,7 +64,7 @@ $coreModules = $this->coreModules ?? [];
padding: 5px;
text-align: center;
cursor: pointer;
margin: 5px 5px 0px 0px;
margin: 5px 5px 0 0;
color: gray;
width: 97%;
}
Expand All @@ -76,7 +75,7 @@ $coreModules = $this->coreModules ?? [];
border: 1px solid #c9c6c6;
padding: 5px;
width: 95%;
border-top: 0px;
border-top: 0;
}

.modal {
Expand Down Expand Up @@ -112,58 +111,7 @@ $coreModules = $this->coreModules ?? [];
</thead>
<tbody>
<?php
/* Laminas directory Unregistered scan */
$slno = 0;
$dpath = $GLOBALS['srcdir'] . "/../{$baseModuleDir}{$zendModDir}/module";
$dp = opendir($dpath);
$inDir = array();
for ($i = 0; false != ($fname = readdir($dp)); $i++) {
if ($fname != "." && $fname != ".." && (!in_array($fname, $coreModules)) && is_dir($dpath . "/" . $fname))
$inDir[$i] = $fname;
}
if (sizeof($InstallersExisting) > 0) {
foreach ($InstallersExisting as $modules) {
$key = "";
$key = array_search($modules->modDirectory, $inDir); /* returns integer or FALSE */
if ($key !== false)
unset($inDir[$key]);
}
}
foreach ($inDir as $fname) {
$slno++; ?>
<tr>
<td><?php echo $this->escapeHtml($slno); ?></td>
<td>
<?php
$form_title_file = null;
if (is_file($GLOBALS['srcdir'] . "/../{$baseModuleDir}{$zendModDir}/$fname/info.txt")) {
$form_title_file = file($GLOBALS['srcdir'] . "/../{$baseModuleDir}{$zendModDir}/module/$fname/info.txt");
}
if (!empty($form_title_file)) {
$form_title = $form_title_file[0];
} else {
$form_title = $fname;
}
echo $this->escapeHtml($listener->z_xlt($form_title));
?>
</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>
<?php echo $listener->z_xlt('Laminas'); ?>
</td>
<td>--</td>
<td>
<a href="javascript:void(0)" onclick="register(1,'<?php echo $this->escapeHtml($form_title); ?>','<?php echo $this->escapeHtml($fname) ?>','register','zend');"><input type='button' class='activate' value="<?php echo $listener->z_xla('Register'); ?>" /></a>
</td>
<td>--</td>
</tr>
<?php }

flush();
/*
* Custorm modules directory Unregistered scan
/* Laminas and Custom modules directory Unregistered scan
* moved to InstallerController auto register.
* */
/******** Laminas Module List Creation ********/
Expand All @@ -185,7 +133,7 @@ $coreModules = $this->coreModules ?? [];
<?php
if ($moduleResult->sqlRun == 0) {
?>
<?php echo $listener->z_xlt('Not Installed'); ?>
<?php echo $listener->z_xlt('Registered'); ?>
<?php
} elseif ($moduleResult->modActive == 1) { ?>
<?php echo $listener->z_xlt('Active'); ?>
Expand Down Expand Up @@ -296,8 +244,7 @@ $coreModules = $this->coreModules ?? [];
</td>
<td>
<?php
if ($moduleResult->sqlRun == 0) {
?>
if ($moduleResult->sqlRun == 0) { ?>
<input type="text" onchange="validateNickName('<?php echo $this->escapeHtml($moduleResult->modId); ?>');" name="mod_nick_name_<?php echo $this->escapeHtml($moduleResult->modId); ?>" id="mod_nick_name_<?php echo $this->escapeHtml($moduleResult->modId); ?>" value="">
<div class="mod_nick_name_message" id="mod_nick_name_message_<?php echo $this->escapeHtml($moduleResult->modId); ?>"></div>
<?php
Expand Down

0 comments on commit c36bc15

Please sign in to comment.