b2evolution PHP Cross Reference Blogging Systems

Source: /inc/files/views/_file_list.inc.php - 694 lines - 22934 bytes - Summary - 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_list.inc.php 6363 2014-03-27 13:10:09Z yura $
  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   * fp> Temporary. I need this for NuSphere debugging.
  42   * @var File
  43   */
  44  global $lFile;
  45  /**
  46   * @var string
  47   */
  48  global $fm_flatmode;
  49  /**
  50   * @var User
  51   */
  52  global $current_User;
  53  /**
  54   * @var UserSettings
  55   */
  56  global $UserSettings;
  57  /**
  58   * @var Log
  59   */
  60  global $Messages;
  61  /**
  62   * @var Filelist
  63   */
  64  global $selected_Filelist;
  65  /**
  66   * @var Link Owner
  67   */
  68  global $LinkOwner;
  69  
  70  global $edited_User;
  71  
  72  global $Blog, $blog;
  73  
  74  global $fm_mode, $fm_hide_dirtree, $create_name, $ads_list_path, $mode;
  75  
  76  // Abstract data we want to pass through:
  77  global $linkctrl, $linkdata;
  78  
  79  // Name of the iframe we want some actions to come back to:
  80  global $iframe_name;
  81  
  82  $Form = new Form( NULL, 'FilesForm', 'post', 'none' );
  83  $Form->begin_form();
  84      $Form->hidden_ctrl();
  85  
  86      $Form->hidden( 'confirmed', '0' );
  87      $Form->hidden( 'md5_filelist', $fm_Filelist->md5_checksum() );
  88      $Form->hidden( 'md5_cwd', md5($fm_Filelist->get_ads_list_path()) );
  89      $Form->hiddens_by_key( get_memorized('fm_selected') ); // 'fm_selected' gets provided by the form itself
  90  ?>
  91  <table class="filelist">
  92      <thead>
  93      <?php
  94          /*****************  Col headers  ****************/
  95  
  96          echo '<tr>';
  97  
  98          // "Go to parent" icon
  99          echo '<th class="firstcol">';
 100          if( empty($fm_Filelist->_rds_list_path) )
 101          { // cannot go higher
 102              echo '&nbsp;';    // for IE
 103          }
 104          else
 105          {
 106              echo action_icon( T_('Go to parent folder'), 'folder_parent', regenerate_url( 'path', 'path='.$fm_Filelist->_rds_list_path.'..' ) );
 107          }
 108          echo '</th>';
 109  
 110          echo '<th class="nowrap">';
 111          if( $UserSettings->get( 'fm_imglistpreview' ) )
 112          { // Image file preview:
 113              $col_title = T_('Icon/Type');
 114          }
 115          else
 116          {
 117              $col_title = /* TRANS: short for (file)Type */ T_('T ');        // Not to be confused with T for Tuesday
 118          }
 119          echo $fm_Filelist->get_sort_link( 'type', $col_title );
 120          echo '</th>';
 121  
 122          if( $fm_flatmode )
 123          {
 124              echo '<th>'.$fm_Filelist->get_sort_link( 'path', /* TRANS: file/directory path */ T_('Path') ).'</th>';
 125          }
 126  
 127          echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'name', /* TRANS: file name */ T_('Name') ).'</th>';
 128  
 129          if( $UserSettings->get('fm_showtypes') )
 130          { // Show file types column
 131              echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'type', /* TRANS: file type */ T_('Type') ).'</th>';
 132          }
 133  
 134          echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'size', /* TRANS: file size */ T_('Size') ).'</th>';
 135  
 136          if( $UserSettings->get('fm_showdate') != 'no' )
 137          { // Show last mod column
 138              echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'lastmod', /* TRANS: file's last change / timestamp */ T_('Last change') ).'</th>';
 139          }
 140  
 141          if( $UserSettings->get('fm_showfsperms') )
 142          { // Show file perms column
 143              echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'perms', /* TRANS: file's permissions (short) */ T_('Perms') ).'</th>';
 144          }
 145  
 146          if( $UserSettings->get('fm_showfsowner') )
 147          { // Show file owner column
 148              echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'fsowner', /* TRANS: file owner */ T_('Owner') ).'</th>';
 149          }
 150  
 151          if( $UserSettings->get('fm_showfsgroup') )
 152          { // Show file group column
 153              echo '<th class="nowrap">'.$fm_Filelist->get_sort_link( 'fsgroup', /* TRANS: file group */ T_('Group') ).'</th>';
 154          }
 155  
 156          echo '<th class="lastcol nowrap">'. /* TRANS: file actions; edit, rename, copy, .. */ T_('Actions').'</th>';
 157          echo '</tr>';
 158      ?>
 159      </thead>
 160  
 161      <tbody>
 162      <?php
 163      $checkall = param( 'checkall', 'integer', 0 );  // Non-Javascript-CheckAll
 164      $fm_highlight = param( 'fm_highlight', 'string', NULL );
 165  
 166      // Set FileList perms
 167      $all_perm = $current_User->check_perm( 'files', 'all', false );
 168      $edit_perm = $current_User->check_perm( 'files', 'edit', false, $fm_Filelist->get_FileRoot() );
 169  
 170      /***********************************************************/
 171      /*                    MAIN FILE LIST:                      */
 172      /***********************************************************/
 173      $countFiles = 0;
 174      while( $lFile = & $fm_Filelist->get_next() )
 175      { // Loop through all Files:
 176          echo '<tr class="'.($countFiles%2 ? 'odd' : 'even').'"';
 177  
 178          if( isset($fm_highlight) && $lFile->get_name() == $fm_highlight )
 179          { // We want a specific file to be highlighted (user clicked on "locate"/target icon
 180              echo ' id="fm_highlighted"'; // could be a class, too..
 181          }
 182          echo '>';
 183  
 184  
 185          /********************    Checkbox:    *******************/
 186  
 187          echo '<td class="checkbox firstcol">';
 188          echo '<span name="surround_check" class="checkbox_surround_init">';
 189          echo '<input title="'.T_('Select this file').'" type="checkbox" class="checkbox"
 190                      name="fm_selected[]" value="'.rawurlencode($lFile->get_rdfp_rel_path()).'" id="cb_filename_'.$countFiles.'"';
 191          if( $checkall || $selected_Filelist->contains( $lFile ) )
 192          {
 193              echo ' checked="checked"';
 194          }
 195          echo ' />';
 196          echo '</span>';
 197  
 198          /***********  Hidden info used by Javascript:  ***********/
 199  
 200          if( $mode == 'upload' )
 201          {    // This mode allows to insert img tags into the post...
 202              // Hidden info used by Javascript:
 203              echo '<input type="hidden" name="img_tag_'.$countFiles.'" id="img_tag_'.$countFiles
 204                  .'" value="'.format_to_output( $lFile->get_tag(), 'formvalue' ).'" />';
 205          }
 206  
 207          echo '</td>';
 208  
 209  
 210          /********************  Icon / File type:  *******************/
 211  
 212          echo '<td class="icon_type">';
 213          if( $UserSettings->get( 'fm_imglistpreview' ) )
 214          {    // Image preview OR full type:
 215              if( $lFile->is_dir() )
 216              { // Navigate into Directory
 217                  echo '<a href="'.$lFile->get_view_url().'" title="'.T_('Change into this directory').'">'.$lFile->get_icon().' '.T_('Directory').'</a>';
 218              }
 219              else
 220              {
 221                  echo $lFile->get_preview_thumb( 'fulltype', true );
 222              }
 223          }
 224          else
 225          {    // No image preview, small type:
 226               if( $lFile->is_dir() )
 227              { // Navigate into Directory
 228                  echo '<a href="'.$lFile->get_view_url().'" title="'.T_('Change into this directory').'">'.$lFile->get_icon().'</a>';
 229              }
 230              else
 231              { // File
 232                  echo $lFile->get_view_link( $lFile->get_icon(), NULL, $lFile->get_icon() );
 233              }
 234          }
 235          echo '</td>';
 236  
 237          /*******************  Path (flatmode): ******************/
 238  
 239          if( $fm_flatmode )
 240          {
 241              echo '<td class="filepath">';
 242              echo dirname($lFile->get_rdfs_rel_path()).'/';
 243              echo '</td>';
 244          }
 245  
 246  
 247          echo '<td class="fm_filename">';
 248  
 249              /*************  Invalid filename warning:  *************/
 250  
 251              if( !$lFile->is_dir() )
 252              {
 253                  if( $error_filename = validate_filename( $lFile->get_name() ) )
 254                  { // TODO: Warning icon with hint
 255                      echo get_icon( 'warning', 'imgtag', array( 'class' => 'filenameIcon', 'title' => $error_filename ) );
 256                  }
 257              }
 258              elseif( $error_dirname = validate_dirname( $lFile->get_name() ) )
 259              { // TODO: Warning icon with hint
 260                  echo get_icon( 'warning', 'imgtag', array( 'class' => 'filenameIcon', 'title' => $error_dirname ) );
 261              }
 262  
 263              /****  Open in a new window  (only directories)  ****/
 264  
 265              if( $lFile->is_dir() )
 266              { // Directory
 267                  $browse_dir_url = $lFile->get_view_url();
 268                  $popup_url = url_add_param( $browse_dir_url, 'mode=popup' );
 269                  $target = 'evo_fm_'.$lFile->get_md5_ID();
 270  
 271                  echo '<a href="'.$browse_dir_url.'" target="'.$target.' " class="filenameIcon"
 272                              title="'.T_('Open in a new window').'" onclick="'
 273                              ."return pop_up_window( '$popup_url', '$target' )"
 274                              .'">'.get_icon( 'window_new' ).'</a>';
 275              }
 276  
 277              /***************  Link ("chain") icon:  **************/
 278  
 279              // if( ! $lFile->is_dir() )    // fp> OK but you need to include an else:placeholder, otherwise the display is ugly
 280              {    // Only provide link/"chain" icons for files.
 281                  // TODO: dh> provide support for direcories (display included files).
 282  
 283                  // fp> here might not be the best place to put the perm check
 284                  if( isset( $LinkOwner ) && $LinkOwner->check_perm( 'edit' ) )
 285                  {    // Offer option to link the file to an Item (or anything else):
 286                      $link_attribs = array();
 287                      $link_action = 'link';
 288                      if( $mode == 'upload' )
 289                      {    // We want the action to happen in the post attachments iframe:
 290                          $link_attribs['target'] = $iframe_name;
 291                          $link_action = 'link_inpost';
 292                      }
 293                      echo action_icon( T_('Link this file!'), 'link',
 294                                  regenerate_url( 'fm_selected', 'action='.$link_action.'&amp;fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path()).'&amp;'.url_crumb('file') ),
 295                                  NULL, NULL, NULL, $link_attribs );
 296                      echo ' ';
 297                  }
 298  
 299                  if( isset($edited_User) ) // fp> Perm already checked in controller
 300                  {    // Offer option to link the file to an Item (or anything else):
 301                      if( $lFile->is_image() )
 302                      {
 303                          echo action_icon( T_('Use this as my profile picture!'), 'link',
 304                                      regenerate_url( 'fm_selected', 'action=link_user&amp;fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path()).'&amp;'.url_crumb('file') ),
 305                                      NULL, NULL, NULL, array() );
 306                          echo ' ';
 307                      }
 308                  }
 309                  elseif( !$lFile->is_dir() && ! empty( $linkctrl ) && ! empty( $linkdata ) )
 310                  {
 311                      echo action_icon( T_('Link this file!'), 'link',
 312                                  regenerate_url( 'fm_selected', 'action=link_data&amp;fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path()).'&amp;'.url_crumb('file') ),
 313                                  NULL, NULL, NULL, array() );
 314  
 315                      echo ' ';
 316                  }
 317              }
 318  
 319              /********************  Filename  ********************/
 320  
 321              if( $lFile->is_dir() )
 322              { // Directory
 323                  // Link to open the directory in the curent window
 324                  echo '<a href="'.$browse_dir_url.'">'.$lFile->dget('name').'</a>';
 325              }
 326              else
 327              { // File
 328                  if( $view_link = $lFile->get_view_link( $lFile->get_name(), NULL, NULL ) )
 329                  {
 330                      echo $view_link;
 331                  }
 332                  else
 333                  { // File extension unrecognized
 334                      echo $lFile->dget('name');
 335                  }
 336              }
 337  
 338              /***************  File meta data:  **************/
 339  
 340              echo '<span class="filemeta">';
 341              // Optionally display IMAGE pixel size:
 342              if( $UserSettings->get( 'fm_getimagesizes' ) )
 343              {
 344                  echo ' ('.$lFile->get_image_size( 'widthxheight' ).')';
 345              }
 346              // Optionally display meta data title:
 347              if( $lFile->meta == 'loaded' )
 348              {    // We have loaded meta data for this file:
 349                  echo ' - '.$lFile->title;
 350              }
 351              echo '</span>';
 352  
 353          echo '</td>';
 354  
 355          /*******************  File type  ******************/
 356  
 357          if( $UserSettings->get('fm_showtypes') )
 358          { // Show file types
 359              echo '<td class="type">'.$lFile->get_type().'</td>';
 360          }
 361  
 362          /*******************  File size  ******************/
 363  
 364          echo '<td class="size">'.$fm_Filelist->get_File_size_formatted($lFile).'</td>';
 365  
 366          /****************  File time stamp  ***************/
 367  
 368          if( $UserSettings->get('fm_showdate') != 'no' )
 369          { // Show last modified datetime (always full in title attribute)
 370              $lastmod_date = $lFile->get_lastmod_formatted( 'date' );
 371              $lastmod_time = $lFile->get_lastmod_formatted( 'time' );
 372              echo '<td class="timestamp" title="'.$lastmod_date.' '.$lastmod_time.'">';
 373              if( $UserSettings->get('fm_showdate') == 'long' )
 374              {
 375                  echo '<span class="date">'.$lastmod_date.'</span> ';
 376                  echo '<span class="time">'.$lastmod_time.'</span>';
 377              }
 378              else
 379              {    // Compact format
 380                  echo $lFile->get_lastmod_formatted( 'compact' );
 381              }
 382              echo '</td>';
 383          }
 384  
 385          /****************  File pemissions  ***************/
 386  
 387          if( $UserSettings->get('fm_showfsperms') )
 388          { // Show file perms
 389              echo '<td class="perms">';
 390              $fm_permlikelsl = $UserSettings->param_Request( 'fm_permlikelsl', 'fm_permlikelsl', 'integer', 0 );
 391  
 392              if( $current_User->check_perm( 'files', 'edit', false, $blog ? $blog : NULL ) )
 393              { // User can edit:
 394                  echo '<a title="'.T_('Edit permissions').'" href="'.regenerate_url( 'fm_selected,action', 'action=edit_perms&amp;fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path()) ).'">'
 395                              .$lFile->get_perms( $fm_permlikelsl ? 'lsl' : '' ).'</a>';
 396              }
 397              else
 398              {
 399                  echo $lFile->get_perms( $fm_permlikelsl ? 'lsl' : '' );
 400              }
 401              echo '</td>';
 402          }
 403  
 404          /****************  File owner  ********************/
 405  
 406          if( $UserSettings->get('fm_showfsowner') )
 407          { // Show file owner
 408              echo '<td class="fsowner">';
 409              echo $lFile->get_fsowner_name();
 410              echo '</td>';
 411          }
 412  
 413          /****************  File group *********************/
 414  
 415          if( $UserSettings->get('fm_showfsgroup') )
 416          { // Show file owner
 417              echo '<td class="fsgroup">';
 418              echo $lFile->get_fsgroup_name();
 419              echo '</td>';
 420          }
 421  
 422          /*****************  Action icons  ****************/
 423  
 424          echo '<td class="actions lastcol">';
 425  
 426          if( $edit_perm )
 427          { // User can edit:
 428              if( $lFile->is_editable( $all_perm ) )
 429              {
 430                  echo action_icon( T_('Edit file...'), 'edit', regenerate_url( 'fm_selected', 'action=edit_file&amp;'.url_crumb('file').'&amp;fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path()) ) );
 431              }
 432              else
 433              {
 434                  echo get_icon( 'edit', 'noimg' );
 435              }
 436          }
 437  
 438          if( $edit_perm )
 439          { // User can edit:
 440              echo action_icon( T_('Edit properties...'), 'properties', regenerate_url( 'fm_selected', 'action=edit_properties&amp;fm_selected[]='.rawurlencode($lFile->get_rdfp_rel_path() ).'&amp;'.url_crumb('file') ) );
 441              echo action_icon( T_('Move'), 'file_move', regenerate_url( 'fm_mode,fm_sources,fm_sources_root', 'fm_mode=file_move&amp;fm_sources[]='.rawurlencode( $lFile->get_rdfp_rel_path() ).'&amp;fm_sources_root='.$fm_Filelist->_FileRoot->ID ) );
 442              echo action_icon( T_('Copy'), 'file_copy', regenerate_url( 'fm_mode,fm_sources,fm_sources_root', 'fm_mode=file_copy&amp;fm_sources[]='.rawurlencode( $lFile->get_rdfp_rel_path() ).'&amp;fm_sources_root='.$fm_Filelist->_FileRoot->ID ) );
 443              echo action_icon( T_('Delete'), 'file_delete', regenerate_url( 'fm_selected', 'action=delete&amp;fm_selected[]='.rawurlencode( $lFile->get_rdfp_rel_path() ).'&amp;'.url_crumb('file') ) );
 444          }
 445          echo '</td>';
 446  
 447          echo '</tr>';
 448  
 449          $countFiles++;
 450      }
 451      // / End of file list..
 452  
 453  
 454      /**
 455       * @global integer Number of cols for the files table, 6 is minimum.
 456       */
 457      $filetable_cols = 5
 458          + (int)$fm_flatmode
 459          + (int)$UserSettings->get('fm_showtypes')
 460          + (int)($UserSettings->get('fm_showdate') != 'no')
 461          + (int)$UserSettings->get('fm_showfsperms')
 462          + (int)$UserSettings->get('fm_showfsowner')
 463          + (int)$UserSettings->get('fm_showfsgroup')
 464          + (int)$UserSettings->get('fm_imglistpreview');
 465  
 466  
 467      if( $countFiles == 0 )
 468      { // Filelist errors or "directory is empty"
 469          ?>
 470  
 471          <tr>
 472              <td class="firstcol">&nbsp;</td> <?php /* blueyed> This empty column is needed so that the defaut width:100% style of the main column below makes the column go over the whole screen */ ?>
 473              <td class="lastcol" colspan="<?php echo $filetable_cols - 1 ?>" id="fileman_error">
 474                  <?php
 475                      if( ! $Messages->has_errors() )
 476                      { // no Filelist errors, the directory must be empty
 477                          $Messages->clear();
 478                          $Messages->add( T_('No files found.')
 479                              .( $fm_Filelist->is_filtering() ? '<br />'.T_('Filter').': &laquo;'.$fm_Filelist->get_filter().'&raquo;' : '' ), 'error' );
 480                          $Messages->display( '', '' );
 481                      }
 482                  ?>
 483              </td>
 484          </tr>
 485  
 486          <?php
 487      }
 488      else
 489      {
 490          // -------------
 491          // Footer with "check all", "with selected: ..":
 492          // --------------
 493          ?>
 494          <tr class="listfooter firstcol lastcol">
 495              <td colspan="<?php echo $filetable_cols ?>">
 496  
 497              <?php
 498              echo $Form->check_all();
 499              $Form->add_crumb( 'file' );
 500  
 501              $field_options = array();
 502  
 503              /*
 504               * TODO: fp> the following is a good idea but in case we also have $mode == 'upload' it currently doesn't refresh the list of attachements
 505               * which makes it seem like this feature is broken. Please add necessary javascript for this.
 506               */
 507              if( $fm_mode == 'link_object' && $mode != 'upload' )
 508              {    // We are linking to an object...
 509                  $field_options['link'] = $LinkOwner->translate( 'Link files to current owner' );
 510              }
 511  
 512              if( $mode != 'upload' && ($fm_Filelist->get_root_type() == 'collection' || !empty($Blog))
 513                  && $current_User->check_perm( 'admin', 'normal' ) )
 514              {    // We are browsing files for a collection:
 515                  // User must have access to admin permission
 516                  // fp> TODO: use current as default but let user choose into which blog he wants to post
 517                  $field_options['make_post'] = T_('Make one post (including all images)');
 518                  $field_options['make_posts_pre'] = T_('Make multiple posts (1 per image)');
 519              }
 520  
 521              if( $mode == 'upload' )
 522              {    // We are uploading in a popup opened by an edit screen
 523                  $field_options['img_tag'] = T_('Insert IMG/link into post');
 524              }
 525  
 526              if( $edit_perm )
 527              { // User can edit:
 528                  $field_options['rename'] = T_('Rename files...');
 529                  $field_options['delete'] = T_('Delete files...');
 530                  // NOTE: No delete confirmation by javascript, we need to check DB integrity!
 531              }
 532  
 533              // BROKEN ?
 534              $field_options['download'] = T_('Download files as ZIP archive...');
 535  
 536              /* Not fully functional:
 537              $field_options['file_copy'] = T_('Copy the selected files...');
 538              $field_options['file_move'] = T_('Move the selected files...');
 539  
 540              // This is too geeky! Default perms radio options and unchecked radio groups! NO WAY!
 541              // If you want this feature to be usable by average users you must only have one line per file OR one file for all. You can't mix both.
 542              // The only way to have both is to have 2 spearate forms: 1 titled "change perms for all files simultaneously"-> submit  and another 1 title "change perms for each file individually" -> another submit
 543              // fplanque>> second thought: changing perms for multiple files at once is useful. BUT assigning different perms to several files with ONE form is trying to solve a problem that not even geeks can face once in a lifetime.
 544              // This has to be simplified to ONE single set of permissions for all selected files. (If you need different perms, click again)
 545              $field_options['file_perms'] = T_('Change permissions for the selected files...');
 546              */
 547  
 548              $Form->switch_layout( 'none' );
 549              $Form->select_input_array( 'group_action', $action, $field_options, ' &mdash; <strong>'.T_('With selected files').'</strong>' );
 550              $Form->submit_input( array( 'name'=>'actionArray[group_action]', 'value'=>T_('Go!'), 'onclick'=>'return js_act_on_selected();' ) );
 551              $Form->switch_layout( NULL );
 552  
 553              /* fp> the following has been integrated into the select.
 554              if( $mode == 'upload' )
 555              {    // We are uploading in a popup opened by an edit screen
 556                  ?>
 557                  &mdash;
 558                  <input class="ActionButton"
 559                      title="<?php echo T_('Insert IMG or link tags for the selected files, directly into the post text'); ?>"
 560                      name="actionArray[img_tag]"
 561                      value="<?php echo T_('Insert IMG/link into post') ?>"
 562                      type="submit"
 563                      onclick="insert_tag_for_selected_files(); return false;" />
 564                  <?php
 565              }
 566              */
 567              ?>
 568              </td>
 569          </tr>
 570          <?php
 571      }
 572      ?>
 573      </tbody>
 574  </table>
 575  <?php
 576      $Form->end_form();
 577  
 578      if( $countFiles )
 579      {{{ // include JS
 580          // TODO: remove these javascript functions to an external .js file and include them through add_headline()
 581          ?>
 582          <script type="text/javascript">
 583              <!--
 584  			function js_act_on_selected()
 585              {
 586                  // There may be an easier selector than below but couldn't make sense of it :(
 587                  selected_value = jQuery('#group_action option:selected').attr('value');
 588                  if( selected_value == 'img_tag' )
 589                  {
 590                      insert_tag_for_selected_files();
 591                      return false;
 592                  }
 593  
 594                  // other actions:
 595  
 596                  if ( selected_value == 'make_posts_pre' )
 597                  {
 598                      jQuery('#FilesForm').append('<input type="hidden" name="ctrl" value="items" />');
 599                  }
 600                  return true;
 601              }
 602  
 603              /**
 604               * Check if files are selected.
 605               *
 606               * This should be used as "onclick" handler for "With selected" actions (onclick="return check_if_selected_files();").
 607               * @return boolean true, if something is selected, false if not.
 608               */
 609  			function check_if_selected_files()
 610              {
 611                  elems = document.getElementsByName( 'fm_selected[]' );
 612                  var checked = 0;
 613                  for( i = 0; i < elems.length; i++ )
 614                  {
 615                      if( elems[i].checked )
 616                      {
 617                          checked++;
 618                      }
 619                  }
 620                  if( !checked )
 621                  {
 622                      alert( '<?php echo TS_('Nothing selected.') ?>' );
 623                      return false;
 624                  }
 625                  else
 626                  {
 627                      return true;
 628                  }
 629              }
 630  
 631              /**
 632               * Insert IMG tags into parent window for selected files.
 633               */
 634  			function insert_tag_for_selected_files()
 635              {
 636                  var elems = document.getElementsByName( 'fm_selected[]' );
 637                  var snippet = '';
 638                  for( i = 0; i < elems.length; i++ )
 639                  {
 640                      if( elems[i].checked )
 641                      {
 642                          id = elems[i].id.substring( elems[i].id.lastIndexOf('_')+1, elems[i].id.length );
 643                          img_tag_info_field = document.getElementById( 'img_tag_'+id );
 644                          snippet += img_tag_info_field.value + '\n';
 645                      }
 646                  }
 647                  if( ! snippet.length )
 648                  {
 649                      alert( '<?php echo TS_('You must select at least one file!') ?>' );
 650                      return false;
 651                  }
 652                  else
 653                  {
 654                      // Remove last newline from snippet:
 655                      snippet = snippet.substring(0, snippet.length-1)
 656                      if (! (window.focus && window.opener))
 657                      {
 658                          return true;
 659                      }
 660                      window.opener.focus();
 661                      textarea_wrap_selection( window.opener.document.getElementById("itemform_post_content"), snippet, '', 1, window.opener.document );
 662                      return true;
 663                  }
 664              }
 665              // -->
 666          </script>
 667          <?php
 668  
 669          if( $fm_highlight )
 670          { // we want to highlight a file (e.g. via "Locate this file!"), scroll there and do the success fade
 671              ?>
 672  
 673              <script type="text/javascript">
 674              jQuery( function() {
 675                  var fm_hl = jQuery("#fm_highlighted");
 676                  if( fm_hl.length ) {
 677                      jQuery.getScript('<?php echo $rsc_url ?>js/jquery/jquery.scrollto.js', function () {
 678                          jQuery.scrollTo( fm_hl,
 679                          { onAfter: function()
 680                              {
 681                                  evoFadeHighlight( fm_hl )
 682                              }
 683                          } );
 684                      });
 685                  }
 686              } );
 687              </script>
 688  
 689              <?php
 690          }
 691  
 692      }}}
 693  ?>
 694  <!-- End of detailed file list -->

title

Description

title

Description

title

Description

title

title

Body