Advertisement
vishnu3006

Jonathan_code

Oct 11th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.88 KB | None | 0 0
  1. <?php
  2.  
  3. function freeway_admin_settings() {
  4.   $options = node_get_types('names');
  5.  
  6.   $form['freeway_node_types'] = array(
  7.     '#type' => 'checkboxes',
  8.     '#title' => t('Contents which can be considered for Freeway'),
  9.     '#options' => $options,
  10.     '#default_value' => variable_get('freeway_node_types', array('page')),
  11.     '#description' => t('A text field will be available on these content types to make user-specific notes.'),
  12.   );
  13. return system_settings_form($form);
  14. }
  15.  
  16.  
  17. function send_for_translation() {
  18.   $node = node_load(arg(1));
  19.   $form = array();
  20.  
  21.   $form['field_wrapper'] = array(
  22.     '#type' => 'fieldset',
  23.     '#title' => 'Some fields to be wrapped',
  24.   );
  25.  
  26.  
  27.   $LoginClient = new SoapClient("wsdlpath", array("trace"=>1));
  28.      $AddFile = new SoapClient("wsdlpath", array("trace"=>1));
  29.  
  30.  
  31.  
  32.  
  33.   try{
  34.   $arrResponse = $LoginClient->Logon(array ('Username'=>'uname','Password'=>'pwrd'));
  35.   $ticket = ($arrResponse->LogonResult);
  36.   $getSrcLang = $AddFile->GetSourceLanguages(array('Ticket'=>$ticket));
  37.                 $array = array();
  38.              
  39.                 foreach
  40.                 ($getSrcLang->GetSourceLanguagesResult->Languages->Language as $language)              
  41.                 {                  
  42.                 $array[] = $language->Description;                     
  43.                 }
  44.   }
  45.   catch (SoapFault $exception){
  46.   return $exception;
  47.   }
  48.  
  49.  
  50. $form['folks_list']=array(
  51.         '#type'=>'select',
  52.         '#title' => t('Freeway Source Languages'),
  53.         '#default_value' => array('1'=>'Joe'),
  54.         '#options' => $array,
  55.         '#multiple' => false,
  56.         '#attributes'=>array('size'=>4),
  57.         '#weight'=>8,
  58.     );
  59.  
  60.  
  61.  
  62.    
  63.   $form['node_id'] = array(
  64.     '#type' => 'hidden',
  65.     '#value' => $node->nid,
  66.   );
  67.  
  68.   $form['translate_node'] = array(
  69.     '#type' => 'submit',
  70.     '#value' => 'Translate',
  71.   );
  72.  
  73.   return $form;
  74. }
  75.  
  76. function send_for_translation_submit($form, &$form_state) {
  77.   $node = node_load($form_state['values']['node_id']);
  78.   $nodes_id = $node->nid;
  79.   $contents = freeway_dashboard_build_filter_query($nodes_id);
  80.  
  81.   print_r('<pre>'. print_r($form_state['values']['folks_list'], true) .'</pre>');
  82.   echo ("TestEcho");
  83.   echo "<br>";
  84.  
  85.   while ($latest_node = db_fetch_object($contents)) {
  86.    
  87.      $body = $latest_node->body ;
  88.      $LoginClient = new SoapClient("wsdlpath", array("trace"=>1));
  89.      $AddFile = new SoapClient("wsdlpath", array("trace"=>1));
  90.    
  91.   $arrayLan = array('fr-fr');
  92.  
  93.             try
  94.             {
  95.            
  96.                 $arrResponse = $LoginClient->Logon(array ('Username'=>'uname','Password'=>'pwrd'));
  97.                 $ticket = ($arrResponse->LogonResult);
  98.                 print_r($ticket);
  99.                 echo "<br>";           
  100.                    
  101.                 $fileName = "vibgyor.txt";             
  102.                 $addTask = $AddFile->AddTaskToProject(array('Ticket'=>$ticket,'ProjectID'=>'436183','SourceLanguageID'=> 'en-us', 'TargetLanguageID'=> 'fr-fr','ComponentID'=> 'Web','SubjectID'=>'std','TaskID'=>'LP','SubTaskID'=>'New Words','Volume'=>'50','UOMID'=>'Word'));
  103.                
  104.                 $addFile = $AddFile->AddFileToProject(array('Ticket'=>$ticket,'ProjectID'=>'436183','Filename'=>$fileName,'FileData'=> $body, 'SourceLanguageID'=> 'en-us', 'TargetLanguageIDs'=> $arrayLan,'Metadata'=> null,'IsReferenceMaterial'=>false));
  105.                
  106.  
  107.             }
  108.            
  109.             catch(SoapFault $exception)
  110.             {
  111.                //echo ("Inside Exception");
  112.                //echo $exception;
  113.                
  114.                return $exception;
  115.             }
  116.    
  117.  }
  118.  //drupal_set_message('<pre>'. print_r($form_state['values']['folks_list'], true) .'</pre>');
  119.  
  120.  switch ($form_state['values']['folks_list']) {
  121.   case 'French(Canada)':
  122.     // You could actually do anything in here, this is just an example :).
  123.    // return translate_to_french($node);
  124.     echo ("TestEcho");
  125.     break;
  126. }
  127.  
  128.  
  129.  
  130.  return 'Success';
  131. }
  132.  
  133. function freeway_dashboard_build_filter_query($nodes_id) {
  134.  $nodes_id_inMethod = $nodes_id;
  135.  $contents = db_query("SELECT n.*, nr.body FROM node n JOIN node_revisions nr on n.vid = nr.vid where n.nid = '$nodes_id_inMethod'" );
  136.  return $contents;
  137. }
  138.  
  139.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement