Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function freeway_admin_settings() {
- $options = node_get_types('names');
- $form['freeway_node_types'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Contents which can be considered for Freeway'),
- '#options' => $options,
- '#default_value' => variable_get('freeway_node_types', array('page')),
- '#description' => t('A text field will be available on these content types to make user-specific notes.'),
- );
- return system_settings_form($form);
- }
- function send_for_translation() {
- $node = node_load(arg(1));
- $form = array();
- $form['field_wrapper'] = array(
- '#type' => 'fieldset',
- '#title' => 'Some fields to be wrapped',
- );
- $LoginClient = new SoapClient("wsdlpath", array("trace"=>1));
- $AddFile = new SoapClient("wsdlpath", array("trace"=>1));
- try{
- $arrResponse = $LoginClient->Logon(array ('Username'=>'uname','Password'=>'pwrd'));
- $ticket = ($arrResponse->LogonResult);
- $getSrcLang = $AddFile->GetSourceLanguages(array('Ticket'=>$ticket));
- $array = array();
- foreach
- ($getSrcLang->GetSourceLanguagesResult->Languages->Language as $language)
- {
- $array[] = $language->Description;
- }
- }
- catch (SoapFault $exception){
- return $exception;
- }
- $form['folks_list']=array(
- '#type'=>'select',
- '#title' => t('Freeway Source Languages'),
- '#default_value' => array('1'=>'Joe'),
- '#options' => $array,
- '#multiple' => false,
- '#attributes'=>array('size'=>4),
- '#weight'=>8,
- );
- $form['node_id'] = array(
- '#type' => 'hidden',
- '#value' => $node->nid,
- );
- $form['translate_node'] = array(
- '#type' => 'submit',
- '#value' => 'Translate',
- );
- return $form;
- }
- function send_for_translation_submit($form, &$form_state) {
- $node = node_load($form_state['values']['node_id']);
- $nodes_id = $node->nid;
- $contents = freeway_dashboard_build_filter_query($nodes_id);
- print_r('<pre>'. print_r($form_state['values']['folks_list'], true) .'</pre>');
- echo ("TestEcho");
- echo "<br>";
- while ($latest_node = db_fetch_object($contents)) {
- $body = $latest_node->body ;
- $LoginClient = new SoapClient("wsdlpath", array("trace"=>1));
- $AddFile = new SoapClient("wsdlpath", array("trace"=>1));
- $arrayLan = array('fr-fr');
- try
- {
- $arrResponse = $LoginClient->Logon(array ('Username'=>'uname','Password'=>'pwrd'));
- $ticket = ($arrResponse->LogonResult);
- print_r($ticket);
- echo "<br>";
- $fileName = "vibgyor.txt";
- $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'));
- $addFile = $AddFile->AddFileToProject(array('Ticket'=>$ticket,'ProjectID'=>'436183','Filename'=>$fileName,'FileData'=> $body, 'SourceLanguageID'=> 'en-us', 'TargetLanguageIDs'=> $arrayLan,'Metadata'=> null,'IsReferenceMaterial'=>false));
- }
- catch(SoapFault $exception)
- {
- //echo ("Inside Exception");
- //echo $exception;
- return $exception;
- }
- }
- //drupal_set_message('<pre>'. print_r($form_state['values']['folks_list'], true) .'</pre>');
- switch ($form_state['values']['folks_list']) {
- case 'French(Canada)':
- // You could actually do anything in here, this is just an example :).
- // return translate_to_french($node);
- echo ("TestEcho");
- break;
- }
- return 'Success';
- }
- function freeway_dashboard_build_filter_query($nodes_id) {
- $nodes_id_inMethod = $nodes_id;
- $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'" );
- return $contents;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement