Example #1
0
 /**
  * Process a photo
  *
  * @param integer $id The photo id of the photo to process
  *
  * @return array An associative array of 'status', and optionally
  *               'error_message', 'auto_publish', 'tile', and 'new_tags'
  */
 public function processPhoto($id)
 {
     $photo = $this->getPhoto($id);
     $photo->setFileBase('../../photos');
     $processor = new PinholePhotoProcessor($this->app);
     $processor->processPhoto($photo);
     return $this->getResponse($photo);
 }
Example #2
0
 protected function processPhotos()
 {
     /* NOTE: this only normally runs if the user doesn't have javacript
     		         enabled or doesn't support ajax. Otherwise, the processing
     		         form is hidden and in-line processing calls are handled via
     		         javascript.
     		*/
     require_once 'Pinhole/PinholePhotoProcessor.php';
     $processor = new PinholePhotoProcessor($this->app);
     foreach ($this->unprocessed_photos as $photo) {
         $processor->processPhoto($photo);
     }
     $this->app->relocate($this->getComponentName() . '/LastUpload');
 }
 /**
  * Creates a new file in this directory
  *
  * @param string   $name the name of the file to create.
  * @param resource $data optional. The initial data payload. If null,
  *                       an empty file is created.
  */
 public function createFile($original_filename, $data = null)
 {
     $ext = strtolower(end(explode('.', $original_filename)));
     $filename = uniqid('file') . '.' . $ext;
     $file_path = sprintf('%s/%s', sys_get_temp_dir(), $filename);
     file_put_contents($file_path, $data);
     $files = PinholePhoto::parseFile($file_path, $original_filename);
     $image_set = $this->getImageSet();
     $now = new SwatDate();
     $now->toUTC();
     foreach ($files as $temp_filename => $original_filename) {
         $class_name = SwatDBClassMap::get('PinholePhoto');
         $photo = new $class_name();
         $photo->setDatabase($this->app->db);
         $photo->image_set = $image_set->id;
         //$photo->upload_set = $upload_set;
         $photo->original_filename = $original_filename;
         $photo->temp_filename = $temp_filename;
         $photo->status = PinholePhoto::STATUS_UNPROCESSED;
         $photo->dav_upload = true;
         $photo->upload_date = $now;
         $config = $this->app->config->pinhole;
         $photo->auto_publish = !$config->dav_set_pending;
         $photo->private = $config->dav_set_private_photos;
         $photo->photo_time_zone = $config->dav_photo_time_zone;
         $photo->camera_time_zone = $config->dav_photo_time_zone;
         $photo->auto_rotate = $config->dav_auto_rotate;
         $photo->set_content_by_meta_data = $config->dav_set_content_by_meta_data;
         $photo->set_tags_by_meta_data = $config->dav_set_tags_by_meta_data;
         $photo->save();
         $photo->setFileBase('../photos');
         $processor = new PinholePhotoProcessor($this->app);
         $processor->processPhoto($photo);
         $photo->save();
     }
 }