b2evolution PHP Cross Reference Blogging Systems

Source: /inc/files/views/_file_quick_upload.view.php - 172 lines - 6053 bytes - Text - Print

Description: This file implements the UI for quick file upload. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI for quick file upload.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * EVO FACTORY grants Francois PLANQUE the right to license
  21   * EVO FACTORY contributions to this file and the b2evolution project
  22   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  23   * }}
  24   *
  25   * @package admin
  26   *
  27   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  28   * @author efy-asimo: Evo Factory / Attila Simo
  29   *
  30   * @version $Id: _file_quick_upload.view.php 6136 2014-03-08 07:59:48Z manuel $
  31   */
  32  
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  /**
  36   * @var Settings
  37   */
  38  global $Settings;
  39  
  40  global $htsrv_url;
  41  
  42  global $ads_list_path, $fm_FileRoot, $tab3;
  43  
  44  global $Hit, $Messages;
  45  
  46  $this->disp_payload_begin();
  47  
  48  $Form = new Form( NULL, 'fm_upload_checkchanges', 'post' );
  49  $Form->begin_form( 'fform' );
  50  $Form->add_crumb( 'file' );
  51  $Form->hidden_ctrl();
  52  $Form->hidden( 'tab3_onsubmit', $tab3 );
  53  
  54  $Widget = new Widget( 'file_browser' );
  55  $Widget->global_icon( T_('Quit upload mode!'), 'close', regenerate_url( 'ctrl,fm_mode', 'ctrl=files' ) );
  56  $Widget->title = T_('File upload').get_manual_link('upload_multiple');
  57  $Widget->disp_template_replaced( 'block_start' );
  58  
  59  echo '<table id="fm_browser" cellspacing="0" cellpadding="0">';
  60  echo '<tbody>';
  61      echo '<tr>';
  62  
  63      // Display directory tree
  64      echo '<td id="fm_dirtree">';
  65      // Version with all roots displayed
  66      echo get_directory_tree( NULL, NULL, $ads_list_path, true, NULL, false, 'add' );
  67      echo '</td>';
  68  
  69      // Display quick upload
  70      echo '<td id="fm_files">';
  71  
  72      ?>
  73      <div id="file-uploader" style="width: 100%;">
  74          <noscript>
  75              <p>Please enable JavaScript to use file uploader.</p>
  76          </noscript>
  77      </div>
  78      <?php
  79      echo '<input id="saveBtn" type="submit" style="display: none;" name="saveBtn" value="'.T_('Save modified files'),'" class="ActionButton" />';
  80  
  81      $root_and_path = $fm_FileRoot->ID.'::';
  82      $quick_upload_url = $htsrv_url.'quick_upload.php?upload=true';
  83  
  84      ?>
  85      <script type="text/javascript">
  86          if( 'draggable' in document.createElement('span') )
  87          {
  88              var button_text = '<?php echo TS_('Drag & Drop files to upload here <br /><span>or click to manually select files...</span>') ?>';
  89              var note_text = '<?php echo TS_('Your browser supports full upload functionality.') ?>';
  90          }
  91          else
  92          {
  93              var button_text = '<?php echo TS_('Click to manually select files...') ?>';
  94              var note_text = '<?php echo TS_('Your browser does not support full upload functionality: You can only upload files one by one and you cannot use Drag & Drop.') ?>';
  95          }
  96  
  97          var url = <?php echo '"'.$quick_upload_url.'&'.url_crumb( 'file' ).'"'; ?>;
  98          var root_and_path = '<?php echo $root_and_path ?>';
  99  
 100          jQuery( '#fm_dirtree input[type=radio]' ).click( function()
 101          {
 102              url = "<?php echo $quick_upload_url; ?>"+"&root_and_path="+this.value+"&"+"<?php echo url_crumb( 'file' ); ?>";
 103              root_and_path = this.value;
 104              uploader.setParams({root_and_path: root_and_path});
 105          } );
 106  
 107          jQuery(document).ready( function()
 108          {
 109              uploader = new qq.FileUploader(
 110              {
 111                  element: document.getElementById('file-uploader'),
 112                  action: url,
 113                  debug: true,
 114                  //sizeLimit: maxsize,
 115                  onComplete: function(id, fileName, responseJSON)
 116                  {
 117                      var container = jQuery(uploader._getItemByFileId(id));
 118  
 119                      var text =  base64_decode(responseJSON.success.text);
 120                      if (responseJSON.success.specialchars == 1)
 121                      {
 122                          text = htmlspecialchars_decode(text);
 123                      }
 124  
 125                      if (responseJSON.success.status != undefined && responseJSON.success.status == 'rename')
 126                      {
 127                          jQuery('#saveBtn').show();
 128                      }
 129  
 130                      if( responseJSON.success.warning != undefined && responseJSON.success.warning != '' )
 131                      {
 132                          text += '<div class="orange">' + responseJSON.success.warning + '</div>';
 133                      }
 134                      container.append(text);
 135                  },
 136                  onCancel: function(id, fileName){},
 137                  messages: {
 138                      typeError: "{file} has invalid extension. Only {extensions} are allowed.",
 139                      sizeError: "{file} is too large, maximum file size is {sizeLimit}.",
 140                      minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
 141                      emptyError: "{file} is empty, please select files again without it.",
 142                      onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
 143                  },
 144                  showMessage: function(message)
 145                  {
 146                      jQuery('.qq-upload-list').append('<li class=" qq-upload-success"><span class="qq-upload-file"></span><span class="qq-upload-size" style="display: inline;"></span><span class="qq-upload-failed-text">Failed</span><span class="result_error">'+message+'</span></li>')
 147                  },
 148                  template: '<div class="qq-uploader">' +
 149                      '<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
 150                      '<div class="qq-upload-button">'+ button_text +'</div>' +
 151                      '<ul class="qq-upload-list"></ul>' +
 152                  '</div>',
 153                  params: { root_and_path: jQuery( '#fm_dirtree input[type=radio]:checked' ).val() }
 154              });
 155          });
 156  
 157          document.write( '<p class="note">' + note_text + '</p>' );
 158      </script>
 159      <?php
 160      echo '</td>';
 161      echo '</tr>';
 162  echo '</tbody>';
 163  echo '</table>';
 164  
 165  $Widget->disp_template_raw( 'block_end' );
 166  
 167  $Form->end_form();
 168  
 169  // End payload block:
 170  $this->disp_payload_end();
 171  
 172  ?>

title

Description

title

Description

title

Description

title

title

Body