« Back to the index
\datasources\DataSource example
";
echo "DomCore version ".\core\WADebug::VERSION."
";
echo "HTML API ? ".(\core\WADebug::getHTMLAPI()?'Yes':'No')."
";
echo "OS Type ? ".(\core\WADebug::getOSType()==\core\WADebug::WINDOWS?'Windows':(\core\WADebug::getOSType()==\core\WADebug::UNIX?'Unix':'Mac'))."
";
echo "
";
// Start the SHM with 20Mb default size and default ID
$SHM = new \core\WASHM();
// Lets create a LanguageSource based on the french messages
$Lang = new \datasources\LanguageSource(new \datasources\FileSource('./', '', 'message.es.xml'),
new \datasources\FastObjectSource(new \datasources\FileSource('./', '', 'temporal.afo'),
new \datasources\SHMSource('spanish', $SHM)
)
);
echo 'Show the full language table:
';
$data = $Lang->read();
foreach($data as $id => $val)
{
echo "
$id: $val
";
}
echo '
';
echo 'Take the entry: WAFile.mkdirproblem
';
echo $data->getEntry('WAFile.mkdirproblem') . "
";
echo '
';
echo 'Write a new entry: datasource.test (The original file, afo AND shared memory are synchronized)
';
$data->setEntry('datasource.test', 'Prueba de una nueva entrada de la tabla de idiomas') . "
";
$Lang->write($data);
echo '
';
echo 'Show the entry: datasource.test
';
echo $data->getEntry('datasource.test') . "
";
echo '
';
echo 'Deletes the entry: datasource.test
';
$data->delEntry('datasource.test') . "
";
$Lang->write($data);
echo '
';
echo 'Show the full language table again, It is supposed to be the same as the first one:
';
foreach($data as $id => $val)
{
echo "
$id: $val
";
}
echo '
';
?>
« Back to the index