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_firmware_path' => $this->sccpvalues['tftp_firmware_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');
|
||||
|
@ -868,11 +869,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
|
||||
function deleteDialPlan($get_file) {
|
||||
if (!empty($get_file)) {
|
||||
$file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml';
|
||||
if (file_exists($file)) {
|
||||
$res = unlink($file);
|
||||
}
|
||||
$file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml';
|
||||
if (file_exists($file)) {
|
||||
$res = unlink($file);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<module>
|
||||
<rawname>sccp_manager</rawname>
|
||||
<name>SCCP Manager</name>
|
||||
<version>14.3.0.1</version>
|
||||
<version>14.3.0.0</version>
|
||||
<type>setup</type>
|
||||
<category>SCCP Connectivity</category>
|
||||
<publisher>Steve Lad, Alex GP</publisher>
|
||||
|
|
|
@ -246,7 +246,8 @@ class extconfigs
|
|||
'dialplan' => 'dialplan',
|
||||
'softkey' => 'softkey',
|
||||
'ringtones' => 'ringtones',
|
||||
'wallpapers' => 'wallpapers'
|
||||
'wallpapers' => 'wallpapers',
|
||||
'countries' => 'countries'
|
||||
);
|
||||
$adv_tree = array('pro' => array('templates' => 'tftproot',
|
||||
'firmware' => 'tftproot',
|
||||
|
@ -257,7 +258,8 @@ class extconfigs
|
|||
'dialplan' => 'tftproot',
|
||||
'softkey' => 'tftproot',
|
||||
'ringtones' => 'tftproot',
|
||||
'wallpapers' => 'tftproot'
|
||||
'wallpapers' => 'tftproot',
|
||||
'countries' => 'locales'
|
||||
),
|
||||
'def' => array('templates' => 'tftproot',
|
||||
'firmware' => '',
|
||||
|
@ -267,7 +269,8 @@ class extconfigs
|
|||
'dialplan' => '',
|
||||
'softkey' => '',
|
||||
'ringtones' => '',
|
||||
'wallpapers' => ''
|
||||
'wallpapers' => '',
|
||||
'countries' => ''
|
||||
)
|
||||
);
|
||||
$base_tree = array('tftp_templates_path' => 'templates',
|
||||
|
@ -277,7 +280,8 @@ class extconfigs
|
|||
'tftp_dialplan_path' => 'dialplan',
|
||||
'tftp_softkey_path' => 'softkey',
|
||||
'tftp_ringtones_path' => 'ringtones',
|
||||
'tftp_wallpapers_path' => 'wallpapers'
|
||||
'tftp_wallpapers_path' => 'wallpapers',
|
||||
'tftp_countries_path' => 'countries'
|
||||
);
|
||||
$baseConfig = array();
|
||||
|
||||
|
|
|
@ -295,16 +295,12 @@ trait ajaxHelper {
|
|||
return array();
|
||||
}
|
||||
$activeDevices = $this->aminterface->sccp_get_active_device();
|
||||
if (!empty($activeDevices)) {
|
||||
foreach ($lineList as $key => $lineArr) {
|
||||
if (isset($activeDevices[$lineArr['mac']])) {
|
||||
$actDevStat = $activeDevices[$lineArr['mac']];
|
||||
if (!empty($actDevStat)) {
|
||||
$lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}";
|
||||
} else {
|
||||
$lineList[$key]['line_status'] = '|';
|
||||
}
|
||||
}
|
||||
foreach ($lineList as $key => $lineArr) {
|
||||
if (array_key_exists($lineArr['mac'], $activeDevices)) {
|
||||
$actDevStat = $activeDevices[$lineArr['mac']];
|
||||
$lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}";
|
||||
} else {
|
||||
$lineList[$key]['line_status'] = '|';
|
||||
}
|
||||
}
|
||||
return $lineList;
|
||||
|
@ -629,33 +625,60 @@ trait ajaxHelper {
|
|||
break;
|
||||
case 'locale':
|
||||
$locale = $request['locale'];
|
||||
$totalFiles = 0;
|
||||
$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);
|
||||
}
|
||||
|
||||
// Get locales
|
||||
$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;
|
||||
$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;
|
||||
|
||||
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 = "{$percentComplete},";
|
||||
echo $data;
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
foreach (array('languages', 'countries') as $section){
|
||||
$srcDir = ${"{$section}SrcDir"};
|
||||
$dstDir = ${"{$section}DstDir"};
|
||||
foreach ($filesToGet[$section] as $srcFile) {
|
||||
file_put_contents("{$dstDir}/{$srcFile}",
|
||||
file_get_contents($provisionerUrl . $srcDir . $srcFile));
|
||||
$filesRetrieved ++;
|
||||
$percentComplete = $filesRetrieved *100 / $totalFiles;
|
||||
$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;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -33,7 +33,11 @@
|
|||
echo "<select class='form-control' id='ext_locale'>";
|
||||
}
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue