Phrases: Remove unused code (#5335)

* Remove unncessery code

* remove unnecessary code

* Update phrases.php
This commit is contained in:
agree
2020-07-06 20:21:56 -04:00
committed by GitHub
parent 2df30633be
commit 71854ba40e
3 changed files with 1 additions and 109 deletions

View File

@@ -28,7 +28,6 @@
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/functions/save_phrases_xml.php";
//check permissions
if (permission_exists('phrase_add') || permission_exists('phrase_edit')) {
@@ -237,9 +236,6 @@
$obj->delete_details($phrase_details_delete);
}
//save the xml to the file system if the phrase directory is set
save_phrases_xml();
//clear the cache
$cache = new cache;
$cache->delete("languages:".$phrase_language.".".$phrase_uuid);

View File

@@ -145,9 +145,6 @@ if (!class_exists('phrases')) {
//revoke temporary permissions
$p->delete('phrase_detail_delete', 'temp');
//save the xml
save_phrases_xml();
//clear the cache
$phrase_languages = array_unique($phrase_languages);
$cache = new cache;
@@ -225,9 +222,6 @@ if (!class_exists('phrases')) {
//revoke temporary permissions
$p->delete('phrase_detail_delete', 'temp');
//save the xml
save_phrases_xml();
//clear the cache
if ($phrase_language != '') {
$cache = new cache;
@@ -301,9 +295,6 @@ if (!class_exists('phrases')) {
$database->save($array);
unset($array);
//save the xml
save_phrases_xml();
//clear the cache
$phrase_languages = array_unique($phrase_languages);
$cache = new cache;
@@ -416,9 +407,6 @@ if (!class_exists('phrases')) {
//revoke temporary permissions
$p->delete('phrase_detail_add', 'temp');
//save the xml
save_phrases_xml();
//clear the cache
$phrase_languages = array_unique($phrase_languages);
$cache = new cache;
@@ -439,4 +427,4 @@ if (!class_exists('phrases')) {
} //class
}
?>
?>

View File

@@ -1,92 +0,0 @@
<?php
function save_phrases_xml() {
//skip saving the xml if the directory is not set
if (strlen($_SESSION['switch']['phrases']['dir']) == 0) {
return;
}
//declare the global variables
global $domain_uuid, $config;
//remove old phrase files for the domain
$phrase_list = glob($_SESSION['switch']['phrases']['dir']."/*/phrases/".$domain_uuid.".xml");
foreach ($phrase_list as $phrase_file) {
unlink($phrase_file);
}
//get the list of phrases and write the xml
$sql = "select * from v_phrases ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and phrase_enabled = 'true' ";
$sql .= "order by phrase_language asc ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$prev_language = '';
if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($row['phrase_language'] != $prev_language) {
if ($prev_language != '') {
//output xml & close previous file
$xml .= "</include>\n";
fwrite($fout, $xml);
unset($xml);
fclose($fout);
}
//create/open new xml file for writing
if (!file_exists($_SESSION['switch']['phrases']['dir']."/".$row['phrase_language']."/phrases/")) {
mkdir($_SESSION['switch']['phrases']['dir']."/".$row['phrase_language']."/phrases/", 0755);
}
$xml_path = $_SESSION['switch']['phrases']['dir']."/".$row['phrase_language']."/phrases/".$domain_uuid.".xml";
$fout = fopen($xml_path, "w");
$xml = "<include>\n";
}
//build xml
$xml .= " <macro name=\"".$row['phrase_uuid']."\">\n";
$xml .= " <input pattern=\"(.*)\">\n";
$xml .= " <match>\n";
$sql = "select * from v_phrase_details ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and phrase_uuid = :phrase_uuid ";
$sql .= "order by phrase_detail_order";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['phrase_uuid'] = $row['phrase_uuid'];
$database = new database;
$result_2 = $database->select($sql, $parameters, 'all');
foreach ($result_2 as &$row_2) {
$xml .= " <action function=\"".$row_2['phrase_detail_function']."\" data=\"".$row_2['phrase_detail_data']."\"/>\n";
}
unset($sql, $parameters, $result_2, $row_2);
$xml .= " </match>\n";
$xml .= " </input>\n";
$xml .= " </macro>\n";
$prev_language = $row['phrase_language'];
}
if ($fout && $xml) {
//output xml & close previous file
$xml .= "</include>\n";
fwrite($fout, $xml);
unset($xml);
fclose($fout);
}
}
unset($result, $row);
//apply settings
$_SESSION["reload_xml"] = true;
}
?>