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:
@@ -1901,31 +1901,33 @@ 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 array $defKeys array of constants to comment out.
|
||||||
* @param string $path path to the language file to edit.
|
* @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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$content = file_get_contents($path);
|
$content = file_get_contents($path);
|
||||||
$lines = explode("\n",$content);
|
$lines = explode("\n",$content);
|
||||||
|
|
||||||
$srch = array();
|
$srch = array();
|
||||||
$repl =array();
|
$repl =array();
|
||||||
|
|
||||||
foreach($defKeys as $const)
|
if(!empty($defKeys))
|
||||||
{
|
{
|
||||||
$srch[] = "define('".$const."'";
|
foreach($defKeys as $const)
|
||||||
$srch[] = 'define("'.$const.'"';
|
{
|
||||||
|
$srch[] = "define('".$const."'";
|
||||||
|
$srch[] = 'define("'.$const.'"';
|
||||||
|
|
||||||
$repl[] = "// define('".$const."'";
|
$repl[] = "// define('".$const."'";
|
||||||
$repl[] = '// define("'.$const.'"';
|
$repl[] = '// define("'.$const.'"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$new = '';
|
$new = '';
|
||||||
@@ -1942,7 +1944,14 @@ class lancheck
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$new .= str_replace($srch,$repl,$ln)."\n";
|
if(!empty($srch))
|
||||||
|
{
|
||||||
|
$new .= str_replace($srch,$repl,$ln)."\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$new .= $ln."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_put_contents($path,$new))
|
if(file_put_contents($path,$new))
|
||||||
|
Reference in New Issue
Block a user