Advertisement
vishnu3006

CodeFull

Oct 12th, 2011
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.40 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("wsdl", array("trace"=>1));
  28.      $AddFile = new SoapClient("wsdl", array("trace"=>1));
  29.  
  30.  
  31.  
  32.  
  33.   try{
  34.   $arrResponse = $LoginClient->Logon(array ('Username'=>'username','Password'=>'password'));
  35.   $ticket = ($arrResponse->LogonResult);
  36.   $getSrcLang = $AddFile->GetSourceLanguages(array('Ticket'=>$ticket));
  37.  
  38.   //print_r($getSrcLang);
  39.                 $array = array();
  40.              
  41.                 foreach
  42.                 ($getSrcLang->GetSourceLanguagesResult->Languages->Language as $language)              
  43.                 {                  
  44.                 //$array[] = $language->Description;                       
  45.                 $array[$language->ID] = $language->Description;
  46.                 }
  47.   }
  48.   catch (SoapFault $exception){
  49.   return $exception;
  50.   }
  51.  
  52.  
  53. $form['folks_list']=array(
  54.         '#type'=>'select',
  55.         '#title' => t('Freeway Source Languages'),
  56.         '#default_value' => array('1'=>'Joe'),
  57.         '#options' => $array,
  58.         '#multiple' => false,
  59.         '#attributes'=>array('size'=>4),
  60.         '#weight'=>8,
  61.     );
  62.  
  63.  
  64.  
  65.    
  66.   $form['node_id'] = array(
  67.     '#type' => 'hidden',
  68.     '#value' => $node->nid,
  69.   );
  70.  
  71.   $form['translate_node'] = array(
  72.     '#type' => 'submit',
  73.     '#value' => 'Translate',
  74.   );
  75.  
  76.   return $form;
  77. }
  78.  
  79. function send_for_translation_submit($form, &$form_state) {
  80.   $node = node_load($form_state['values']['node_id']);
  81.   $nodes_id = $node->nid;
  82.   $contents = freeway_dashboard_build_filter_query($nodes_id);
  83.  
  84.   print_r('<pre>'. print_r($form_state['values']['folks_list'], true) .'</pre>');
  85.   echo ("TestEcho");
  86.   echo "<br>";
  87.  
  88.   while ($latest_node = db_fetch_object($contents)) {
  89.    
  90.      $body = $latest_node->body ;
  91.      $LoginClient = new SoapClient("wsdl", array("trace"=>1));
  92.      $AddFile = new SoapClient("wsdl", array("trace"=>1));
  93.    
  94.   $arrayLan = array('fr-fr');
  95.  
  96.             try
  97.             {
  98.            
  99.                 $arrResponse = $LoginClient->Logon(array ('Username'=>'username','Password'=>'passwrd'));
  100.                 $ticket = ($arrResponse->LogonResult);
  101.                 print_r($ticket);
  102.                 echo "<br>";           
  103.                    
  104.                 $fileName = "vibgyor.txt";             
  105.                 $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'));
  106.                
  107.                 $addFile = $AddFile->AddFileToProject(array('Ticket'=>$ticket,'ProjectID'=>'436183','Filename'=>$fileName,'FileData'=> $body, 'SourceLanguageID'=> 'en-us', 'TargetLanguageIDs'=> $arrayLan,'Metadata'=> null,'IsReferenceMaterial'=>false));
  108.                
  109.  
  110.             }
  111.            
  112.             catch(SoapFault $exception)
  113.             {      
  114.                return $exception;
  115.             }
  116.    
  117.  }
  118.  
  119.  
  120.  switch ($form_state['values']['folks_list']) {
  121.   case 'French(Canada)':
  122.     echo ("TestEcho");
  123.     break;
  124. }
  125.  
  126.  
  127.  
  128.  return 'Success';
  129. }
  130.  
  131. function freeway_dashboard_build_filter_query($nodes_id) {
  132.  $nodes_id_inMethod = $nodes_id;
  133.  $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'" );
  134.  return $contents;
  135. }
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. function create_freeway_project (){
  143.   $node = node_load(arg(1));
  144.   $form = array();
  145.   date_popup_load();
  146.   $form['field_wrapper'] = array(
  147.     '#type' => 'fieldset',
  148.     '#title' => 'Some fields to be wrapped',
  149.   );
  150.  
  151.   $form['title'] = array(
  152.   '#type' => 'textfield',
  153.   '#title' => t('Project Description'),
  154.   '#size' => 60,
  155.   '#maxlength' => 128,
  156.   '#required' => TRUE,
  157. );
  158.  
  159.   $form['custRef'] = array(
  160.   '#type' => 'textfield',
  161.   '#title' => t('Customer Reference'),
  162.   '#size' => 60,
  163.   '#maxlength' => 128,
  164.   '#required' => TRUE,
  165. );
  166.  
  167.   $form['poRef'] = array(
  168.   '#type' => 'textfield',
  169.   '#title' => t('PO Reference'),
  170.   '#size' => 60,
  171.   '#maxlength' => 128,
  172.   '#required' => TRUE,
  173. );
  174.  
  175.  
  176.   $form['splinst'] = array(
  177.   '#type' => 'textarea',
  178.   '#title' => t('Special Instructions'),
  179.   '#size' => 60,
  180.   '#maxlength' => 128,
  181.   '#required' => TRUE,
  182. );
  183.  
  184.  
  185.   $form['strtdate'] = array(
  186.   '#type' => 'date_popup',
  187.   '#title' => t('Start Date'),
  188.   '#size' => 60,
  189.   '#maxlength' => 128,
  190.   '#required' => TRUE,
  191. );
  192.  
  193.  
  194.   $form['enddate'] = array(
  195.   '#type' => 'date_popup',
  196.   '#title' => t('End Date'),
  197.   '#size' => 60,
  198.   '#maxlength' => 128,
  199.   '#required' => TRUE,
  200. );
  201.  
  202.  
  203.    $form['create_project_btn'] = array(
  204.     '#type' => 'submit',
  205.     '#value' => 'Create Freeway Project',
  206.   );
  207.  
  208.  
  209.    return $form;
  210.  
  211. }
  212.  
  213.  
  214. function create_freeway_project_submit($form, &$form_state){
  215. //print_r('<pre>'. print_r($form_state['values']['title'], true) .'</pre>');
  216. $projDesc = ($form_state['values']['title']);
  217. $custRef = ($form_state['values']['custRef']);
  218. $poRef = ($form_state['values']['poRef']);
  219. $strtDate = ($form_state['values']['strtdate']);
  220. $endDate = ($form_state['values']['enddate']);
  221. $splInst = ($form_state['values']['splinst']);
  222. print_r($strtDate);
  223.  
  224. $startDateConv = date( 'Y-m-d', strtotime($strtDate));
  225. $endDateConv = date( 'Y-m-d', strtotime($endDate));
  226.  
  227.  
  228.  
  229.      $LoginClient = new SoapClient("wsdl", array("trace"=>1));
  230.  
  231.      $AddFile = new SoapClient("wsdl", array("trace"=>1));
  232.  
  233.             try
  234.             {
  235.  
  236.                 $arrResponse = $LoginClient->Logon(array ('Username'=>'username','Password'=>'password'));
  237.  
  238.                 $ticket = ($arrResponse->LogonResult);
  239.  
  240.                 $createProj = $AddFile->CreateProject(array('Ticket'=>$ticket,'Description'=>$projDesc,'SpecialInstructions'=> $splInst, 'CustomReference'=> $custRef,'POReference'=> $poRef,'ExpectedStartingDate'=>$startDateConv,'ExpectedDeliveryDate'=>$endDateConv,'MetaData'=>null));
  241.                    
  242.  
  243.             print_r($createProj);                  
  244.             }
  245.            
  246.             catch(SoapFault $exception)
  247.             {                  
  248.                return $exception;
  249.             }
  250.  
  251.            
  252.             drupal_set_message("Your project has been created");
  253.             drupal_goto("user");
  254.  
  255. }
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement