Apache2-FileManager

 view release on metacpan or  search on metacpan

FileManager.pm  view on Meta::CPAN

        var f=window.document.FileManager;
        if (get_num_checked() == 0) {
          window.alert('Please select a file to extract by clicking on a '+
                       'check box with the mouse.');
        } else {
          f.FILEMANAGER_cmd.value='extract';
          f.submit();
        }
        return false;\"
        ><FONT COLOR=WHITE><B>extract</B></FONT></A>",

    #New File
    "<A HREF=# onclick=\"
        var f=window.document.FileManager;
        var rv = window.prompt('new file name','');
        var cd = f.FILEMANAGER_curr_dir.value;
        if (cd != '') {
          rv = cd+'/'+rv;
        }
        if ((rv != null) && (rv != '')) {
          var w = window.open('".r->uri."?FILEMANAGER_cmd=editfile".
                                        "&FILEMANAGER_curr_dir='+escape(cd)+'".
                                        "&FILEMANAGER_editfile='+escape(rv),
                              'FileManagerEditFile',
                              'scrollbars,resizable');
          w.focus();

        } else if (rv == '') {
          window.alert('can not create blank file names');
        }
        return false; \">
        <FONT COLOR=WHITE><B>new file</B></FONT></A>",

    #New Directory
    "<A HREF=# onclick=\"
        var f=window.document.FileManager;
        var rv=window.prompt('new directory name','');
        if ((rv != null) && (rv != '')) {
          f.FILEMANAGER_arg.value=rv;
          f.FILEMANAGER_cmd.value='mkdir';
          f.submit();

        } else if (rv == '') {
          window.alert('can not create blank directory names');
        }
        return false;\"
        ><FONT COLOR=WHITE><B>new directory</B></FONT></A>",

    #Upload
    "<A HREF=# onclick=\"
        window.print_upload();
        return false;\"
        ><FONT COLOR=WHITE><B>upload<B></FONT></A>"
  );

  #Rsync
  my $rsync = "";
  if ($$o{'RSYNC_TO'}) {
    push @cmds,
      "<TD><A HREF=# onclick=\"
          if (window.confirm('Are you sure you want to synchronize with ".
              "the production server?')) {
            var w=window.open('','RSYNC',
                              'scrollbars=yes,resizables=yes,width=400,height=500');
            w.focus();
            var d=w.document.open();
            d.write('<HTML><BODY><BR><BR><BR>".
                    "<CENTER>Please wait synchronizing production server.".
                    "<BR>This could take several minutes.".
                    "</CENTER></BODY></HTML>');
            d.close();
            w.location.replace('".r->uri."?FILEMANAGER_cmd=rsync',
                               'RSYNC',
                               'scrollbars=yes,resizables=yes,width=400,height=500');
          } return false;\"
          ><FONT COLOR=WHITE><B>synchronize</B></FONT></A>";
  }

  return "
    <!-- Actions Tool bar -->
    <TABLE CELLPADDING=0 CELLSPACING=0
           BORDER=0>
      <TR ALIGN=CENTER>
        <TD ALIGN=CENTER>"
    .join("</TD><TD>&nbsp;<B><FONT COLOR=#bcbcbc SIZE=+2>|</FONT>&nbsp;</B>"
         ."</TD><TD>",
         @cmds)
    ."</TD></TR></TABLE>";
}


sub html_file_list {
  my $o = shift;
  my $up_a_href = shift || "";

  my $bgcolor = "efefef";

  #get the list in this directory
  my $curr_dir = "";
  $curr_dir = r->param('FILEMANAGER_curr_dir')."/"
    if (r->param('FILEMANAGER_curr_dir') ne "");

  #if there is a value for the ".." directory, then add a row for that link
  #at the *top* of the list
  my $acum = "";
  if ($up_a_href ne "") {
    $acum = "
        <TR BGCOLOR=#$bgcolor>
        <TD>&nbsp;</TD>
        <TD>$up_a_href</TD>
        <TD ALIGN=CENTER>--</TD>
        <TD ALIGN=CENTER>--</TD>
        </TR>";
    $bgcolor = "ffffff";
  }

  my $ct_rows = 0;

  foreach my $file (sort <*>) {

    my ($link,$last_modified,$size,$type);
    $ct_rows++;

    #if directory?
    if (-d $file) {
      $last_modified = "--";
      $size = "<TD ALIGN=CENTER>--</TD>";
      $type = "/"; # "/" designates "directory"
      $link = "<A HREF=#
                onclick=\"
                  var f=window.document.FileManager;
                  f.FILEMANAGER_curr_dir.value='"
                      .Apache2::Util::escape_path($curr_dir.$file, r->pool)."';
                  f.submit();
                  return false;\">
                <FONT COLOR=#006699>$file$type</FONT></A>";



( run in 0.350 second using v1.01-cache-2.11-cpan-e1769b4cff6 )