Get Country tones with locales
Get country files with locales WIP incompatibility between provision, its rewrite rules and the file structure WIP - need to clean up get files from provisioner
This commit is contained in:
parent
3a53e9ac8b
commit
215cacae41
|
@ -809,7 +809,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
'tftp_lang_path' => $this->sccpvalues['tftp_lang_path']['data'],
|
'tftp_lang_path' => $this->sccpvalues['tftp_lang_path']['data'],
|
||||||
'tftp_firmware_path' => $this->sccpvalues['tftp_firmware_path']['data'],
|
'tftp_firmware_path' => $this->sccpvalues['tftp_firmware_path']['data'],
|
||||||
'tftp_dialplan_path' => $this->sccpvalues['tftp_dialplan_path']['data'],
|
'tftp_dialplan_path' => $this->sccpvalues['tftp_dialplan_path']['data'],
|
||||||
'tftp_softkey_path' => $this->sccpvalues['tftp_softkey_path']['data']
|
'tftp_softkey_path' => $this->sccpvalues['tftp_softkey_path']['data'],
|
||||||
|
'tftp_countries_path' => $this->sccpvalues['tftp_countries_path']['data']
|
||||||
);
|
);
|
||||||
|
|
||||||
$read_config = $this->cnf_read->getConfig('sccp.conf');
|
$read_config = $this->cnf_read->getConfig('sccp.conf');
|
||||||
|
@ -868,11 +869,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteDialPlan($get_file) {
|
function deleteDialPlan($get_file) {
|
||||||
if (!empty($get_file)) {
|
$file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml';
|
||||||
$file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml';
|
if (file_exists($file)) {
|
||||||
if (file_exists($file)) {
|
$res = unlink($file);
|
||||||
$res = unlink($file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<module>
|
<module>
|
||||||
<rawname>sccp_manager</rawname>
|
<rawname>sccp_manager</rawname>
|
||||||
<name>SCCP Manager</name>
|
<name>SCCP Manager</name>
|
||||||
<version>14.3.0.1</version>
|
<version>14.3.0.0</version>
|
||||||
<type>setup</type>
|
<type>setup</type>
|
||||||
<category>SCCP Connectivity</category>
|
<category>SCCP Connectivity</category>
|
||||||
<publisher>Steve Lad, Alex GP</publisher>
|
<publisher>Steve Lad, Alex GP</publisher>
|
||||||
|
|
|
@ -246,7 +246,8 @@ class extconfigs
|
||||||
'dialplan' => 'dialplan',
|
'dialplan' => 'dialplan',
|
||||||
'softkey' => 'softkey',
|
'softkey' => 'softkey',
|
||||||
'ringtones' => 'ringtones',
|
'ringtones' => 'ringtones',
|
||||||
'wallpapers' => 'wallpapers'
|
'wallpapers' => 'wallpapers',
|
||||||
|
'countries' => 'countries'
|
||||||
);
|
);
|
||||||
$adv_tree = array('pro' => array('templates' => 'tftproot',
|
$adv_tree = array('pro' => array('templates' => 'tftproot',
|
||||||
'firmware' => 'tftproot',
|
'firmware' => 'tftproot',
|
||||||
|
@ -257,7 +258,8 @@ class extconfigs
|
||||||
'dialplan' => 'tftproot',
|
'dialplan' => 'tftproot',
|
||||||
'softkey' => 'tftproot',
|
'softkey' => 'tftproot',
|
||||||
'ringtones' => 'tftproot',
|
'ringtones' => 'tftproot',
|
||||||
'wallpapers' => 'tftproot'
|
'wallpapers' => 'tftproot',
|
||||||
|
'countries' => 'locales'
|
||||||
),
|
),
|
||||||
'def' => array('templates' => 'tftproot',
|
'def' => array('templates' => 'tftproot',
|
||||||
'firmware' => '',
|
'firmware' => '',
|
||||||
|
@ -267,7 +269,8 @@ class extconfigs
|
||||||
'dialplan' => '',
|
'dialplan' => '',
|
||||||
'softkey' => '',
|
'softkey' => '',
|
||||||
'ringtones' => '',
|
'ringtones' => '',
|
||||||
'wallpapers' => ''
|
'wallpapers' => '',
|
||||||
|
'countries' => ''
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$base_tree = array('tftp_templates_path' => 'templates',
|
$base_tree = array('tftp_templates_path' => 'templates',
|
||||||
|
@ -277,7 +280,8 @@ class extconfigs
|
||||||
'tftp_dialplan_path' => 'dialplan',
|
'tftp_dialplan_path' => 'dialplan',
|
||||||
'tftp_softkey_path' => 'softkey',
|
'tftp_softkey_path' => 'softkey',
|
||||||
'tftp_ringtones_path' => 'ringtones',
|
'tftp_ringtones_path' => 'ringtones',
|
||||||
'tftp_wallpapers_path' => 'wallpapers'
|
'tftp_wallpapers_path' => 'wallpapers',
|
||||||
|
'tftp_countries_path' => 'countries'
|
||||||
);
|
);
|
||||||
$baseConfig = array();
|
$baseConfig = array();
|
||||||
|
|
||||||
|
|
|
@ -295,16 +295,12 @@ trait ajaxHelper {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$activeDevices = $this->aminterface->sccp_get_active_device();
|
$activeDevices = $this->aminterface->sccp_get_active_device();
|
||||||
if (!empty($activeDevices)) {
|
foreach ($lineList as $key => $lineArr) {
|
||||||
foreach ($lineList as $key => $lineArr) {
|
if (array_key_exists($lineArr['mac'], $activeDevices)) {
|
||||||
if (isset($activeDevices[$lineArr['mac']])) {
|
$actDevStat = $activeDevices[$lineArr['mac']];
|
||||||
$actDevStat = $activeDevices[$lineArr['mac']];
|
$lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}";
|
||||||
if (!empty($actDevStat)) {
|
} else {
|
||||||
$lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}";
|
$lineList[$key]['line_status'] = '|';
|
||||||
} else {
|
|
||||||
$lineList[$key]['line_status'] = '|';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $lineList;
|
return $lineList;
|
||||||
|
@ -629,33 +625,60 @@ trait ajaxHelper {
|
||||||
break;
|
break;
|
||||||
case 'locale':
|
case 'locale':
|
||||||
$locale = $request['locale'];
|
$locale = $request['locale'];
|
||||||
|
$totalFiles = 0;
|
||||||
$langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang');
|
$langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang');
|
||||||
$language = $langArr[$locale]['locale'];
|
$language = $langArr[$locale]['locale'];
|
||||||
|
|
||||||
if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) {
|
if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) {
|
||||||
mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755);
|
mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755);
|
||||||
}
|
}
|
||||||
|
// Get locales
|
||||||
$localeDir = $tftpBootXml->xpath("//Directory[@name='locales']");
|
$localeDir = $tftpBootXml->xpath("//Directory[@name='locales']");
|
||||||
$localeDir = $localeDir[0]->xpath("//Directory[@name='languages']");
|
$localeDir = $localeDir[0]->xpath("//Directory[@name='languages']");
|
||||||
$result = $localeDir[0]->xpath("//Directory[@name='{$language}']");
|
$result = $localeDir[0]->xpath("//Directory[@name='{$language}']");
|
||||||
$filesToGet = (array)$result[0]->FileName;
|
$filesToGet['languages'] = (array)$result[0]->FileName;
|
||||||
|
$totalFiles += count($filesToGet['languages']);
|
||||||
|
$languagesSrcDir = (string)$result[0]->DirectoryPath;
|
||||||
|
$languagesDstDir = "{$this->sccppath['tftp_lang_path']}/{$language}";
|
||||||
|
|
||||||
|
// Get countries. Country is a substring of locale with exception of korea
|
||||||
|
$country = explode('_', $language);
|
||||||
|
array_shift($country);
|
||||||
|
|
||||||
|
$countryName = array_shift($country);
|
||||||
|
while (count($country)>=1) {
|
||||||
|
$countryName .= '_' . array_shift($country);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_dir("{$this->sccppath['tftp_countries_path']}/{$countryName}")) {
|
||||||
|
mkdir("{$this->sccppath['tftp_countries_path']}/{$countryName}", 0755);
|
||||||
|
}
|
||||||
|
|
||||||
|
$countryDir = $tftpBootXml->xpath("//Directory[@name='locales']");
|
||||||
|
$countryDir = $countryDir[0]->xpath("//Directory[@name='countries']");
|
||||||
|
$result = $countryDir[0]->xpath("//Directory[@name='{$countryName}']");
|
||||||
|
$filesToGet['countries'] = (array)$result[0]->FileName;
|
||||||
|
$totalFiles += count($filesToGet['countries']);
|
||||||
|
$countriesSrcDir = (string)$result[0]->DirectoryPath;
|
||||||
|
$countriesDstDir = "{$this->sccppath['tftp_countries_path']}/{$countryName}";
|
||||||
|
|
||||||
$totalFiles = count($filesToGet);
|
|
||||||
$filesRetrieved = 0;
|
$filesRetrieved = 0;
|
||||||
|
|
||||||
foreach ($filesToGet as $srcFile) {
|
foreach (array('languages', 'countries') as $section){
|
||||||
file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}",
|
$srcDir = ${"{$section}SrcDir"};
|
||||||
file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile));
|
$dstDir = ${"{$section}DstDir"};
|
||||||
$filesRetrieved ++;
|
foreach ($filesToGet[$section] as $srcFile) {
|
||||||
$percentComplete = $filesRetrieved *100 / $totalFiles;
|
file_put_contents("{$dstDir}/{$srcFile}",
|
||||||
$data = "{$percentComplete},";
|
file_get_contents($provisionerUrl . $srcDir . $srcFile));
|
||||||
echo $data;
|
$filesRetrieved ++;
|
||||||
ob_flush();
|
$percentComplete = $filesRetrieved *100 / $totalFiles;
|
||||||
flush();
|
$data = "{$percentComplete},";
|
||||||
|
echo $data;
|
||||||
|
ob_flush();
|
||||||
|
flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$msg = "{$locale} Locale has been successfully downloaded";
|
$msg = "{$locale} Locale and Country tones have been successfully downloaded";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -33,7 +33,11 @@
|
||||||
echo "<select class='form-control' id='ext_locale'>";
|
echo "<select class='form-control' id='ext_locale'>";
|
||||||
}
|
}
|
||||||
foreach ($selectArray as $key => $val) {
|
foreach ($selectArray as $key => $val) {
|
||||||
echo "<option value= '{$key}' >{$val}</option>";
|
echo "<option value= '{$key}'";
|
||||||
|
if ($key == 'en_GB') {
|
||||||
|
echo ' selected="selected"';
|
||||||
|
}
|
||||||
|
echo ">{$val}</option>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in a new issue