예제 #1
0
 /**
  * Updates this file's data
  *
  * @param resource $data
  *
  * @return void
  */
 public function put($data)
 {
     $path = sprintf('%s/%s', sys_get_temp_dir(), $this->photo->temp_filename);
     file_put_contents($path, $data);
     $this->photo->upload_date = new SwatDate();
     $this->photo->upload_date->toUTC();
     $this->photo->save();
 }
예제 #2
0
파일: Edit.php 프로젝트: gauthierm/pinhole
 protected function saveDBData()
 {
     $this->setPhotoValues();
     $this->photo->save();
     $tags = $this->ui->getWidget('tags')->getSelectedTagArray();
     $this->photo->addTagsByName($tags, true);
     if ($this->app->config->pinhole->passphrase === null && $this->ui->getWidget('private')->value) {
         $this->app->config->pinhole->passphrase = md5($this->ui->getWidget('passphrase')->value);
         $this->app->config->save(array('pinhole.passphrase'));
     }
     $this->addToSearchQueue();
     if (isset($this->app->memcache)) {
         $this->app->memcache->flushNs('photos');
     }
     $message = new SwatMessage(sprintf(Pinhole::_('“%s” has been saved.'), $this->photo->getTitle(true)));
     $this->app->messages->add($message);
 }
예제 #3
0
 /**
  * Applies this tag to a photo
  *
  * @param PinholePhoto $photo the photo this tag is to be applied to.
  */
 public function applyToPhoto(PinholePhoto $photo)
 {
     $photo->for_sale = $this->getValue();
     $photo->save();
 }
예제 #4
0
    /**
     * Applies this tag to a photo
     *
     * Any unsaved changes to the tag and photo are saved before this tag is
     * applied to the photo.
     *
     * @param PinholePhoto $photo the photo this tag is to be applied to.
     */
    public function applyToPhoto(PinholePhoto $photo)
    {
        $transaction = new SwatDBTransaction($this->db);
        try {
            // save photo and tag
            $photo->save();
            $this->save();
            // save binding
            $sql = sprintf('insert into PhotoPhotoTagBinding (photo, tag)
				values (%s, %s)', $this->db->quote($photo->id, 'integer'), $this->db->quote($this->id, 'integer'));
            SwatDB::exec($this->db, $sql);
            $transaction->commit();
        } catch (Exception $e) {
            $transaction->rollback();
            throw $e;
        }
        $this->photos->add($photo);
    }