Login   Register  
PHP Classes
elePHPant
Icontem

File: example_SQL.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alan H. Lake  >  I18N class  >  example_SQL.php  >  Download  
File: example_SQL.php
Role: Example script
Content type: text/plain
Description: Example with usage of SQL data
Class: I18N class
Get translation texts from different containers
Author: By
Last change: Change reference to ".inc" files to ".inc.php" for greater security.
Date: 9 years ago
Size: 1,854 bytes
 

Contents

Class file image Download
<?php
$LocaleMechanism 
'SQL';
$nativeLocale 'en_US';

include 
'cnx_i18n.inc.php';
include_once 
'rfc1766.class.php';
$oRfc1766 = new rfc1766_class;
$_SESSION['oRfc1766'] = $oRfc1766;
include_once 
'i18n.class.php';
$oI18N = new I18N_class;
include_once 
'langTable.class.php';


// The following parameters must be provided to the class: 
// host name, user, password, database name and table name.
// Modify the file cnx_i18n.inc.php.
$oLang = new LangTable_class($host,$user,$password,$db,$table);
$_SESSION['oLang'] = $oLang;

$oLang->OpenDb();
if(!
$oLang->TableExists())
  
$oLang->CreateTable();

if(isset(
$_POST['locale'])){
  
setcookie('ex_SQL-locale',$_POST['locale'],time()+2592000); // This expiration time is 30 days.
  
$locale $_POST['locale'];
}elseif (isset(
$_COOKIE['ex_SQL-locale']))
  
$locale $_COOKIE['ex_SQL-locale'];
else
  
$locale $nativeLocale;

eval (
$oI18N->XL('ExampleSQL''$example'$locale));
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title><?=$example?></title>
</head>

<body>
<?
  
eval ($oI18N->XL('SelectLang''$selectLang'$locale));
  eval (
$oI18N->XL('Submit''$submitCap'$locale));
?>
  <h2><?=$example?></h2>
  <form name="example" method="post" enctype="multipart/form-data" action="example_SQL.php">
<?  $language $oI18N->GetLocales(); ?>
    <?=$selectLang?>
    <select name="locale" tabindex="1">
<?
      
foreach($language as $code => $name){
        if(
$code == $locale)
          print 
"<option selected=\"true\" value=\"$code\">$name</option>";
        else  
          print 
"<option value=\"$code\">$name</option>";
      } 
?>
    </select><br />
    <input name="submit" type="submit" value="<?=$submitCap?>" tabindex="2" />
  </form>
</body>
</html>