/**
  * Prepare and sanitise the table prior to saving.
  *
  * @param SocialCommunityTableProfile $table
  * @param array                       $data
  *
  * @since    1.6
  */
 protected function prepareImages($table, $data)
 {
     // Prepare image
     if (!empty($data['image'])) {
         $params = JComponentHelper::getParams($this->option);
         /** @var  $params Joomla\Registry\Registry */
         jimport('Prism.libs.init');
         $filesystemHelper = new Prism\Filesystem\Helper($params);
         $mediaFolder = $filesystemHelper->getMediaFolder($data['user_id']);
         $storageFilesystem = $filesystemHelper->getFilesystem();
         // Delete old image if I upload a new one
         if ($table->get('image')) {
             $this->deleteImages($table, $mediaFolder, $storageFilesystem);
         }
         // Move the images from temporary to media folder.
         $this->moveImages($data, $mediaFolder, $storageFilesystem);
         $table->set('image', $data['image']);
         $table->set('image_small', $data['image_small']);
         $table->set('image_icon', $data['image_icon']);
         $table->set('image_square', $data['image_square']);
     }
 }
예제 #2
0
파일: profile.php 프로젝트: pashakiz/crowdf
 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @param SocialCommunityTableProfile $table
  * @param array                       $data
  *
  * @since    1.6
  */
 protected function prepareImages($table, $data)
 {
     // Prepare image
     if (!empty($data["image"])) {
         // Delete old image if I upload a new one
         if ($table->get("image")) {
             jimport('joomla.filesystem.file');
             /** @var  $params Joomla\Registry\Registry */
             $params = JComponentHelper::getParams($this->option);
             $imagesFolder = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $params->get("images_directory", "images/profiles"));
             // Remove an image from the filesystem
             $fileImage = $imagesFolder . DIRECTORY_SEPARATOR . $table->get("image");
             $fileSmall = $imagesFolder . DIRECTORY_SEPARATOR . $table->get("image_small");
             $fileIcon = $imagesFolder . DIRECTORY_SEPARATOR . $table->get("image_icon");
             $fileSquare = $imagesFolder . DIRECTORY_SEPARATOR . $table->get("image_square");
             if (JFile::exists($fileImage)) {
                 JFile::delete($fileImage);
             }
             if (JFile::exists($fileSmall)) {
                 JFile::delete($fileSmall);
             }
             if (JFile::exists($fileIcon)) {
                 JFile::delete($fileIcon);
             }
             if (JFile::exists($fileSquare)) {
                 JFile::delete($fileSquare);
             }
         }
         $table->set("image", $data["image"]);
         $table->set("image_small", $data["image_small"]);
         $table->set("image_icon", $data["image_icon"]);
         $table->set("image_square", $data["image_square"]);
     }
 }