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("wsdl", array("trace"=>1));
- $AddFile = new SoapClient("wsdl", array("trace"=>1));
- try{
- $arrResponse = $LoginClient->Logon(array ('Username'=>'username','Password'=>'password'));
- $ticket = ($arrResponse->LogonResult);
- $getSrcLang = $AddFile->GetSourceLanguages(array('Ticket'=>$ticket));
- //print_r($getSrcLang);
- $array = array();
- foreach
- ($getSrcLang->GetSourceLanguagesResult->Languages->Language as $language)
- {
- //$array[] = $language->Description;
- $array[$language->ID] = $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("wsdl", array("trace"=>1));
- $AddFile = new SoapClient("wsdl", array("trace"=>1));
- $arrayLan = array('fr-fr');
- try
- {
- $arrResponse = $LoginClient->Logon(array ('Username'=>'username','Password'=>'passwrd'));
- $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)
- {
- return $exception;
- }
- }
- switch ($form_state['values']['folks_list']) {
- case 'French(Canada)':
- 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;
- }
- function create_freeway_project (){
- $node = node_load(arg(1));
- $form = array();
- date_popup_load();
- $form['field_wrapper'] = array(
- '#type' => 'fieldset',
- '#title' => 'Some fields to be wrapped',
- );
- $form['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Project Description'),
- '#size' => 60,
- '#maxlength' => 128,
- '#required' => TRUE,
- );
- $form['custRef'] = array(
- '#type' => 'textfield',
- '#title' => t('Customer Reference'),
- '#size' => 60,
- '#maxlength' => 128,
- '#required' => TRUE,
- );
- $form['poRef'] = array(
- '#type' => 'textfield',
- '#title' => t('PO Reference'),
- '#size' => 60,
- '#maxlength' => 128,
- '#required' => TRUE,
- );
- $form['splinst'] = array(
- '#type' => 'textarea',
- '#title' => t('Special Instructions'),
- '#size' => 60,
- '#maxlength' => 128,
- '#required' => TRUE,
- );
- $form['strtdate'] = array(
- '#type' => 'date_popup',
- '#title' => t('Start Date'),
- '#size' => 60,
- '#maxlength' => 128,
- '#required' => TRUE,
- );
- $form['enddate'] = array(
- '#type' => 'date_popup',
- '#title' => t('End Date'),
- '#size' => 60,
- '#maxlength' => 128,
- '#required' => TRUE,
- );
- $form['create_project_btn'] = array(
- '#type' => 'submit',
- '#value' => 'Create Freeway Project',
- );
- return $form;
- }
- function create_freeway_project_submit($form, &$form_state){
- //print_r('<pre>'. print_r($form_state['values']['title'], true) .'</pre>');
- $projDesc = ($form_state['values']['title']);
- $custRef = ($form_state['values']['custRef']);
- $poRef = ($form_state['values']['poRef']);
- $strtDate = ($form_state['values']['strtdate']);
- $endDate = ($form_state['values']['enddate']);
- $splInst = ($form_state['values']['splinst']);
- print_r($strtDate);
- $startDateConv = date( 'Y-m-d', strtotime($strtDate));
- $endDateConv = date( 'Y-m-d', strtotime($endDate));
- $LoginClient = new SoapClient("wsdl", array("trace"=>1));
- $AddFile = new SoapClient("wsdl", array("trace"=>1));
- try
- {
- $arrResponse = $LoginClient->Logon(array ('Username'=>'username','Password'=>'password'));
- $ticket = ($arrResponse->LogonResult);
- $createProj = $AddFile->CreateProject(array('Ticket'=>$ticket,'Description'=>$projDesc,'SpecialInstructions'=> $splInst, 'CustomReference'=> $custRef,'POReference'=> $poRef,'ExpectedStartingDate'=>$startDateConv,'ExpectedDeliveryDate'=>$endDateConv,'MetaData'=>null));
- print_r($createProj);
- }
- catch(SoapFault $exception)
- {
- return $exception;
- }
- drupal_set_message("Your project has been created");
- drupal_goto("user");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement