PHP Classes

File: class

Recommend this page to a friend!
  Classes of César Bruschi   Translation and Dictionary   class   Download  
File: class
Role: Class source
Content type: text/plain
Description: Font code and doc
Class: Translation and Dictionary
Get application texts in several idioms from MySQL
Author: By
Last change: Accessible without user login
Date: 13 years ago
Size: 2,567 bytes
 

Contents

Class file image Download
<?php

class Dictionary {

    public
$xWords = array();
    private
$xTheme = false;
    private
$xLangName = false;
   
    public function
Dictionary($xTheme, $xLangName = "ENG"){

       
$this->xTheme = $xTheme;
       
$this->xLangName = $xLangName;
       
        return
$this->getDictionary($xTheme, $xLangName);
    }
       
    private function
getDictionary($xTheme, $xLangName){
       
       
$xSQL = "SELECT DID.dictio_word as Word, IF((DIE.dictio_traslat IS NOT NULL) and (DIE.dictio_traslat <>''), DIE.dictio_traslat, DID.dictio_traslat) AS Translation
                FROM "
.TABLE_PREFIX."dictio DID
                INNER JOIN "
.TABLE_PREFIX."langs IDE ON (IDE.lang_name LIKE '".$xLangName."')
                INNER JOIN "
.TABLE_PREFIX."themes TE ON (TE.themes_id = DID.dictio_theme)
                LEFT JOIN "
.TABLE_PREFIX."dictio DIE ON (DID.dictio_word = DIE.dictio_word)
                AND (DID.dictio_theme = DIE.dictio_theme)
                AND (DIE.dictio_langid = IDE.lang_id)
                WHERE DID.dictio_langid = '0001'
                AND (TE.themes_theme LIKE '"
.$xTheme."%')";
       
        if(!
$query = mysql_query($xSQL)) return mysql_error();
        if(!
mysql_num_rows($query)) return false;
        while(
$data = mysql_fetch_assoc($query)){
           
$this->xWords[$data["Word"]] = $data["Translation"];
        }
       
        return
$this->xWords;
       
    }
   
    public function
getLanguages(){
       
       
$return = array();
       
       
$xSQL = "SELECT * FROM ".TABLE_PREFIX."langs;";
        if(!
$query = mysql_query($xSQL)) return 0;
        if(!
mysql_num_rows($query)) return 0;
       
        while(
$data = mysql_fetch_assoc($query)){
           
$return[]['lang_id'] = array(
           
'lang_id' => $data["lang_id"],
           
'lang_name' => $data["lang_name"],
           
'lang_flag' => $data["lang_flag"],
            );
        }
       
        return
$return;
    }
   
    public function
getLanguagesBar(){
       
       
//El link para adjuntar a la imagen
       
$link = "";
        foreach(
$_GET as $key => $value)
        if(
$key!="lang")
           
$link.= $key ."=". $value ."&";
       
           
$link = substr($link, 0, -1);
       
//$return = "<table><tr>";
       
$return = "";
       
       
$xSQL = "SELECT * FROM ".TABLE_PREFIX."langs;";
        if(!
$query = mysql_query($xSQL)) return 0;
        if(!
mysql_num_rows($query)) return 0;
       
        while(
$data = mysql_fetch_assoc($query)){
       
           
//$return .= "<td>
           
$return .= " <a href=\"".$_SERVER['PHP_SELF']."?lang=".$data['lang_name']."&".$link."\">
            <img src=\""
.$data['lang_flag']."\" border=\"0\" width=\"20\" height=\"15\" align=\"top\">
            </a>"
;
           
//</td>";
           
       
}
       
       
//$return .= "</tr></table>";
       
       
return $return;
    }

}

?>