Example #1
0
 public function Format($row, $fieldname, $value)
 {
     $files = $this->_context->getUploadFileNames();
     if ($files[$fieldname] != "") {
         $fileProcessor = new UploadFilenameProcessor($this->_saveAs);
         $fileProcessor->setFilenameLocation(ForceFilenameLocation::DefinePath, FileUtil::GetTempDir());
         // Save the files in a temporary directory
         $result = $this->_context->processUpload($fileProcessor, false, $fieldname);
         // Get a way to rename the files
         $fileinfo = pathinfo($result[0]);
         if ($this->_saveAs != "*") {
             $path_parts = pathinfo($this->_saveAs);
         } else {
             $path_parts = pathinfo($result[0]);
         }
         $newName = $this->_path . FileUtil::Slash() . $path_parts['filename'] . "." . $fileinfo["extension"];
         // Put the image in the right place
         if (strpos(".jpg.gif.jpeg.png", "." . $fileinfo["extension"]) === false) {
             rename($result[0], $newName);
         } else {
             if ($this->_width > 0 || $this->_height > 0) {
                 $image = new ImageUtil($result[0]);
                 $image->resizeAspectRatio($this->_width, $this->_height, 255, 255, 255)->save($newName);
             } else {
                 rename($result[0], $newName);
             }
         }
         return $newName;
     } else {
         return $row->getField($fieldname);
     }
 }
Example #2
0
 /**
  * Action Upload
  *
  */
 protected function actionUpload()
 {
     $blockCenter = new XmlBlockCollection($this->_myWords->Value("UPLOAD"), BlockPosition::Center);
     $this->_document->addXmlnukeObject($blockCenter);
     $paragraph = new XmlParagraphCollection();
     $blockCenter->addXmlnukeObject($paragraph);
     switch ($this->_action) {
         case 'add':
             $fileProcessor = new UploadFilenameProcessor('*.*');
             $fileProcessor->setFilenameLocation(ForceFilenameLocation::DefinePath, "diretorio/subdir/");
             $result = $this->_context->processUpload($fileProcessor, false, 'form_file');
             $paragraph->addXmlnukeObject(new XmlnukeText("Arquivo " . $result[0] . " enviado com sucesso ao servidor!"));
             break;
         default:
             $paragraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("DESCUPLOADTEXT2")));
             $url = new XmlnukeManageUrl(URLTYPE::MODULE, $this->_url);
             $url->addParam('op', '6');
             $url->addParam('action', 'add');
             $form = new XmlFormCollection($this->_context, $url->getUrl(), $this->_myWords->Value("MAKEUPLOAD"));
             $paragraph = new XmlParagraphCollection();
             $blockCenter->addXmlnukeObject($paragraph);
             $paragraph->addXmlnukeObject($form);
             $fileField = new XmlInputFile($this->_myWords->Value("FILE"), 'form_file');
             $form->addXmlnukeObject($fileField);
             $button = new XmlInputButtons();
             $button->addSubmit($this->_myWords->Value("ADD"), "");
             $form->addXmlnukeObject($button);
             break;
     }
 }