6 import(
'Dataface/TranslationForm.php');
9 $query =&
$app->getQuery();
10 $resultSet =&
$app->getResultSet();
12 $source = ( isset($_REQUEST[
'-sourceLanguage']) ? $_REQUEST[
'-sourceLanguage'] :
$app->_conf[
'default_language']);
13 $dest = ( isset($_REQUEST[
'-destinationLanguage']) ? $_REQUEST[
'-destinationLanguage'] : null);
16 if ( $resultSet->found()>0){
23 $res = $form->_build();
25 throw new Exception($res->toString().Dataface_Error::printStackTrace(), E_USER_ERROR);
35 foreach ( $query as $key=>$value){
36 if ( strpos($key,
'-')===0 ){
37 $form->addElement(
'hidden', $key);
38 $form->setDefaults( array( $key=>$value) );
47 $form->addElement(
'hidden',
'-query');
48 $form->setDefaults( array(
'-action'=>$query[
'-action'],
'-query'=>
$_SERVER[
'QUERY_STRING']) );
62 if ( $form->validate() ){
68 $app->clearMessages();
69 $result = $form->process( array( &$form,
'save') );
75 throw new Exception(
"Error occurred in save. See error log for details.");
85 throw new Exception(
$result->toString(), E_USER_ERROR);
103 $vals = $form->exportValues();
104 $vals[
'-query'] = preg_replace(
'/[&\?]-new=[^&]+/i',
'', $vals[
'-query']);
106 $msg = implode(
"\n",
$app->getMessages());
111 'Record successfully translated',
113 "Record successfully translated.<br>"
116 $link =
$_SERVER[
'HOST_URI'].DATAFACE_SITE_HREF.
'?'.$vals[
'-query'].
'&--msg='.$msg;
124 $app->redirect($link);
131 $out = ob_get_contents();
135 $context = array(
'form'=>
$out,
'formObj'=>$form);
140 $context = array(
'form'=>
'',
'formObj'=>$form);
143 'No records matched request',
144 'No records matched your request'
150 if ( isset($query[
'-template']) ) $template = $query[
'-template'];
151 else if ( isset( $params[
'action'][
'template']) ) $template = $params[
'action'][
'template'];
152 else $template =
'Dataface_Translate_Record.html';
153 df_display($context, $template,
true);