Some rows can be edited but some won't change, can't figure out why...
Can someone please check what I am doing wrong (I am soon out of hair:/)
Code: Select all
function edit_help_topic()
{
global $option;
switch (JRequest::getVar('save', 0, '','string'))
{
case 'Save':
function replaceLineInTextFile($file, $pattern, $replacement)
{
if(!file_exists($file))
{ // if file doesn't exist...
$this->setRedirect('index.php?option=' . $option .'&view=help', 'File does not exist...'); // ...stop executing code.
}
else
{ // if file exists...
$f = file($file); // ...make new variable...
$content; // ...and another...
for($i = 0; $i < count($f); $i++)
{ // ...run through the loop...
if(eregi($pattern, $f[$i]))
{ // and
$content .= $replacement . "\n"; // get
}
else
{ // the
$content .= $f[$i]; // content.
}
}
$fi = fopen($file, "w"); // open specified file...
fwrite($fi, $content); // and rewrite it's content.
fclose($fi); // close file.
}
}
if(JRequest::getVar('language', '', 'post','string') == '' || JRequest::getVar('language', '', 'post','string') == 'sv-SE'){
preg_match_all("/(".JRequest::getVar('old_big_lang', '', 'post','string').")=(.*)/", file_get_contents(JPATH_SITE.DS.'language'.DS.'sv-SE'.DS.'sv-SE'.'.com_mycomponent.ini'), $matches);
$language = 'sv-SE';
}
else{
preg_match_all("/(".JRequest::getVar('old_big_lang', '', 'post','string').")=(.*)/", file_get_contents(JPATH_SITE.DS.'language'.DS.JRequest::getVar('language', '', 'post','string').DS.JRequest::getVar('language', '', 'post','string').'.com_mycomponent.ini'), $matches);
$language = JRequest::getVar('language', '', 'post', 'string');
}
$white_removed = str_replace(array('\r\n', '\r', '\n', '\t'), ' ', JRequest::getVar('text_langfile', '', 'post', 'string', JREQUEST_ALLOWRAW));
replaceLineInTextFile(JPATH_SITE.DS.'language'.DS.$language.DS.$language.'.com_mycomponent.ini', JRequest::getVar('old_big_lang', 0, 'post','string').'='.$matches[2][0], JRequest::getVar('old_big_lang', 0, 'post','string').'='.$white_removed); // testing...
$this->setRedirect('index.php?option=' . $option .'&view=help&del=edit&tmpl=component&old_big_lang='.JRequest::getVar('old_big_lang', 0, '','string').'&language='.JRequest::getVar('language', 0, 'post','string').'&help_view='.JRequest::getVar('help_view', 0, 'post','string'), 'String replaced...');
break;
}
}