[Isocial-svn] SF.net SVN: isocial: [231] app
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <fsn...@us...> - 2008-06-01 16:39:50
|
Revision: 231 http://isocial.svn.sourceforge.net/isocial/?rev=231&view=rev Author: fsnobody Date: 2008-06-01 09:39:58 -0700 (Sun, 01 Jun 2008) Log Message: ----------- changes with stored file Modified Paths: -------------- app/controllers/photoapp/album_controller.php app/installers/photoapp/album_installer.php app/models/photoapp_photo.php app/models/stored_file.php app/views/photoapp/album/edit_photo.tpl app/views/photoapp/album/uploaded.tpl app/views/photoapp/album/view.tpl Modified: app/controllers/photoapp/album_controller.php =================================================================== --- app/controllers/photoapp/album_controller.php 2008-06-01 15:41:30 UTC (rev 230) +++ app/controllers/photoapp/album_controller.php 2008-06-01 16:39:58 UTC (rev 231) @@ -24,10 +24,7 @@ } //$this->photos = $this->PhotoappPhoto->find('all', array('conditions' => array("album_id =" . $this->params['id']))); - - $_filter_pagination = array('items_per_page' => 15, 'count_conditions' => "album_id =" . $this->params['id'] ); - $this->photo_pages = $this->pagination_helper->getPaginator($this->PhotoappPhoto, $_filter_pagination);// paginator $_filter = array('conditions' => "album_id =" . $this->params['id']); @@ -99,8 +96,8 @@ $photo->album->load(); if ($photo->album->getId() && $photo->album->owner == $this->current_user->getId()) { if ($photo->destroy()) { - //$photo->album->photos_count = $photo->album->photos_count - 1; - //$photo->album->save(); + $photo->album->photos_count -= 1; + $photo->album->save(); $this->redirectTo(array('action' => 'view', 'id' => $photo->album->id)); } else { $this->importErrors( $this->PhotoappPhoto->getErrors() ); @@ -163,7 +160,10 @@ //$photo->stored_file->build(); //$photo->stored_file->assign($file); $photo->save(); + $this->album->photos_count += 1; } + $this->album->save(); + $this->redirectTo(array('action' => 'uploaded', 'id' => $photo->album_id)); } else if ($this->params['id']) { $this->album = $this->PhotoappAlbum->find($this->params['id']); return; Modified: app/installers/photoapp/album_installer.php =================================================================== --- app/installers/photoapp/album_installer.php 2008-06-01 15:41:30 UTC (rev 230) +++ app/installers/photoapp/album_installer.php 2008-06-01 16:39:58 UTC (rev 231) @@ -32,33 +32,8 @@ ) ENGINE=InnoDB"); - $this->execute( - "CREATE TRIGGER papp_photo_insert AFTER INSERT ON photoapp_photos - FOR EACH ROW BEGIN - UPDATE `photoapp_albums` SET photos_count = photos_count + 1 WHERE id = NEW.album_id; - END; - "); - $this->execute( - "CREATE TRIGGER papp_photo_delete AFTER DELETE ON photoapp_photos - FOR EACH ROW BEGIN - UPDATE `photoapp_albums` SET photos_count = photos_count - 1 WHERE id = OLD.album_id; - END; - "); - $this->execute( - "CREATE TRIGGER papp_photo_update AFTER UPDATE ON photoapp_photos - FOR EACH ROW BEGIN - - IF OLD.album_id != NEW.album_id THEN - UPDATE `photoapp_albums` SET photos_count = photos_count - 1 WHERE id = OLD.album_id; - UPDATE `photoapp_albums` SET photos_count = photos_count + 1 WHERE id = NEW.album_id; - END IF; - - END; - "); - - } Modified: app/models/photoapp_photo.php =================================================================== --- app/models/photoapp_photo.php 2008-06-01 15:41:30 UTC (rev 230) +++ app/models/photoapp_photo.php 2008-06-01 16:39:58 UTC (rev 231) @@ -5,9 +5,9 @@ var $belongs_to = array('album' => array('class_name' => 'PhotoappAlbum', 'primary_key_name' => 'album_id'), 'stored_file' => array('class_name' => 'StoredFile', 'primary_key_name' => 'base_file_id')); - /* + function beforeDestroy() { - +/* $albums_cover = $this->album->find('all', array('conditions' => array("img = '" . $this->img . "'"))); if ($albums_cover) foreach ($albums_cover as $album) { @@ -16,14 +16,14 @@ $album->save(); } } +*/ - $path = str_replace("@" , "/", $this->img); - $file = AK_PUBLIC_DIR . "/images/uploaded/" . $path; - `rm -f $file`; + $this->stored_file->load(); + $this->stored_file->remove(); return parent::beforeDestroy(); } - */ + } ?> \ No newline at end of file Modified: app/models/stored_file.php =================================================================== --- app/models/stored_file.php 2008-06-01 15:41:30 UTC (rev 230) +++ app/models/stored_file.php 2008-06-01 16:39:58 UTC (rev 231) @@ -3,6 +3,14 @@ class StoredFile extends BaseFile { + function location () { + return $this->user_id . DS . $this->name; + } + + function preview () { + return $this->user_id . "@" . $this->name; + } + function path () { return "images" . DS . "uploaded" . DS . $this->user_id . DS; } @@ -22,7 +30,7 @@ } function url () { - return AK_ASSET_URL_PREFIX . "/" . $this->path() . "/" . $this->name; + return AK_ASSET_URL_PREFIX . $this->path() . $this->name; } } Modified: app/views/photoapp/album/edit_photo.tpl =================================================================== --- app/views/photoapp/album/edit_photo.tpl 2008-06-01 15:41:30 UTC (rev 230) +++ app/views/photoapp/album/edit_photo.tpl 2008-06-01 16:39:58 UTC (rev 231) @@ -10,8 +10,8 @@ <?= $form_helper->hidden_field('photo_old', 'album_id', array('value' => $photo->get('album_id')))?> <div class="edit_container"> - <div class="photo_comment"> - <div class="img_medium"><img src="/preview/index/620x500/<?= $photo->get('img')?>" /></div> + <div class="photo_comment"><? $photo->stored_file->load();?> + <div class="img_medium"><img src="/preview/index/620x500/<?= $photo->stored_file->preview() ?>" /></div> <div class="data_medium"> <div class="form_create_row"> Modified: app/views/photoapp/album/uploaded.tpl =================================================================== --- app/views/photoapp/album/uploaded.tpl 2008-06-01 15:41:30 UTC (rev 230) +++ app/views/photoapp/album/uploaded.tpl 2008-06-01 16:39:58 UTC (rev 231) @@ -16,8 +16,8 @@ <div class="edit_container"> {loop uploaded_photos} <div class="photo_comment"> - <div class="img"> - <img src="/preview/index/100x100/<?= $uploaded_photo->get('img')?>" /> + <div class="img"><? $uploaded_photo->stored_file->load();?> + <img src="/preview/index/100x100/<?= $uploaded_photo->stored_file->preview() ?>" /> </div> <div class="data"> Modified: app/views/photoapp/album/view.tpl =================================================================== --- app/views/photoapp/album/view.tpl 2008-06-01 15:41:30 UTC (rev 230) +++ app/views/photoapp/album/view.tpl 2008-06-01 16:39:58 UTC (rev 231) @@ -16,10 +16,9 @@ <div class="edit_container"> {loop photos} <div class="photo_view"> - <div class="img"> - <ximg src="/preview/index/100x100/<?= $photo->stored_file->load()->url()?>" /> - <img src="<? $photo->stored_file->load(); echo $photo->stored_file->url() ?>" /> - </div> + <div class="img"><? $photo->stored_file->load() + ?><img src="/preview/index/100x100/<?= $photo->stored_file->preview() ?>" /><? + ?></div> <div class="links"> <ul class="actions_list"> <li><a href="/photoapp/album/edit_photo/<?= $photo->getId()?>">_{Edit}</a></li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |