Beispiel #1
0
 /**
  * Processes rules after storing an image
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function afterStore($file, SocialImage $image)
 {
     // Load up exif library
     $exif = FD::get('Exif');
     // Push all the ordering of the photo down
     $model = FD::model('Photos');
     $model->pushPhotosOrdering($this->album_id, $this->id);
     // Detect location for the photo
     if ($exif->isAvailable() && $image->hasExifSupport()) {
         // Load the file
         $exif->load($file['tmp_name']);
         // Get the location
         $locationCoordinates = $exif->getLocation();
         // Once we have the coordinates, we need to reverse geocode it to get the address.
         if ($locationCoordinates) {
             $my = FD::user();
             $geocode = FD::get('GeoCode');
             $address = $geocode->reverse($locationCoordinates->latitude, $locationCoordinates->longitude);
             $location = FD::table('Location');
             $location->loadByType($this->id, SOCIAL_TYPE_PHOTO, $my->id);
             $location->address = $address;
             $location->latitude = $locationCoordinates->latitude;
             $location->longitude = $locationCoordinates->longitude;
             $location->user_id = $my->id;
             $location->type = SOCIAL_TYPE_PHOTO;
             $location->uid = $this->id;
             $state = $location->store();
         }
         // Store custom meta data for the photo
         $model->storeCustomMeta($this, $exif);
     }
     // Synchronize with our search index
     $indexer = FD::get('Indexer');
     $template = $indexer->getTemplate();
     $template->setContent($this->title, $this->caption);
     // Get the url for the photo
     // $url     = FRoute::photos( array( 'layout' => 'item', 'id' => $this->getAlias() ) );
     $url = $this->getPermalink();
     $template->setSource($this->id, SOCIAL_INDEXER_TYPE_PHOTOS, $this->uid, $url);
     $template->setThumbnail($this->getSource('thumbnail'));
     $indexer->index($template);
 }