Plugin Directory

Changeset 508223


Ignore:
Timestamp:
02/21/2012 01:29:05 PM (14 years ago)
Author:
christian_gnoth
Message:
 
Location:
joomla-to-wordpress-migrator/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • joomla-to-wordpress-migrator/trunk/joomla2wp-admin.php

    r368362 r508223  
    3535  $page_sel          = get_option("j2wp_page_sel");
    3636  $users_sel         = get_option("j2wp_users_sel");
     37  $joomgallery_sel   = get_option("j2wp_joomgallery_sel");
    3738  $mysql_change_vars = get_option("j2wp_mysql_change_vars");
    3839  $j2wp_cpage_conv   = get_option("j2wp_cpage_conv");
     
    7273  {
    7374    $users_sel_checkbox = ' ';
     75  }
     76
     77  if ( $joomgallery_sel == 'on' )
     78  {
     79    $joomgallery_sel_checkbox = ' checked="checked" ';
     80  }
     81  else
     82  {
     83    $joomgallery_sel_checkbox = ' ';
    7484  }
    7585
     
    401411  '                    <input type="checkbox" name="new_j2wp_users_sel" value="open" ' . $users_sel_checkbox . '/>' . "\n" .
    402412  '                      </td>' . "\n" .
    403   '                    </tr>' . "\n" .
     413  '                    </tr>' . "\n";
     414 
     415  if ( $j2wp_cms_types[$j2wp_cms_type] == 'Joomla' )
     416  {
     417    echo
     418    '                    <tr>' . "\n" .
     419    '                      <td>' . "\n" .
     420    '                        Migrate JoomGallery Images:' . "\n" .
     421    '                      </td>' . "\n" .
     422    '                      <td>' . "\n" .
     423    '                      <input type="checkbox" name="new_j2wp_joomgallery_sel" value="open" ' . $joomgallery_sel_checkbox . '/>' . "\n" .
     424    '                      </td>' . "\n" .
     425    '                    </tr>' . "\n";
     426  }
     427 
     428  echo
    404429  '                    <tr>' . "\n" .
    405430  '                      <td>' . "\n" .
     
    525550  $j2wp_cms_type     = get_option('j2wp_cms_type');
    526551  $cat_sel           = get_option('j2wp_cat_sel');
     552  $joomgallery_sel   = get_option("j2wp_joomgallery_sel");
    527553
    528554  if ( $cat_sel == 'on' )
     
    548574  '      </p>' . "\n" .
    549575  '      </div><br />' . "\n" .
    550   '      <br />' . "\n";
    551 echo '<h3>Data Migration</h3>' . "\n";
    552 echo '<br />' . "\n";
    553   _e('To start the migration of ' . $j2wp_cms_types[$j2wp_cms_type] . ' posts to Wordpress - press the button below!', 'joomla2wp');
    554   echo "\n";
    555 echo '<br />' . "\n";
    556 echo '<div id="j2wp_migrator_btn">' . "\n";
    557 echo '<p class="submit">';
    558 echo '<input type="submit" name="do_mig_btn" value="Start Migration to WP" />';
    559 echo '</p>' . "\n";
    560 echo '</div><br /><hr /><br />' . "\n";
    561 echo '<h3>URLs in Posts Migration</h3>' . "\n";
    562 echo '<br />' . "\n";
    563   _e('To change the URLs in the content from ' . $j2wp_cms_types[$j2wp_cms_type] . ' posts to WP posts - press the button below!', 'joomla2wp');
    564   echo "\n";
    565 echo '<br />' . "\n";
    566 echo '<p class="submit">';
    567 echo '<input type="submit" name="change_urls_btn" value="Change Urls" />';
    568 echo '</p>';
    569 echo '</form>';
    570 echo '</div>   <!--- DIV wrap END  --->' . "\n";
     576  '      <br />' . "\n" .
     577  '<h3>Data Migration</h3>' . "\n" .
     578  '<br />' . "\n" .
     579  _e('To start the migration of ' . $j2wp_cms_types[$j2wp_cms_type] . ' posts to Wordpress - press the button below!', 'joomla2wp') . "\n" .
     580  '<br />' . "\n" .
     581  '<div id="j2wp_migrator_btn">' . "\n" .
     582  '<p class="submit">' .
     583  '<input type="submit" name="do_mig_btn" value="Start Migration to WP" />' .
     584  '</p>' . "\n" .
     585  '</div>' . "\n";
     586 
     587  if ( ($j2wp_cms_types[$j2wp_cms_type] == 0) AND ($joomgallery_sel == 'on') )
     588  {
     589    echo
     590    '<br />' . "\n" .
     591    _e('To start the migration of JoomGallery data to Wordpress - press the button below!', 'joomla2wp') . "\n" .
     592    '<br />' . "\n" .
     593    '<div class="j2wp_migrator_btn">' . "\n" .
     594    '<p class="submit">' .
     595    '<input type="submit" name="do_mig_joomgallery_btn" value="Start Migration of Media Data to WP" />' .
     596    '</p>' . "\n" .
     597    '</div>' . "\n";
     598  }
     599 
     600  echo
     601  '<br /><hr /><br />' . "\n" .
     602  '<h3>URLs in Posts Migration</h3>' . "\n" .
     603  '<br />' . "\n" .
     604  _e('To change the URLs in the content from ' . $j2wp_cms_types[$j2wp_cms_type] . ' posts to WP posts - press the button below!', 'joomla2wp') . "\n" .
     605  '<br />' . "\n" .
     606  '<p class="submit">' . "\n" .
     607  '<input type="submit" name="change_urls_btn" value="Change Urls" />' . "\n" .
     608  '</p>' . "\n" .
     609  '</form>' . "\n" .
     610  '</div>   <!--- DIV wrap END  --->' . "\n";
    571611
    572612  return;
     
    607647  return;
    608648}
     649
     650
     651function joomla2wp_print_joomgallery_cat_sel_page()
     652{
     653  //  get all cats from joomla
     654  $joomla_cats = j2wp_get_joomla_joomgallery_cats();
     655
     656  // print panel with cats
     657  echo '<div class="wrap">' . "\n";
     658  echo '<h3>' . __( 'Select the image categories you want migrate to WP !' , 'joomla2wp' ) . '</h3>' . "\n";
     659  echo '<br />' . "\n";
     660  echo '<form id="j2wp_cat_sel_form" name="joomla_cat_sel_list" enctype="application/x-www-form-urlencoded" method="post">' . "\n";
     661  echo '  <p>' . "\n";
     662  $rows = count($joomla_cats);
     663  $height = $rows * 10;
     664//  echo '    <select name="joomla_cat_box[]" style="height:' . $height . 'px" multiple="multiple" size="' . $rows . '">' . "\n";
     665  echo '    <select id="cat_select_id" class="cat_select" name="joomla_cat_joomgallery_box[]" multiple="multiple" size="' . $rows . '">' . "\n";
     666  $index = 0;
     667  foreach ( $joomla_cats as $jcat )
     668  {
     669    echo '      <option value="' . $index . '" >' . $jcat['name'] . '</option>' . "\n";
     670    $index++;
     671  }
     672  echo '    </select>' . "\n";
     673  echo '  </p>' . "\n";
     674  echo '  <p class="submit">' . "\n";
     675  echo '    <input type="submit" name="j2wp_cats_abort_btn" value="' . __( 'Abort', 'joomla2wp') . '" />' . "\n";
     676  echo '    <input id="j2wp_cat_joomgallery_sel_cont_btn" type="submit" name="j2wp_cats_joomgallery_continue_btn" value="' . __( 'Continue', 'joomla2wp') . '" />' . "\n";
     677  echo '    <br />' . "\n";
     678  echo '  </p>' . "\n";
     679  echo '</form>' . "\n";
     680  echo '</div>   <!--- DIV wrap END  --->' . "\n";
     681 
     682  return;
     683}
     684
    609685
    610686
  • joomla-to-wordpress-migrator/trunk/joomla2wp-functions.php

    r388845 r508223  
    44Plugin URI: http://www.it-gnoth.de/wordpress/wordpress-plugins/
    55Description: migrates/imports all posts/pages from Joomla/Mambo tables to WP tables
    6 Version: 1.5.4
     6Version: 1.6.0
    77Author: Christian Gnoth
    88Author URI: http://www.it-gnoth.de
     
    133133  add_option( 'j2wp_page_sel', 'on' );
    134134  add_option( 'j2wp_users_sel', 'on' );
     135  add_option( 'j2wp_joomgallery_sel', 'on' );
    135136  add_option( 'j2wp_mysql_srv', 'localhost' );
    136137  add_option( 'j2wp_mysql_use_one_srv', '0' );
     
    283284    }
    284285  }
     286 
     287  if ( isset( $_POST['j2wp_cats_joomgallery_continue_btn'] ) )
     288  {
     289    // get the selected cats
     290    $sel_values = $_POST['joomla_cat_joomgallery_box'];
     291
     292    if ( $sel_values )
     293    {
     294      $j2wp_error_flag = j2wp_prepare_mig( 3, $sel_values );
     295    }
     296    else
     297    {
     298      echo '<div id="message" class="error">';
     299      echo '<strong>No category selected !!!</strong>.</div>';
     300    }
     301  }
     302 
    285303
    286304  if ( $_POST['print_cats_sel_page'] )
     
    296314    $_POST['print_cats_sel_page'] = false;
    297315    joomla2wp_print_plugin_migration_page();
     316  }
     317
     318  if ( isset( $_POST['do_mig_joomgallery_btn'] ) )
     319  {
     320    j2wp_print_output_page();
     321
     322    joomla2wp_print_joomgallery_cat_sel_page();
    298323  }
    299324
     
    394419    $j2wp_users_sel = 'on';
    395420  }
     421  if (!isset( $_POST['new_j2wp_joomgallery_sel'] ))
     422  {
     423    $_POST['new_j2wp_joomgallery_sel'] = 'off';
     424    $j2wp_joomgallery_sel = 'off';
     425  }
     426  else
     427  {
     428    $_POST['new_j2wp_joomgallery_sel'] = 'on';
     429    $j2wp_joomgallery_sel = 'on';
     430  }
    396431  if (!isset( $_POST['new_j2wp_cpage_conv'] ))
    397432  {
     
    407442  update_option( 'j2wp_page_sel' , $j2wp_page_sel );
    408443  update_option( 'j2wp_users_sel', $j2wp_users_sel );
     444  update_option( 'j2wp_joomgallery_sel', $j2wp_joomgallery_sel );
    409445  update_option( 'j2wp_cat_sel'  , $j2wp_cat_sel );
    410446  update_option( 'j2wp_cpage_conv',$j2wp_cpage_conv );
  • joomla-to-wordpress-migrator/trunk/joomla2wp-mig.php

    r388845 r508223  
    2828}
    2929
    30 function j2wp_prepare_mig( $func )
     30function j2wp_prepare_mig( $func, $sel_values = NULL )
    3131{
    3232  global  $j2wp_error_flag;
     
    111111
    112112        break;
     113      case 3:
     114        j2wp_print_output_page();
     115        ob_end_flush();
     116
     117        //  get all cats from joomla
     118        $joomla_cats = j2wp_get_joomla_joomgallery_cats();
     119
     120        $joomla_temp_cats = array();
     121        foreach ( $sel_values as $val )
     122        {
     123          $joomla_temp_cats[] = array(
     124                              'cid'     => $joomla_cats[$val]['cid'],
     125                              'name'    => $joomla_cats[$val]['name'],
     126                              'catpath' => $joomla_cats[$val]['catpath']
     127                              );
     128        }
     129
     130        j2wp_do_joomgallery_mig( $joomla_temp_cats );
     131
     132        break;
    113133    }
    114134    $j2wp_error_flag = 0;
     
    186206    echo '<b><i>migrating pages</i></b>....<br /><br />' . "\n";
    187207    j2wp_mig_pages($j2wp_user_array);
     208  }
     209
     210  $mtime = microtime();
     211  $mtime_end = explode(' ',$mtime);
     212  $totaltime[0] = ($mtime_end[0] - $mtime_start[0]); // microseconds like 0.xxxxxxx
     213  $totaltime[1] = ($mtime_end[1] - $mtime_start[1]);
     214
     215  echo '<br />' . "\n";
     216  echo 'script execution time: ' . $totaltime[1] . ' seconds <br /><br />';
     217
     218  echo '<div id="message" class="updated fade">';
     219  echo '<strong>Migration done </strong>.</div>';
     220
     221  ob_end_flush();
     222
     223  return;
     224}
     225
     226function j2wp_do_joomgallery_mig( $joomla_cats )
     227{
     228  global  $wpdb,
     229          $CON,
     230          $user_id;
     231
     232  global  $j2wp_mysql_srv,
     233          $j2wp_mysql_usr,
     234          $j2wp_mysql_pswd,
     235          $j2wp_user_array,
     236          $j2wp_joomla_db_name,
     237          $j2wp_joomla_tb_prefix,
     238          $j2wp_joomla_web_url,
     239          $j2wp_wp_db_name,
     240          $j2wp_wp_tb_prefix,
     241          $j2wp_wp_web_url;
     242
     243
     244  $mtime = microtime();
     245  $mtime_start = explode(' ',$mtime);
     246
     247  // setting timelimit
     248  if ( function_exists('set_time_limit') )
     249  {
     250    ignore_user_abort(1);
     251    set_time_limit(0);
     252  }
     253  else
     254    _e( '<br />Warning: can not execute set_time_limit() script may abort...<br />', 'joomla2wp');
     255
     256  if ( !$CON )
     257    $CON = j2wp_do_mysql_connect();
     258
     259  $j2wp_wp_tb_prefix = get_option('j2wp_wp_tb_prefix');
     260  j2wp_do_wp_connect();
     261
     262  //  check if user adminwp exists
     263  $user_name = 'adminwp';
     264  $user_id = username_exists( $user_name );
     265  if ( !$user_id )
     266  {
     267    $random_password = wp_generate_password( 12, false );
     268    $user_id = wp_create_user( $user_name, $random_password, $user_email );
     269  }
     270 
     271  //  check if Fotogallery Category exists
     272  $joomgallery_cat = get_cat_ID('Fotogallery');
     273  if ( !$joomgallery_cat )
     274    $joomgallery_cat = wp_create_category( 'Fotogallery' );
     275 
     276  echo '<h4>Content Migration</h4><br />' . "\n";
     277
     278  //  j2wp_joomla_wp_posts_by_cat( $mig_cat_array[10], 10, $user_id );
     279
     280  $index = 0; 
     281  foreach ( $joomla_cats as $jcat )
     282  {
     283    // for each category in joomgallery process all data
     284    j2wp_joomla_wp_joomgallery_by_cat( $joomgallery_cat, $jcat, $user_id );
     285    $index++;
    188286  }
    189287
     
    619717}
    620718
     719function j2wp_get_joomla_joomgallery_cats()
     720{
     721  global  $wpdb,
     722          $CON;
     723         
     724
     725  if ( !$CON )
     726    $CON = j2wp_do_mysql_connect();
     727
     728  $j2wp_joomla_tb_prefix = get_option('j2wp_joomla_tb_prefix');
     729  j2wp_do_joomla_connect();
     730 
     731  $query = "SELECT cid, name, catpath FROM " . $j2wp_joomla_tb_prefix . "joomgallery_catg WHERE published = 1 ORDER BY cid ";
     732  $result = mysql_query($query, $CON);
     733  if ( !$result )
     734    echo mysql_error();
     735 
     736  while($row = mysql_fetch_array($result))
     737  {
     738    $joomla_cats[] = array(
     739                          'cid' => $row['cid'],
     740                          'name' => $row['name'],
     741                          'catpath' => $row['catpath']
     742                          );
     743  }
     744  mysql_free_result($result);
     745
     746  return $joomla_cats;
     747}
     748
     749
    621750
    622751function j2wp_get_post_count( $mig_cat_array )
     
    642771}
    643772
     773
     774function j2wp_get_image_count( $jcat )
     775{
     776  global  $wpdb,
     777          $CON;
     778
     779  $j2wp_joomla_tb_prefix = get_option('j2wp_joomla_tb_prefix');
     780  j2wp_do_joomla_connect();
     781  set_time_limit(25);
     782
     783  $query = "SELECT COUNT(*) FROM `" . $j2wp_joomla_tb_prefix . "joomgallery` WHERE catid = '" . $jcat . "' ";
     784  $result = mysql_query($query, $CON);
     785  if ( !$result )
     786    echo mysql_error();
     787  while($R = mysql_fetch_array($result))
     788  {
     789    $j2wp_image_count = $R[0];
     790  }
     791  mysql_free_result($result);
     792
     793  return $j2wp_image_count;
     794}
     795
     796
     797function  j2wp_joomla_wp_joomgallery_by_cat( $joomgallery_cat, $jcat, $user_id )
     798{
     799  global  $wpdb,
     800          $CON;
     801
     802  $wp_img_folder       = get_option('j2wp_wp_images_folder');
     803  $wp_blog_url         = 'http://' . get_option('j2wp_wp_web_url');
     804  $j2wp_joomla_tb_prefix = get_option('j2wp_joomla_tb_prefix');
     805  j2wp_do_joomla_connect();
     806
     807  echo '<br />' . __('Processing Category: <b>', 'joomla2wp') . $jcat['name'] . '</b>   ===>';
     808
     809  // first get count of posts in category
     810  $j2wp_image_count = j2wp_get_image_count( $jcat['cid'] );
     811
     812  _e( ' found ', 'joomla2wp');
     813  echo $j2wp_image_count . ' images.... <br />';
     814  flush();
     815  ob_flush();
     816  sleep(1);
     817
     818  // process all images
     819  set_time_limit(0);
     820
     821  $post_contant = '';
     822  $query = "SELECT * FROM `" . $j2wp_joomla_tb_prefix . "joomgallery` WHERE catid = '" . $jcat['cid'] . "' ";
     823  $result = mysql_query($query, $CON);
     824  if ( !$result )
     825    echo mysql_error();
     826  while( $R = mysql_fetch_array($result) )
     827  {
     828    $j2wp_image = array( 'title'  => $R['imgtitle'],
     829                         'author' => $R['imgauthor'],
     830                         'text'   => $R['imgtext'],
     831                         'file'   => $R['imgfilename'] 
     832                       );
     833                       
     834    //  create post image link entry
     835    $img_src =  $wp_blog_url . $wp_img_folder . '/gallery/' . $jcat['catpath'] . '/' . $j2wp_image['file'];
     836    $post_content .= '<a title="' . $j2wp_image['title'] . '" href="' . $img_src . '"><img src="' . $img_src . '" title="' . $j2wp_image['title'] . '" alt="' . $j2wp_image['title'] . '" /></a>';
     837  }
     838  mysql_free_result($result);
     839
     840  $j2wp_wp_tb_prefix = get_option('j2wp_wp_tb_prefix');
     841  j2wp_do_wp_connect();
     842
     843  //  create post
     844  $wp_post = array(
     845        'post_author' => $user_id,
     846        'post_category' => array($joomgallery_cat),
     847        'post_content' => $post_content,
     848        'post_title' => $jcat['name'],
     849        'post_status' => 'publish',
     850        'comment_status' => 'open',
     851        'ping_status' => 'open',
     852        'post_name' => sanitize_title($jcat['name']),
     853        'post_type' => 'post'
     854      );
     855
     856  /*
     857        'post_date'     => NULL,
     858        'post_date_gmt' => NULL,
     859        'post_modified' => NULL,
     860        'post_modified_gmt' => NULL,
     861    */
     862
     863  wp_insert_post( $wp_post );             
     864 
     865  echo '<br />Post created.<br />' . "\n";
     866
     867  return;
     868}
    644869
    645870
  • joomla-to-wordpress-migrator/trunk/joomla2wp-output.php

    r326743 r508223  
    1111  echo '  </div>' . "\n";
    1212
    13   ob_flush();
    14   ob_end_clean();
     13  flush();
    1514
    1615  return;
Note: See TracChangeset for help on using the changeset viewer.