b2evolution PHP Cross Reference Blogging Systems

Source: /inc/files/views/_file_browse.view.php - 428 lines - 13483 bytes - Text - Print

Description: This file implements the UI for file browsing. 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 file browsing.
   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   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * Daniel HAHLER grants Francois PLANQUE the right to license
  22   * Daniel HAHLER's contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package admin
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author blueyed: Daniel HAHLER.
  30   * @author fplanque: Francois PLANQUE.
  31   *
  32   * @version $Id: _file_browse.view.php 6136 2014-03-08 07:59:48Z manuel $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  /**
  37   * @var Filelist
  38   */
  39  global $fm_Filelist;
  40  /**
  41   * @var FileRootCache
  42   */
  43  global $FileRootCache;
  44  /**
  45   * @var string
  46   */
  47  global $fm_flatmode;
  48  /**
  49   * @var User
  50   */
  51  global $current_User;
  52  /**
  53   * @var GeneralSettings
  54   */
  55  global $Settings;
  56  
  57  global $UserSettings;
  58  
  59  global $fm_hide_dirtree, $create_name, $ads_list_path, $rsc_url;
  60  
  61  global $fm_FileRoot, $path;
  62  
  63  /**
  64   * @var Link Owner
  65   */
  66  global $LinkOwner;
  67  
  68  global $edited_User;
  69  
  70  global $blog;
  71  
  72  if( isset( $edited_User ) )
  73  {    // Display a help notice for setting a new avatar:
  74      printf( '<div>'.T_( 'Click on a link %s icon below to select the image to use as your profile picture.' )
  75                     .'</div>', get_icon( 'link', 'imgtag', array( 'class'=>'top' ) ) );
  76  }
  77  ?>
  78  
  79  <!-- FILE BROWSER -->
  80  
  81  <?php
  82      $Widget = new Widget( 'file_browser' );
  83  
  84      if( $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) )
  85      {
  86          $Widget->global_icon( /* TRANS: verb */ T_('Upload...'), '', regenerate_url( 'ctrl', 'ctrl=upload' ), /* TRANS: verb */ T_('Upload ').' &raquo;', 1, 5 );
  87      }
  88  
  89      if( ! empty( $LinkOwner ) )
  90      { // Display a link to close file browser and return to post editing:
  91          $close_link_params = array();
  92          global $mode;
  93          if( $mode == 'upload' )
  94          { // Initialize JavaScript function to close popup window
  95              echo '<script type="text/javascript">
  96              function close_popup_window()
  97              {
  98                  window.close();
  99              }
 100              </script>';
 101              $close_link_params['onclick'] = 'return close_popup_window()';
 102          }
 103  
 104          $Widget->global_icon( T_('Close file manager'), 'close', $LinkOwner->get_edit_url(), '', 3, 2, $close_link_params );
 105      }
 106  
 107      $Widget->title = T_('File browser').get_manual_link('file_browser');
 108      $Widget->disp_template_replaced( 'block_start' );
 109  ?>
 110  
 111  <table id="fm_browser" cellspacing="0" cellpadding="0">
 112      <thead>
 113          <tr>
 114              <td colspan="2" id="fm_bar">
 115              <?php
 116                  if( $UserSettings->get( 'fm_allowfiltering' ) != 'no' )
 117                  {
 118                      // Title for checkbox and its label
 119                      $titleRegExp = format_to_output( T_('Filter is a regular expression'), 'formvalue' );
 120  
 121                      echo '<div class="toolbaritem">';
 122  
 123                      $Form = new Form( NULL, 'fmbar_filter_checkchanges', 'get', 'none' );
 124                      $Form->begin_form();
 125                      $Form->hidden_ctrl();
 126                      $Form->hiddens_by_key( get_memorized(), array('fm_filter', 'fm_filter_regex') );
 127                      ?>
 128  
 129                      <label for="fm_filter" class="tooltitle"><?php echo T_('Filter') ?>:</label>
 130                      <input type="text" name="fm_filter" id="fm_filter"
 131                          value="<?php echo format_to_output( $fm_Filelist->get_filter( false ), 'formvalue' ) ?>"
 132                          size="7" accesskey="f" />
 133  
 134                      <?php
 135                          if( $UserSettings->get( 'fm_allowfiltering' ) == 'regexp' )
 136                          {
 137                              ?>
 138                              <input type="checkbox" class="checkbox" name="fm_filter_regex" id="fm_filter_regex" title="<?php echo $titleRegExp; ?>"
 139                                  value="1"<?php if( $fm_Filelist->is_filter_regexp() ) echo ' checked="checked"' ?> />
 140                              <label for="fm_filter_regex" title="<?php echo $titleRegExp; ?>"><?php
 141                                  echo /* TRANS: short for "is regular expression" */ T_('RegExp').'</label>';
 142                          }
 143                      ?>
 144  
 145                      <input type="submit" name="actionArray[filter]" class="SmallButton"
 146                          value="<?php echo format_to_output( T_('Apply'), 'formvalue' ) ?>" />
 147  
 148                      <?php
 149                      if( $fm_Filelist->is_filtering() )
 150                      { // "reset filter" form
 151                          ?>
 152                          <button type="submit" name="actionArray[filter_unset]" value="<?php echo T_('Unset filter'); ?>"
 153                              title="<?php echo T_('Unset filter'); ?>" class="ActionButton" style="background:none;border:none;padding:0;cursor:pointer;"><?php echo get_icon( 'delete' ) ?></button>
 154                          <?php
 155                      }
 156                  $Form->end_form();
 157  
 158                  echo '</div>';
 159              }
 160              ?>
 161  
 162              <!-- ROOTS SELECT -->
 163  
 164              <?php
 165                  $Form = new Form( NULL, 'fmbar_roots', 'post', 'none' );
 166                  $Form->begin_form();
 167                  // $Form->hidden_ctrl();
 168                  $Form->hiddens_by_key( get_memorized() );
 169  
 170                  $rootlist = $FileRootCache->get_available_FileRoots();
 171                  if( count($rootlist) > 1 )
 172                  { // provide list of roots to choose from
 173                      ?>
 174                      <select name="new_root" onchange="this.form.submit();">
 175                      <?php
 176                      $optgroup = '';
 177                      foreach( $rootlist as $l_FileRoot )
 178                      {
 179                          if( ! $current_User->check_perm( 'files', 'view', false, $l_FileRoot ) )
 180                          {
 181                              continue;
 182                          }
 183                          if( ($typegroupname = $l_FileRoot->get_typegroupname()) != $optgroup )
 184                          { // We're entering a new group:
 185                              if( ! empty($optgroup) )
 186                              {
 187                                  echo '</optgroup>';
 188                              }
 189                              echo '<optgroup label="'.T_($typegroupname).'">';
 190                              $optgroup = $typegroupname;
 191                          }
 192                          echo '<option value="'.$l_FileRoot->ID.'"';
 193  
 194                          if( $fm_Filelist->_FileRoot && $fm_Filelist->_FileRoot->ID == $l_FileRoot->ID )
 195                          {
 196                              echo ' selected="selected"';
 197                          }
 198  
 199                          echo '>'.format_to_output( $l_FileRoot->name )."</option>\n";
 200                      }
 201                      if( ! empty($optgroup) )
 202                      {
 203                          echo '</optgroup>';
 204                      }
 205                      ?>
 206                      </select>
 207                      <script type="text/javascript">
 208                          <!--
 209                          // Just to have noscript tag below (which has to know what type it is not for).
 210                          // -->
 211                      </script>
 212                      <noscript>
 213                          <input class="ActionButton" type="submit" value="<?php echo T_('Change root'); ?>" />
 214                      </noscript>
 215  
 216                      <?php
 217                  }
 218  
 219                  /*
 220                   * Display link to display directory tree:
 221                   */
 222                  if( $fm_hide_dirtree )
 223                  {
 224                      echo ' <a href="'.regenerate_url('fm_hide_dirtree', 'fm_hide_dirtree=0').'">'.T_('Display directory tree').'</a>';
 225                  }
 226                  else
 227                  {
 228                      echo ' <a href="'.regenerate_url('fm_hide_dirtree', 'fm_hide_dirtree=1').'">'.T_('Hide directory tree').'</a>';
 229                  }
 230  
 231                  /*
 232                   * Flat mode
 233                   */
 234                  echo ' - ';
 235                  if( $fm_flatmode )
 236                  {
 237                      echo ' <a href="'.regenerate_url('fm_flatmode', 'fm_flatmode=0').'" title="'
 238                                  .T_('View one folder per page').'">'.T_('Folder mode').'</a>';
 239                  }
 240                  else
 241                  {
 242                      echo ' <a href="'.regenerate_url('fm_flatmode', 'fm_flatmode=1').'" title="'
 243                                  .T_('View all files and subfolders on a single page').'">'.T_('Flat mode').'</a>';
 244                  }
 245  
 246                  /*
 247                   * Settings:
 248                   */
 249                  echo ' - <a href="'.regenerate_url('', 'action=edit_settings').'" title="'
 250                                  .T_('Edit display settings').'">'.T_('Display settings').'</a>';
 251  
 252                  $Form->end_form();
 253  
 254  
 255          // -----------------------------------------------
 256          // Display table header: directory location info:
 257          // -----------------------------------------------
 258          echo '<div id="fmbar_cwd">';
 259          // Display current dir:
 260          echo T_('Current dir').': <strong class="currentdir">'.$fm_Filelist->get_cwd_clickable().'</strong>';
 261          echo '</div> ';
 262  
 263          // Display current filter:
 264          if( $fm_Filelist->is_filtering() )
 265          {
 266              echo '<div id="fmbar_filter">';
 267              echo '[<em class="filter">'.$fm_Filelist->get_filter().'</em>]';
 268              // TODO: maybe clicking on the filter should open a JS popup saying "Remove filter [...]? Yes|No"
 269              echo '</div> ';
 270          }
 271  
 272  
 273          // The hidden reload button, which gets displayed if a popup detects that the displayed files have changed
 274          ?>
 275          <span style="display:none;" id="fm_reloadhint">
 276              <a href="<?php echo regenerate_url() ?>"
 277                  title="<?php echo T_('A popup has discovered that the displayed content of this window is not up to date. Click to reload.'); ?>">
 278                  <?php echo get_icon( 'refresh' ) ?>
 279              </a>
 280          </span>
 281  
 282          <?php
 283          // Display number of directories/files:
 284          ?>
 285  
 286          <div id="fmbar_filecounts" title="<?php printf( T_('%s bytes'), number_format($fm_Filelist->count_bytes()) ); ?>"> (<?php
 287              disp_cond( $fm_Filelist->count_dirs(), T_('One directory'), T_('%d directories'), T_('No directories') );
 288              echo ', ';
 289              disp_cond( $fm_Filelist->count_files(), T_('One file'), T_('%d files'), T_('No files' ) );
 290              echo ', '.bytesreadable( $fm_Filelist->count_bytes() );
 291              ?>
 292              )
 293          </div>
 294  
 295              </td>
 296          </tr>
 297      </thead>
 298  
 299      <tbody>
 300          <tr>
 301              <?php
 302                  // ______________________________ Directory tree ______________________________
 303                  if( ! $fm_hide_dirtree )
 304                  {
 305                      echo '<td id="fm_dirtree">';
 306  
 307                      // Version with all roots displayed
 308                      //echo get_directory_tree( NULL, NULL, $ads_list_path );
 309  
 310                      // Version with only the current root displayed:
 311                      echo get_directory_tree( $fm_Filelist->_FileRoot, $fm_Filelist->_FileRoot->ads_path, $ads_list_path );
 312  
 313                      echo '</td>';
 314                  }
 315  
 316                  echo '<td id="fm_files">';
 317  
 318                  // ______________________________ Toolbar ______________________________
 319                  // Start capturing toolbar panel
 320                  @ob_start();
 321  
 322                  echo '<div class="fileman_toolbars_bottom">';
 323  
 324                  /*
 325                   * CREATE FILE/FOLDER TOOLBAR:
 326                   */
 327                  if( ($Settings->get( 'fm_enable_create_dir' ) || $Settings->get( 'fm_enable_create_file' ))
 328                              && $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) )
 329                  { // dir or file creation is enabled and we're allowed to add files:
 330                      global $create_type;
 331  
 332                      echo '<div class="toolbaritem">';
 333                      $Form = new Form( NULL, '', 'post', 'none' );
 334                      $Form->begin_form();
 335                          $Form->hidden( 'action', 'createnew' );
 336                          $Form->add_crumb( 'file' );
 337                          $Form->hidden_ctrl();
 338                          $Form->hiddens_by_key( get_memorized() );
 339                          if( ! $Settings->get( 'fm_enable_create_dir' ) )
 340                          {    // We can create files only:
 341                              echo '<label for="fm_createname" class="tooltitle">'.T_('New file:').'</label>';
 342                              echo '<input type="hidden" name="create_type" value="file" />';
 343                          }
 344                          elseif( ! $Settings->get( 'fm_enable_create_file' ) )
 345                          {    // We can create directories only:
 346                              echo '<label for="fm_createname" class="tooltitle">'.T_('New folder:').'</label>';
 347                              echo '<input type="hidden" name="create_type" value="dir" />';
 348                          }
 349                          else
 350                          {    // We can create both files and directories:
 351                              echo T_('New').': ';
 352                              echo '<select name="create_type">';
 353                              echo '<option value="dir"';
 354                              if( isset($create_type) &&  $create_type == 'dir' )
 355                              {
 356                                  echo ' selected="selected"';
 357                              }
 358                              echo '>'.T_('folder').'</option>';
 359  
 360                              echo '<option value="file"';
 361                              if( isset($create_type) && $create_type == 'file' )
 362                              {
 363                                  echo ' selected="selected"';
 364                              }
 365                              echo '>'.T_('file').'</option>';
 366                              echo '</select>:';
 367                          }
 368                      ?>
 369                      <input type="text" name="create_name" id="fm_createname" value="<?php
 370                          if( isset( $create_name ) )
 371                          {
 372                              echo $create_name;
 373                          } ?>" size="15" />
 374                      <input class="ActionButton" type="submit" value="<?php echo format_to_output( T_('Create!'), 'formvalue' ) ?>" />
 375                      <?php
 376                      $Form->end_form();
 377                      echo '</div>';
 378                  }
 379  
 380  
 381                  /*
 382                   * UPLOAD:
 383                   */
 384                  if( $Settings->get('upload_enabled') && $current_User->check_perm( 'files', 'add', false, $fm_FileRoot ) )
 385                  {    // Upload is enabled and we have permission to use it...
 386                      echo "<!-- QUICK UPLOAD: -->\n";
 387                      echo '<div class="toolbaritem">';
 388                      $Form = new Form( NULL, '', 'post', 'none', 'multipart/form-data' );
 389                      $Form->begin_form();
 390                          $Form->add_crumb( 'file' );
 391                          $Form->hidden( 'ctrl', 'upload' );
 392                          $Form->hidden( 'upload_quickmode', 1 );
 393                          $Form->hidden( 'tab3_onsubmit', 'standard' );
 394                          // The following is mainly a hint to the browser.
 395                          $Form->hidden( 'MAX_FILE_SIZE', $Settings->get( 'upload_maxkb' )*1024 );
 396                          $Form->hiddens_by_key( get_memorized('ctrl') );
 397                          echo '<div>';
 398                          echo '<input name="uploadfile[]" type="file" size="10" />';
 399                          echo '<input class="ActionButton" type="submit" value="&gt; '.T_('Quick upload!').'" />';
 400                          echo '</div>';
 401                      $Form->end_form();
 402                      echo '</div>';
 403                  }
 404  
 405                  echo '</div>';
 406                  echo '<div class="clear"></div>';
 407  
 408                  // Get captured toolbar panel
 409                  $toobar_panel = @ob_get_clean();
 410  
 411                  // Display the toolbar
 412                  echo $toobar_panel;
 413  
 414                  // ______________________________ Files ______________________________
 415                  require dirname(__FILE__).'/_file_list.inc.php';
 416  
 417                  // Display the toolbar
 418                  echo $toobar_panel;
 419  
 420                  echo '</td>'
 421              ?>
 422          </tr>
 423      </tbody>
 424  </table>
 425  
 426  <?php
 427      $Widget->disp_template_raw( 'block_end' );
 428  ?>

title

Description

title

Description

title

Description

title

title

Body