Advertisement
DrupalCustom

formmod

Feb 1st, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.44 KB | None | 0 0
  1. function formModifications_translate_bulk(){
  2. $arrayForSendTranslation = array();
  3. $arrayForSendTranslation = formModCredentialProvider();
  4.  
  5.  
  6. $finalFunctionUserName = $arrayForSendTranslation[0];
  7. $finalFunctionPassword = $arrayForSendTranslation[1];
  8.  
  9.  
  10.  
  11.  
  12.  drupal_add_js(drupal_get_path('module', 'formModifications') .'/js/script.js');
  13.       // Get the nodes.
  14.       $chosenContents = "Contents Chosen :";
  15.       $nodes_ser = trim($_GET['nodes']);
  16.       $nodes = explode("-",$nodes_ser);
  17.       $form = array();
  18.       $tarLangId = "Langs:";
  19.        
  20.          
  21.      foreach( $nodes as $key => $value){
  22.             $node = node_load($value); 
  23.             $chosenContents .= $node->title." , ";
  24.             }
  25.  
  26.          $finalString = rtrim($chosenContents, ' , ');
  27.            
  28.     $form['content_information'] = array(
  29.         '#value' => variable_get('content_form_information', $finalString),
  30.         );
  31.  
  32.        
  33.             $LoginClient = new SoapClient("https://freeway.demo.lionbridge.com/vojo/FreewayAuth.asmx?wsdl", array("trace"=>1));
  34.             $ServicesLink = new SoapClient("https://freeway.demo.lionbridge.com/vojo/Service.asmx?wsdl", array("trace"=>1));
  35.  
  36.  
  37.               try{
  38.              
  39.               $arrResponse = $LoginClient->Logon(array ('Username'=>$finalFunctionUserName,'Password'=>$finalFunctionPassword));
  40.            
  41. /*         
  42.               $filename = "./translate/tempFile.txt";
  43.               if(file_exists($filename)){
  44.               unlink($filename);
  45.               }
  46.             else{              
  47.                    $Handle = fopen($filename , 'w');
  48.                     $Data = $finalFunctionUserName.'-#';
  49.                     fwrite($Handle, $Data);
  50.                     $Data = $finalFunctionPassword;
  51.                     fwrite($Handle, $Data);
  52.                      fclose($Handle);
  53.                 }            
  54. */       
  55.              
  56.               $ticket = ($arrResponse->LogonResult);
  57.               $getSrcLang = $ServicesLink->GetSourceLanguages(array('Ticket'=>$ticket));
  58.               $getDraftProjectIds = $ServicesLink->GetProjectSummariesList(array('Ticket'=>$ticket,'NumberOfProjects'=>100,'SortOrder'=>MostRecent,'ProjectStatusCode'=>'Draft'));
  59.                      
  60.                             $array = array();
  61.                             $arrayT = array();
  62.                             $forTarLang = array();
  63.                             $listOfProjects = array();
  64.                             $hopeArray = array();
  65.                            
  66.                             foreach($getSrcLang->GetSourceLanguagesResult->Languages->Language as $language)               
  67.                             {                                      
  68.                               $array[$language->ID] = $language->Description."_".$language->ID;                                
  69.                                 $forTarLang[] = $language->ID;
  70.                             }
  71.  
  72.                    
  73.                             foreach($getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary as $projectSummary)
  74.                             {
  75.                               $listOfProjects[$projectSummary->ID] = $projectSummary-> ID;
  76.                             }
  77.                                            
  78.                                                    
  79.                                                  
  80.               }
  81.                   catch (SoapFault $exception){
  82.             drupal_get_messages();
  83.             drupal_set_message("The following exception took place.".$exception."Kindly check Freeway mapping");
  84.             drupal_goto("user");
  85.                  
  86.            
  87.                   }
  88.  
  89.                           try{
  90.                          
  91.                           if (count($forTarLang)!=0){
  92.                                 $getTarLang = $ServicesLink->GetTargetLanguages(array('Ticket'=>$ticket,'SourceLanguageID'=>$forTarLang[0]));
  93.                                        
  94.                                 foreach($getTarLang->GetTargetLanguagesResult->Languages->Language as $languageT)  
  95.                                     {                  
  96.                                     //$arrayT[$languageT->ID] = $languageT->Description;
  97.                                     $arrayT[$languageT->ID] = $languageT->Description."_".$languageT->ID;
  98.                                     }                              
  99.                             }
  100.                          }
  101.                           catch (Exception  $exception1){
  102.             drupal_get_messages();       
  103.             drupal_set_message("The following exception took place.".$exception1);
  104.             drupal_goto("user");
  105.                          
  106.                           }
  107.  
  108.  
  109.  
  110.  
  111.         $form['folks_list']=array(
  112.                 '#type'=>'select',
  113.                 '#title' => t('Freeway Source Languages'),
  114.                 '#options' => $array,
  115.                 '#default_value' => ('English (Canada)_en-ca'),
  116.                 '#attributes'=> array('onselect' => "populateTargetlangs();"),
  117.                 '#weight'=>7,
  118.             );
  119.            
  120.            
  121.            
  122.  
  123. // listbox for target language.
  124.  
  125.            
  126.  
  127.    
  128.             $form['targetLang_list']=array(
  129.                 '#type'=>'select',
  130.                 '#title' => t('Freeway Target Languages'),
  131.                 '#options' => $arrayT,
  132.                 '#multiple' => true,
  133.                 '#default_value' => $arrayT,
  134.                 '#attributes'=>array('size'=>4, 'class' => 'select_folks_list'),
  135.                
  136.                 '#weight'=>8,
  137.             );
  138.        
  139.               $form['projectId'] = array(
  140.               '#type' => 'select',
  141.               '#title' => t('List of Draft projects created by you.'),
  142.                '#weight'=>9,
  143.               '#options' => $listOfProjects,
  144.             ); 
  145.                    
  146.               $form['translate_node'] = array(
  147.               '#type' => 'submit',
  148.               '#value' => 'Send To Freeway',
  149.               '#weight'=>10,
  150.               );   
  151.                    
  152.                    
  153.                        
  154.              return $form;
  155.    
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement