Inheritance: extends BaseModel
Esempio n. 1
0
 /**
  * @return string
  */
 public static function get()
 {
     $application = 'Backend';
     if (Model::has('request') && Model::get('request')->attributes->has('_route') && stripos(Model::get('request')->attributes->get('_route'), 'frontend') === 0) {
         $application = 'Frontend';
     }
     return $application . '\\Core\\Language\\Language';
 }
Esempio n. 2
0
 private function uploadFile()
 {
     //--Check if the file is an image or file
     if ($this->isImage()) {
         // the image path
         $path = FRONTEND_FILES_PATH . '/Media/Images';
         if (!\SpoonDirectory::exists($path . '/Source')) {
             \SpoonDirectory::create($path . '/Source');
         }
     } else {
         // the file path
         $path = FRONTEND_FILES_PATH . '/Media/Files';
     }
     // create folders if needed
     // build the filename
     $filename = $this->checkFilename();
     $item = array();
     $item["filename"] = $filename;
     $item["extension"] = $this->field->getExtension();
     $item["created_on"] = BackendModel::getUTCDate('Y-m-d H:i:s');
     $item["filesize"] = $this->field->getFileSize("b");
     $data = array();
     //--Check if file is an image to specify data
     if ($this->isImage()) {
         $item["filetype"] = $this->fieldTypeImage;
         //--Put file on disk
         $this->field->moveFile($path . "/Source/" . $filename);
         // create folders if needed
         if (!\SpoonDirectory::exists($path . '/128x128')) {
             \SpoonDirectory::create($path . '/128x128');
         }
         //--Create all tumbs/resizes of file
         $thumbnail = new \SpoonThumbnail($path . "/Source/" . $filename);
         $thumbnail->setAllowEnlargement(true);
         \Common\Core\Model::generateThumbnails($path, $path . '/Source/' . $filename);
     } else {
         $item["filetype"] = $this->fieldTypeFile;
         // move the source file
         $this->field->moveFile($path . "/" . $filename);
     }
     //--Serialize data
     $item["data"] = serialize($data);
     //--Store item so we can access it
     $this->item = $item;
     //--Insert into media
     return BackendModel::getContainer()->get('database')->insert("media", $item);
 }