= function(text, fieldId, divDictionary)
{
if(text.length < 2)
{
return false;
}
var Content = new Array();
";
$functionEnd ="
var l = text[0];
if(!is_array(Content[l]))
{
return '';
}
var contentReturn = '';
f = (Content[l].length > 20) ? 20 : Content[l].length;
var divControl = 0;
for(x = 0; x < f; x++ )
{
if(Content[l][x].indexOf(text) > -1)
{
++divControl;
contentReturn+= '
'+ Content[l][x] +'
';
}
}
return contentReturn;
}
";
$connect = pg_connect("host=localhost port=5432 dbname=gnuteca3 user=postgres");
$query = pg_query($connect, "SELECT DISTINCT dictionaryid FROM gtcDictionary");
$dictionaryScriptPath = str_replace("misc/tools", "html/scripts/dictionary", str_replace("\\", "/", dirname(__FILE__)));
$row = 0;
while ($data = @pg_fetch_object($query, $row++))
{
if(!$data->dictionaryid)
{
continue;
}
$queryContent = pg_query($connect, "SELECT DISTINCT content FROM gtcdictionarycontent WHERE dictionaryid = '{$data->dictionaryid}' ORDER BY content");
$rowContent = 0;
$fileName = "{$dictionaryScriptPath}/gnutecaDictionary{$data->dictionaryid}.js";
$contentForWrite = "";
$arrayExists[$data->dictionaryid] = array();
//file_put_contents($fileName, str_replace('', $data->dictionaryid, $functionBegin));
$fr = fopen($fileName, "w");
fwrite($fr, str_replace('', $data->dictionaryid, $functionBegin));
while ($dataContent = @pg_fetch_object($queryContent, $rowContent++))
{
$dataContent->content = addslashes($dataContent->content);
if(!eregi("^[a-z0-9]{1}$", $dataContent->content[0]))
{
continue;
}
$newArray = "";
$str = "Content";
$str.="['{$dataContent->content[0]}']";
if(!in_array($str, $arrayExists[$data->dictionaryid]))
{
$arrayExists[$data->dictionaryid][] = $str;
$newArray.= "\t$str = new Array();\n\tvar {$dataContent->content[0]} = 0;\n";
}
$str.= "[{$dataContent->content[0]}++] = '$dataContent->content'";
//file_put_contents($fileName, "{$newArray}\t{$str};\n", FILE_APPEND);
fwrite($fr, "{$newArray}\t{$str};\n");
}
echo "\n\ntotal = $rowContent\n\n";
//file_put_contents($fileName, $functionEnd, FILE_APPEND);
fwrite($fr, $functionEnd);
fclose($fr);
pg_free_result ($queryContent);
}
pg_free_result ($query);
?>