<?php
//+-----------------------------------------------------+//
//+ Copyright Floopo.com
//+ languagebuilder.php
//+ Creates the output for language file
//+-----------------------------------------------------+//

defined('BASEPATH') or die('You can not directly access this file');//check its within this framework

//_________load all the vars from database_____________________

$builder =  $dbase->SelectRecordLoop("SELECT *
                                    FROM lang_mine
								    WHERE my_lang = 1");						  

//_________Some additional stuff________________________________

$comment         = '//My Language File - Generated on: '.date('d-m-Y, g:i a');
$php_opening     = '<?php defined(\'BASEPATH\') or die(\'You can not directly access this file\');';
$php_closing     = '?>';

$lang_count = count($builder);


//_________start creating the list of vars_______________________
for($count =0; $count< $lang_count; $count++){

//Try and pick out the array keys and values ... a bit messy
$key = current($builder[$count]);
next($builder[$count]);
next($builder[$count]);
$value = current($builder[$count]);


//remove bad characters
$value = str_replace("'", "\'", $value);

$config_line .= '$lang[\''.$key.'\'] = \''.$value.'\';'."\n";
}

//_________final build____________________________________________

$config_line = "$php_opening\n\n$comment\n\n\n$config_line\n\n$php_closing";

?>