Changeset 485

Show
Ignore:
Timestamp:
12/02/08 10:21:47 (1 month ago)
Author:
nicolas
Message:

Upload photos en flash (ne pas faire de release)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/intranet/modules/picture/actions/actions.class.php

    r426 r485  
    101101    $this->pictures = PicturePeer::doSelect($c); 
    102102 
    103     if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg') { 
    104       $fileType = 'jpg'; 
    105       $fileCreateFunc = 'imagecreatefromjpeg'; 
    106       $fileImageFunc = 'imagejpeg'; 
    107     } 
    108     elseif ($fileType == 'image/png' || $fileType == 'image/x-png') { 
    109       $fileType = 'jpg'; 
    110       $fileCreateFunc = 'imagecreatefrompng'; 
    111       $fileImageFunc = 'imagejpeg'; 
    112     } 
     103    $fileCreateFunc = 'imagecreatefromjpeg'; 
     104    $fileImageFunc = 'imagejpeg'; 
    113105 
    114106    $picture = new Picture(); 
    115107    $picture->setEstateId($estate_id); 
    116108    $picture->setName($uniqid); 
    117     $picture->setFormat($fileType); 
     109    $picture->setFormat('jpg'); 
    118110    $picture->setContent($content); 
    119111    $picture->setRank(PicturePeer::getMaxRank($estate_id)+1); 
     
    122114    $picture->save(); 
    123115 
    124                 // Redimensionnement 
    125                 // Calcul des nouvelles dimensions 
    126                 list ($width, $height) = getimagesize($this->getRequest()->getFilePath('file')); 
    127                 if ($height >= $width) { 
    128                         $new_height[0] = 800; 
    129                         $new_height[1] = 400; 
    130                         $new_height[2] = 100; 
    131                         $new_width[0] = round($new_height[0] / $height * $width); 
    132                         $new_width[1] = round($new_height[1] / $height * $width); 
    133                         $new_width[2] = round($new_height[2] / $height * $width); 
    134                 } else { 
    135                         $new_width[0] = 800; 
    136                         $new_width[1] = 400; 
    137                         $new_width[2] = 100; 
    138                         $new_height[0] = round($new_width[0] / $width * $height); 
    139                         $new_height[1] = round($new_width[1] / $width * $height); 
    140                         $new_height[2] = round($new_width[2] / $width * $height); 
    141                 } 
    142  
    143                 for ($i = 0; $i < count($new_width); $i ++) { 
    144                         if ($height >= $width) 
    145                                 $filesize = $new_height[$i]; 
    146                         else 
    147                                 $filesize = $new_width[$i]; 
    148                         $image_p = imagecreatetruecolor($new_width[$i], $new_height[$i]); 
    149                         $image = $fileCreateFunc($this->getRequest()->getFilePath('file')); 
    150                         imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width[$i], $new_height[$i], $width, $height); 
    151                         mkdir(sfConfig::get('sf_upload_dir').'/estate_pictures/'.$estate_id, 0755); 
    152                         $fileImageFunc($image_p, sfConfig::get('sf_upload_dir').'/estate_pictures/'.$estate_id.'/'.$uniqid.'_'.$filesize.'.'.$fileType, 100); 
    153                 } 
     116        // Redimensionnement 
     117        // Calcul des nouvelles dimensions 
     118        list ($width, $height) = getimagesize($this->getRequest()->getFilePath('file')); 
     119        if ($height >= $width) { 
     120                $new_height[0] = 800; 
     121                $new_height[1] = 400; 
     122                $new_height[2] = 100; 
     123                $new_width[0] = round($new_height[0] / $height * $width); 
     124                $new_width[1] = round($new_height[1] / $height * $width); 
     125                $new_width[2] = round($new_height[2] / $height * $width); 
     126    } else { 
     127                $new_width[0] = 800; 
     128                $new_width[1] = 400; 
     129                $new_width[2] = 100; 
     130                $new_height[0] = round($new_width[0] / $width * $height); 
     131                $new_height[1] = round($new_width[1] / $width * $height); 
     132                $new_height[2] = round($new_width[2] / $width * $height); 
     133    } 
     134 
     135        for ($i = 0; $i < count($new_width); $i ++) { 
     136          if ($height >= $width) 
     137          $filesize = $new_height[$i]; 
     138          else 
     139          $filesize = $new_width[$i]; 
     140          $image_p = imagecreatetruecolor($new_width[$i], $new_height[$i]); 
     141          $image = $fileCreateFunc($this->getRequest()->getFilePath('file')); 
     142          imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width[$i], $new_height[$i], $width, $height); 
     143          mkdir(sfConfig::get('sf_upload_dir').'/estate_pictures/'.$estate_id, 0755); 
     144          $fileImageFunc($image_p, sfConfig::get('sf_upload_dir').'/estate_pictures/'.$estate_id.'/'.$uniqid.'_'.$filesize.'.jpg', 100); 
     145        } 
     146    /* 
    154147    if ($this->getRequestParameter('sales_id')) 
    155148    $this->redirect('sales/show?id='.$this->getRequestParameter('sales_id').'&referer=picture'); 
    156149    elseif($this->getRequestParameter('rent_id')) 
    157150    $this->redirect('rent/show?id='.$this->getRequestParameter('rent_id').'&referer=picture'); 
     151    */ 
    158152  } 
    159153 
  • trunk/apps/intranet/modules/picture/config/view.yml

    r425 r485  
    11xmlSuccess: 
    22  has_layout:     false 
     3 
     4uploadSuccess: 
     5  http_metas: 
     6    content-type: text/html; charset=UTF-8 
     7 
     8  metas: 
     9    title:        Apimo 
     10    robots:       index, follow 
     11    language:     fr 
     12 
     13  stylesheets:    [main, default] 
     14 
     15  has_layout:     on 
     16  layout:         login 
  • trunk/apps/intranet/modules/picture/templates/_thumb.php

    r426 r485  
    117117         if($access[2]): ?> 
    118118        <hr /> 
     119 
     120 
     121 
    119122        <h3><?php echo ucfirst(__('add')) ?></h3> 
    120         <?php echo form_tag('picture/upload', 'multipart=true') ?> 
    121           <?php echo input_file_tag('file') ?> 
    122           <?php if(isset($sales)) echo input_hidden_tag('sales_id', $sales->getId()) ?> 
    123           <?php if(isset($rent))  echo input_hidden_tag('rent_id', $rent->getId()) ?> 
    124           <?php echo input_hidden_tag('estate_id', $estate->getId()) ?><br /><br /> 
    125           <?php echo ucfirst(__('comment')) ?> : <?php echo input_tag('comment', '', array('size' => '40')) ?> 
    126           <br /><br /> 
    127           <?php echo submit_image_tag('tpl_02/'.$sf_user->getCulture().'/button/save.png') ?> 
    128         </form> 
     123    <?php include_partial('picture/form') ?> 
    129124        <?php endif; 
    130125 } ?> 
  • trunk/web/css/tpl_02.css

    r452 r485  
    166166.homepage_table td a:hover              { text-decoration:underline; } 
    167167.homepage_table .highlight a            { color:#db001b; } 
     168 
     169.homepage_table2 th, 
     170.homepage_table2 td                     { height:20px; font-size:13px; font-weight:bold; } 
     171.homepage_table2 td                     { color:#666; } 
     172.homepage_table2 td a                   { color:#83b817; text-decoration:none; } 
     173.homepage_table2 td.highlight           { color:#db001b; }