Exemplo n.º 1
0
 public static function uploadImage($file, $location)
 {
     if ($file && $location) {
         $user = CustomLoginProvider::getLoggedInUser();
         $info = pathinfo($file);
         $discussion = new Image();
         $discussion->UploadedBy = $user->UserID;
         $discussion->save();
         $discussion->Source = '/static/images/uploaded/' . $discussion->UniqueIdentifier . '.' . $info['extension'];
         if (!is_dir('static/images/uploaded/')) {
             mkdir('static/images/uploaded', 0777, true);
         }
         $discussion->save();
         rename($location, 'static/images/uploaded/' . $discussion->UniqueIdentifier . '.' . $info['extension']);
         ImageResize::resizeIntoMultipleFormats($discussion->UniqueIdentifier . '.' . $info['extension'], 'static/images/uploaded/');
         self::$createdImagesForGallery[] = $discussion->ImageID;
     }
 }
 public static function moveAndCreateImages($galleryID)
 {
     if (!self::isDirectoryEmpty(self::$imgpath)) {
         foreach (scandir(self::$imgpath) as $img) {
             if (!is_dir($img)) {
                 GalleryAddView::uploadImage($img, self::$imgpath . $img);
             }
         }
     }
     foreach (GalleryAddView::$createdImagesForGallery as $id) {
         $image = new Image($id);
         $image->GalleryID = $galleryID;
         $image->save();
     }
 }
Exemplo n.º 3
0
 public function createPresenters()
 {
     parent::createPresenters();
     $images = Image::find(new Equals('GalleryID', $this->getData('GalleryID')))->addSort('Order');
     $this->addPresenters($table = new Table($images, 25, 'Images'), $delete = new Button('Dzēst', 'Dzēst', function ($id) {
         $image = new Image($id);
         $image->delete();
     }), $down = new Button('down', 'Uz leju', function ($id) {
         $image = new Image($id);
         $image->Order++;
         $image->save();
     }), $up = new Button('up', 'Uz augšu', function ($id) {
         $image = new Image($id);
         $image->Order--;
         $image->save();
     }));
     $delete->setConfirmMessage('Vai jūs tiešam gribat dzēst šo lietotāju?');
     $table->addTableCssClass(['table']);
     $table->Columns = ['Bilde' => '<img style="max-width: 250px;" src="{Thumbnail}">', 'Indekss' => 'Order', '&nbsp' => new FixedWidthColumn($delete), '&nbsp&nbsp' => new FixedWidthColumn($up), '&nbsp&nbsp&nbsp' => new FixedWidthColumn($down)];
 }