2017-06-08 17:35:36 +02:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2017
|
|
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Matthew Vale <github@mafoo.org>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ($domains_processed == 1) {
|
2024-10-16 19:53:45 +02:00
|
|
|
//add the variables to the database
|
|
|
|
|
$sql = "select count(*) from v_number_translations ";
|
|
|
|
|
$num_rows = $database->select($sql, null, 'column');
|
|
|
|
|
unset($sql);
|
|
|
|
|
|
|
|
|
|
if ($num_rows == 0) {
|
|
|
|
|
//get the array of xml files
|
2017-06-08 17:35:36 +02:00
|
|
|
$xml_list = glob($_SERVER["PROJECT_ROOT"] . "/*/*/resources/switch/conf/number_translation/*.xml");
|
|
|
|
|
|
2024-10-16 19:53:45 +02:00
|
|
|
//number_translation class
|
2017-12-24 08:01:33 +01:00
|
|
|
$number_translation = new number_translations;
|
2017-06-08 17:35:36 +02:00
|
|
|
|
2024-10-16 19:53:45 +02:00
|
|
|
//process the xml files
|
2024-08-22 20:41:10 +02:00
|
|
|
foreach ($xml_list as $xml_file) {
|
2017-06-08 17:35:36 +02:00
|
|
|
//get and parse the xml
|
|
|
|
|
$number_translation->xml = file_get_contents($xml_file);
|
|
|
|
|
$number_translation->import();
|
|
|
|
|
}
|
2023-09-16 08:22:12 +02:00
|
|
|
|
2024-10-16 19:53:45 +02:00
|
|
|
//check for existing configuration
|
2025-03-14 23:19:49 +01:00
|
|
|
if (!empty($settings->get('switch','conf')) && file_exists($settings->get('switch','conf')."/autoload_configs/translate.conf.xml")) {
|
2017-06-08 17:35:36 +02:00
|
|
|
//import existing data
|
2025-03-14 23:19:49 +01:00
|
|
|
$xml = file_get_contents($settings->get('switch','conf')."/autoload_configs/translate.conf.xml");
|
2023-05-17 18:07:49 +02:00
|
|
|
|
2017-06-08 17:35:36 +02:00
|
|
|
//convert the xml string to an xml object
|
2024-10-16 19:53:45 +02:00
|
|
|
$xml = simplexml_load_string($xml);
|
2023-05-17 18:07:49 +02:00
|
|
|
|
2017-06-08 17:35:36 +02:00
|
|
|
//convert to json
|
2024-10-16 19:53:45 +02:00
|
|
|
$json = json_encode($xml);
|
2023-05-17 18:07:49 +02:00
|
|
|
|
2017-06-08 17:35:36 +02:00
|
|
|
//convert to an array
|
2024-10-16 19:53:45 +02:00
|
|
|
$number_translations = json_decode($json, true);
|
|
|
|
|
if (array_key_exists('include', $number_translations)) {
|
|
|
|
|
$number_translations = $number_translations['include'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($number_translations['configuration']) && $number_translations['configuration']['@attributes']['autogenerated'] != 'true') {
|
|
|
|
|
foreach ($number_translations['configuration']['profiles']['profile'] as $profile) {
|
|
|
|
|
$json = json_encode($profile);
|
|
|
|
|
$number_translation->display_type = $display_type;
|
|
|
|
|
$number_translation->json = $json;
|
|
|
|
|
$number_translation->import();
|
2017-06-08 17:35:36 +02:00
|
|
|
}
|
2024-10-16 19:53:45 +02:00
|
|
|
}
|
2017-06-08 17:35:36 +02:00
|
|
|
}
|
2024-10-16 19:53:45 +02:00
|
|
|
}
|
2017-06-08 17:35:36 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|