b2evolution PHP Cross Reference Blogging Systems

Source: /inc/tools/views/_wpxml_file.form.php - 146 lines - 4683 bytes - Text - Print

Description: This file display the 1st step of WordPress XML importer

   1  <?php
   2  /**

   3   * This file display the 1st step of WordPress XML importer

   4   *

   5   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.

   9   * Parts of this file are copyright (c)2005 by Daniel HAHLER - {@link http://thequod.de/contact}.

  10   *

  11   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)

  12   *

  13   * @package admin

  14   *

  15   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  16   * @author fplanque: Francois PLANQUE.

  17   *

  18   * @version $Id: _wpxml_file.view.php 505 2011-12-09 20:54:21Z fplanque $

  19   */
  20  
  21  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  22  
  23  global $admin_url, $media_path;
  24  
  25  $Form = new Form( NULL, '', 'post', NULL, 'multipart/form-data' );
  26  
  27  $Form->begin_form( 'fform', T_('WordPress XML Importer') );
  28  
  29  $Form->add_crumb( 'wpxml' );
  30  $Form->hidden_ctrl();
  31  $Form->hidden( 'action', 'import' );
  32  
  33  // Get available files to import from the folder /media/import/

  34  $import_files = wpxml_get_import_files();
  35  
  36  $Table = new Table( NULL, 'import' );
  37  
  38  $Table->cols = array(
  39      array( 'th' => T_('Import'), 'td_class' => 'shrinkwrap' ),
  40      array( 'th' => T_('File') ),
  41      array( 'th' => T_('Type') ),
  42      array( 'th' => T_('Uploaded'), 'td_class' => 'shrinkwrap' ),
  43  );
  44  
  45  $Table->title = T_('Potential files to be imported').get_manual_link('file-importer');
  46  $Table->title .= ' - '.action_icon( T_('Refresh'), 'refresh', $admin_url.'?ctrl=wpimportxml', T_('Refresh'), 3, 4 );
  47  $Table->display_init();
  48  // TABLE START:

  49  $Table->display_list_start();
  50  // TITLE:

  51  $Table->display_head();
  52  
  53  if( empty( $import_files ) )
  54  { // No files to import
  55  
  56      // BODY START:

  57      $Table->display_body_start();
  58  
  59      $Table->display_line_start();
  60      $Table->display_col_start();
  61      echo '<p class="center">'.T_('We have not found any suitable file to perform the blog import. Please read the details at the manual page.').get_manual_link('file-importer').'</p>';
  62      $Table->display_col_end();
  63      $Table->display_line_end();
  64  }
  65  else
  66  { // Display the files to import in table
  67  
  68      // COLUMN HEADERS:

  69      $Table->display_col_headers();
  70      // BODY START:

  71      $Table->display_body_start();
  72  
  73      foreach( $import_files as $import_file )
  74      {
  75          $Table->display_line_start();
  76  
  77          // Checkbox to import

  78          $Table->display_col_start();
  79          echo '<input type="radio" name="wp_file" value="'.$import_file['path'].'"'.( get_param( 'wp_file' ) == $import_file['path'] ? ' checked="checked"' : '' ).' />';
  80          $Table->display_col_end();
  81  
  82          // File

  83          $Table->display_col_start();
  84          echo basename( $import_file['path'] );
  85          $Table->display_col_end();
  86  
  87          // Type

  88          $Table->display_col_start();
  89          echo $import_file['type'];
  90          $Table->display_col_end();
  91  
  92          // File date

  93          $Table->display_col_start();
  94          echo date( locale_datefmt().' '.locale_timefmt(), filemtime( $import_file['path'] ) );
  95          $Table->display_col_end();
  96  
  97          $Table->display_line_end();
  98  
  99          evo_flush();
 100      }
 101  }
 102  
 103  // BODY END / TABLE END:

 104  $Table->display_body_end();
 105  $Table->display_list_end();
 106  
 107  
 108  if( ! empty( $import_files ) )
 109  {
 110      $Form->begin_fieldset( T_('Select a blog for import') );
 111  
 112      $BlogCache = & get_BlogCache();
 113      $BlogCache->load_all( 'shortname,name', 'ASC' );
 114      $BlogCache->none_option_text = '&nbsp;';
 115  
 116      $Form->select_input_object( 'wp_blog_ID', param( 'wp_blog_ID', 'integer', 0 ), $BlogCache, T_('Blog for import'), array(
 117              'note' => T_('This blog will be used for import.').' <a href="'.$admin_url.'?ctrl=collections&action=new">'.T_('Create new blog').' &raquo;</a>',
 118              'allow_none' => true,
 119              'required' => true,
 120              'loop_object_method' => 'get_extended_name' ) );
 121  
 122      $Form->radio_input( 'import_type', param( 'import_type', 'string', 'replace' ), array(
 123                  array(
 124                      'value' => 'replace',
 125                      'label' => T_('Replace existing contents'),
 126                      'note'  => T_('WARNING: this option will permanently remove existing Posts, comments, categories and tags from the selected blog.') ),
 127                  array(
 128                      'value' => 'append',
 129                      'label' => T_('Append to existing contents') ),
 130              ), '', array( 'lines' => true ) );
 131  
 132      $Form->end_fieldset();
 133  
 134      $Form->buttons( array( array( 'submit', 'submit', T_('Continue !'), 'SaveButton' ),
 135                                               array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 136  }
 137  
 138  $Form->end_form();
 139  
 140  ?>
 141  <script type="text/javascript">
 142  jQuery( '.table_scroll td' ).click( function()
 143  {
 144      jQuery( this ).parent().find( 'input[type=radio]' ).attr( 'checked', 'checked' );
 145  } );
 146  </script>

title

Description

title

Description

title

Description

title

title

Body