Get locales from provisioner
Add progress bar and xhr handler
This commit is contained in:
parent
1b32e0977e
commit
d7fd77dfe8
|
@ -754,6 +754,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
private function findInstLangs() {
|
||||
//locales and languages are installed in the tftp_lang_path
|
||||
$result = array();
|
||||
// TODO: Installer comes here so need to set default / ?
|
||||
$langDir = $this->sccppath["tftp_lang_path"];
|
||||
$localeJar = 'be-sccp.jar'; // This jar should exist if the locale is populated
|
||||
$langArr = $this->extconfigs->getExtConfig('sccp_lang');
|
||||
|
@ -839,11 +840,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$dir = $this->sccppath["tftp_dialplan_path"] . '/dial*.xml';
|
||||
$base_len = strlen($this->sccppath["tftp_dialplan_path"]) + 1;
|
||||
$res = glob($dir);
|
||||
$dp_list = array();
|
||||
foreach ($res as $key => $value) {
|
||||
$res[$key] = array('id' => substr($value, $base_len, -4), 'file' => substr($value, $base_len));
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -877,34 +876,32 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
|
||||
/*
|
||||
* Update Butons Labels on mysql DB
|
||||
* Update buttons Labels on mysql DB
|
||||
*/
|
||||
|
||||
private function updateSccpButtons($hw_list = array()) {
|
||||
|
||||
$save_buttons = array();
|
||||
$button_list = array();
|
||||
if (!empty($hw_list)) {
|
||||
$buton_list = array();
|
||||
foreach ($hw_list as $value) {
|
||||
$buton_tmp = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name']));
|
||||
if (!empty($buton_tmp)) {
|
||||
$buton_list = array_merge($buton_list, $buton_tmp);
|
||||
}
|
||||
$button_tmp = (array)$this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name']));
|
||||
$button_list = array_merge($button_list, $button_tmp);
|
||||
}
|
||||
} else {
|
||||
$buton_list = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial'));
|
||||
$button_list = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial'));
|
||||
}
|
||||
if (empty($buton_list)) {
|
||||
if (empty($button_list)) {
|
||||
return array('Response' => ' 0 buttons found ', 'data' => '');
|
||||
}
|
||||
$copy_fld = array('ref', 'reftype', 'instance', 'buttontype');
|
||||
$user_list = $user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name');
|
||||
foreach ($buton_list as $value) {
|
||||
$extList = $extList = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name');
|
||||
foreach ($button_list as $value) {
|
||||
$btn_opt = explode(',', $value['options']);
|
||||
$btn_id = $btn_opt[0];
|
||||
if (!empty($user_list[$btn_id])) {
|
||||
if ($user_list[$btn_id]['label'] != $value['name']) {
|
||||
$btn_data['name'] = $user_list[$btn_id]['label'];
|
||||
if (!empty($extList[$btn_id])) {
|
||||
if ($extList[$btn_id]['label'] != $value['name']) {
|
||||
$btn_data['name'] = $extList[$btn_id]['label'];
|
||||
foreach ($copy_fld as $ckey) {
|
||||
$btn_data[$ckey] = $value[$ckey];
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@ and open the template in the editor.
|
|||
.sccpmultiselect {
|
||||
min-height: 100px;
|
||||
padding: 1px 1px;
|
||||
|
||||
|
||||
}
|
||||
.sccpbtn {
|
||||
min-height: 10px;
|
||||
padding: 1px 1px;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,6 +195,8 @@ $(document).ready(function () {
|
|||
});
|
||||
// ---------------------------------------
|
||||
|
||||
|
||||
|
||||
$('.btnMultiselect').click(function (e) {
|
||||
var kid = $(this).data('id');
|
||||
if ($(this).data('key') === 'Right') {
|
||||
|
@ -482,6 +484,8 @@ $(document).ready(function () {
|
|||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$('.sccp_update').on('click', function (e) {
|
||||
// console.log($(this).data('id'));
|
||||
|
||||
|
@ -513,16 +517,6 @@ $(document).ready(function () {
|
|||
}
|
||||
|
||||
// ----------------------- Server.model form ----------------
|
||||
if ($(this).data('id') === 'get_ext_files') {
|
||||
var dev_cmd = 'get_ext_files';
|
||||
var dev_fld = ["device"];
|
||||
datas = 'enabled=0' + '&' + 'type=firmware' + '&' + 'name=' + '&';
|
||||
|
||||
for (var i = 0; i < dev_fld.length; i++) {
|
||||
datas = datas + dev_fld[i] + '=' + $('#ext_' + dev_fld[i]).val() + '&';
|
||||
}
|
||||
;
|
||||
}
|
||||
if ($(this).data('id') === 'model_add') {
|
||||
var dev_cmd = 'model_add';
|
||||
// var dev_fld = ["model","vendor","dns","buttons","loadimage","loadinformationid","validate","enabled"];
|
||||
|
@ -631,7 +625,10 @@ $(document).ready(function () {
|
|||
url: 'ajax.php?module=sccp_manager&command=' + dev_cmd,
|
||||
data: datas,
|
||||
success: function (data) {
|
||||
// console.log(data);
|
||||
//$('.progress-bar').css('width', data.progress + '%');
|
||||
//console.log(data.progress);
|
||||
|
||||
$('#pleaseWaitDialog').modal('hide');
|
||||
if (data.status === true) {
|
||||
if (data.table_reload === true) {
|
||||
$('table').bootstrapTable('refresh');
|
||||
|
@ -664,6 +661,81 @@ $(document).ready(function () {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
$('.sccp_get_ext').on('click', function (e) {
|
||||
// console.log($(this).data('id'));
|
||||
|
||||
|
||||
// ----------------------- Get external Files----------------
|
||||
if ($(this).data('id') === 'get_ext_files') {
|
||||
var dev_cmd = 'get_ext_files';
|
||||
var dev_fld = ["device", "locale"];
|
||||
datas = 'type=' + $(this).data('type') + '&' + 'name=' + '&';
|
||||
|
||||
for (var i = 0; i < dev_fld.length; i++) {
|
||||
datas = datas + dev_fld[i] + '=' + $('#ext_' + dev_fld[i]).val() + '&';
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
if (dev_cmd !== '') {
|
||||
$.ajax({
|
||||
// Need to modify xhr here to add listener
|
||||
xhr: function() {
|
||||
const controller = new AbortController();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener('progress', function(evt) {
|
||||
var result = evt.srcElement.responseText.split(',');
|
||||
var percentComplete = result[result.length - 2]; //last element is empty.
|
||||
$('#progress-bar').css('width', percentComplete + '%');
|
||||
if (percentComplete == 100 ) {
|
||||
controller.abort();
|
||||
}
|
||||
}, true, { signal: controller.signal });
|
||||
return xhr;
|
||||
},
|
||||
type: 'POST',
|
||||
url: 'ajax.php?module=sccp_manager&command=' + dev_cmd,
|
||||
data: datas,
|
||||
success: function (data) {
|
||||
|
||||
$('#pleaseWaitDialog').modal('hide');
|
||||
data = JSON.parse(data.replace(/^(.*\{)/,"\{"));
|
||||
if (data.status === true) {
|
||||
if (data.table_reload === true) {
|
||||
$('table').bootstrapTable('refresh');
|
||||
}
|
||||
if (data.message) {
|
||||
fpbxToast(data.message,_('Operation Result'), 'success');
|
||||
if (data.reload === true) {
|
||||
//Need setTimout or reload will kill Toast
|
||||
setTimeout(function(){location.reload();},500);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Array.isArray(data.message)) {
|
||||
data.message.forEach(function (entry) {
|
||||
fpbxToast(data.message[1],_('Error Result'), 'warning');
|
||||
});
|
||||
} else {
|
||||
if (data.message) {
|
||||
fpbxToast(data.message,_('Error Result'), 'warning');
|
||||
} else {
|
||||
if (data) {
|
||||
bs_alert(data,data.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#cr_sccp_phone_xml').on('click', function (e) {
|
||||
// console.log("asasdasdasdasd");
|
||||
// console.log($('#update-sccp-phone').find(':selected').data('val'));
|
||||
|
@ -1055,6 +1127,14 @@ function hex2bin(hex)
|
|||
return String.fromCharCode.apply(String, bytes);
|
||||
}
|
||||
|
||||
function showProgress() {
|
||||
$('#pleaseWaitDialog').modal();
|
||||
}
|
||||
|
||||
function closeProgress() {
|
||||
$('#pleaseWaitDialog').modal('hide');
|
||||
}
|
||||
|
||||
function sleep(milliseconds)
|
||||
{
|
||||
var start = new Date().getTime();
|
||||
|
|
|
@ -12,7 +12,8 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
* Input element Select SLD - Date format
|
||||
* SLZ - Time Zone
|
||||
* SLTZN - Time Zone List
|
||||
* SLT - TFTP Lang
|
||||
* SLT - Installed Languages
|
||||
* SLTD - Device Languages
|
||||
* SLM - Music on hold
|
||||
* SLK - System KeySet
|
||||
* SLG - call groups
|
||||
|
@ -246,14 +247,14 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
<name>netlang</name>
|
||||
<default>English_United_States</default>
|
||||
<select></select>
|
||||
<help>The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country.</help>
|
||||
<help>The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server</help>
|
||||
</item>
|
||||
<item type="SLT" id="3">
|
||||
<item type="SLTD" id="3">
|
||||
<label>SCCP Phone Device Language</label>
|
||||
<name>devlang</name>
|
||||
<default>English_United_States</default>
|
||||
<select> </select>
|
||||
<help>The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language.</help>
|
||||
<help>The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. If No language packs found is shown, you need to add locales in the tftp server</help>
|
||||
</item>
|
||||
</page_group>
|
||||
|
||||
|
@ -1334,19 +1335,19 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
<select></select>
|
||||
<help>Time Zone offset</help>
|
||||
</item>
|
||||
<item type="SLT" id="4" seq="98">
|
||||
<item type="SLTD" id="4" seq="98">
|
||||
<label>SCCP Network Device Language</label>
|
||||
<name>netlang</name>
|
||||
<default>English_United_States</default>
|
||||
<select></select>
|
||||
<help>The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country.</help>
|
||||
<help>The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server</help>
|
||||
</item>
|
||||
<item type="SLT" id="5" seq="98">
|
||||
<item type="SLTD" id="5" seq="98">
|
||||
<label>SCCP Phone Device Language</label>
|
||||
<name>devlang</name>
|
||||
<default>English_United_States</default>
|
||||
<select> </select>
|
||||
<help>The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language.</help>
|
||||
<help>The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. If No language packs found is shown, you need to add locales in the tftp server</help>
|
||||
</item>
|
||||
<item type="IE" id="6" seq="99">
|
||||
<label>Background Image</label>
|
||||
|
|
|
@ -867,6 +867,7 @@ function checkTftpServer() {
|
|||
$possibleFtpDirs = array('/srv', '/srv/tftp','/var/lib/tftp', '/tftpboot');
|
||||
|
||||
// write a couple of sentinels to different distro tftp locations in the filesystem
|
||||
// TODO: Depending on distro, do we have write permissions
|
||||
foreach ($possibleFtpDirs as $dirToTest) {
|
||||
if (is_dir($dirToTest) && is_writable($dirToTest)) {
|
||||
$tempFile = "${dirToTest}/{$remoteFileName}";
|
||||
|
|
|
@ -305,6 +305,7 @@ class extconfigs
|
|||
if (file_exists($adv_ini)){
|
||||
rename($adv_ini, "{$adv_ini}.old");
|
||||
}
|
||||
// TODO: index file is not declared
|
||||
$indexFile = fopen($adv_ini,'w');
|
||||
fwrite($indexFile, "[main]\n");
|
||||
foreach ($adv_config as $advKey => $advVal) {
|
||||
|
|
|
@ -501,8 +501,12 @@ class formcreate
|
|||
}
|
||||
$select_opt= $syslangs;
|
||||
break;
|
||||
case 'SLT':
|
||||
$select_opt= $installedLangs;
|
||||
case 'SLTD':
|
||||
$select_opt = array('xx' => 'No language packs found');
|
||||
if (!empty($installedLangs)) {
|
||||
$select_opt = (array)$installedLangs;
|
||||
|
||||
}
|
||||
break;
|
||||
case 'SLZ':
|
||||
$timeZoneOffsetList = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9',
|
||||
|
@ -514,7 +518,7 @@ class formcreate
|
|||
$select_opt= $timeZoneOffsetList;
|
||||
break;
|
||||
case 'SLA':
|
||||
$select_opt ='';
|
||||
$select_opt = array();
|
||||
if (!empty($fvalues[$res_n])) {
|
||||
if (!empty($fvalues[$res_n]['data'])) {
|
||||
$res_value = explode(';', $fvalues[$res_n]['data']);
|
||||
|
@ -616,6 +620,167 @@ class formcreate
|
|||
<?php
|
||||
}
|
||||
|
||||
function addElementSLT($child, $fvalues, $sccp_defaults,$npref, $installedLangs) {
|
||||
// Input element Select SLS - System Language
|
||||
$res_n = (string)$child ->name;
|
||||
$res_id = $npref.$res_n;
|
||||
$child->value ='';
|
||||
// $select_opt is an associative array for these types.
|
||||
if (!empty($metainfo[$res_n])) {
|
||||
if ($child->meta_help == '1' || $child->help == 'Help!') {
|
||||
$child->help = $metaInfo[$res_n];
|
||||
}
|
||||
}
|
||||
$select_opt = array('xx' => 'No language packs found');
|
||||
if (!empty($installedLangs)) {
|
||||
$select_opt = $installedLangs;
|
||||
}
|
||||
|
||||
if (empty($child->class)) {
|
||||
$child->class = 'form-control';
|
||||
}
|
||||
if (!empty($fvalues[$res_n])) {
|
||||
if (!empty($fvalues[$res_n]['data'])) {
|
||||
$child->value = $fvalues[$res_n]['data'];
|
||||
}
|
||||
}
|
||||
if (empty($child->value)) {
|
||||
if (!empty($child->default)) {
|
||||
$child->value = $child->default;
|
||||
}
|
||||
}
|
||||
$langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang');
|
||||
$localeArray = array_combine(array_keys($langArr),array_column($langArr, 'locale'));
|
||||
$requestType = 'locale';
|
||||
?>
|
||||
<div class="element-container">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<!--Begin modal include-->
|
||||
<div class="modal fade get_ext_file" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="gridSystemModalLabel"><?php echo _('Get Files From Provisioner');?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="element-container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?php echo "Sccp_Manager will try to download {$requestType} files from Provision_Sccp on GitHub.<br>
|
||||
This site, dkgroot/provision_sccp, is unrelated to Sccp_Manager, and the files found cannot be warrantied<br>
|
||||
If you accept this, please select the {$requestType} that you want to try to get files for and then Get Files From Provisioner<br><br>
|
||||
Please be patient - this may take some time depending on your internet link<br><br>" ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="element-container">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="get_model_files"><?php echo _('Fetch Files for');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" ></i>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class = "lnet form-group form-inline" data-nextid=1>
|
||||
<?php
|
||||
echo "<select class={$child->class} id='ext_locale'>";
|
||||
foreach ($localeArray as $key => $val) {
|
||||
|
||||
echo "<option value= '{$key}'";
|
||||
if ($key == 'en_GB') {
|
||||
echo " selected='selected'";
|
||||
}
|
||||
echo ">{$val}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<span id="new_model-help" class="help-block fpbx-help-block">Help.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _('Cancel');?></button>
|
||||
<button type="button" class="btn btn-primary sccp_get_ext" data-id="get_ext_files" data-type="locales" onclick="showProgress();" id="get_model_files" data-dismiss="modal"><?php echo _('Get Files from Provisioner');?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--End modal include-->
|
||||
<!--Start progress modal include-->
|
||||
<div id="pleaseWaitDialog" class="modal" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1>Getting files .....please wait</h1>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="progress">
|
||||
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated active" role="progressbar" style="width:0%">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="progress progress-striped active">
|
||||
<div class="progress-bar" style="width: 100%;">
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
<!--End progress modal include-->
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="<?php echo $res_id; ?>"><?php echo _($child->label);?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="<?php echo $res_id; ?>"></i>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class = "lnet form-group form-inline" data-nextid=1>
|
||||
<?php
|
||||
echo '<select name="'.$res_id.'" class="'. $child->class . '" id="' . $res_id . '">';
|
||||
foreach ($select_opt as $key => $val) {
|
||||
$opt_key = $key;
|
||||
$opt_val = $val;
|
||||
|
||||
echo '<option value="' . $opt_key . '"';
|
||||
if ($opt_key == $child->value) {
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo "> {$opt_val} </option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target=".get_ext_file"><i class="fa fa-bolt"></i> <?php echo _("Get language from Provisioner"); ?>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<span id="<?php echo $res_id;?>-help" class="help-block fpbx-help-block"><?php echo _($child->help);?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
function addElementSD($child, $fvalues, $sccp_defaults,$npref) {
|
||||
/*
|
||||
* Input element Select SDM - Model List
|
||||
|
|
|
@ -384,8 +384,7 @@ trait ajaxHelper {
|
|||
case 'validateMac':
|
||||
break;
|
||||
case 'get_ext_files':
|
||||
$result = $this->getFilesFromProvisioner($request['type'],$request['name'],$request['device']);
|
||||
return $result;
|
||||
return $this->getFilesFromProvisioner($request);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,15 +271,17 @@ trait helperfunctions {
|
|||
|
||||
}
|
||||
|
||||
public function getFilesFromProvisioner($type = '',$name = '',$device = '') {
|
||||
public function getFilesFromProvisioner($request) {
|
||||
dbug($request);
|
||||
$filesToGet = array();
|
||||
$provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/";
|
||||
if (!$tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) {
|
||||
$this->getFileListFromProvisioner();
|
||||
$tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml");
|
||||
}
|
||||
switch ($type) {
|
||||
switch ($request['type']) {
|
||||
case 'firmware':
|
||||
$device = $request['device'];
|
||||
if (!is_dir("{$this->sccppath['tftp_firmware_path']}/{$device}")) {
|
||||
mkdir("{$this->sccppath['tftp_firmware_path']}/{$device}", 0755);
|
||||
}
|
||||
|
@ -290,13 +292,49 @@ trait helperfunctions {
|
|||
file_put_contents("{$this->sccppath['tftp_firmware_path']}/{$device}/{$srcFile}",
|
||||
file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile));
|
||||
}
|
||||
return "thanks for trying Diederik :-)";
|
||||
break;
|
||||
$msg = "Firmware for {$device} has been successfully downloaded";
|
||||
break;
|
||||
case 'locales':
|
||||
$locale = $request['locale'];
|
||||
$langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang');
|
||||
$language = $langArr[$locale]['locale'];
|
||||
|
||||
if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) {
|
||||
mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755);
|
||||
}
|
||||
|
||||
$localeDir = $tftpBootXml->xpath("//Directory[@name='locales']");
|
||||
$localeDir = $localeDir[0]->xpath("//Directory[@name='languages']");
|
||||
$result = $localeDir[0]->xpath("//Directory[@name='{$language}']");
|
||||
$filesToGet = (array)$result[0]->FileName;
|
||||
|
||||
$totalFiles = count($filesToGet);
|
||||
$filesRetrieved = 0;
|
||||
|
||||
foreach ($filesToGet as $srcFile) {
|
||||
|
||||
file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}",
|
||||
file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile));
|
||||
$filesRetrieved ++;
|
||||
$percentComplete = $filesRetrieved *100 / $totalFiles;
|
||||
|
||||
//$data = array('data' => array('percentComplete' => $percentComplete));
|
||||
$data = "{$percentComplete},";
|
||||
//echo "id: $filesRetrieved" . PHP_EOL;
|
||||
//echo json_encode($data);
|
||||
echo $data;
|
||||
//echo PHP_EOL;
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
}
|
||||
$msg = "{$locale} Locale has been successfully downloaded";
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return array('status' => true, 'message' => $msg, 'reload' => true);
|
||||
}
|
||||
|
||||
public function initVarfromXml() {
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
<div class="form-group">
|
||||
<div class="col-md-3">
|
||||
<label class="control-label" for="get_model_files"><?php echo _('Fetch Files for');?></label>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" data-for="get_model_files"></i>
|
||||
<i class="fa fa-question-circle fpbx-help-icon" ></i>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="ext_device" name="new_model" value="79XX">
|
||||
|
@ -188,7 +188,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _('Cancel');?></button>
|
||||
<button type="button" class="btn btn-primary sccp_update" data-id="get_ext_files" id="get_model_files" data-dismiss="modal"><?php echo _('Get Files from Provisioner');?></button>
|
||||
<button type="button" class="btn btn-primary sccp_get_ext" data-id="get_ext_files" data-type="firmware" id="get_model_files" data-dismiss="modal"><?php echo _('Get Files from Provisioner');?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -77,12 +77,15 @@ foreach ($items as $child) {
|
|||
case 'SLK':
|
||||
case 'SLP':
|
||||
case 'SLS':
|
||||
case 'SLT':
|
||||
case 'SLTD':
|
||||
case 'SLA':
|
||||
case 'SLZ':
|
||||
case 'SL':
|
||||
\FreePbx::sccp_manager()->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref, $installedLangs);
|
||||
break;
|
||||
case 'SLT':
|
||||
\FreePbx::sccp_manager()->formcreate->addElementSLT($child, $fvalues, $sccp_defaults,$npref, $installedLangs);
|
||||
break;
|
||||
case 'SDM':
|
||||
case 'SDMS':
|
||||
case 'SDE':
|
||||
|
@ -105,4 +108,3 @@ if ($h_show==1) {
|
|||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
installedLangs
|
||||
|
|
Loading…
Reference in a new issue