Advertisement
vishnu3006

Untitled

Nov 25th, 2011
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2.  
  3. function formModifications_form_alter(&$form,&$form_state,$form_id){
  4.     if ($form_id == 'node_admin_content') {
  5.  
  6.             $form['admin']['options']['operation']['#options']['send_for_translation'] = t('Send For Translation');
  7.             $form['admin']['options']['submit']['#submit'][] = 'custom_send_for_translation_submit_admin';
  8.    
  9.     }
  10.  
  11. }
  12.  
  13. function custom_send_for_translation_submit_admin($form, &$form_state) {           
  14.                        
  15.             foreach ($form_state['values']['nodes'] as $key => $value) {
  16.                             if ($value != 0) {
  17.                                     $selected[] = node_load($key);
  18.                             }
  19.                 }
  20.                
  21.  
  22.  
  23.             foreach ($selected as $key => $value ){
  24.                         $structure = './sites/all/tempfolder/';
  25.                        
  26.                        
  27.                         if(!is_dir($structure))
  28.                         {
  29.                         mkdir($structure, 0, true);
  30.                         }
  31.                        
  32.                    
  33.                             $fileName = $value->title;         
  34.                             $sPattern = '/\s*/m';
  35.                             $sReplace = '';
  36.                             $refinedFileName = preg_replace( $sPattern, $sReplace, $fileName ).".xml";
  37.                             $finalRefinedFileName = $structure.$refinedFileName;
  38.                            
  39.                             $ourFileHandle = fopen($finalRefinedFileName, 'w') or die("can't open file");
  40.                            
  41.                        
  42.                                
  43.                                 $xml = array(
  44.                                     'title' => $value->title,
  45.                                     'body' => $value->body,
  46.                                     );
  47.                                                
  48.                 }
  49.  
  50.            
  51.             fclose($ourFileHandle);
  52.  
  53.  
  54.            
  55. }
  56.            
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement