mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Deprecated LANs checking now working again.
This commit is contained in:
@@ -196,8 +196,30 @@ if (varset($action) == "tools")
|
|||||||
|
|
||||||
$data = file_get_contents($script);
|
$data = file_get_contents($script);
|
||||||
|
|
||||||
preg_match_all("/.*(include_lan|require_once|include|include_once) ?\((.*e_LANGUAGE.*?\.php)/i",$data,$match);
|
$dir = dirname($script);
|
||||||
|
$plugin = basename($dir);
|
||||||
|
|
||||||
|
$newLangs = array(
|
||||||
|
0 => $dir."/languages/English/English_admin_".$plugin.".php",
|
||||||
|
1 => $dir."/languages/English_admin_".$plugin.".php",
|
||||||
|
2 => $dir."/languages/English_admin.php",
|
||||||
|
3 => $dir."/languages/English/English_admin.php"
|
||||||
|
);
|
||||||
|
|
||||||
|
// if(strpos($data, 'e_admin_dispatcher')!==false)
|
||||||
|
{
|
||||||
|
foreach($newLangs as $path)
|
||||||
|
{
|
||||||
|
if(file_exists($path))
|
||||||
|
{
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
preg_match_all("/.*(include_lan|require_once|include|include_once) ?\((.*e_LANGUAGE.*?\.php)/i",$data,$match);
|
||||||
|
|
||||||
$srch = array(" ",'e_PLUGIN.', 'e_LANGUAGEDIR', '.e_LANGUAGE.', "'", '"', "'.");
|
$srch = array(" ",'e_PLUGIN.', 'e_LANGUAGEDIR', '.e_LANGUAGE.', "'", '"', "'.");
|
||||||
$repl = array("", e_PLUGIN, e_LANGUAGEDIR, "English", "", "", "");
|
$repl = array("", e_PLUGIN, e_LANGUAGEDIR, "English", "", "", "");
|
||||||
@@ -211,10 +233,48 @@ if (varset($action) == "tools")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $arr[0];
|
return $arr[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(vartrue($_POST['disabled-unused']) && vartrue($_POST['disable-unused-lanfile']))
|
||||||
|
{
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
|
$data = file_get_contents($_POST['disable-unused-lanfile']);
|
||||||
|
|
||||||
|
$new = disableUnused($data);
|
||||||
|
if(file_put_contents($_POST['disable-unused-lanfile'],$new))
|
||||||
|
{
|
||||||
|
$mes->addSuccess("Overwriting ".$_POST['disable-unused-lanfile']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mes->addError("Couldn't overwrite ".$_POST['disable-unused-lanfile']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ns->tablerender("Processed".SEP.$_POST['disable-unused-lanfile'],$mes->render()."<pre>".htmlentities($new)."</pre>");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableUnused($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
$tmp = explode("\n",$data);
|
||||||
|
foreach($tmp as $line)
|
||||||
|
{
|
||||||
|
$ret = getDefined($line);
|
||||||
|
$newline[] = (in_array($ret['define'],$_SESSION['language-tools-unused']) && substr($line,0,2) !='//') ? "// ".$line : $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode("\n",$newline);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
@@ -223,14 +283,17 @@ if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
|||||||
$script = $_POST['deprecatedLans'];
|
$script = $_POST['deprecatedLans'];
|
||||||
|
|
||||||
|
|
||||||
// $scriptname = str_replace("lan_","",basename($lanfile));
|
|
||||||
|
|
||||||
if(strpos($script,'admin')!=true) // Plugin
|
|
||||||
|
if(strpos($script,e_ADMIN)!==false) // CORE
|
||||||
{
|
{
|
||||||
|
$mes->addDebug("Mode: Core Admin Calculated");
|
||||||
|
//$scriptname = str_replace("lan_","",basename($lanfile));
|
||||||
$lanfile = e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_".basename($script);
|
$lanfile = e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_".basename($script);
|
||||||
}
|
}
|
||||||
else // admin area.
|
else // Plugin
|
||||||
{
|
{
|
||||||
|
$mes->addDebug("Mode: Search Plugins");
|
||||||
$lanfile = findIncludedFiles($script);
|
$lanfile = findIncludedFiles($script);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +327,7 @@ if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans']))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mes->addDebug("Couldn't Read LanFile... ");
|
$mes->addError("No Language file found!");
|
||||||
$ns -> tablerender(vartrue($res['caption']), $mes->render(). vartrue($res['text']));
|
$ns -> tablerender(vartrue($res['caption']), $mes->render(). vartrue($res['text']));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +531,7 @@ function multilang_prefs()
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form>\n";
|
</form>\n";
|
||||||
|
|
||||||
e107::getRender()->tablerender(LANG_LAN_PAGE_TITLE.' - '.LANG_LAN_13, $mes->render().$text); // "Language Preferences";
|
e107::getRender()->tablerender(ADLAN_132.SEP.LAN_PREFS, $mes->render().$text); // "Language Preferences";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -600,7 +663,7 @@ function multilang_db()
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
";
|
";
|
||||||
|
|
||||||
e107::getRender()->tablerender(LANG_LAN_PAGE_TITLE.' - '.LANG_LAN_16, $emessage->render().$text);
|
e107::getRender()->tablerender(ADLAN_132.SEP.LANG_LAN_16, $emessage->render().$text); // Languages -> Tables
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -625,7 +688,7 @@ function show_tools()
|
|||||||
<tr>
|
<tr>
|
||||||
<td>".LAN_CHECK_1."</td>
|
<td>".LAN_CHECK_1."</td>
|
||||||
<td>
|
<td>
|
||||||
<select name='language' class='tbox select'>
|
<select name='language' class='tbox e-select'>
|
||||||
<option value=''>".LAN_SELECT."</option>";
|
<option value=''>".LAN_SELECT."</option>";
|
||||||
$languages = explode(",", e_LANLIST);
|
$languages = explode(",", e_LANLIST);
|
||||||
sort($languages);
|
sort($languages);
|
||||||
@@ -660,7 +723,7 @@ function show_tools()
|
|||||||
<tr>
|
<tr>
|
||||||
<td>".LANG_LAN_23."</td>
|
<td>".LANG_LAN_23."</td>
|
||||||
<td>
|
<td>
|
||||||
<select name='language' class='tbox select'>
|
<select name='language' class='tbox e-select'>
|
||||||
<option value=''>".LAN_SELECT."</option>";
|
<option value=''>".LAN_SELECT."</option>";
|
||||||
$languages = explode(",", e_LANLIST);
|
$languages = explode(",", e_LANLIST);
|
||||||
sort($languages);
|
sort($languages);
|
||||||
@@ -685,7 +748,7 @@ function show_tools()
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Search for Deprecated Lans</td>
|
<td>Search for Deprecated Lans</td>
|
||||||
<td>
|
<td>
|
||||||
<select name='deprecatedLans' class='tbox select'>
|
<select name='deprecatedLans' class='tbox e-select'>
|
||||||
<option value=''>".LAN_SELECT."</option>";
|
<option value=''>".LAN_SELECT."</option>";
|
||||||
|
|
||||||
$fl = e107::getFile();
|
$fl = e107::getFile();
|
||||||
@@ -741,7 +804,7 @@ function show_tools()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
e107::getRender()->tablerender(LANG_LAN_PAGE_TITLE.' - '.LANG_LAN_21, $mes->render().$text);
|
e107::getRender()->tablerender(ADLAN_132.SEP.LANG_LAN_21, $mes->render().$text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -945,8 +1008,13 @@ function grab_lans($path, $language, $filter = "")
|
|||||||
*/
|
*/
|
||||||
function unused($lanfile,$script)
|
function unused($lanfile,$script)
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
|
||||||
|
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unset($_SESSION['language-tools-unused']);
|
||||||
// $mes->addInfo("LAN=".$lanfile."<br />Script = ".$script);
|
// $mes->addInfo("LAN=".$lanfile."<br />Script = ".$script);
|
||||||
|
|
||||||
|
|
||||||
@@ -963,13 +1031,11 @@ function unused($lanfile,$script)
|
|||||||
|
|
||||||
if(!$compare)
|
if(!$compare)
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
|
||||||
$mes->add("Couldn't read ".$script, E_MESSAGE_ERROR);
|
$mes->add("Couldn't read ".$script, E_MESSAGE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$lanDefines)
|
if(!$lanDefines)
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
|
||||||
$mes->add("Couldn't read ".$lanfile, E_MESSAGE_ERROR);
|
$mes->add("Couldn't read ".$lanfile, E_MESSAGE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -980,8 +1046,8 @@ function unused($lanfile,$script)
|
|||||||
|
|
||||||
if($lanDefines && $compare)
|
if($lanDefines && $compare)
|
||||||
{
|
{
|
||||||
|
$text = $frm->open('language-unused');
|
||||||
$text = "<table class='table adminlist'>
|
$text .= "<table class='table adminlist'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style='width:40%' />
|
<col style='width:40%' />
|
||||||
<col style='auto' />
|
<col style='auto' />
|
||||||
@@ -1016,6 +1082,14 @@ function unused($lanfile,$script)
|
|||||||
|
|
||||||
$text .= "</tbody></table>";
|
$text .= "</tbody></table>";
|
||||||
|
|
||||||
|
if(count($_SESSION['language-tools-unused'])>0)
|
||||||
|
{
|
||||||
|
$text .= "<div class='buttons-bar center'>".$frm->admin_button('disabled-unused','Disable All Unused','submit').
|
||||||
|
$frm->hidden('disable-unused-lanfile',$lanfile)."</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= $frm->close();
|
||||||
|
|
||||||
|
|
||||||
$mes->addInfo("<b>Pink items are likely to be unused LANs.<br />Comment out and test thoroughly.</b>");
|
$mes->addInfo("<b>Pink items are likely to be unused LANs.<br />Comment out and test thoroughly.</b>");
|
||||||
|
|
||||||
@@ -1115,7 +1189,12 @@ function compareit($needle,$haystack,$value='',$disabled=FALSE){
|
|||||||
|
|
||||||
if(!$found)
|
if(!$found)
|
||||||
{
|
{
|
||||||
|
// echo "<br />Unused: ".$needle;
|
||||||
$text .= "-";
|
$text .= "-";
|
||||||
|
if(!$disabled)
|
||||||
|
{
|
||||||
|
$_SESSION['language-tools-unused'][] = $needle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$text .= "</td>";
|
$text .= "</td>";
|
||||||
|
|
||||||
@@ -1143,7 +1222,10 @@ function compareit($needle,$haystack,$value='',$disabled=FALSE){
|
|||||||
$color = "background-color:#DFFFDF";
|
$color = "background-color:#DFFFDF";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$found)
|
||||||
|
{
|
||||||
|
$needle = "<a class='e-tip' href='#' title=\"".$value."\">".$needle."</a>";
|
||||||
|
}
|
||||||
|
|
||||||
return "<tr><td style='width:25%;$color'>".$needle .$disabled. "</td>".$text."</tr>";
|
return "<tr><td style='width:25%;$color'>".$needle .$disabled. "</td>".$text."</tr>";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user