Changeset 1381
- Timestamp:
- 05/23/06 20:26:26 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/generator/sfPropelAdmin/default/template/actions/actions.class.php
r1368 r1381 95 95 <?php $input_type = $this->getParameterValue('edit.fields.'.$column->getName().'.type') ?> 96 96 <?php if ($input_type == 'admin_input_upload_tag'): ?> 97 <?php $upload_dir = $this-> getParameterValue('edit.fields.'.$column->getName().'.upload_dir') ?>98 $currentFile = sfConfig::get('sf_upload_dir'). '/<?php echo $upload_dir ?>/'.$this-><?php echo $this->getSingularName() ?>->get<?php echo $column->getPhpName() ?>();97 <?php $upload_dir = $this->replaceConstants($this->getParameterValue('edit.fields.'.$column->getName().'.upload_dir')) ?> 98 $currentFile = sfConfig::get('sf_upload_dir')."/<?php echo $upload_dir ?>/".$this-><?php echo $this->getSingularName() ?>->get<?php echo $column->getPhpName() ?>(); 99 99 if (is_file($currentFile)) 100 100 { … … 142 142 <?php endif; ?> 143 143 <?php if ($input_type == 'admin_input_upload_tag'): ?> 144 <?php $upload_dir = $this-> getParameterValue('edit.fields.'.$column->getName().'.upload_dir') ?>145 $currentFile = sfConfig::get('sf_upload_dir'). '/<?php echo $upload_dir ?>/'.$this-><?php echo $this->getSingularName() ?>->get<?php echo $column->getPhpName() ?>();144 <?php $upload_dir = $this->replaceConstants($this->getParameterValue('edit.fields.'.$column->getName().'.upload_dir')) ?> 145 $currentFile = sfConfig::get('sf_upload_dir')."/<?php echo $upload_dir ?>/".$this-><?php echo $this->getSingularName() ?>->get<?php echo $column->getPhpName() ?>(); 146 146 if (!$this->getRequest()->hasErrors() && isset($<?php echo $this->getSingularName() ?>['<?php echo $name ?>_remove'])) 147 147 { … … 160 160 <?php endif; ?> 161 161 <?php if ($input_type == 'admin_input_upload_tag'): ?> 162 <?php if ($this->getParameterValue('edit.fields.'.$column->getName().'.filename')): ?> 163 $fileName = '<?php echo str_replace("'", "\\'", $this->getParameterValue('edit.fields.'.$column->getName().'.filename')) ?>'; 164 <?php else: ?> 162 165 $fileName = md5($this->getRequest()->getFileName('<?php echo $this->getSingularName() ?>[<?php echo $name ?>]').time()); 166 <?php endif ?> 163 167 $ext = $this->getRequest()->getFileExtension('<?php echo $this->getSingularName() ?>[<?php echo $name ?>]'); 164 168 if (is_file($currentFile)) … … 166 170 unlink($currentFile); 167 171 } 168 $this->getRequest()->moveFile('<?php echo $this->getSingularName() ?>[<?php echo $name ?>]', sfConfig::get('sf_upload_dir'). '/<?php echo $upload_dir ?>/'.$fileName.$ext);172 $this->getRequest()->moveFile('<?php echo $this->getSingularName() ?>[<?php echo $name ?>]', sfConfig::get('sf_upload_dir')."/<?php echo $upload_dir ?>/".$fileName.$ext); 169 173 $this-><?php echo $this->getSingularName() ?>->set<?php echo $column->getPhpName() ?>($fileName.$ext); 170 174 <?php elseif ($type == CreoleTypes::DATE || $type == CreoleTypes::TIMESTAMP): ?> trunk/lib/generator/sfPropelAdminGenerator.class.php
r1370 r1381 502 502 } 503 503 504 public function replaceConstants($value) 505 { 506 // find %%xx%% strings 507 preg_match_all('/%%([^%]+)%%/', $value, $matches, PREG_PATTERN_ORDER); 508 $this->params['tmp']['display'] = array(); 509 foreach ($matches[1] as $name) 510 { 511 $this->params['tmp']['display'][] = $name; 512 } 513 514 foreach ($this->getColumns('tmp.display') as $column) 515 { 516 $value = str_replace('%%'.$column->getName().'%%', '{$this->'.$this->getSingularName().'->get'.$column->getPhpName().'()}', $value); 517 } 518 519 return $value; 520 } 521 504 522 public function getColumnListTag($column, $params = array()) 505 523 {

