Xataface 2.0
Xataface Application Framework
Dataface/TranslationTool.php
Go to the documentation of this file.
00001 <?php
00002 define('TRANSLATION_STATUS_UNTRANSLATED',8);
00003 define('TRANSLATION_STATUS_UNKNOWN',0);
00004 define('TRANSLATION_STATUS_SOURCE',1);
00005 define('TRANSLATION_STATUS_MACHINE',2);
00006 define('TRANSLATION_STATUS_UNVERIFIED', 3);
00007 define('TRANSLATION_STATUS_APPROVED',4);
00008 define('TRANSLATION_STATUS_NEEDS_UPDATE',5);
00009 define('TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE',6);
00010 define('TRANSLATION_STATUS_NEEDS_UPDATE_UNVERIFIED',7);
00011 define('TRANSLATION_STATUS_EXTERNAL', 9);
00012 class Dataface_TranslationTool {
00013         
00017         var $schema = array(
00018                 'id'=>array('Field'=>'id','Type'=>'int(11)','Key'=>'PRI','Null'=>'NOT NULL','Extra'=>'auto_increment'),
00019                 'record_id'=>array('Field'=>'record_id','Type'=>'varchar(126)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
00020                 'language'=>array('Field'=>'language','Type'=>'varchar(2)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
00021                 'table'=>array('Field'=>'table','Type'=>'varchar(128)','Key'=>'record_key', 'Null'=>'NOT NULL','Extra'=>''),
00022                 'version'=>array('Field'=>'version','Type'=>'int(11)','Key'=>'','Null'=>'NOT NULL','Default'=>1,'Extra'=>''),
00023                 'translation_status'=>array('Field'=>'translation_status','Type'=>'int(11)','Key'=>'','Null'=>'NOT NULL','Default'=>0,'Extra'=>''),
00024                 'last_modified'=>array('Field'=>'last_modified','Type'=>'datetime','Key'=>'','Null'=>'','Default'=>'0000-00-00','Extra'=>'')
00025                 );
00026                 
00027         var $submission_schema = array(
00028                 'id'=>array('Field'=>'id','Type'=>'int(11)','Key'=>'PRI','Null'=>'NOT NULL','Extra'=>'auto_increment'),
00029                 'record_id'=>array('Field'=>'record_id','Type'=>'varchar(126)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
00030                 'language'=>array('Field'=>'language','Type'=>'varchar(2)','Key'=>'record_key','Null'=>'NOT NULL','Extra'=>''),
00031                 'url'=>array('Field'=>'url','Type'=>'text','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
00032                 'original_text'=>array('Field'=>'original_text','Type'=>'text','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
00033                 'translated_text'=>array('Field'=>'translated_text','Type'=>'text','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
00034                 'translated_by'=>array('Field'=>'translated_by','Type'=>'varchar(128)','Key'=>'','Null'=>'NOT NULL','Default'=>'','Extra'=>''),
00035                 'date_submitted'=>array('Field'=>'last_modified','Type'=>'timestamp','Key'=>'','Null'=>'','Default'=>'','Extra'=>'')
00036                 );
00037                 
00042         var $translation_status_codes = array(
00043                 TRANSLATION_STATUS_UNTRANSLATED => 'Untranslated',
00044                 TRANSLATION_STATUS_UNKNOWN => 'Unknown translation status',
00045                 TRANSLATION_STATUS_SOURCE => 'Source translation',
00046                 TRANSLATION_STATUS_MACHINE => 'Machine translation',
00047                 TRANSLATION_STATUS_UNVERIFIED => 'Unverified translation',
00048                 TRANSLATION_STATUS_APPROVED => 'Approved translation',
00049                 TRANSLATION_STATUS_NEEDS_UPDATE => 'Out-of-date',
00050                 TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE =>'Out-of-date (Machine translation)',
00051                 TRANSLATION_STATUS_NEEDS_UPDATE_UNVERIFIED =>'Out-of-date (Unverified)',
00052                 TRANSLATION_STATUS_EXTERNAL => 'Managed Externally'
00053                 );
00054                 
00055         function Dataface_TranslationTool() {
00056         
00057         }
00058         
00069         function getHTMLStatusSelector(&$record, $language, $name, $onchange=''){
00070                 $trec =& $this->getTranslationRecord($record, $language);
00071                 if ( !$trec ){
00072                         //  no translation currently exists, so we will set the default 
00073                         // value to -1, the flag for no translation yet.
00074                         $default = -1;
00075                 } else {
00076                         $default = $trec->val('translation_status');
00077                 }
00078                 $out = array();
00079                 $out[] = <<<END
00080                         <select name="$name" onchange='$onchange'>
00081 END;
00082                 if ( $default == -1 ){
00083                         $out[] = <<<END
00084                         <option value="-1" selected>No translation provided</option>
00085 END;
00086                 }
00087                 foreach ( $this->translation_status_codes as $key=>$val){
00088                         if ( $default == $key ) $selected = "selected";
00089                         else $selected = '';
00090                         $out[] = <<<END
00091                                 <option value="$key" $selected>$val</option>
00092 END;
00093                 }
00094                 $out[] = "</select>";
00095                 return implode("\n", $out);
00096         }       
00097         
00101         function createTranslationsTable(){
00102                 $app =& Dataface_Application::getInstance();
00103                 $sql = "create table if not exists `dataface__translations` (";
00104                 $cols = array();
00105                 $primary_key_cols = array();
00106                 $other_keys = array();
00107                 foreach ($this->schema as $field){
00108                         $default = (isset($field['Default']) ? "DEFAULT '{$field['Default']}'" : '');
00109                         $cols[] = "`{$field['Field']}` {$field['Type']} {$field['Extra']} {$field['Null']} {$default}";
00110                         if ( strcasecmp($field['Key'],'PRI') === 0 ){
00111                                 $primary_key_cols[$field['Field']] = $field;
00112                         } else if ( $field['Key'] ){
00113                                 $other_keys[$field['Key']][$field['Field']] = $field;
00114                         }
00115                 }
00116                 
00117                 $sql .= implode(',',$cols).", PRIMARY KEY (`".implode('`,`',array_keys($primary_key_cols))."`)";
00118                 if ( count($other_keys) > 0 ){
00119                         $sql .=', ';
00120                         foreach ($other_keys as $key_name=>$key){
00121                                 $sql .= "KEY `$key_name` (`".implode('`,`',array_keys($key))."`)";
00122                         }
00123                 }
00124                 $sql .= ")";
00125                 
00126                 $res = mysql_query($sql, $app->db());
00127                 if ( !$res ) {throw new Exception(mysql_error($app->db()), E_USER_ERROR);}
00128                 return true;
00129                 
00130         }
00131         function updateTranslationsTable(){
00132                 $app =& Dataface_Application::getInstance();
00133                 if ( !Dataface_Table::tableExists('dataface__translations',false) ){
00134                         $this->createTranslationsTable();
00135                 }
00136                 
00137                 $res = mysql_query("show columns from `dataface__translations`", $app->db());
00138                 if ( !$res ) throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00139                 $cols = array();
00140                 while ( $row = mysql_fetch_assoc($res) ){
00141                         $cols[$row['Field']] = $row;
00142                 }
00143                 foreach ($this->schema as $field ){
00144                         if (!isset($cols[$field['Field']]) ){
00145                                 $default = (isset($field['Default']) ? "DEFAULT '{$field['Default']}'" : '');
00146                                 $sql = "alter table `dataface__translations` add column `{$field['Field']}` {$field['Type']} {$field['Null']} {$default}";
00147                                 $res = mysql_query($sql, $app->db());
00148                                 if (!$res ) throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00149                         }
00150                 }
00151                 
00152                 return true;
00153                 
00154         }
00155         
00159         function createTranslationSubmissionsTable(){
00160                 $app =& Dataface_Application::getInstance();
00161                 $sql = "create table if not exists `dataface__translation_submissions` (";
00162                 $cols = array();
00163                 $primary_key_cols = array();
00164                 $other_keys = array();
00165                 foreach ($this->submission_schema as $field){
00166                         $default = (isset($field['Default']) ? "DEFAULT '{$field['Default']}'" : '');
00167                         $cols[] = "`{$field['Field']}` {$field['Type']} {$field['Extra']} {$field['Null']} {$default}";
00168                         if ( strcasecmp($field['Key'],'PRI') === 0 ){
00169                                 $primary_key_cols[$field['Field']] = $field;
00170                         } else if ( $field['Key'] ){
00171                                 $other_keys[$field['Key']][$field['Field']] = $field;
00172                         }
00173                 }
00174                 
00175                 $sql .= implode(',',$cols).", PRIMARY KEY (`".implode('`,`',array_keys($primary_key_cols))."`)";
00176                 if ( count($other_keys) > 0 ){
00177                         $sql .=', ';
00178                         foreach ($other_keys as $key_name=>$key){
00179                                 $sql .= "KEY `$key_name` (`".implode('`,`',array_keys($key))."`)";
00180                         }
00181                 }
00182                 $sql .= ")";
00183                 
00184                 $res = mysql_query($sql, $app->db());
00185                 if ( !$res ) {echo $sql;throw new Exception(mysql_error($app->db()), E_USER_ERROR);}
00186                 return true;
00187                 
00188         }
00189         function updateTranslationSubmissionsTable(){
00190                 $app =& Dataface_Application::getInstance();
00191                 if ( !Dataface_Table::tableExists('dataface__translation_submissions',false) ){
00192                         $this->createTranslationSubmissionsTable();
00193                 }
00194                 
00195                 $res = mysql_query("show columns from `dataface__translation_submissions`", $app->db());
00196                 if ( !$res ) throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00197                 $cols = array();
00198                 while ( $row = mysql_fetch_assoc($res) ){
00199                         $cols[$row['Field']] = $row;
00200                 }
00201                 foreach ($this->submission_schema as $field ){
00202                         if (!isset($cols[$field['Field']]) ){
00203                                 $default = (isset($field['Default']) ? "DEFAULT '{$field['Default']}'" : '');
00204                                 $sql = "alter table `dataface__translation_submissions` add column `{$field['Field']}` {$field['Type']} {$field['Null']} {$default}";
00205                                 $res = mysql_query($sql, $app->db());
00206                                 if (!$res ) throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00207                         }
00208                 }
00209                 
00210                 return true;
00211                 
00212         }
00213         
00214         function submitTranslation(&$record, $params=array()){
00215                 if ( !Dataface_Table::tableExists('dataface__translation_submissions',false) ){
00216                         $this->createTranslationSubmissionsTable();
00217                 }
00218                 $trec = new Dataface_Record('dataface__translation_submissions', array());
00219                 $trec->setValues($params);
00220                 $trec->save();
00221         }
00226         function getRecordId(&$record){
00227                 if (!$record ){
00228                         throw new Exception("No record provided");
00229                 }
00230                 $vals = $record->strvals(array_keys($record->_table->keys()));
00231                 $parts = array();
00232                 foreach ($vals as $key=>$val){
00233                         $parts[] = urlencode($key).'='.urlencode($val);
00234                 }
00235                 return implode('&',$parts);
00236                 
00237         }
00238         
00239         function translateRecord(&$record, $sourceLanguage, $destLanguage){}
00240         function translateRecords(&$records, $sourceLanguage, $destLanguage){}
00241         
00242         function getTranslationId(&$record, $language){
00243                 $app =& Dataface_Application::getInstance();
00244                 $sql = "select `id` from `dataface__translations` where `record_id`='".addslashes($this->getRecordId($record))."' and `table`='".addslashes($record->_table->tablename)."' and `language`='".addslashes($language)."' limit 1";
00245                 $res = mysql_query($sql, $app->db());
00246                 if ( !$res ){
00247                         $this->updateTranslationsTable();
00248                         $res = mysql_query($sql, $app->db());
00249                         if ( !$res ){
00250                                 throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00251                         }
00252                 }
00253                 if ( mysql_num_rows($res) === 0 ){
00254                         @mysql_free_result($res);
00255                         $sql = "insert into `dataface__translations` (`record_id`,`language`,`table`,`last_modified`) VALUES (
00256                                         '".addslashes($this->getRecordId($record))."',
00257                                         '".addslashes($language)."',
00258                                         '".addslashes($record->_table->tablename)."',
00259                                         NOW()
00260                                         )";
00261                         $res = mysql_query($sql, $app->db());
00262                         if ( !$res ) {
00263                                 $this->updateTranslationsTable();
00264                                 $res = mysql_query($sql, $app->db());
00265                                 if ( !$res ){
00266                                         throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00267                                 }
00268                         }
00269                         $id = mysql_insert_id($app->db());
00270                 } else {
00271                         list($id) = mysql_fetch_row($res);
00272                         @mysql_free_result($res);
00273                 }
00274                 
00275                 return $id;
00276         }
00277         
00286         function getTranslationRecord(&$record, $language){
00287                 $app =& Dataface_Application::getInstance();
00288                 $id = $this->getTranslationId($record, $language);
00289                 $trecord =& df_get_record('dataface__translations', array('id'=>$id));
00290                 if ( !isset($trecord) ) {
00291                         $this->updateTranslationsTable();
00292                         $trecord =& df_get_record('dataface__translations', array('id'=>$id));
00293                         if ( !isset($trecord) ) throw new Exception("Error loading translation record for translation id '$id'", E_USER_ERROR);
00294                 }
00295                 return $trecord;
00296         }
00297         
00305         function getCanonicalVersion(&$record, $language){
00306                 $app =& Dataface_Application::getInstance();
00307                 $trecord =& $this->getTranslationRecord($record, $language);
00308                 if ( PEAR::isError($trecord) ) return $trecord;
00309                 return $trecord->val('version');
00310         }
00311         
00318         function markNewCanonicalVersion(&$record, $language=null){
00319                 $app =& Dataface_Application::getInstance();
00320                 $trecord =& $this->getTranslationRecord($record, $language);
00321                 $trecord->setValue('version', $trecord->val('version')+1);
00322                 $trecord->setValue('translation_status', TRANSLATION_STATUS_SOURCE);
00323                 $res = $trecord->save();
00324                 if ( PEAR::isError($res) ){
00325                         return $res;
00326                 }
00327                 
00328                 $this->invalidateTranslations($record);
00329                 return $this->getCanonicalVersion($record, $language);
00330                 
00331         }
00332         
00343         function invalidateTranslations(&$record){
00344         
00345                 $records = df_get_records('dataface__translations',array('record_id'=>'='.$this->getRecordId($record),'table'=>$record->_table->tablename));
00346                 if ( PEAR::isError($records) ){
00347                         throw new Exception($records->toString(), E_USER_ERROR);
00348                 }
00349                 while ($records->hasNext()){
00350                         $trecord =& $records->next();
00351                         $update=true;
00352                         switch($trecord->val('translation_status')){
00353                                 case TRANSLATION_STATUS_MACHINE:
00354                                         $trecord->setValue('translation_status', TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE);
00355                                         break;
00356                                 case TRANSLATION_STATUS_UNVERIFIED:
00357                                         $trecord->setValue('translation_status', TRANSLATION_STATUS_NEEDS_UPDATE_UNVERIFIED);
00358                                         break;
00359                                 case TRANSLATION_STATUS_APPROVED:
00360                                         $trecord->setValue('translation_status', TRANSLATION_STATUS_NEEDS_UPDATE);
00361                                         break;
00362                                 default:
00363                                         $update = false;
00364                                                 //  no update necessary
00365                                 
00366                         }
00367                         
00368                         if ( $update ){
00369                                 $res = $trecord->save();
00370                                 if ( PEAR::isError($res) ) return $res;
00371                         }
00372                         unset($trecord);
00373                 }
00374                 
00375                 return true;
00376         }
00377         
00378         function setTranslationStatus(&$record, $language, $status){
00379                 $trecord =& $this->getTranslationRecord($record, $language);
00380                 $trecord->setValue('translation_status', $status);
00381                 if ( $status == TRANSLATION_STATUS_APPROVED || $status == TRANSLATION_STATUS_MACHINE){
00382                         $app =& Dataface_Application::getInstance();
00383                         $def_record =& $this->getTranslationRecord($record, $app->_conf['default_language']);
00384                         if ( $def_record ){
00385                                 $trecord->setValue('version', $def_record->val('version'));
00386                         }
00387                 }
00388                 $trecord->save();
00389         }
00390         
00401         function untranslate(&$record, $language, $fieldname=null){
00402                 $trecord =& $this->getTranslationRecord($record, $language);
00403                 $app =& Dataface_Application::getInstance();
00404                 switch ($trecord->val('translation_status')){
00405                         case TRANSLATION_STATUS_MACHINE:
00406                         case TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE:
00407                                 
00408                                 $keyvals = $record->strvals(array_keys($record->_table->keys()));
00409                                 $clauses = array();
00410                                 foreach ($keyvals as $key=>$val){
00411                                         $clauses[] = "`{$key}`='".addslashes($val)."'";
00412                                 }
00413                                 if ( count($clauses) === 0 ) throw new Exception("Error trying to untranslate record: '".$record->getTitle()."'.  The table '".$record->_table->tablename."' does not appear to have a primary key.");
00414                                 if ( isset($fieldname) ){
00415                                         $sql = "update `{$record->_table->tablename}_{$language}` set `{$fieldname}`=NULL where ".implode(' and ', $clauses)." limit 1";
00416                                 } else {
00417                                         $sql = "delete from `{$record->_table->tablename}_{$language}` where ".implode(' and ', $clauses)." limit 1";
00418                                 }
00419                                 $res = mysql_query($sql, $app->db());
00420                                 if ( !$res ) throw new Exception(mysql_error($app->db()), E_USER_ERROR);
00421                                 return true;
00422                 }
00423                 return false;
00424         }
00425         
00426         
00427         
00439         function getChanges(&$record,$version, $lang=null,$fieldname=null){
00440                 $app =& Dataface_Application::getInstance();
00441                 if ( !isset($lang) ) $lang = $app->_conf['lang'];
00442                 list($major_version,$minor_version) = explode('.', $version);
00443                 $trecord = $this->getTranslationRecord($record, $lang);
00444                 
00445                 import('Dataface/HistoryTool.php');
00446                 $ht = new Dataface_HistoryTool();
00447                 
00448                 $hrecord = $ht->searchArchives($trecord, array('major_version'=>$major_version, 'minor_version'=>$minor_version), $lang);
00449                 $modified = $hrecord->strval('history__modified');
00450                 return $ht->getDiffsByDate($record, $modified, null, $lang, $fieldname);
00451         
00452         }
00453         
00454         
00464         function migrateDefaultLanguage($newDefault, $tables=null){
00465                 
00466                 import('Dataface/Utilities.php');
00467                 import('Dataface/IO.php');
00468                 $app =& Dataface_Application::getInstance();
00469                 $no_fallback = @$app->_conf['default_language_no_fallback'];
00470                         // Whether or not the application is currently set to disable fallback
00471                         // to default language.
00472                         
00473                 $tables = $this->getMigratableTables();
00474                 
00475                 $log = array();
00476                 
00477                 foreach ($tables as $tablename){
00478                         
00479                         
00480                         $table =& Dataface_Table::loadTable($tablename);
00481                         $t_tablename = $tablename.'_'.$app->_conf['default_language'];
00482                         
00483                         if ( !$table || PEAR::isError($table) ) continue;
00484                         $res = mysql_query("create table `{$tablename}_bu_".time()."` select * from `{$tablename}`", $app->db());
00485                         $sql = "select `".join('`,`', array_keys($table->keys()))."` from `".$tablename."`";
00486                         $res2 = mysql_query($sql, $app->db());
00487                         $io = new Dataface_IO($tablename);
00488                         $io->lang = $newDefault;
00489                         while ( $rec = mysql_fetch_assoc($res2) ){
00490                                 //foreach (array_keys($rec) as $colkey){
00491                                 //      $rec[$colkey] = '='.$rec[$colkey];
00492                                 //}
00493                                 $app->_conf['default_language_no_fallback'] = 1;
00494                                 
00495                                 $record = df_get_record($tablename, $rec, $io);
00496                                 //print_r($record->strvals());
00497 
00498                                 $app->_conf['default_language_no_fallback'] = 0;
00499                                 
00500                                 $record2 = new Dataface_Record($tablename, array());
00501                                 $record2->setValues($record->vals());
00502 
00503                                 $r = $io->write($record2);
00504                                 if ( PEAR::isError($r) ){
00505                                         $log[$tablename] = "Failed to migrate data from table '{$t_tablename}' to '{$tablename}': ".$r->getMessage()."'";
00506                                         
00507                                 } else {
00508                                         $log[$tablename] = "Successfully migrated data from table '{$t_tablename}' to '{$tablename}'.";
00509                                 }
00510                                 unset($record);
00511                                 
00512                                 
00513                         }
00514                         mysql_free_result($res2);
00515                         
00516                         $res = mysql_query("create table `{$t_tablename}_bu_".time()."` select * from `{$t_tablename}`", $app->db());
00517                         $res = mysql_query("truncate `{$t_tablename}`", $app->db());
00518                         
00519                         unset($io);
00520                         unset($table);
00521                         
00522                         
00523                 }
00524                 return $log;
00525                 $app->_conf['default_language_no_fallback'] = $no_fallback;
00526         }
00527         
00528         
00533         function requiresMigration(){
00534                 
00535                 $migrations = $this->getMigratableTables();
00536                 if ( count($migrations) > 0 ){
00537                         return "<p>The following tables need to be migrated so that the default language is stored inside the main table - not the translation table:</p>
00538                                 <ul><li>".implode('</li><li>', $migrations)."</li></ul>
00539                                 <p>This migration is necessary because older versions of the query translation extension would automatically store translations 
00540                                 in their respective translation tables rather than the main table.  However it is desirable to store the default language
00541                                 in the default table so that other translations can fall-back to the correct default translation if the record does not
00542                                 have a translation.</p>";
00543                 }       else {
00544                         return false;
00545                 }
00546         }
00547         
00551         function getMigratableTables(){
00552                 $app =& Dataface_Application::getInstance();
00553                 if ( @$app->_conf['default_language_no_fallback'] ) return false;
00554                         // We are still using the old style of translations, so there is no migration required.
00555                         
00556                 $migrations = array();
00557                 $res = mysql_query("show tables", $app->db());
00558                 $tables = array();
00559                 while ( $row = mysql_fetch_row($res) ){
00560                         $tables[] = $row[0];
00561                 }
00562                 mysql_free_result($res);
00563                 foreach ($tables as $tablename){
00564                         $translation_tablename = $tablename."_".$app->_conf['default_language'];
00565                         if ( mysql_num_rows($res = mysql_query("show tables like '".addslashes($translation_tablename)."'", $app->db())) > 0){
00566                                 @mysql_free_result($res);
00567                                 list($num) = mysql_fetch_row($res = mysql_query("select count(*) from `".$translation_tablename."`",$app->db()));
00568                                 if ( $num > 0 ){
00569                                         $migrations[] = $tablename;
00570                                 }
00571                         } else {
00572                                 
00573                         }
00574                         mysql_free_result($res);
00575                 }
00576                 return $migrations;
00577         
00578         }
00579         
00580         function migrate(){
00581                 $app =& Dataface_Application::getInstance();
00582                 return $this->migrateDefaultLanguage($app->_conf['default_language']);
00583                 
00584         }
00585         
00586         function printTranslationStatusAlert($record, $language=null){
00587                 if ( !isset($language) ){
00588                         $app =& Dataface_Application::getInstance();
00589                         $language = $app->_conf['lang'];
00590                 }
00591                 $trec =& $this->getTranslationRecord($record, $language);
00592                 if ( !$trec) return;
00593                 $status = $trec->val('translation_status');
00594                 switch ($status){
00595                         case TRANSLATION_STATUS_MACHINE:
00596                                 $msg = df_translate('machine translation warning',"This section was translated using a machine translator and may contain errors.");
00597                                 break;
00598                         
00599                         case TRANSLATION_STATUS_NEEDS_UPDATE_MACHINE:
00600                                 $msg = df_translate('old machine translation warning', "This section was translated using a machine translator and may contain errors.  The original version has also been modified since this translation was completed so this translation may be out of date.");
00601                                 break;
00602                         
00603                         case TRANSLATION_STATUS_UNVERIVIED:
00604                                 $msg = df_translate('unverified translation warning', "This translation has not been verified by an administrator yet.");
00605                                 break;
00606                                 
00607                         case TRANSLATION_STATUS_NEEDS_UPDATE_UNVERIFIED:
00608                                 $msg = df_translate('old unverified translation warning', "This translation has not been verified by an administrator yet.  The original version has also been modified since this translation was completed so this translation may be out of date.");
00609                                 break;
00610                                 
00611                         case TRANSLATION_STATUS_NEEDS_UPDATE:
00612                                 $msg = df_translate('old translation warning', "This translation may be out of date as the original version has been modified since this was last translated.");
00613                                 break;
00614                                 
00615                 }
00616                 if ( !@$msg ) return;
00617                 import('Dataface/ActionTool.php');
00618                 $at =& Dataface_ActionTool::getInstance();
00619                 $actions = $at->getActions(array('category'=>'translation_warning_actions','record_id'=>$record->getId()));
00620                 $actions_html = "<ul class=\"translation_options\">";
00621                 foreach ($actions as $action){
00622                         $actions_html .= <<<END
00623                                 <li><a href="{$action['url']}" title="{$action['description']}">{$action['label']}</a></li>
00624 END;
00625                         
00626                 }       
00627                 $actions_html .= '</ul>';
00628                 echo <<<END
00629                 
00630                 <div class="portalMessage">
00631                         {$msg}
00632                         {$actions_html}
00633                 </div>
00634 END;
00635         }
00636 
00637         
00638         
00639         
00640         
00641         /*
00642          What do we need to do?
00643          
00644          1. Set Translation status
00645          2. Update translation version.
00646          3. Untranslate (machine translations only).
00647          4. View changes
00648          5. 
00649          */
00650         
00651         
00652 }
 All Data Structures Namespaces Files Functions Variables Enumerations