Caravel CMS PHP Cross Reference Content Management Systems

Source: /apps/RapidPublicUploader/RapidPublicUploader.php - 143 lines - 5874 bytes - Summary - Text - Print

   1  <?
   2  
   3  class RapidPublicUploader extends App
   4    {
   5    function getContent()
   6        {
   7        if($this->httpVars['upload'] != "")
   8            {
   9            for($i=0; $i < 5; $i++)
  10                {
  11                if($_FILES[$this->paramName('uploadFile' . $i)]['name'] != "")
  12                    {
  13                    $uploadDN = "mnF=".$_FILES[$this->paramName('uploadFile' . $i)]['name'] . "," . $this->httpVars['uploadFolder' . $i];
  14  
  15                    //Delete the existing file if the same file alredy exist
  16                    //if ($this->ldap->dnExists($uploadDN))
  17                    //    $this->ldap->delete($uploadDN);
  18                    $num = 1;
  19                    $origuploadDN = $uploadDN;
  20                    while(($this->ldap->dnExists($uploadDN) || ((strpos(DN::dnToName($uploadDN), DN::dnToName($origuploadDN)) !== false) && $num !== 1)) && $num < 25)
  21                        {
  22                        $uploadDN = $origuploadDN;
  23                        $tmpnme = substr(DN::dnToName($uploadDN), 0, strpos(DN::dnToName($uploadDN), "."));
  24                        $tmpext = substr(DN::dnToName($uploadDN), strpos(DN::dnToName($uploadDN), "."));
  25                        $tmpnme .= $num;
  26  
  27                        $uploadDN = "mnF=" . $tmpnme . $tmpext . "," . DN::dnToParent($uploadDN);
  28                        $num++;
  29                        }
  30  
  31                    //uploading file
  32                    $upload = oFile::create($this->ldap, $uploadDN, $_FILES[$this->paramName('uploadFile' . $i)]['tmp_name'], $_FILES[$this->paramName('uploadFile' . $i)]['type']);
  33                    if (mnError::isError($upload))
  34                      return new mnError('Error uploading project file: ' . $upload->getMessage(), __FILE__, __LINE__);
  35                    if($this->settingsVars['requestMeta'] != "")
  36                         {    
  37                        $a = Utility::processParams($upload->get(C_LDAP_ATTRIBUTES_ATTR, true));
  38                        $a = array_merge($a, array('author' => $this->httpVars['uploadAuthor' . $i], 'title' => $this->httpVars['uploadTitle' . $i], 'description' => $this->httpVars['uploadDesc' . $i]));
  39                        $attrs = array(C_LDAP_ATTRIBUTES_ATTR => Utility::packageParams(array($GLOBALS['CV_CURR_LANG'] => $a)));
  40                        $res = $upload->update($attrs);
  41                        }
  42                    }
  43                }
  44            
  45            }
  46        
  47        $f = FormWidget::init('', 'form.nonsettings.tpl.html');
  48        $f->name('rapidu');
  49        
  50        $f->folderList('uploadFolder1', $this->settingsVars['savedFolder1']);
  51        $f->file('uploadFile1');
  52        if($this->settingsVars['requestMeta'] != "")
  53            {
  54            $f->html('<br />Title: ');
  55            $f->text('uploadTitle1', '');
  56            $f->html('Author: ');
  57            $f->text('uploadAuthor1', '');
  58            $f->html('<br />Short Description: <br />');
  59            $f->textarea('uploadDesc1', '', 3, 5, array('style' => 'width: 240px;'));
  60            }
  61        $f->html('<br />&nbsp;<br />');
  62  
  63        $f->folderList('uploadFolder2', $this->settingsVars['savedFolder2']);
  64        $f->file('uploadFile2');
  65        if($this->settingsVars['requestMeta'] != "")
  66            {
  67            $f->html('<br />Title: ');
  68            $f->text('uploadTitle2', '');
  69            $f->html('Author: ');
  70            $f->text('uploadAuthor2', '');
  71            $f->html('<br />Short Description: <br />');
  72            $f->textarea('uploadDesc2', '', 3, 5, array('style' => 'width: 240px;'));
  73            }
  74        $f->html('<br />&nbsp;<br />');
  75        
  76        $f->folderList('uploadFolder3', $this->settingsVars['savedFolder3']);
  77        $f->file('uploadFile3');
  78        if($this->settingsVars['requestMeta'] != "")
  79            {
  80            $f->html('<br />Title: ');
  81            $f->text('uploadTitle3', '');
  82            $f->html('Author: ');
  83            $f->text('uploadAuthor3', '');
  84            $f->html('<br />Short Description: <br />');
  85            $f->textarea('uploadDesc3', '', 3, 5, array('style' => 'width: 240px;'));
  86            }
  87        $f->html('<br />&nbsp;<br />');
  88  
  89        $f->folderList('uploadFolder4', $this->settingsVars['savedFolder4']);
  90        $f->file('uploadFile4');
  91        if($this->settingsVars['requestMeta'] != "")
  92            {
  93            $f->html('<br />Title: ');
  94            $f->text('uploadTitle4', '');
  95            $f->html('Author: ');
  96            $f->text('uploadAuthor4', '');
  97            $f->html('<br />Short Description: <br />');
  98            $f->textarea('uploadDesc4', '', 3, 5, array('style' => 'width: 240px;'));
  99            }
 100        $f->html('<br />&nbsp;<br />');
 101   
 102        $f->html('<div style="float: right;margin-top: 5px;">');
 103        $f->submit('upload', 'Upload');
 104        $f->html('</div><div style="clear: both;">&nbsp;</div>');
 105  
 106  
 107        return  $f->get();
 108        }
 109    function onSave()
 110        {
 111        $this->settingsVars['savedFolder1'] = $this->httpVars['saveFolder1'];
 112        $this->settingsVars['savedFolder2'] = $this->httpVars['saveFolder2'];
 113        $this->settingsVars['savedFolder3'] = $this->httpVars['saveFolder3'];
 114        $this->settingsVars['savedFolder4'] = $this->httpVars['saveFolder4'];
 115        $this->settingsVars['requestMeta'] = $this->httpVars['requestMeta'];
 116        $this->saveSettings($this->settingsVars);
 117        }    
 118        
 119    function getConfig()
 120        {
 121        $f = FormWidget::init();
 122        $f->name('rapiduedit');
 123  
 124        $f->html('Here you can choose the default folder that is selected by the four foulder dropdowns on the front end.');
 125        $f->html('<br />&nbsp;<br />');
 126        $f->folderList('saveFolder1', $this->settingsVars['savedFolder1']);
 127        $f->html('<br />&nbsp;<br />');
 128        $f->folderList('saveFolder2', $this->settingsVars['savedFolder2']);
 129        $f->html('<br />&nbsp;<br />');
 130        $f->folderList('saveFolder3', $this->settingsVars['savedFolder3']);
 131        $f->html('<br />&nbsp;<br />');
 132        $f->folderList('saveFolder4', $this->settingsVars['savedFolder4']);
 133        $f->html('<br />&nbsp;<br />');
 134        $f->checkbox('requestMeta', $this->settingsVars['requestMeta'], 'Allow the uploader to enter file metadata before they upload.');
 135  
 136        $f->html('<div style="float: right;margin-top: 5px;">');
 137        $f->defaultButtons();
 138        $f->html('</div><div style="clear: both;">&nbsp;</div>');
 139  
 140        return  $f->get();
 141        }
 142    }
 143  ?>

title

Description

title

Description

title

Description

title

title

Body