Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function formModifications_translate_bulk(){
- $arrayForSendTranslation = array();
- $arrayForSendTranslation = formModCredentialProvider();
- $finalFunctionUserName = $arrayForSendTranslation[0];
- $finalFunctionPassword = $arrayForSendTranslation[1];
- drupal_add_js(drupal_get_path('module', 'formModifications') .'/js/script.js');
- // Get the nodes.
- $chosenContents = "Contents Chosen :";
- $nodes_ser = trim($_GET['nodes']);
- $nodes = explode("-",$nodes_ser);
- $form = array();
- $tarLangId = "Langs:";
- foreach( $nodes as $key => $value){
- $node = node_load($value);
- $chosenContents .= $node->title." , ";
- }
- $finalString = rtrim($chosenContents, ' , ');
- $form['content_information'] = array(
- '#value' => variable_get('content_form_information', $finalString),
- );
- $LoginClient = new SoapClient("https://freeway.demo.lionbridge.com/vojo/FreewayAuth.asmx?wsdl", array("trace"=>1));
- $ServicesLink = new SoapClient("https://freeway.demo.lionbridge.com/vojo/Service.asmx?wsdl", array("trace"=>1));
- try{
- $arrResponse = $LoginClient->Logon(array ('Username'=>$finalFunctionUserName,'Password'=>$finalFunctionPassword));
- /*
- $filename = "./translate/tempFile.txt";
- if(file_exists($filename)){
- unlink($filename);
- }
- else{
- $Handle = fopen($filename , 'w');
- $Data = $finalFunctionUserName.'-#';
- fwrite($Handle, $Data);
- $Data = $finalFunctionPassword;
- fwrite($Handle, $Data);
- fclose($Handle);
- }
- */
- $ticket = ($arrResponse->LogonResult);
- $getSrcLang = $ServicesLink->GetSourceLanguages(array('Ticket'=>$ticket));
- $getDraftProjectIds = $ServicesLink->GetProjectSummariesList(array('Ticket'=>$ticket,'NumberOfProjects'=>100,'SortOrder'=>MostRecent,'ProjectStatusCode'=>'Draft'));
- $array = array();
- $arrayT = array();
- $forTarLang = array();
- $listOfProjects = array();
- $hopeArray = array();
- foreach($getSrcLang->GetSourceLanguagesResult->Languages->Language as $language)
- {
- $array[$language->ID] = $language->Description."_".$language->ID;
- $forTarLang[] = $language->ID;
- }
- foreach($getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary as $projectSummary)
- {
- $listOfProjects[$projectSummary->ID] = $projectSummary-> ID;
- }
- }
- catch (SoapFault $exception){
- drupal_get_messages();
- drupal_set_message("The following exception took place.".$exception."Kindly check Freeway mapping");
- drupal_goto("user");
- }
- try{
- if (count($forTarLang)!=0){
- $getTarLang = $ServicesLink->GetTargetLanguages(array('Ticket'=>$ticket,'SourceLanguageID'=>$forTarLang[0]));
- foreach($getTarLang->GetTargetLanguagesResult->Languages->Language as $languageT)
- {
- //$arrayT[$languageT->ID] = $languageT->Description;
- $arrayT[$languageT->ID] = $languageT->Description."_".$languageT->ID;
- }
- }
- }
- catch (Exception $exception1){
- drupal_get_messages();
- drupal_set_message("The following exception took place.".$exception1);
- drupal_goto("user");
- }
- $form['folks_list']=array(
- '#type'=>'select',
- '#title' => t('Freeway Source Languages'),
- '#options' => $array,
- '#default_value' => ('English (Canada)_en-ca'),
- '#attributes'=> array('onselect' => "populateTargetlangs();"),
- '#weight'=>7,
- );
- // listbox for target language.
- $form['targetLang_list']=array(
- '#type'=>'select',
- '#title' => t('Freeway Target Languages'),
- '#options' => $arrayT,
- '#multiple' => true,
- '#default_value' => $arrayT,
- '#attributes'=>array('size'=>4, 'class' => 'select_folks_list'),
- '#weight'=>8,
- );
- $form['projectId'] = array(
- '#type' => 'select',
- '#title' => t('List of Draft projects created by you.'),
- '#weight'=>9,
- '#options' => $listOfProjects,
- );
- $form['translate_node'] = array(
- '#type' => 'submit',
- '#value' => 'Send To Freeway',
- '#weight'=>10,
- );
- return $form;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement