Changeset 14537
- Timestamp:
- 06/24/08 22:38:00 (5 years ago)
- Location:
- events/phpframework/rhaco/trunk
- Files:
-
- 4 modified
-
index.php (modified) (1 diff)
-
library/PhwittrUser.php (modified) (3 diffs)
-
library/Picturize.php (modified) (3 diffs)
-
resources/templates/default/account/picture.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/rhaco/trunk/index.php
r14536 r14537 87 87 'method' => 'passwordChange', 88 88 ), 89 // '^account\/picture$' => array( 90 // 'class' => 'PhwittrUser', 91 // 'method' => 'picture', 92 // ), 89 '^account\/picture$' => array( 90 'class' => 'PhwittrUser', 91 'method' => 'picture', 92 ), 93 '^account\/delete_picture$' => array( 94 'class' => 'PhwittrUser', 95 'method' => 'delete_picture', 96 ), 93 97 '^account\/confirm\/(.*?)$' => array( 94 98 'class' => 'PhwittrUser', -
events/phpframework/rhaco/trunk/library/PhwittrUser.php
r14536 r14537 9 9 10 10 Rhaco::import('Phwittr'); 11 Rhaco::import('Picturize'); 11 12 12 13 class PhwittrUser extends Phwittr … … 87 88 try { 88 89 $picturize = new Picturize(); 89 $picturize->loadfile($file->tmp)->fit(48, 48)->save(Rhaco::constant( 'UPLOAD_PATH') . '/thumbnail/' . $user->getId(), null, true);90 $picturize->loadfile($file->tmp)->fit(48, 48)->save(Rhaco::constant(VAR_UPLOAD_PATH) . '/thumbnail/' . $user->getId(), null, true); 90 91 } catch(PicturizeException $e){ 91 92 L::warning($e->getMessage()); 92 93 return new HtmlParser(Rhaco::constant('THEME'). '/account/picture.html'); 93 94 } 94 $file->generate(Rhaco::constant(VAR_UPLOAD_PATH) . '/original/' . $user->getId() . '.' .$file->getExtension());95 $user->setImage($user->getId() . '.' .$file->getExtension());95 $file->generate(Rhaco::constant(VAR_UPLOAD_PATH) . '/original/' . $user->getId() . $file->getExtension()); 96 $user->setImage($user->getId() . $file->getExtension()); 96 97 if($user->save($this->dbUtil)){ 97 98 Header::redirect(Rhaco::url('account/picture')); … … 99 100 } 100 101 return new HtmlParser(Rhaco::constant('THEME'). '/account/picture.html'); 102 } 103 104 function delete_picture(){ 105 $user = $this->loginRequired(); 106 $user = $this->dbUtil->get(new User($user->getId())); 107 if(file_exists(Rhaco::constant(VAR_UPLOAD_PATH) . '/original/' . $user->getImage())){ 108 @unlink(Rhaco::constant(VAR_UPLOAD_PATH) . '/original/' . $user->getImage()); 109 } 110 if(file_exists(Rhaco::constant(VAR_UPLOAD_PATH) . '/thumbnail/' . $user->getImage())){ 111 @unlink(Rhaco::constant(VAR_UPLOAD_PATH) . '/thumbnail/' . $user->getImage()); 112 } 113 $user->setImage(''); 114 $user->save($this->dbUtil); 115 Header::redirect(Rhaco::url('account/picture')); 101 116 } 102 117 -
events/phpframework/rhaco/trunk/library/Picturize.php
r14536 r14537 39 39 */ 40 40 public function loadFile($filename){ 41 if( file_exists($filename)){41 if(!file_exists($filename)){ 42 42 throw new PicturizeException('File is not found.'); 43 43 } … … 63 63 break; 64 64 case IMAGETYPE_WBMP: 65 $handle = imagecreatefrom png($filename);65 $handle = imagecreatefromwbmp($filename); 66 66 break; 67 67 } … … 200 200 $filename .= '.' . $ext; 201 201 } 202 switch($type){ 203 case IMAGETYPE_GIF: 204 $handle = imagegif($this->handle, $filename); 205 break; 206 case IMAGETYPE_JPEG: 207 $handle = imagejpeg($this->handle, $filename); 208 break; 209 case IMAGETYPE_PNG: 210 $handle = imagepng($this->handle, $filename); 211 break; 212 case IMAGETYPE_WBMP: 213 $handle = imagewbmp($this->handle, $filename); 214 break; 215 } 216 202 217 return $this; 203 218 } -
events/phpframework/rhaco/trunk/resources/templates/default/account/picture.html
r14536 r14537 9 9 <dd><input type="file" name="picture" /></dd> 10 10 11 <dd><a href="{$rhaco.url('account/delete_picture')}"> </a> or <input type="submit" value="Save" /></dd>11 <dd><a href="{$rhaco.url('account/delete_picture')}">Delete Picture</a> or <input type="submit" value="Save" /></dd> 12 12 </dl> 13 13 </form>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)