protected function configureView()
 {
     $this->view->attachEventHandler('DeleteImage', function ($imgID) {
         try {
             $image = new Image($imgID);
             $image->delete();
             return true;
         } catch (RecordNotFoundException $ex) {
             return false;
         }
     });
     return parent::configureView();
 }
 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
 protected function beforeDelete()
 {
     parent::beforeDelete();
     foreach (Image::find(new Equals('GalleryID', $this->UniqueIdentifier)) as $image) {
         $image->delete();
     }
 }
Exemplo n.º 4
0
    protected function printViewContent()
    {
        ?>
        <a href="/portal/gallery/<?php 
        echo $this->gallery->UniqueIdentifier;
        ?>
/">
            <div class="gallery-overlay">
                <p>
                    <?php 
        $images = Image::find(new Equals('GalleryID', $this->gallery->UniqueIdentifier))->calculateAggregates(new Count('ImageID'))[0];
        $imgText = $images == 1 ? "bilde" : "bildes";
        print $images . ' ' . $imgText;
        ?>
                </p>
            </div>
        </a>
        <a href="/portal/gallery/<?php 
        echo $this->gallery->UniqueIdentifier;
        ?>
/"><p
                class="gallery-title"><?php 
        echo htmlspecialchars($this->gallery->Title);
        ?>
</p></a>
        <a href="/portal/gallery/<?php 
        echo $this->gallery->UniqueIdentifier;
        ?>
/"><img style="width: 100%; height: 100%;"
                src="<?php 
        echo $this->gallery->getDefaultImage();
        ?>
"></a>
        <?php 
    }
Exemplo n.º 5
0
 public function createPresenters()
 {
     parent::createPresenters();
     $model = $this->raiseEvent('GetRestModel');
     $slideView = new ImageCommentsPanorama(Image::find(new Equals('GalleryID', $model->GalleryID))->addSort('Order'), 'SlideView');
     $this->addPresenters($slideView);
 }
Exemplo n.º 6
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;
     }
 }
Exemplo n.º 7
0
 protected function printViewContent()
 {
     parent::printViewContent();
     $html = new HtmlPageSettings();
     $html->PageTitle = 'Pievienot vēl bildes galerijā';
     ?>
         <div class="__container">
             Bildes jau galerijā<br>
             <div id="image-orders" class="serialization">
                 <?php 
     $images = Image::find(new Equals('GalleryID', $this->getData('GalleryID')))->addSort('Order');
     foreach ($images as $image) {
         print '<div class="image-existing-container" iiid="' . $image->ImageID . '"><a href="" class="delete-image"><i class="fa fa-minus-circle"></i></a><img iiid="' . $image->ImageID . '" src="' . $image->getThumbnail() . ' "></div>';
     }
     ?>
             </div>
             <div class="__clear-floats"></div>
         </div>
     <?php 
 }
Exemplo n.º 8
0
 public static function checkRecords($oldVersion, $newVersion)
 {
     parent::checkRecords($oldVersion, $newVersion);
     if ($newVersion == 2) {
         foreach (Gallery::find() as $gallery) {
             $i = 0;
             foreach (Image::find(new Equals('GalleryID', $gallery->GalleryID)) as $image) {
                 $image->Order = $i++;
                 $image->save();
             }
         }
     }
 }