Esempio n. 1
0
 public function save($conn = null)
 {
     parent::save();
     $BASE = sfConfig::get('sf_web_dir') . '/' . $this->WEB_IMAGE;
     $OC = $this->getObject();
     if ($OC instanceof Cicles) {
         $I = $OC->getImatge();
         if (!empty($I) && file_exists($BASE . $I)) {
             $img = new sfImage($BASE . $I, 'image/jpg');
             $img->resize(100, 100);
             $nom = $OC->getCicleid() . '.jpg';
             $img->saveAs($BASE . $nom);
             if ($I != $nom) {
                 unlink($BASE . $I);
             }
             $OC->setImatge($nom)->save();
         }
         $P = $OC->getPdf();
         if (!empty($P) && file_exists($BASE . $P)) {
             $nom = $OC->getCicleid() . '.pdf';
             rename($BASE . $P, $BASE . $nom);
             if ($P != $nom) {
                 unlink($BASE . $P);
             }
             $OC->setPdf($nom)->save();
         }
     }
 }
 public function save($conn = null)
 {
     parent::save();
     //Si guardem el cicle per primera vegada, mirem les imatges que s'han entrat i que no tenen cicle. Les assignarem a aquest.
     $dir = getcwd() . '/images/cicles/';
     $mini = false;
     $normal = false;
     $big = false;
     $pdf = false;
     $IDC = $this->getObject()->getCicleid();
     foreach (glob($dir . 'C--*') as $K => $arxiu) {
         $a = str_replace($dir, "", $arxiu);
         //Si té un -M és la foto mini.
         if (substr_count($arxiu, "-M") > 0) {
             rename($arxiu, str_replace('--', '-' . $IDC . '-', $arxiu));
         }
         if (substr_count($arxiu, "-L") > 0) {
             rename($arxiu, str_replace('--', '-' . $IDC . '-', $arxiu));
         }
         if (substr_count($arxiu, "-XL") > 0) {
             rename($arxiu, str_replace('--', '-' . $IDC . '-', $arxiu));
         }
         if (substr_count($arxiu, "-PDF") > 0) {
             rename($arxiu, str_replace('--', '-' . $IDC . '-', $arxiu));
         }
     }
     /*
       	$BASE = sfConfig::get('sf_web_dir').'/'.$this->WEB_IMAGE;  	
       	$OC = $this->getObject(); 	
       	if($OC instanceof Cicles):
       	  		
       		$I = $OC->getImatge();
       		if(!empty($I) && file_exists($BASE.$I)):  				
     		  	$img = new sfImage($BASE.$I,'image/jpg');  	
     		    $img->resize(100,100);
     		    $nom = $OC->getCicleid().'.jpg';
     		    $img->saveAs($BASE.$nom);
     		    if( $I <> $nom ) unlink($BASE.$I);		    
     		    $OC->setImatge($nom)->save();		    
     	    endif;
     	    
     	    $P = $OC->getPdf();  		
       		if(!empty($P) && file_exists($BASE.$P)):  		
       			$nom = $OC->getCicleid().'.pdf';		
     		  	rename($BASE.$P,$BASE.$nom);
     		    if( $P <> $nom ) unlink($BASE.$P);		    
     		    $OC->setPdf($nom)->save();		    
     	    endif;	    	      	    	    	      	    
     	endif;
     */
 }