Lithron.LMediaManager
[ class tree: Lithron.LMediaManager ] [ index: Lithron.LMediaManager ] [ all elements ]

Source for file LMediaManagerWebUpload.php

Documentation is available at LMediaManagerWebUpload.php

  1. <?php
  2.  
  3. /**
  4. * class file.
  5. *
  6. * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  7. * @copyright 2005, diemeisterei GmbH. All rights reserved.
  8. * @author $Author: schmunk $
  9. * @version $Revision: 246 $ $Date: 2006-06-01 15:11:24 +0000 (Do, 01 Jun 2006) $
  10. * @package Lithron.LMediaManager
  11. * @subpackage WebControls
  12. */
  13.  
  14. /**
  15. * Provides A Web Upload Component for LMediaManager
  16. *
  17. * @package System.Web.UI.WebControls
  18. * @subpackage MediaManager
  19. */
  20.  
  21. class LMediaManagerWebUpload extends TTemplateControl
  22. {
  23. public function onInit($param)
  24. {
  25. $this->Uploader->OnFileUpload[]= array (
  26. $this,
  27. "fileUploaded"
  28. );
  29. }
  30.  
  31. private function handleUpload($name, $tmpname, $overwrite= false)
  32. {
  33. $MP= $this->Application->getParameters()->itemAt("UploadPath");
  34. if (!is_writeable($MP . "/"))
  35. return 2;
  36. if (is_file($MP . "/" . $name))
  37. {
  38. if (!$overwrite)
  39. return 3;
  40. if (!unlink($MP . "/" . $name))
  41. return 4;
  42. }
  43. if (!move_uploaded_file($tmpname, $MP . "/" . $name))
  44. return 5;
  45. $core = new LMediaManagerCore();
  46. $core->updateDatabase();
  47. return 0;
  48. }
  49.  
  50. public function fileUploaded($sender, $param)
  51. {
  52. if (!$sender->HasFile)
  53. return;
  54.  
  55. $res= $this->handleUpload($sender->FileName, $sender->LocalName, $this->OverwriteSelector->getChecked());
  56.  
  57. switch ($res)
  58. {
  59. case 0 :
  60. $str= "Upload succesful.";
  61. $this->Service->reload();
  62. break;
  63. #case 1:
  64. # $str = "Kategorie nicht vorhanden!";
  65. # break;
  66. case 2 :
  67. $str= "Upload Folder is not writable!";
  68. break;
  69. case 3 :
  70. $str= "File exists!";
  71. break;
  72. case 4 :
  73. $str= "Can not delete exisiting file!";
  74. break;
  75. case 5 :
  76. $str= "Error while moving uploaded file!";
  77. break;
  78. }
  79.  
  80. $this->UploadResult->Controls[]= "$res: " . $str;
  81.  
  82. }
  83.  
  84. }
  85. ?>

Documentation generated on Tue, 20 Jun 2006 05:15:16 +0200 by phpDocumentor 1.3.0RC4