html
[ class tree: html ] [ index: html ] [ all elements ]

Source for file FTPUploadApplet.class.php

Documentation is available at FTPUploadApplet.class.php

  1. <?php
  2. /**
  3.  * @package    html
  4.  * @subpackage components
  5.  */
  6.  
  7. /**
  8.  *
  9.  */
  10. include_once CLASSPATH."communication/FTPHost.class.php";
  11.  
  12. /**
  13.  * @package    html
  14.  * @subpackage components
  15.  *
  16.  * @version    1.0
  17.  * @since      0.9.0.8
  18.  * @todo       Functions
  19.  *              file_exists()
  20.  * @author     Daniel Plücken <daniel@debakel.net>
  21.  * @license    http://www.gnu.org/copyleft/lesser.html
  22.  *              GNU Lesser General Public License
  23.  * @copyright  Copyright (C) 2006 Daniel Plücken <daniel@debakel.net>
  24.  *
  25.  *  This library is free software; you can redistribute it and/or
  26.  *  modify it under the terms of the GNU Lesser General Public
  27.  *  License as published by the Free Software Foundation; either
  28.  *  version 2.1 of the License.
  29.  *
  30.  *  This library is distributed in the hope that it will be useful,
  31.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  32.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33.  *  GNU Lesser General Public License for more details.
  34.  *
  35.  *  You should have received a copy of the GNU Lesser General
  36.  *  Public License along with this library; if not, write to the
  37.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  38.  *  Boston, MA 02111-1307 USA
  39.  */
  40. class FTPUploadApplet extends FTPHost
  41. {
  42.   /**
  43.    * Stores the value of the width-attribute of this applet.
  44.    *
  45.    * @var   integer $width 
  46.    *  access public
  47.    */
  48.   var $width = 200;
  49.   /**
  50.    * Stores the value of the height-attribute of this applet.
  51.    *
  52.    * @var   integer $height 
  53.    *  access public
  54.    */
  55.   var $height = 90;
  56.   /**
  57.    * The label of the button for browsing the filesystem.
  58.    *
  59.    * @var    string $browse_bt_label 
  60.    * @access public
  61.    */
  62.   /**
  63.    * The label of the button for sending the selected file.
  64.    *
  65.    * @var    string $send_bt_label 
  66.    * @access public
  67.    */
  68.   var $send_bt_label;
  69.   /**
  70.    * Stores the background color of the applet.
  71.    *
  72.    * @var    string $bg_color 
  73.    * @access public
  74.    */
  75.   var $bg_color = "#FFFFFF";
  76.   /**
  77.    * Stores the background color of the progressbar in the applet.
  78.    *
  79.    * @var    string $progressbar_bgcolor 
  80.    * @access public
  81.    */
  82.   var $progressbar_bgcolor = "#000000";
  83.   /**
  84.    * Stores the foreground color of the progressbar in the applet.
  85.    *
  86.    * @var    string $bg_color 
  87.    * @access public
  88.    */
  89.   var $progressbar_fgcolor = "#FFFFFF";
  90.   /**
  91.    * Stores the target path for uploaded files. Must have an ending slash.
  92.    *
  93.    * @var    string $target_path 
  94.    * @access public
  95.    */
  96.   var $target_path = "/";
  97.   /**
  98.    * Stores the filename for uploaded file.
  99.    *
  100.    * @var    string $target_path 
  101.    * @access public
  102.    */
  103.   var $target_filename = "";
  104.   /**
  105.    * Stores the target url to retrieve after the selectedfile is uploaded.
  106.    * Can also be a javascript (javascript:document...).
  107.    *
  108.    * @var    string $target_href_after_upload 
  109.    * @access public
  110.    */
  111.   /**
  112.    * Stores whether the percentage display should be shown or not.
  113.    *
  114.    * @var    string  $target_href_after_upload 
  115.    * @access private
  116.    */
  117.   var $percentage_display = "true";
  118.   /**
  119.    * Stores the path to the jar-archive.
  120.    *
  121.    * @var   string $codebase 
  122.    *  access public
  123.    */
  124.   var $codebase = "";
  125.   /**
  126.    * Stores whether the file should zipped before upload.
  127.    *
  128.    * @var   string $zip_it 
  129.    *  access public
  130.    */
  131.   var $zip_it = "false";
  132.   /**
  133.    * Stores the path to the target zip archive.
  134.    *
  135.    * @var   string $zip_path 
  136.    *  access public
  137.    */
  138.   var $zip_path = "";
  139.   /**
  140.    * Stores the filename of the target zip archive.
  141.    *
  142.    * @var   string $zip_filename 
  143.    *  access public
  144.    */
  145.   var $zip_filename = "";
  146.   /**
  147.    * Stores the mode how to communicate.
  148.    *
  149.    * @var   string $mode 
  150.    *  access public
  151.    */
  152.   var $mode = "PASV";
  153.   
  154.   
  155.   /**
  156.    * Constructor
  157.    *
  158.    * @version 1.2
  159.    * @since   1.0
  160.    * @author  Daniel Plücken <daniel@debakel.net>
  161.    * @access  public
  162.    * @param   string  $host 
  163.    * @param   string  $user 
  164.    * @param   string  $password 
  165.    * @param   string  $port 
  166.    */
  167.   function FTPUploadApplet$host$user$password$port 21 )
  168.   {
  169.     parent::FTPHost$host$user$password$port );
  170.     $this->codebase = CLASSPATH."java";
  171.   }
  172.   
  173.   
  174.   
  175.   /**
  176.    * Sets the string to act as label for the browse-button.
  177.    *
  178.    * @version 1.0
  179.    * @since   1.0
  180.    * @author  Daniel Plücken <daniel@debakel.net>
  181.    * @param   string $string The label to store.
  182.    * @return  void 
  183.    */
  184.   function setBrowseButtonLabel$string )
  185.   $this->browse_bt_label = $string}
  186.   
  187.   
  188.   
  189.   /**
  190.    * Sets the string to act as label for the send-button.
  191.    *
  192.    * @version 1.0
  193.    * @since   1.0
  194.    * @author  Daniel Plücken <daniel@debakel.net>
  195.    * @param   string $string The label to store.
  196.    * @return  void 
  197.    */
  198.   function setSendButtonLabel$string )
  199.   $this->send_bt_label = $string}
  200.   
  201.   
  202.   
  203.   /**
  204.    * Sets the target url to retrieve after the selectedfile is uploaded.
  205.    * Can also be a javascript (javascript:document...).
  206.    *
  207.    * @version 1.0
  208.    * @since   1.0
  209.    * @author  Daniel Plücken <daniel@debakel.net>
  210.    * @param   string $string The label to store.
  211.    * @return  void 
  212.    */
  213.   function setTargetAfterUpload$string )
  214.   $this->target_href_after_upload = $string}
  215.   
  216.   
  217.   
  218.   /**
  219.    * Sets where to put the files to upload. The path has to have an ending
  220.    * slash.
  221.    *
  222.    * @version 1.0
  223.    * @since   1.0
  224.    * @author  Daniel Plücken <daniel@debakel.net>
  225.    * @param   string $string The path to store.
  226.    * @return  void 
  227.    */
  228.   function setTargetPath$string )
  229.   $this->target_path = $string}
  230.   
  231.   
  232.   
  233.   /**
  234.    * Sets how the uploaded file should be named.
  235.    *
  236.    * @version 1.0
  237.    * @since   1.0
  238.    * @author  Daniel Plücken <daniel@debakel.net>
  239.    * @param   string $string The filename to store.
  240.    * @return  void 
  241.    */
  242.   function setTargetFilename$string )
  243.   $this->target_filename = $string}
  244.   
  245.   
  246.   
  247.   /**
  248.    * Sets how the uploaded file should be named.
  249.    *
  250.    * @version 1.0
  251.    * @since   1.0
  252.    * @author  Daniel Plücken <daniel@debakel.net>
  253.    * @param   integer $int 
  254.    * @return  void 
  255.    */
  256.   function setWidth$int )
  257.   {
  258.     if preg_match"!^\d+$!" ) )
  259.        $this->width = intval$int );
  260.   }
  261.   
  262.   
  263.   
  264.   /**
  265.    * Sets how the uploaded file should be named.
  266.    *
  267.    * @version 1.0
  268.    * @since   1.0
  269.    * @author  Daniel Plücken <daniel@debakel.net>
  270.    * @param   integer $int 
  271.    * @return  void 
  272.    */
  273.   function setHeight$int )
  274.   {
  275.     if preg_match"!^\d+$!" ) )
  276.        $this->height = intval$int );
  277.   }
  278.   
  279.   
  280.   
  281.   /**
  282.    * Sets whether the file should zipped before upload.
  283.    *
  284.    * @version 1.0
  285.    * @since   1.0
  286.    * @author  Daniel Plücken <daniel@debakel.net>
  287.    * @param   boolean $bool 
  288.    * @return  void 
  289.    */
  290.   function setShouldZipped$bool )
  291.   {
  292.     if is_bool$bool ) )
  293.        if $bool )
  294.           $this->zip_it = "true";
  295.        else
  296.           $this->zip_it = "false";
  297.   }
  298.   
  299.   
  300.   
  301.   /**
  302.    * Use this only if you want to upload the file AND generate separatly a zip
  303.    * archive of the file. If you only want to get the file to upload zipped,
  304.    * then it is effectual to give only the target filename.
  305.    *
  306.    * @version 1.0
  307.    * @since   1.0
  308.    * @author  Daniel Plücken <daniel@debakel.net>
  309.    * @param   string $string 
  310.    * @return  void 
  311.    */
  312.   function setZipFilename$string )
  313.   $this->zip_filename = $string}
  314.   
  315.   
  316.   
  317.   /**
  318.    * Use this only if you want to upload the file AND generate separatly a zip
  319.    * archive of the file. If you only want to get the file to upload zipped in
  320.    * the target folder of the file, then it is effectual to give only the
  321.    * target path.
  322.    *
  323.    * @version 1.0
  324.    * @since   1.0
  325.    * @author  Daniel Plücken <daniel@debakel.net>
  326.    * @param   string $string 
  327.    * @return  void 
  328.    */
  329.   function setZipPath$string )
  330.   $this->zip_path = $string}
  331.   
  332.   
  333.   
  334.   /**
  335.    * Stets the connection mode (PASV or ACTIVE)
  336.    *
  337.    * @version 1.0
  338.    * @since   1.0
  339.    * @author  Daniel Plücken <daniel@debakel.net>
  340.    * @param   string $string 
  341.    * @return  void 
  342.    */
  343.   function setMode$string )
  344.   {
  345.     if strtoupper$string == "ACTIVE" )
  346.        $this->mode = "ACTIVE";
  347.     else
  348.        $this->mode = "PASV";
  349.   }
  350.  
  351.  
  352.  
  353.   /**
  354.    * Returns a generated string based on the attributes of this HTML-Object.
  355.    *
  356.    * @version 1.0
  357.    * @since   1.0
  358.    * @author  Daniel Plücken <daniel@debakel.net>
  359.    * @access  public
  360.    * @return  string 
  361.    */
  362.   function get()
  363.   {
  364.     return "<applet codebase=\"".$this->codebase."\"\r\n"
  365.           ."        archive=\"applets/GilliGanFTP.jar,lib/edtftpj.jar\"\r\n"
  366.           ."        code=\"org.pluecken.applets.GilliGanFTP.GilliGanFTP\"\r\n"
  367.           ."        height=\"".$this->height."\" "
  368.                   ."width=\"".$this->width."\">\r\n"
  369.           ."        <!--\r\n"
  370.           ."           on Linux KDE (with ProgressBarLabel): "
  371.                      ."MIN-Height 80 / MIN-Width 231\r\n"
  372.           ."           on Linux KDE (without ProgressBarLabel): "
  373.                      ."MIN-Height 74 / MIN-Width 231\r\n"
  374.           ."          -->\r\n"
  375.           ."        <!-- on WinXP: MIN-Height 76 / MIN-Width 223 -->\r\n"
  376.           ."        <param name=\"host\" value=\"".$this->name."\" />\r\n"
  377.           ."        <param name=\"user\" value=\"".$this->user."\" />\r\n"
  378.           ."        <param name=\"pass\" value=\"".$this->password."\" />\r\n"
  379.           ."        <param name=\"port\" value=\"".$this->port."\" />\r\n"
  380.           ."        <param name=\"connection_mode\" "
  381.                          ."value=\"".$this->mode."\" />\r\n"
  382.           ."        <param name=\"browse_bt_label\" "
  383.                          ."value=\"".$this->browse_bt_label."\" />\r\n"
  384.           ."        <param name=\"send_bt_label\" "
  385.                          ."value=\"".$this->send_bt_label."\" />\r\n"
  386.           ."        <param name=\"target_path\" "
  387.                          ."value=\"".$this->target_path."\" />\r\n"
  388.           ."        <param name=\"zip_it\" "
  389.                          ."value=\"".$this->zip_it."\" />\r\n"
  390.           .(
  391.              empty$this->target_filename )
  392.              ? ""
  393.              : "        <param name=\"target_filename\" "
  394.                              ."value=\"".$this->target_filename."\" />\r\n"
  395.            )
  396.           .(
  397.              empty$this->zip_path )
  398.              ? ""
  399.              : "        <param name=\"target_zip_path\" "
  400.                              ."value=\"".$this->zip_path."\" />\r\n"
  401.            )
  402.           .(
  403.              empty$this->zip_filename )
  404.              ? ""
  405.              : "        <param name=\"target_zip_filename\" "
  406.                              ."value=\"".$this->zip_filename."\" />\r\n"
  407.            )
  408.           ."        <param name=\"target_href_after_upload\" "
  409.                          ."value=\"".$this->target_href_after_upload."\" />\r\n"
  410.            /*
  411.           ."        <!--
  412.   <param name="browse_bt_image" value="http://www.google.de/images/firefox/google.gif" />
  413.   <param name="sent_bt_image" value="http://www.google.de/images/firefox/google.gif" />
  414.   -->
  415.   */
  416.           ."        <param name=\"percentage_display\" "
  417.                          ."value=\"".$this->percentage_display."\" />\r\n"
  418.                          /*
  419.   <!-- GAPS -->
  420.   <!-- <param name="gap_progressbar_textfield" value="1" />
  421.   <!-- <param name="gap_textfield_buttons" value="1" />
  422.   <!-- <param name="gap_buttons_to_each_other" value="5" /> -->
  423.   */
  424.           ."        <param name=\"progressbar_bgcolor\" "
  425.                           ."value=\"".$this->progressbar_bgcolor."\" />\r\n"
  426.           ."        <param name=\"progressbar_fgcolor\" "
  427.                           ."value=\"".$this->progressbar_fgcolor."\" />\r\n"
  428.           ."        <param name=\"bgcolor\" "
  429.                           ."value=\"".$this->bg_color."\" />\r\n"
  430.           ."</applet>\r\n";
  431.     }
  432. // END of class FTPUploadApplet
  433. ?>

Documentation generated on Thu, 05 Jun 2008 19:11:53 +0200 by phpDocumentor 1.4.1