Beispiel #1
0
 public function executeUpload(sfWebRequest $request)
 {
     $result = 'All broken :(';
     try {
         //@todo: added CSRF check;
         $files = $request->getFiles();
         $fileData = array_pop($files);
         $validator = new sfValidatorFile(array('max_size' => 1024 * 1024, 'mime_types' => array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'application/octet-stream')));
         $file = $validator->clean($fileData);
         $file instanceof sfValidatedFile;
         $uploader = new ImageUploader();
         $uploaded = $uploader->login()->upload($file->getTempName());
         $photo = new Photo();
         $photo->name = $uploaded->image;
         $photo->thumb = $uploaded->thumb;
         $photo->save();
         $result = array('id' => $photo->getId(), 'image' => $uploaded->image, 'thumb' => $uploaded->thumb);
     } catch (Exception $e) {
         $result = $e->getMessage();
     }
     return $this->renderText(json_encode($result));
 }
    $photoObj = new Photo();
    if (isset($_POST['is_item'])) {
        $is_item = '1';
    } else {
        $is_item = '0';
    }
    if (isset($_POST['is_photo'])) {
        $is_photo = '1';
    } else {
        $is_photo = '0';
    }
    $photoObj->setID($_POST['id']);
    $photoObj->setDescription($_POST['description']);
    $photoObj->setIsItem($is_item);
    $photoObj->setIsPhoto($is_photo);
    $rowphoto = $photoDao->editOne($photoObj->getId(), $photoObj->getDescription(), $photoObj->getIsItem(), $photoObj->getIsPhoto());
}
?>

<div class="main container-fluid">
    <!--div class="section"-->
        <?php 
while ($row = $showPhotos->fetch_assoc()) {
    ?>
            <div class="secolPhoto">
                <table class="table datagrid" style="width: 25%">
                    <tr style="background-color: chocolate">
                        <th style="width: 25%"><?php 
    echo "<a style='color:darkred' href='showPhoto.php?photoid={$row['id']}'> " . $row['id'] . "</a>";
    ?>
</th>
 /**
  * Load an instance of an Photo entity from the database that corresponds to the previous Photo in Album
  *
  * @access public
  * @param Photo $photo
  * @param array $options (Optional) Read documentation on parseOptions for details
  * @return Photo
  */
 public function loadPrevious(Photo $photo, $options = null)
 {
     $this->resetQueryStrings();
     $this->query_reset_lock = true;
     if (!is_array($options) || !array_key_exists("order", $options)) {
         $this->query_order = "ORDER BY {$this->tableName}.id DESC";
     }
     $this->query_where = "WHERE " . $this->getTableName() . ".id < ? AND {$this->tableName}.albumid = ?";
     $this->query_params = array($photo->getId(), $photo->getAlbumId());
     $result = $this->loadGeneral($options);
     $this->query_reset_lock = false;
     return $result;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Photo $value A Photo object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Photo $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
 /**
  * Declares an association between this object and a Photo object.
  *
  * @param      Photo $v
  * @return     ProductHasPhoto The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setPhoto(Photo $v = null)
 {
     if ($v === null) {
         $this->setPhotoId(NULL);
     } else {
         $this->setPhotoId($v->getId());
     }
     $this->aPhoto = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Photo object, it will not be re-added.
     if ($v !== null) {
         $v->addProductHasPhoto($this);
     }
     return $this;
 }