예제 #1
0
 private function InitDocumentObject()
 {
     $document = new \Applications\EasyMvc\Models\Dao\Document();
     $document->setDocument_category($this->dataPost["itemCategory"]);
     $document->setDocument_content_type($this->GetExtension());
     $document->setDocument_value($this->GetFileNameToSaveInDatabase());
     $document->setDocument_size($this->GetSizeInKb());
     return $document;
 }
 /**
  * PDF copy method
  * $dataPost is actually having the Document model
  * $file is having the master file details in pseudo format
  */
 public static function copyFile($files, $dataPost, $caller)
 {
     $manager = $caller->managers()->getDalInstance("Document");
     $manager->setRootDirectory($caller->app()->config()->get(\Puzzlout\Framework\Enums\AppSettingKeys::RootDocumentUpload));
     $manager->setWebDirectory($caller->app()->config()->get(\Puzzlout\Framework\Enums\AppSettingKeys::BaseUrl) . $caller->app()->config()->get(\Puzzlout\Framework\Enums\AppSettingKeys::RootUploadsFolderPath));
     $directory = str_replace("_id", "", $dataPost['itemCategory']);
     $manager->setObjectDirectory($directory);
     if ($dataPost['itemReplace'] === "true") {
         $manager->selectManyByCategoryAndId($dataPost['itemCategory'], $dataPost['itemId']);
     }
     $manager->setFilenamePrefix($dataPost['itemId'] . '_');
     $document = new \Applications\EasyMvc\Models\Dao\Document();
     $document->setDocument_category($dataPost['itemCategory']);
     if (isset($dataPost['title']) && $dataPost['title'] != "") {
         $document->setDocument_title($dataPost['title']);
     } else {
         $document->setDocument_title($files['file']['name']);
     }
     $manager->copyWithFile($document, $files['file']);
 }