Completed
Branch master (010acb)
by Gordon
05:58
created
code/ExifTask.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
     protected $enabled = true;
9 9
  
10 10
     function run($request) {
11
-		$imagesToProcess = GalleryImage::get()->filter('ExifRead', false);
12
-		foreach ($imagesToProcess->getIterator() as $image) {
13
-			echo 'Processing image '.$image->Title.'<br/>';
14
-			$image->processExifData();
15
-		}
11
+    $imagesToProcess = GalleryImage::get()->filter('ExifRead', false);
12
+    foreach ($imagesToProcess->getIterator() as $image) {
13
+      echo 'Processing image '.$image->Title.'<br/>';
14
+      $image->processExifData();
15
+    }
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
code/ImageMetaDataExtension.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class ImageMetaDataExtension extends DataExtension implements Mappable {
4
- static $db = array(
4
+  static $db = array(
5 5
     'Lat' => 'Decimal(18,15)',
6 6
     'Lon' => 'Decimal(18,15)',
7 7
     'ZoomLevel' => 'Int',
@@ -19,21 +19,21 @@  discard block
 block discarded – undo
19 19
 
20 20
 
21 21
   public function processExifData() {
22
-  	error_log('Processing exif data for '.$this->owner->ID);
23
-  	$filename = BASE_PATH.'/'.$this->owner->Image()->Filename;
24
-  	error_log('Checking '.$filename);
25
-
26
-  	// when the image is first saved, the file will still be a temp file
27
-  	if (file_exists($filename)) {
28
-  		try {
29
-     		$exif = exif_read_data($filename,0,true);
22
+    error_log('Processing exif data for '.$this->owner->ID);
23
+    $filename = BASE_PATH.'/'.$this->owner->Image()->Filename;
24
+    error_log('Checking '.$filename);
25
+
26
+    // when the image is first saved, the file will still be a temp file
27
+    if (file_exists($filename)) {
28
+      try {
29
+          $exif = exif_read_data($filename,0,true);
30 30
       
31
-		  	$aperture = $exif['COMPUTED']['ApertureFNumber'];
31
+        $aperture = $exif['COMPUTED']['ApertureFNumber'];
32 32
 
33
-		  	$aperture = str_replace('f/', '', $aperture);
34
-		  	error_log('APERTURE:'.$aperture);
33
+        $aperture = str_replace('f/', '', $aperture);
34
+        error_log('APERTURE:'.$aperture);
35 35
 
36
-		  	$this->owner->Aperture = $aperture;
36
+        $this->owner->Aperture = $aperture;
37 37
 
38 38
         $shutterspeed = '';
39 39
         if (isset($exif['ExposureTime'])) {
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
           $shutterspeed = $exif['EXIF']['ExposureTime'];
43 43
         }
44 44
 		  	
45
-		  	error_log('EXPOSURE:'.$shutterspeed);
46
-		  	$this->owner->ShutterSpeed = $shutterspeed;
45
+        error_log('EXPOSURE:'.$shutterspeed);
46
+        $this->owner->ShutterSpeed = $shutterspeed;
47 47
         if (isset($exif['DateTimeOriginal'])) {
48 48
           $this->owner->TakenAt = $exif['DateTimeOriginal'];  
49 49
         } else {
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
         error_log('ISO:'.$iso);
62 62
 		  	
63 63
 
64
-		  	// coors
65
-		  	if (isset($exif['GPS'])) {
64
+        // coors
65
+        if (isset($exif['GPS'])) {
66 66
           $gps = $exif['GPS'];
67
-		  		$latarray = $gps['GPSLatitude'];
67
+          $latarray = $gps['GPSLatitude'];
68 68
           $degrees = $latarray[0];
69 69
           $parts = explode('/', $degrees);
70 70
           $degrees = $parts[0] / $parts[1];
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
           $seconds = $parts[0] / $parts[1];
77 77
 
78 78
           error_log('LATITUDE: DMS='.$degrees.','.$minutes.','.$seconds);
79
-		  		$latitude = $degrees+$minutes/60+$seconds/3600;
79
+          $latitude = $degrees+$minutes/60+$seconds/3600;
80 80
           error_log('LAT:'.$latitude);
81 81
 
82 82
           error_log('LATITUDE:'.$latitude);
83 83
 
84
-		  		$lonarray = $gps['GPSLongitude'];
84
+          $lonarray = $gps['GPSLongitude'];
85 85
           $degrees = $lonarray[0];
86 86
           $parts = explode('/', $degrees);
87 87
           $degrees = $parts[0] / $parts[1];
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
           $parts = explode('/', $seconds);
93 93
           $seconds = $parts[0] / $parts[1];
94 94
 
95
-		  		$longitude =  $degrees+$minutes/60+$seconds/3600;
96
-		  		$this->owner->Lat = $latitude;
97
-		  		$this->owner->Lon = $longitude;
98
-		  	} else {
95
+          $longitude =  $degrees+$minutes/60+$seconds/3600;
96
+          $this->owner->Lat = $latitude;
97
+          $this->owner->Lon = $longitude;
98
+        } else {
99 99
           error_log('*** NO GPS DATA ***');
100 100
         }
101 101
         $image = $this->owner->Image();
@@ -104,46 +104,46 @@  discard block
 block discarded – undo
104 104
         }
105 105
 		  	
106 106
         $this->owner->ExifRead = true;
107
-		  	$this->owner->write();	
108
-  		}
109
-  		catch (Exception $e) {
110
-  			error_log($e);
111
-  		}
107
+        $this->owner->write();	
108
+      }
109
+      catch (Exception $e) {
110
+        error_log($e);
111
+      }
112 112
   		
113
-  	}
113
+    }
114 114
 
115 115
   	
116
-  	//print_r($exif);
116
+    //print_r($exif);
117 117
   }
118 118
 
119 119
 
120 120
 
121 121
   public function onAfterWriteNOT() {
122
-  	error_log('GI: On after write');
123
-  	parent::onAfterWrite();
122
+    error_log('GI: On after write');
123
+    parent::onAfterWrite();
124 124
    	
125
-  	if (!($this->owner->ExifRead)) {
126
-  		error_log('processing exif data');
127
-  		$this->processExifData();
128
-  	}
125
+    if (!($this->owner->ExifRead)) {
126
+      error_log('processing exif data');
127
+      $this->processExifData();
128
+    }
129 129
 
130
-  	error_log('/GI: On after write');
130
+    error_log('/GI: On after write');
131 131
 
132 132
   	
133 133
   }
134 134
 
135
-  	public function requireDefaultRecordsNOT() {
136
-		parent::requireDefaultRecords();
137
-		error_log('**** REQUIRE DEFAULT RECORDS FOR IMAGES ****');
138
-		$imagesToProcess = GalleryImage::get()->filter('ExifRead', false);
139
-		foreach ($imagesToProcess->getIterator() as $image) {
140
-			$image->processExifData();
141
-		}
142
-	}
135
+    public function requireDefaultRecordsNOT() {
136
+    parent::requireDefaultRecords();
137
+    error_log('**** REQUIRE DEFAULT RECORDS FOR IMAGES ****');
138
+    $imagesToProcess = GalleryImage::get()->filter('ExifRead', false);
139
+    foreach ($imagesToProcess->getIterator() as $image) {
140
+      $image->processExifData();
141
+    }
142
+  }
143 143
 
144 144
 
145 145
 
146
-	public function getMappableLatitude() {
146
+  public function getMappableLatitude() {
147 147
     return $this->owner->Lat;
148 148
   }
149 149
 
Please login to merge, or discard this patch.
code/GalleryFolder.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,21 +2,21 @@
 block discarded – undo
2 2
 
3 3
 class GalleryFolder extends PageWithImage {
4 4
 
5
-	private static $allowed_children = array(
6
-		'GalleryFolder',
7
-		'GalleryPage'
8
-	);
5
+  private static $allowed_children = array(
6
+    'GalleryFolder',
7
+    'GalleryPage'
8
+  );
9 9
 
10
-	public function getCMSFields() {
11
-		$fields = parent::getCMSFields();
12
-		$fields->renameField('Content','Brief Summary');
13
-		return $fields;
14
-	}
10
+  public function getCMSFields() {
11
+    $fields = parent::getCMSFields();
12
+    $fields->renameField('Content','Brief Summary');
13
+    return $fields;
14
+  }
15 15
 
16
-	/* Summary is a remapping of the content */
17
-	public function Summary() {
18
-		return $this->Content;
19
-	}
16
+  /* Summary is a remapping of the content */
17
+  public function Summary() {
18
+    return $this->Content;
19
+  }
20 20
 }
21 21
 
22 22
 class GalleryFolder_Controller extends PageWithImage_Controller {
Please login to merge, or discard this patch.
code/GalleryPage.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -2,40 +2,40 @@  discard block
 block discarded – undo
2 2
 
3 3
 class GalleryPage extends PageWithImage {
4 4
 	
5
-	public static $has_many = array(
6
-    	'GalleryImages' => 'GalleryImage'
7
-  	);
5
+  public static $has_many = array(
6
+      'GalleryImages' => 'GalleryImage'
7
+    );
8 8
 
9 9
   private static $db = array(
10 10
     'GalleryDate' => 'Date'
11 11
   );
12 12
 
13
-   private static $icon = 'ss3gallery/icons/photo.png'; 
13
+    private static $icon = 'ss3gallery/icons/photo.png'; 
14 14
 
15 15
   
16
-   public function getCMSFields() {
17
-   		$fields = parent::getCMSFields();
18
-  		$gridFieldConfig = GridFieldConfig_RecordEditor::create(); 
19
-  		//$gridFieldConfig->addComponent(new GridFieldBulkEditingTools());
20
-  		$gridFieldConfig->addComponent($gbu = new GridFieldBulkUpload());  
21
-  		$gridFieldConfig->addComponent($gbm = new GridFieldBulkManager()); 
22
-  		$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));    
23
-  		$galleryimagesi18n = _t('GalleryImage.PLURALNAME', "Gallery Images");
24
-  		//$gbu->setConfig('fileRelationName','Image');
25
-  		$gbu->setConfig('folderName', 'galleries/'.$this->ID);
26
-  		//$gbm->setConfig('editableFields', array('Title'));
27
-  		$gbm->setConfig('fieldsNameBlacklist', array('Lat','Lon','ZoomLevel'));
28
-  		$gridfield = new GridField("GalleryImages", $galleryimagesi18n, $this->GalleryImages()->sort("SortOrder"), $gridFieldConfig);
29
-  		$fields->addFieldToTab('Root.'.$galleryimagesi18n, $gridfield);
16
+    public function getCMSFields() {
17
+        $fields = parent::getCMSFields();
18
+      $gridFieldConfig = GridFieldConfig_RecordEditor::create(); 
19
+      //$gridFieldConfig->addComponent(new GridFieldBulkEditingTools());
20
+      $gridFieldConfig->addComponent($gbu = new GridFieldBulkUpload());  
21
+      $gridFieldConfig->addComponent($gbm = new GridFieldBulkManager()); 
22
+      $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));    
23
+      $galleryimagesi18n = _t('GalleryImage.PLURALNAME', "Gallery Images");
24
+      //$gbu->setConfig('fileRelationName','Image');
25
+      $gbu->setConfig('folderName', 'galleries/'.$this->ID);
26
+      //$gbm->setConfig('editableFields', array('Title'));
27
+      $gbm->setConfig('fieldsNameBlacklist', array('Lat','Lon','ZoomLevel'));
28
+      $gridfield = new GridField("GalleryImages", $galleryimagesi18n, $this->GalleryImages()->sort("SortOrder"), $gridFieldConfig);
29
+      $fields->addFieldToTab('Root.'.$galleryimagesi18n, $gridfield);
30 30
 
31 31
       $fields->addFieldToTab('Root.Date', new DateField('GalleryDate'));
32
-  		return $fields;
32
+      return $fields;
33 33
   }
34 34
 
35 35
 
36 36
 
37 37
   public function Map() {
38
-  	$photosWithLocation = $this->GalleryImages()->where('Lat != 0 AND Lon !=0');
38
+    $photosWithLocation = $this->GalleryImages()->where('Lat != 0 AND Lon !=0');
39 39
     if ($photosWithLocation->count() == 0) {
40 40
       return 'No locations found'; // don't render a map
41 41
     }
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 }
61 61
 class GalleryPage_Controller extends Page_Controller {
62 62
 	
63
-	public static $allowed_actions = array (
64
-	);
63
+  public static $allowed_actions = array (
64
+  );
65 65
 	
66
-	public function GetGalleryImages() {
67
-		return $this->GalleryImages()->sort("SortOrder");
68
-	}
66
+  public function GetGalleryImages() {
67
+    return $this->GalleryImages()->sort("SortOrder");
68
+  }
69 69
 }
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
code/GalleryImageShortCodeHandler.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
         $customise['Aperture'] = $galleryImage->Aperture;
31 31
         $customise['ShutterSpeed'] = $galleryImage->ShutterSpeed;
32 32
     
33
-         //set the caption
33
+          //set the caption
34 34
         $customise['Title'] = $galleryImage->Title;
35 35
    
36 36
         //overide the defaults with the arguments supplied
Please login to merge, or discard this patch.
code/GalleryImage.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
  
5 5
   
6 6
   public static $db = array(	
7
-	  'SortOrder' => 'Int',
8
-	  'Title' => 'Varchar'
7
+    'SortOrder' => 'Int',
8
+    'Title' => 'Varchar'
9 9
   );
10 10
  
11 11
   // One-to-one relationship with gallery page
@@ -14,28 +14,28 @@  discard block
 block discarded – undo
14 14
     'GalleryPage' => 'GalleryPage'	
15 15
   );
16 16
  
17
- // tidy up the CMS by not showing these fields
17
+  // tidy up the CMS by not showing these fields
18 18
   public function getCMSFields() {
19
- 		$fields = parent::getCMSFields();
20
-		$fields->removeFieldFromTab("Root.Main","GalleryPageID");
19
+      $fields = parent::getCMSFields();
20
+    $fields->removeFieldFromTab("Root.Main","GalleryPageID");
21 21
     $fields->removeFieldFromTab("Root.Main","SortOrder");
22 22
     $fields->renameField('Title', _t('GalleryImage.TITLE', 'Title'));
23 23
     $fields->renameField('Image', _t('GalleryImage.IMAGE', 'Image'));
24 24
 
25 25
 
26
-		return $fields;		
26
+    return $fields;		
27 27
   }
28 28
   
29 29
   // Tell the datagrid what fields to show in the table
30
-   public static $summary_fields = array( 
31
-       'ID' => 'ID',
32
-	   'Title' => 'Title',
33
-	   'Thumbnail' => 'Thumbnail'     
34
-   );
30
+    public static $summary_fields = array( 
31
+        'ID' => 'ID',
32
+      'Title' => 'Title',
33
+      'Thumbnail' => 'Thumbnail'     
34
+    );
35 35
   
36 36
   // this function creates the thumnail for the summary fields to use
37
-   public function getThumbnail() { 
38
-     return $this->Image()->CMSThumbnail();
37
+    public function getThumbnail() { 
38
+      return $this->Image()->CMSThumbnail();
39 39
   }
40 40
 
41 41
 
Please login to merge, or discard this patch.