From: Gustavo Martin Morcuende Date: Sat, 26 May 2012 18:23:55 +0000 (+0200) Subject: Load ads pictures directly on the server. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=3597b3309154564c4af9f1c14a2cadbcfd8b79ff;p=mobi%2F.git Load ads pictures directly on the server. --- diff --git a/apps/companyfront/config/app.yml b/apps/companyfront/config/app.yml index 40a5a99..c36f791 100644 --- a/apps/companyfront/config/app.yml +++ b/apps/companyfront/config/app.yml @@ -3,10 +3,11 @@ # default values all: - max_offices_on_pager: 3 - max_ads_on_pager: 2 - max_categories_on_pager: 3 - default_language: eng # Everything must exist at least with this language + max_offices_on_pager: 3 + max_ads_on_pager: 2 + max_categories_on_pager: 3 + default_picture_directory: /home/gustavo/symfonyreloaded/mobiads/web/uploads/images/ + default_language: eng # Everything must exist at least with this language sf_guard_plugin: remember_key_expiration_age: 2592000 # 30 days in seconds diff --git a/apps/companyfront/modules/ad/actions/actions.class.php b/apps/companyfront/modules/ad/actions/actions.class.php index 9919373..76a177b 100644 --- a/apps/companyfront/modules/ad/actions/actions.class.php +++ b/apps/companyfront/modules/ad/actions/actions.class.php @@ -159,6 +159,10 @@ class adActions extends sfActions $this->forward404Unless($companyId == $companyUserId, sprintf('Ad does not exist (%s).', $request->getParameter('id'))); + //Remove picture from file system. + $fs = new sfFilesystem(); + $fs->remove(sfConfig::get('app_default_picture_directory').$ad->getAdMobileImageLink()); + //Remove ad from database. $ad->delete(); $this->redirect('ad/index'); diff --git a/apps/companyfront/modules/ad/templates/_list.php b/apps/companyfront/modules/ad/templates/_list.php index ca8ac29..84322dc 100644 --- a/apps/companyfront/modules/ad/templates/_list.php +++ b/apps/companyfront/modules/ad/templates/_list.php @@ -17,14 +17,14 @@ - <?php echo $ad->getAdName() ?> + getAd()->getAdMobileImageLink() ?>" width="80" height="80" alt="getAdName() ?>"/> getAd()->getCompanyCategId() != null): ?> getAd()->getCompanyCategory() ?> getAdName() ?> - + ', 'ad/delete?id='.$ad->getAd()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?> diff --git a/lib/form/doctrine/AdForm.class.php b/lib/form/doctrine/AdForm.class.php index 7235442..6ad7420 100644 --- a/lib/form/doctrine/AdForm.class.php +++ b/lib/form/doctrine/AdForm.class.php @@ -28,6 +28,19 @@ class AdForm extends BaseAdForm 'required' => false, 'query' => $companyCategs)); + + $this->widgetSchema['ad_mobile_image_link'] = + new sfWidgetFormInputFileEditable(array('file_src' => '/uploads/images/'.$this->getObject()->ad_mobile_image_link, + 'edit_mode' => !$this->isNew(), + 'is_image' => true, + 'with_delete' => false)); + + + $this->validatorSchema['ad_mobile_image_link'] = new sfValidatorFile(array('mime_types' => 'web_images', + 'path' => sfConfig::get('app_default_picture_directory'), + 'required' => true)); + + $this->widgetSchema->setLabels(array('company_categ_id' => 'Company Category')); $this->widgetSchema->setLabels(array('ad_mobile_image_link' => "Picture on the user's mobile"));