Advertisement
vishnu3006

full code

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