function add_to_gallery() { $gallery_peer = new GalleryPeer(); $gallery = $gallery_peer->find_by_id(Params::get("id_gallery")); $collection_peer = new GalleryCollectionPeer(); $gallery_collection = $collection_peer->find_by_id($gallery->id_gallery_collection); $full_folder_path = GalleryCollectionController::GALLERY_COLLECTION_ROOT_DIR . $gallery_collection->folder . "/" . $gallery->folder; if (Upload::isUploadSuccessful("file")) { $filename = Random::newHexString() . "_" . Upload::getRealFilename("file"); $gallery_dir = new Dir($full_folder_path); $uploaded_img = Upload::saveTo("file", $gallery_dir, $filename); if (isset(Config::instance()->GALLERY_RESIZE_BY_WIDTH)) { image_w($uploaded_img->getPath(), Config::instance()->GALLERY_RESIZE_BY_WIDTH); } else { if (isset(Config::instance()->GALLERY_RESIZE_BY_HEIGHT)) { image_h($uploaded_img->getPath(), Config::instance()->GALLERY_RESIZE_BY_HEIGHT); } } $peer = new GalleryImagePeer(); $do = $peer->new_do(); $peer->setupByParams($do); $do->image_name = $filename; $peer->save($do); return Redirect::success(); } else { Flash::error(Upload::getUploadError("file")); return Redirect::failure(); } }
function create_collection() { $peer = new GalleryCollectionPeer(); $do = $peer->new_do(); $peer->setupByParams($do); $do->folder = Random::newHexString(); $d = new Dir(self::GALLERY_COLLECTION_ROOT_DIR . $do->folder); $d->touch(); $peer->save($do); if (is_html()) { return Redirect::success(); } else { return Result::ok(); } }
function create_gallery() { $peer = new GalleryPeer(); $gallery = $peer->new_do(); $peer->setupByParams($gallery); $gallery->folder = Random::newHexString(); $peer_collection = new GalleryCollectionPeer(); $collection = $peer_collection->find_by_id($gallery->id_gallery_collection); $d = new Dir(GalleryCollectionController::GALLERY_COLLECTION_ROOT_DIR . $collection->folder . "/" . $gallery->folder); $d->touch(); $peer->save($gallery); if (is_html()) { return Redirect::success(); } else { return Result::ok(); } }
function newRandomSubdir() { return $this->newSubdir(Random::newHexString()); }