Xataface 2.0
Xataface Application Framework
actions/submit_translation.php
Go to the documentation of this file.
00001 <?php
00002 import('Dataface/TranslationTool.php');
00003 class dataface_actions_submit_translation {
00004 
00005         function handle(&$params){
00006                 $app =& Dataface_Application::getInstance();
00007                 $tt = new Dataface_TranslationTool();
00008                 if ( !Dataface_Table::tableExists('dataface__translation_submissions',false) ){
00009                         $tt->createTranslationSubmissionsTable();
00010                         $app->redirect($app->url(''));
00011                         
00012                 }
00013                 
00014                 if ( !@$_POST['--submit']){
00015 
00016                         df_display(array('query'=>$app->getQuery(), 'success'=>@$_REQUEST['--success']), 'Dataface_submit_translation.html');
00017                         return;
00018                 } else {
00019 
00020                         if ( @$_POST['subject'] ){
00021                                 // This is a dummy field - possible hacking attempt
00022                                 $app->redirect($app->url('-action=list'));
00023                                 
00024                         }
00025                         if ( @$_POST['--recordid'] ){
00026                                 $record = df_get_record_by_id($_POST['--recordid']);
00027                                 $values = array(
00028                                         'record_id'=>@$_POST['--recordid'],
00029                                         'language'=>@$_POST['--language'],
00030                                         'url'=>@$_POST['--url'],
00031                                         'original_text'=>@$_POST['--original_text'],
00032                                         'translated_text'=>@$_POST['--translated_text'],
00033                                         'translated_by'=>@$_POST['--translated_by']);
00034                                 $trec = new Dataface_Record('dataface__translation_submissions', array());
00035                                 $trec->setValues($values);
00036                                 $trec->save();
00037                                 
00038                                 $email = <<<END
00039  The following translation was submitted to the web site {$app->url('')}:
00040  
00041  Translation for record {$record->getTitle()} which can be viewed at {$record->getURL('-action=view')}.
00042  This translation was submitted by {$_POST['--translated_by']} after viewing the content at {$_POST['--url']}.
00043  
00044  The original text that was being translated is as follows:
00045  
00046  {$_POST['--original_text']}
00047  
00048  The translation proposed by this person is as follows:
00049  
00050  {$_POST['--translated_text']}
00051  
00052  For more details about this translation, please visit {$trec->getURL('-action=view')}.
00053 END;
00054 
00055                                 
00056                                 if ( @$app->_conf['admin_email'] ){
00057                                         mail($app->_conf['admin_email'],
00058                                                 'New translation submitted',
00059                                                 $email
00060                                         );
00061                                                 
00062                                 }
00063                                 
00064                                 if ( @$_POST['--redirect'] || @$_POST['--url']){
00065                                         $url = @$_POST['--redirect'] ? $_POST['--redirect'] : $_POST['--url'];
00066                                         $app->redirect($url.'&--msg='.urlencode('Thank you for your submission.'));
00067 
00068                                 } else {
00069                                         $app->redirect($app->url('').'&--success=1&--msg='.urlencode('Thank you for your submission.'));
00070 
00071                                 }
00072                         } else {
00073                                 throw new Exception("No record id was provided", E_USER_ERROR);
00074                         
00075                         }
00076                 }
00077                 
00078         
00079         }
00080 }
00081 
00082 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations