1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Renamed commentOut() to cleanFile().

This commit is contained in:
Cameron
2017-10-16 20:00:04 -07:00
parent 7b59fb31c2
commit 632d9b11c2

View File

@@ -1901,24 +1901,25 @@ class lancheck
/**
* Comment out definitions in a language file.
* Clean-up out definitions in a language file.
* @param array $defKeys array of constants to comment out.
* @param string $path path to the language file to edit.
*/
function commentOut($defKeys, $path)
function cleanFile($path, $defKeys=null)
{
if(empty($defKeys) || empty($path) || !file_exists($path) || stripos($path,'English')!==false)
if(empty($path) || !file_exists($path) || stripos($path,'English')!==false)
{
return null;
}
$content = file_get_contents($path);
$lines = explode("\n",$content);
$srch = array();
$repl =array();
if(!empty($defKeys))
{
foreach($defKeys as $const)
{
$srch[] = "define('".$const."'";
@@ -1927,6 +1928,7 @@ class lancheck
$repl[] = "// define('".$const."'";
$repl[] = '// define("'.$const.'"';
}
}
$new = '';
foreach($lines as $ln)
@@ -1942,8 +1944,15 @@ class lancheck
continue;
}
if(!empty($srch))
{
$new .= str_replace($srch,$repl,$ln)."\n";
}
else
{
$new .= $ln."\n";
}
}
if(file_put_contents($path,$new))
{