Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Bug Reports


Reply


297 Posts   50846 Views

Avatar
socks

Community Member, 190 Posts

7 January 2011 at 5:03pm

Edited: 07/01/2011 5:05pm

ImageGallery Rotate Image Not Working (SS 2.4.4, Image Gallery r525, Uploadify r524)

Hey Uncle Cheese,

I noticed the Rotate Image feature wasn't working on my Localhost. I came across this fix http://www.silverstripe.org/dataobjectmanager-module-forum/show/13308 and didn't know if you didn't think it was a viable solution or if you hadn't seen it since it wasn't in this Bug Reports thread.

Seems to work, but there's some weirdness (in the Pop-up) when you only rotate 90 deg. and the rotated thumb isn't represented properly (CMS > Content > Photos) until I log out and back in.

Thanks

Avatar
Devlin

Community Member, 215 Posts

12 February 2011 at 1:33am

Edited: 12/02/2011 2:05am

Hi there.

Traversing $summary_fields seems to not work with HasManyDataObjectManager.

$DOM = new HasManyDataObjectManager($this, 'Beleuchtung', 'ReportData_has_many_Beleuchtung');

class ReportData_has_many_Beleuchtung extends DataObject {
static $has_one = array(
'ESL' => 'ReportData_has_one_ESL'
)
static $summary_fields = array(
'ESL.Name' => 'ESL',
);
}

In HasManyDataObjectManager.php the line 72-78 in getQuery() seems to be the problem.

// Add more selected fields if they are from joined table.

$SNG = singleton($this->sourceClass);
foreach($this->FieldList() as $k => $title) {
   if(! $SNG->hasField($k) && ! $SNG->hasMethod('get' . $k))
      $query->select[] = $k;
}

If I delete the "!" in the if condition or completely delete these lines, traversing works like intended.
But maybe I'm missing something.

Avatar
moloko_man

Community Member, 72 Posts

12 February 2011 at 9:14am

Edited: 12/02/2011 9:16am

Maybe this is in the wrong place... When having nested DOM objects, the nested DOM window is displayed inside the first DOM window, but on different browsers it shows up in different places and in IE 7 has different desired results.

Chrome on Mac, the nested window opens below all the first window content and buttons - https://img.skitch.com/20110211-x2fj7d627gejdpjexp27urnqfs.jpg

Firefox on Mac/Windows, the nested window opens in the correct place, but there is no control to set the width - https://img.skitch.com/20110211-8wa8af2nqfua8q6ym59qbcbicd.jpg

IE7/IE8 the nested window opens OVER the first window, forcing you to close the First Window DOM after you save the nested object. A pain if you are adding more than one file to the First DOM - https://img.skitch.com/20110211-e99yac4n2jrdm2uwk1tddtup4k.jpg

I don't have IE9 to test it

Functionality is still there, so this is more of an UI/UX bug.

Avatar
BLU42 Media

Community Member, 71 Posts

25 February 2011 at 9:20am

I'm using SS 2.4.5 w/ the DatePickerField in Model Admin and noticed that the field is pre-filling with both the date and time. I adjusted the code in the Field() function to remove the time. The old CalendarDateField had this issue too. Is this something you might be willing to add to the field code?

      #$val = $this->attrValue();

      //   BLU FIX... field was returning time
      if ($this->attrValue()) {
         $val = 'dd/mm/yy' == self::$dateFormat
            ? date('d/m/Y', strtotime( $this->attrValue() ))
            : date('m/d/Y', strtotime( $this->attrValue() ));
      }
      else {
         $val = null;
      }

Thanks,
John

Avatar
moloko_man

Community Member, 72 Posts

10 March 2011 at 8:29am

Not sure if this is an Uploadify or DataObjectManager bug, but when using the ImageDataObjectManager and choosing an existing image to import, the image is not imported properly.

The info is all correct in the database, but the thumbnail is a broken image and the URLSegment is "assets/" instead of the correct full path to the image. The image also does not show up in the front end.

In order to get the image to show up I have to click on the blank thumbnail to edit the details. Inside the details there is no thumbnail and I'm presented with the standard SS image uploader instead of uploadify. I have to repeat the process of choosing an existing image from the file store and then attach it. Once I do that and hit save, the thumbnail shows up and the image shows up on the front end.

Images going through the above process:

Here is my code for the page & dataobject

