Changeset 10980
- Timestamp:
- Mar 10, 2009, 6:01:01 PM (12 years ago)
- Location:
- OpenPNE3/trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/trunk/apps/pc_frontend/i18n/messages.ja.xml
r10927 r10980 523 523 <target>退会者データ</target> 524 524 </trans-unit> 525 <trans-unit id=""> 526 <source>Remove the current photo</source> 527 <target>この写真を削除する</target> 528 </trans-unit> 525 529 </body> 526 530 </file> -
OpenPNE3/trunk/lib/action/sfOpenPNECommunityAction.class.php
r10939 r10980 53 53 54 54 $this->community = CommunityPeer::retrieveByPk($this->id); 55 if (!$this->community) 56 { 57 $this->community = new Community(); 58 } 59 55 60 56 61 $this->communityForm = new CommunityForm($this->community); 57 62 $this->communityConfigForm = new CommunityConfigForm(array(), array('community' => $this->community)); 58 $this->communityFileForm = new CommunityFileForm( );63 $this->communityFileForm = new CommunityFileForm(array(), array('community' => $this->community)); 59 64 60 65 if ($request->isMethod('post')) … … 67 72 if ($this->communityForm->isValid() && $this->communityConfigForm->isValid() && $this->communityFileForm->isValid()) 68 73 { 69 $community = $this->communityForm->save(); 70 $this->communityConfigForm->save($community); 71 $this->communityFileForm->save($community); 72 $this->redirect('community/home?id='.$community->getId()); 74 $this->communityForm->save(); 75 $this->communityConfigForm->save(); 76 $this->communityFileForm->save(); 77 78 $this->redirect('community/home?id='.$this->community->getId()); 73 79 } 74 80 } -
OpenPNE3/trunk/lib/form/CommunityConfigForm.class.php
r10939 r10980 50 50 if (!($community instanceof Community)) 51 51 { 52 if (!$this->community) 53 { 54 $community = new Community(); 55 } 56 else 57 { 58 return; 59 } 52 $community = new Community(); 60 53 } 61 54 $this->community = $community; … … 100 93 } 101 94 102 public function save( Community $community)95 public function save() 103 96 { 104 97 foreach ($this->getValues() as $key => $value) … … 108 101 { 109 102 $config = new CommunityConfig(); 110 $config->setCommunity($ community);103 $config->setCommunity($this->community); 111 104 $config->setName($key); 112 105 } -
OpenPNE3/trunk/lib/form/CommunityFileForm.class.php
r10939 r10980 19 19 class CommunityFileForm extends sfForm 20 20 { 21 protected 22 $community; 23 21 24 public function __construct($defaults = array(), $options = array(), $CSRFSecret = null) 22 25 { … … 26 29 public function configure() 27 30 { 28 $this->setWidget('file', new sfWidgetFormInputFile()); 31 $this->setCommunity($this->getOption('community')); 32 33 $options = array( 34 'file_src' => '', 35 'is_image' => true, 36 'with_delete' => true, 37 'delete_label' => sfContext::getInstance()->getI18N()->__('Remove the current photo') 38 ); 39 40 if (!$this->community->isNew() && $this->community->getFileId()) 41 { 42 sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); 43 $options['edit_mode'] = true; 44 $options['template'] = get_partial('default/formEditImage', array('image' => $this->community)); 45 $this->setValidator('file_delete', new sfValidatorBoolean(array('required' => false))); 46 } 47 else 48 { 49 $options['edit_mode'] = false; 50 } 51 52 $this->setWidget('file', new sfWidgetFormInputFileEditable($options, array('size' => 40))); 29 53 $this->setValidator('file', new opValidatorImageFile(array('required' => false))); 30 54 … … 34 58 } 35 59 36 public function s ave(Community$community)60 public function setCommunity($community) 37 61 { 38 if (! $this->getValue('file'))62 if (!($community instanceof Community)) 39 63 { 40 return false; 64 $community = new Community(); 65 } 66 $this->community = $community; 67 } 68 69 public function save() 70 { 71 if ($this->getValue('file')) 72 { 73 if ($this->community->getFile()) 74 { 75 $this->community->getFile()->delete(); 76 } 77 78 $file = new File(); 79 $file->setFromValidatedFile($this->getValue('file')); 80 $file->setName('c_'.$this->community->getId().'_'.$file->getName()); 81 82 $this->community->setFile($file); 83 } 84 elseif ($this->getValue('file_delete')) 85 { 86 $this->community->getFile()->delete(); 87 $this->community->setFile(null); 88 } 89 else 90 { 91 return; 41 92 } 42 93 43 if ($community->getFile()) 44 { 45 $community->getFile()->delete(); 46 } 47 48 $file = new File(); 49 $file->setFromValidatedFile($this->getValue('file')); 50 $file->setName('c_'.$community->getId().'_'.$file->getName()); 51 52 $community->setFile($file); 53 54 $community->save(); 94 $this->community->save(); 55 95 } 56 96 }
Note: See TracChangeset
for help on using the changeset viewer.