From 64624fa5975c4e0fc1bded41b8054f5bf21f0ab0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 30 Jun 2021 08:14:15 +0200 Subject: [PATCH] Simplify chan-sccp help usage Convert array to string when loaded, and rename arrays that hold the data for clarity --- Sccp_manager.class.php | 12 +++++---- conf/sccpgeneral.xml.v433 | 1 - views/formShow.php | 16 ++++++------ views/formShowSysDefs.php | 52 ++++++++++++++++++++++----------------- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 63c052f..c6f78a9 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -101,7 +101,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public $xml_data; public $class_error; //error construct public $info_warning; - public $sccp_metainfo = array(); + public $sccpHelpInfo = array(); // Move all non sccp_manager specific functions to traits use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions; @@ -155,11 +155,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v433'; $this->xml_data = simplexml_load_file($xml_vars); // load metainfo from chan-sccp - help information if not in xml. Only load first time as static data. - if (empty($this->sccp_metainfo)) { + if (empty($this->sccpHelpInfo)) { $sysConfiguration = $this->aminterface->getSCCPConfigMetaData('general'); foreach ($sysConfiguration['Options'] as $key => $valueArray) { - $this->sccp_metainfo[$valueArray['Name']] = $valueArray['Description']; + foreach ($valueArray['Description'] as $descKey => $descValue) { + $this->sccpHelpInfo[$valueArray['Name']] .= $descValue . '
'; + } } unset($sysConfiguration); } @@ -174,7 +176,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo, + 'chanSccpHelp' => $this->sccpHelpInfo, 'sccp_defaults' => $this->sccpvalues )); } else { @@ -184,7 +186,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo, + 'chanSccpHelp' => $this->sccpHelpInfo, 'sccp_defaults' => $this->sccpvalues ) ); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index e9214aa..c777dcb 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -107,7 +107,6 @@ and open the template in the editor. Base Version before all crash :-) sccp-custom - External IP Address of the firewall, required in case the PBX is running on a separate host behind it. IP Address that we're going to notify in RTP media stream as the pbx source address. Resolve Hostname (if dynamic) that we're going to resolve when setting up the RTP media stream (only active if externip=0.0.0.0 and host is natted.) 1 / diff --git a/views/formShow.php b/views/formShow.php index 2c3183a..b3c691f 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -92,7 +92,7 @@ foreach ($items as $child) { $res_id = $npref.$res_oid; if (!empty($metainfo[$res_oid])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_oid]['Description']; + $child->help = $metainfo[$res_oid]; } } @@ -179,7 +179,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } // $res_value @@ -323,7 +323,7 @@ foreach ($items as $child) { $res_ext = str_replace($npref,'',$res_n); if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -410,7 +410,7 @@ foreach ($items as $child) { $res_id = $npref.$res_n; if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -490,7 +490,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -582,7 +582,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -643,7 +643,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -935,7 +935,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index e1497a4..335daa3 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -89,11 +89,11 @@ foreach ($items as $child) { $res_input = ''; $res_name = ''; $usingSysDefaults = true; - $res_oid = (string)$child->input[0]->name; - $res_id = $npref.$res_oid; - if (!empty($metainfo[$res_oid])) { + $shortId = (string)$child->input[0]->name; + $res_id = $npref.$shortId; + if (!empty($metainfo[$shortId])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_oid]['Description']; + $child->help = $metainfo[$shortId]; } } @@ -109,7 +109,17 @@ foreach ($items as $child) { $i = 0; echo ''; - + ?> +
+
+
+
+ + +
+
+ xpath('input') as $value) { $res_n = (string)$value->name; $res_name = $npref . $res_n; @@ -133,19 +143,16 @@ foreach ($items as $child) { if (empty($value->class)) { $value->class = 'form-control'; } + // TODO: This is a temporary workaround and should be fixed $item = array('id' => $res_id, 'setting' => $child->label, 'feature' => $res_id, 'iscustom' => 'checked'); + + if ($i > 0) { + echo $child->nameseparator; + } + echo $value->value; $i ++; } ?> -
-
-
-
- - -
-
- value; ?>
@@ -158,11 +165,12 @@ foreach ($items as $child) {