HomePage.php
class HomePage extends Page {
...
static $has_many = array(
      'SliderImages' => 'SliderImage',
   );
public function getCMSFields() {
$fields = parent::getCMSFields();
$a = array('png', 'jpg', 'jpeg', 'gif');
$dom = new ImageDataObjectManager(
         $this,
         'SliderImages',
         'SliderImage'
      );
      $dom->setUploadFolder('Uploads/HomePageHeroImages');
      $dom->setAllowedFileTypes($a);
      $dom->setPageSize(20);
$fields->addFieldToTab('Root.Content.SliderImages', $dom);
   return $fields;
}
...
}

SliderImage.php
static $has_one = array(
      'Photo' => 'BetterImage',
      'HomePage' => 'HomePage',
   );

any insight on this?

I can replicate this issue on my local dev environment (OSX 10.6, MAMP PRO) and production server (Rackspace)

Avatar
mdaum

Community Member, 2 Posts

10 March 2011 at 10:29am

Edited: 10/03/2011 10:30am

Hello,
I'm getting a rather funky issue with the latest trunks of ImageGallery, DOM, and Uploadify installed on a stock 2.4.4 install of SilverStripe.

Every time I try changing a page to ImageGallery type, if I click save it works. If I click Save & Publish, it'll give me this error:

Error: Uncaught Exception: Cannot move .../assets/image-gallery/Images-2/ to .../assets/image-gallery/Images-2/
At line 422 in .../sapphire/filesystem/File.php

The relevant code in File.php being (with line 422 labeled):

   public function updateFilesystem() {
      // Regenerate "Filename", just to be sure
      $this->setField('Filename', $this->getRelativePath());
      
      // If certain elements are changed, update the filesystem reference
      if(!$this->isChanged('Filename')) return false;
      
      $changedFields = $this->getChangedFields();
      $pathBefore = $changedFields['Filename']['before'];
      $pathAfter = $changedFields['Filename']['after'];
      
      // If the file or folder didn't exist before, don't rename - its created
      if(!$pathBefore) return;
      
      $pathBeforeAbs = Director::getAbsFile($pathBefore);
      $pathAfterAbs = Director::getAbsFile($pathAfter);
      
      // TODO Fix Filetest->testCreateWithFilenameWithSubfolder() to enable this
      // // Create parent folders recursively in database and filesystem
      // if(!is_a($this, 'Folder')) {
      //    $folder = Folder::findOrMake(dirname($pathAfterAbs));
      //    if($folder) $this->ParentID = $folder->ID;
      // }
      
      // Check that original file or folder exists, and rename on filesystem if required.
      // The folder of the path might've already been renamed by Folder->updateFilesystem()
      // before any filesystem update on contained file or subfolder records is triggered.
      if(!file_exists($pathAfterAbs)) {
         if(!is_a($this, 'Folder')) {
            // Only throw a fatal error if *both* before and after paths don't exist.
            if(!file_exists($pathBeforeAbs)) throw new Exception("Cannot move $pathBefore to $pathAfter - $pathBefore doesn't exist");
            
            // Check that target directory (not the file itself) exists.
            // Only check if we're dealing with a file, otherwise the folder will need to be created
            if(!file_exists(dirname($pathAfterAbs))) throw new Exception("Cannot move $pathBefore to $pathAfter - Directory " . dirname($pathAfter) . " doesn't exist");
         }
         
         // Rename file or folder
         $success = rename($pathBeforeAbs, $pathAfterAbs);
         if(!$success) throw new Exception("Cannot move $pathBeforeAbs to $pathAfterAbs"); //Line 422
      }
      
      
      // Update any database references
      $this->updateLinks($pathBefore, $pathAfter);
   }


When/if it works (by clicking Publish and waiting, sometimes it actually does it), it often obfusticates certain images/albums, by pointing to non-existent assets.

My guess is that it may have something to do with permissions (i.e. not being able to create the needed files), however one would (reasonably) assume that the rest of silverstripe would have an issues (especially at install time). Note please that I have not messed with permissions since install.

A stock 2.4.5 has the same issue.

Any ideas/need anything else?

Avatar
UncleCheese

Forum Moderator, 4092 Posts

10 March 2011 at 10:56am

You probably just need to grant read/write perms to apache on your assets directory.

Avatar
moloko_man

Community Member, 72 Posts

10 March 2011 at 11:44am

Edited: 10/03/2011 11:44am

I had that same issue mdaum and had to set write permissions to assets and every image-gallery folder and it's sub folders. Once I did that everything worked peachy.