Changeset 14537

Show
Ignore:
Timestamp:
06/24/08 22:38:00 (5 years ago)
Author:
riaf
Message:

いろいろボケてた

Location:
events/phpframework/rhaco/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/rhaco/trunk/index.php

    r14536 r14537  
    8787            'method' => 'passwordChange', 
    8888        ), 
    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        ), 
    9397        '^account\/confirm\/(.*?)$' => array( 
    9498            'class' => 'PhwittrUser', 
  • events/phpframework/rhaco/trunk/library/PhwittrUser.php

    r14536 r14537  
    99 
    1010Rhaco::import('Phwittr'); 
     11Rhaco::import('Picturize'); 
    1112 
    1213class PhwittrUser extends Phwittr 
     
    8788            try { 
    8889                $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); 
    9091            } catch(PicturizeException $e){ 
    9192                L::warning($e->getMessage()); 
    9293                return new HtmlParser(Rhaco::constant('THEME'). '/account/picture.html'); 
    9394            } 
    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()); 
    9697            if($user->save($this->dbUtil)){ 
    9798                Header::redirect(Rhaco::url('account/picture')); 
     
    99100        } 
    100101        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')); 
    101116    } 
    102117 
  • events/phpframework/rhaco/trunk/library/Picturize.php

    r14536 r14537  
    3939     */ 
    4040    public function loadFile($filename){ 
    41         if(file_exists($filename)){ 
     41        if(!file_exists($filename)){ 
    4242            throw new PicturizeException('File is not found.'); 
    4343        } 
     
    6363                break; 
    6464            case IMAGETYPE_WBMP: 
    65                 $handle = imagecreatefrompng($filename); 
     65                $handle = imagecreatefromwbmp($filename); 
    6666                break; 
    6767        } 
     
    200200            $filename .= '.' . $ext; 
    201201        } 
     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 
    202217        return $this; 
    203218    } 
  • events/phpframework/rhaco/trunk/resources/templates/default/account/picture.html

    r14536 r14537  
    99                        <dd><input type="file" name="picture" /></dd> 
    1010 
    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> 
    1212                </dl> 
    1313        </form>