Changeset 8663

Show
Ignore:
Timestamp:
07/06/10 17:56:19 (2 months ago)
Author:
inureyes
Message:

refs #1482

  • 관련 기존 클래스 호출 수정
Location:
branches/1.8
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • branches/1.8/framework/legacy/Textcube.Function.Image.php

    r8198 r8663  
    33/// All rights reserved. Licensed under the GPL. 
    44/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) 
    5 class Image { 
    6     function Image() { 
    7         $this->reset(); 
    8     } 
    9      
    10     function reset() { 
    11         $this->extraPadding = 0; 
    12         $this->imageFile = NULL; 
    13         $this->resultImageDevice = NULL; 
    14     } 
    15      
    16     function resample($width, $height) { 
    17         if (empty($width) && empty($height)) 
    18             return false; 
    19         if (empty($this->imageFile) || !file_exists($this->imageFile)) 
    20             return false; 
    21          
    22         // create an image device as image format. 
    23         switch ($this->getImageType($this->imageFile)) { 
    24             case "gif": 
    25                 if (imagetypes() & IMG_GIF) { 
    26                     $originImageDevice = imagecreatefromgif($this->imageFile); 
    27                 } else { 
    28                     return false; 
    29                 } 
    30                 break; 
    31             case "jpg": 
    32                 if (imagetypes() & IMG_JPG) { 
    33                     $originImageDevice = imagecreatefromjpeg($this->imageFile); 
    34                 } else { 
    35                     return false; 
    36                 } 
    37                 break; 
    38             case "png": 
    39                 if ((imagetypes() & IMG_PNG) && function_exists('imagecreatefrompng')) { 
    40                     $originImageDevice = imagecreatefrompng($this->imageFile); 
    41                 } else { 
    42                     return false; 
    43                 } 
    44                 break; 
    45             case "wbmp": 
    46                 if (imagetypes() & IMG_WBMP) { 
    47                     $originImageDevice = imagecreatefromwbmp($this->imageFile); 
    48                 } else { 
    49                     return false; 
    50                 } 
    51                 break; 
    52             case "xpm": 
    53                 if (imagetypes() & IMG_XPM) { 
    54                     $originImageDevice = imagecreatefromxpm($this->imageFile); 
    55                 } else { 
    56                     return false; 
    57                 } 
    58                 break; 
    59             default: 
    60                 return false; 
    61                 break; 
    62         } 
    63         // 리샘플링은 최종단계에서 리샘플링만을 하는 기능임. 시스템을 예로 들면 OS의 기능에 해당함. 
    64         // 이미지 프로세스는 어플리케이션의 기능으로 볼 수 있고, 따라서 이미지 리샘플링 중에는 이벤트가 끼어들면 안 됨. 
    65         //$originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this); 
    66          
    67         if (Path::getExtension($this->imageFile) == ".gif") { 
    68             $this->resultImageDevice = imagecreate($width, $height); 
    69         } else { 
    70             $this->resultImageDevice = imagecreatetruecolor($width, $height); 
    71         } 
    72          
    73         $bgColorBy16 = $this->hexRGB("FFFFFF"); 
    74         $temp = imagecolorallocate($this->resultImageDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); 
    75         imagefilledrectangle($this->resultImageDevice, 0, 0, $width, $height, $temp); 
    76         imagecopyresampled($this->resultImageDevice, $originImageDevice, 0, 0, 0, 0, $width, $height, imagesx($originImageDevice), imagesy($originImageDevice)); 
    77         imagedestroy($originImageDevice); 
    78         //$this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this); 
    79          
    80         return true; 
    81     } 
    82      
    83     function resizeImageToContent($property, $originSrc, $imageWidth) { 
    84         if ( !is_readable($originSrc) ) { 
    85             return array($property, false); 
    86         } 
    87          
    88         list($originWidth, $originHeight, $type, $attr) = getimagesize($originSrc);      
    89         $attributes = Misc::getAttributesFromString($property, false); 
    90          
    91         // 단위 변환. 
    92         $onclickFlag = false; 
    93         if (array_key_exists('width', $attributes)) { 
    94             if (preg_match('/(.+)(%?)/', $attributes['width'], $matches)) { 
    95                 if($matches[2] == '%') 
    96                     $attributes['width'] = round($originWidth * $matches[1] / 100); 
    97                 else 
    98                     $attributes['width'] = intval($matches[1]); 
    99                  
    100             } 
    101         } 
    1025 
    103         if (array_key_exists('height', $attributes)) { 
    104             if (preg_match('/(.+)(%?)/', $attributes['height'], $matches)) { 
    105                 if ($matches[2] == '%') 
    106                     $attributes['height'] = round($originHeight * $matches[1] / 100); 
    107                 else 
    108                     $attributes['height'] = intval($matches[1]); 
    109                  
    110             } 
    111         } 
    112          
    113         // 가로, 세로 어느 쪽이든 0이면 이미지는 표시되지 않음. 따라서 계산할 필요 없음. 
    114         if ((isset($attributes['width']) && $attributes['width'] <= 0) || (isset($attributes['height']) && $attributes['height'] <= 0)) { 
    115             return array($property, false); 
    116         } 
     6/// Legacy code for plugins. See /framework/utils/Image.php for working codes.  
    1177 
    118         // 가로만 지정된 이미지의 경우. 
    119         if (isset($attributes['width']) && !isset($attributes['height'])) { 
    120             // 비어있는 세로를 가로의 크기를 이용하여 계산. 
    121             $attributes['height'] = floor($originHeight * $attributes['width'] / $originWidth); 
    122         // 세로만 지정된 이미지의 경우. 
    123         } else if (!isset($attributes['width']) && isset($attributes['height'])) { 
    124             // 비어있는 가로를 세로의 크기를 이용하여 계산. 
    125             $attributes['width'] = floor($originWidth * $attributes['height'] / $originHeight); 
    126         // 둘 다 지정되지 않은 이미지의 경우. 
    127         } else if (!isset($attributes['width']) && !isset($attributes['height'])) { 
    128             // 둘 다 비어 있을 경우는 오리지널 사이즈로 대치. 
    129             $attributes['width'] = $originWidth; 
    130             $attributes['height'] = $originHeight; 
    131         } 
    132  
    133         if ($attributes['width'] > $imageWidth) { 
    134             $attributes['height'] = floor($attributes['height'] * $imageWidth / $attributes['width']); 
    135             $attributes['width'] = $imageWidth; 
    136         } 
    137          
    138         if ($attributes['width'] < $originWidth || $attributes['height'] < $originHeight) { 
    139             $onclickFlag = true; 
    140         } else { 
    141             $onclickFlag = false; 
    142         } 
    143  
    144         $properties = array(); 
    145         ksort($attributes); 
    146         foreach($attributes as $key => $value) { 
    147             array_push($properties, "$key=\"$value\""); 
    148         } 
    149          
    150         return array(implode(' ', $properties), $onclickFlag); 
    151     } 
    152      
    153     function impressWaterMark($waterMarkFile, $position="left=10|bottom=10", $gamma=100) { 
    154         if ($this->getImageType($waterMarkFile) == "png") 
    155             return $this->_impressWaterMarkCore("PNG", $waterMarkFile, $position); 
    156         else 
    157             return $this->_impressWaterMarkCore("GIF", $waterMarkFile, $position, $gamma); 
    158     } 
    159      
    160     function _impressWaterMarkCore($type, $waterMarkFile, $position, $gamma=100) { 
    161         if (empty($waterMarkFile)) 
    162             return false; 
    163         if (!file_exists($waterMarkFile)) 
    164             return false; 
    165         if (empty($this->resultImageDevice)) 
    166             return false; 
    167          
    168         // validate gamma. 
    169         if (!is_int($gamma)) { 
    170             $gamma = 100; 
    171         } else if ($gamma < 0) { 
    172             $gamma = 0; 
    173         } else if ($gamma > 100) { 
    174             $gamma = 100; 
    175         } 
    176          
    177         list($waterMarkWidth, $waterMarkHeight, $waterMakrType) = getimagesize($waterMarkFile); 
    178          
    179         // position of watermark. 
    180         if (preg_match("/^(-?[0-9A-Z]+) (-?[0-9A-Z]+)$/i", $position, $temp)) { 
    181             $resultWidth = imagesx($this->resultImageDevice); 
    182             $resultHeight = imagesy($this->resultImageDevice); 
    183              
    184             switch ($temp[1]) { 
    185                 case "left": 
    186                     $xPosition = $this->extraPadding; 
    187                     break; 
    188                 case "center": 
    189                     $xPosition = $resultWidth / 2 - $waterMarkWidth / 2; 
    190                     break; 
    191                 case "right": 
    192                     $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; 
    193                     break; 
    194                 default: 
    195                     // if positive, calculate x value from left. 
    196                     if (preg_match("/^([1-9][0-9]*)$/", $temp[1], $extra)) { 
    197                         if ($extra[1] > $resultWidth - $waterMarkWidth) { 
    198                             $xPosition = $resultWidth - $waterMarkWidth; 
    199                         } else { 
    200                             $xPosition = $extra[1]; 
    201                         } 
    202                     // if negative, calculate x value from right. 
    203                     } else if (preg_match("/^(-?[1-9][0-9]*)$/", $temp[1], $extra)) { 
    204                         if ($resultWidth - $waterMarkWidth - abs($extra[1]) < 0) { 
    205                             $xPosition = 0; 
    206                         } else { 
    207                             $xPosition = $resultWidth - $waterMarkWidth - abs($extra[1]); 
    208                         } 
    209                     // in the case of 0. 
    210                     } else if ($temp[1] == "0") { 
    211                         $xPosition = 0; 
    212                     // the others. calculate x value from left. 
    213                     } else { 
    214                         $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; 
    215                     } 
    216             } 
    217              
    218             switch ($temp[2]) { 
    219                 case "top": 
    220                     $yPosition = $this->extraPadding; 
    221                     break; 
    222                 case "middle": 
    223                     $yPosition = $resultHeight / 2 - $waterMarkHeight / 2; 
    224                     break; 
    225                 case "bottom": 
    226                     $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; 
    227                     break; 
    228                 default: 
    229                     // if positive, calculate y value from top. 
    230                     if (preg_match("/^([1-9][0-9]*)$/", $temp[2], $extra)) { 
    231                         if ($extra[1] > $resultHeight - $waterMarkHeight) { 
    232                             $yPosition = $resultHeight - $waterMarkHeight; 
    233                         } else { 
    234                             $yPosition = $extra[1]; 
    235                         } 
    236                     // if negative, calculate y value from bottom. 
    237                     } else if (preg_match("/^(-?[1-9][0-9]*)$/", $temp[2], $extra)) { 
    238                         if ($resultHeight - $waterMarkHeight - abs($extra[1]) < 0) { 
    239                             $yPosition = 0; 
    240                         } else { 
    241                             $yPosition = $resultHeight - $waterMarkHeight - abs($extra[1]); 
    242                         } 
    243                     // in the case of 0. 
    244                     } else if ($temp[1] == "0") { 
    245                         $yPosition = 0; 
    246                     // the others. calculate y value from bottom. 
    247                     } else { 
    248                         $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; 
    249                     } 
    250             } 
    251         } else { 
    252             $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; 
    253             $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; 
    254         } 
    255          
    256         // create watermark image device. 
    257         switch ($waterMakrType) { 
    258             case 1: 
    259                 $waterMarkDevice = imagecreatefromgif($waterMarkFile); 
    260                 break; 
    261             case 2: 
    262                 $waterMarkDevice = imagecreatefromjpeg($waterMarkFile); 
    263                 break; 
    264             case 3: 
    265                 $waterMarkDevice = imagecreatefrompng($waterMarkFile); 
    266                 break; 
    267         } 
    268          
    269         // PHP >= 4.0.6 
    270         if (strtolower($type) == "png" && function_exists("imagealphablending")) { 
    271             imagealphablending($this->resultImageDevice, true); 
    272             imagecopy($this->resultImageDevice, $waterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight); 
    273         } else { 
    274             // if not support alpha channel, support GIF transparency. 
    275             $tempWaterMarkDevice = imagecreatetruecolor($waterMarkWidth, $waterMarkHeight); 
    276              
    277             $bgColorBy16 = $this->hexRGB("FF00FF"); 
    278             $temp = imagecolorallocate($tempWaterMarkDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); 
    279             imagecolortransparent($this->resultImageDevice, $temp); 
    280             imagefill($tempWaterMarkDevice, 0, 0, $temp); 
    281             imagecopy($tempWaterMarkDevice, $waterMarkDevice, 0, 0, 0, 0, $waterMarkWidth, $waterMarkHeight); 
    282              
    283             if (function_exists("imagecopymerge")) 
    284                 imagecopymerge($this->resultImageDevice, $tempWaterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight, $gamma); 
    285             else 
    286                 imagecopy($this->resultImageDevice, $tempWaterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight); 
    287              
    288             imagedestroy($tempWaterMarkDevice); 
    289         } 
    290          
    291         imagedestroy($waterMarkDevice); 
    292         return true; 
    293     } 
    294      
    295     function cropRectByCoordinates($startX, $startY, $finishX, $finishY) { 
    296         $width = $finishX - $startX; 
    297         $height = $finishY - $startY; 
    298          
    299         $targetDevice = imagecreatetruecolor($width, $height); 
    300         $bgColorBy16 = $this->hexRGB('FFFFFF'); 
    301         imagecolorallocate($tempWaterMarkDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); 
    302         imagecopy($targetDevice, $this->resultImageDevice, 0, 0, $startX, $startY, $width, $height); 
    303         $this->resultImageDevice = $targetDevice; 
    304         unset($targetDevice); 
    305          
    306         return true; 
    307     } 
    308      
    309     function cropRectBySize($width, $height, $align='center', $valign='middle') { 
    310         switch ($align) { 
    311             case 'left': 
    312                 $srcX = 0; 
    313                 break; 
    314             case 'center': 
    315                 $srcX = floor((imagesx($this->resultImageDevice) - $width) / 2); 
    316                 break; 
    317             case 'right': 
    318                 $srcX = imagesx($this->resultImageDevice) - $width; 
    319                 break; 
    320         } 
    321          
    322         switch ($valign) { 
    323             case 'top': 
    324                 $srcY = 0; 
    325                 break; 
    326             case 'middle': 
    327                 $srcY = floor((imagesy($this->resultImageDevice) - $height) / 2); 
    328                 break; 
    329             case 'bottom': 
    330                 $srcY = imagesy($this->resultImageDevice) - $height; 
    331                 break; 
    332         } 
    333          
    334         $targetDevice = imagecreatetruecolor($width, $height); 
    335         $bgColorBy16 = $this->hexRGB('FFFFFF'); 
    336         imagecolorallocate($targetDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); 
    337         imagecopy($targetDevice, $this->resultImageDevice, 0, 0, $srcX, $srcY, $width, $height); 
    338         $this->resultImageDevice = $targetDevice; 
    339         unset($targetDevice); 
    340          
    341         return true; 
    342     } 
    343      
    344     function saveAsFile($fileName) { 
    345         return $this->createThumbnailIntoFile($fileName); 
    346     } 
    347      
    348     function createThumbnailIntoFile($fileName) { 
    349         if (empty($this->resultImageDevice)) 
    350             return false; 
    351          
    352         imageinterlace($this->resultImageDevice); 
    353         switch ($this->getImageType($this->imageFile)) { 
    354             case "gif": 
    355                 imagegif($this->resultImageDevice, $fileName); 
    356                 break; 
    357             case "png": 
    358                 imagepng($this->resultImageDevice, $fileName); 
    359                 break; 
    360             case "wbmp": 
    361                 imagewbmp($this->resultImageDevice, $fileName); 
    362                 break; 
    363             case "jpg": 
    364             default: 
    365                 imagejpeg($this->resultImageDevice, $fileName, 80); 
    366                 break; 
    367         } 
    368          
    369         $this->resultImageDevice = NULL; 
    370          
    371         return true; 
    372     } 
    373      
    374     function saveAsCache() { 
    375         return $this->createThumbnailIntoCache(); 
    376     } 
    377      
    378     function createThumbnailIntoCache() { 
    379         header("Content-type: image/jpeg"); 
    380         imagejpeg($this->resultImageDevice); 
    381          
    382         $originImageDevice = NULL; 
    383         $this->resultImageDevice = NULL; 
    384          
    385         return true; 
    386     } 
    387      
    388     function calcOptimizedImageSize($argWidth, $argHeight, $boxWidth=NULL, $boxHeight=NULL, $resizeFlag="reduce") { 
    389         if (empty($boxWidth) && empty($boxHeight)) { 
    390             return array($argWidth, $argHeight); 
    391         } else if (!empty($boxWidth) && empty($boxHeight)) { 
    392             if ($argWidth > $boxWidth) { 
    393                 $newWidth = $boxWidth; 
    394                 $newHeight = floor($argHeight * $newWidth / $argWidth); 
    395             } else { 
    396                 $newWidth = $argWidth; 
    397                 $newHeight = $argHeight; 
    398             } 
    399         } else if (empty($boxWidth) && !empty($boxHeight)) { 
    400             if ($argHeight > $boxHeight) { 
    401                 $newHeight = $boxHeight; 
    402                 $newWidth = floor($argWidth * $newHeight / $argHeight); 
    403             } else { 
    404                 $newWidth = $argWidth; 
    405                 $newHeight = $argHeight; 
    406             } 
    407         } else { 
    408             if ($argWidth > $boxWidth) { 
    409                 $newWidth = $boxWidth; 
    410                 $newHeight = floor($argHeight * $newWidth / $argWidth); 
    411             } else { 
    412                 $newWidth = $argWidth; 
    413                 $newHeight = $argHeight; 
    414             } 
    415              
    416             if ($newHeight > $boxHeight) { 
    417                 $tempHeight = $newHeight; 
    418                 $newHeight = $boxHeight; 
    419                 $newWidth = floor($newWidth * $newHeight / $tempHeight); 
    420             } 
    421         } 
    422          
    423         if ($argWidth * $argHeight > $newWidth * $newHeight) { 
    424             if ($resizeFlag == "reduce" || $resizeFlag == "both") { 
    425                 $imgWidth = $newWidth; 
    426                 $imgHeight = $newHeight; 
    427             } else { 
    428                 $imgWidth = $argWidth; 
    429                 $imgHeight = $argHeight; 
    430             } 
    431         } else if ($argWidth * $argHeight == $newWidth * $newHeight) { 
    432             $imgWidth = $argWidth; 
    433             $imgHeight = $argHeight; 
    434         } else if ($argWidth * $argHeight < $newWidth * $newHeight) { 
    435             if ($resizeFlag == "enlarge" || $resizeFlag == "both") { 
    436                 $imgWidth = $newWidth; 
    437                 $imgHeight = $newHeight; 
    438             } else { 
    439                 $imgWidth = $argWidth; 
    440                 $imgHeight = $argHeight; 
    441             } 
    442         } 
    443          
    444         return array($imgWidth, $imgHeight); 
    445     } 
    446      
    447     function getImageType($filename) { 
    448         if (file_exists($filename)) { 
    449             if (function_exists("exif_imagetype")) { 
    450                 $imageType = exif_imagetype($filename); 
    451             } else { 
    452                 $tempInfo = getimagesize($filename); 
    453                 $imageType = $tempInfo[2]; 
    454             } 
    455              
    456             switch ($imageType) { 
    457                 case IMAGETYPE_GIF: 
    458                     $extension = 'gif'; 
    459                     break; 
    460                 case IMAGETYPE_JPEG: 
    461                     $extension = 'jpg'; 
    462                     break; 
    463                 case IMAGETYPE_PNG: 
    464                     $extension = 'png'; 
    465                     break; 
    466                 case IMAGETYPE_SWF: 
    467                     $extension = 'swf'; 
    468                     break; 
    469                 case IMAGETYPE_PSD: 
    470                     $extension = 'psd'; 
    471                     break; 
    472                 case IMAGETYPE_BMP: 
    473                     $extension = 'bmp'; 
    474                     break; 
    475                 case IMAGETYPE_TIFF_II: 
    476                 case IMAGETYPE_TIFF_MM: 
    477                     $extension = 'tiff'; 
    478                     break; 
    479                 case IMAGETYPE_JPC: 
    480                     $extension = 'jpc'; 
    481                     break; 
    482                 case IMAGETYPE_JP2: 
    483                     $extension = 'jp2'; 
    484                     break; 
    485                 case IMAGETYPE_JPX: 
    486                     $extension = 'jpx'; 
    487                     break; 
    488                 case IMAGETYPE_JB2: 
    489                     $extension = 'jb2'; 
    490                     break; 
    491                 case IMAGETYPE_SWC: 
    492                     $extension = 'swc'; 
    493                     break; 
    494                 case IMAGETYPE_IFF: 
    495                     $extension = 'aiff'; 
    496                     break; 
    497                 case IMAGETYPE_WBMP: 
    498                     $extension = 'wbmp'; 
    499                     break; 
    500                 case IMAGETYPE_XBM: 
    501                     $extension = 'xbm'; 
    502                     break; 
    503                 default: 
    504                     $extension = false; 
    505             } 
    506         } else { 
    507             $extension = false; 
    508         } 
    509          
    510         return $extension; 
    511     } 
    512      
    513     /* "FFFFFF" => array(255, 255, 255) */ 
    514     function hexRGB($hexstr) { 
    515         $int = hexdec($hexstr); 
    516         return array('R' => 0xFF & ($int >> 0x10), 'G' => 0xFF & ($int >> 0x8), 'B' => 0xFF & $int); 
     8if(!class_exists('Image')) { 
     9    class Image extends Utils_Image { 
    51710    } 
    51811} 
    519 ?> 
  • branches/1.8/framework/utils/Image.php

    r8661 r8663  
    33/// All rights reserved. Licensed under the GPL. 
    44/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) 
    5 class Utils_Image { 
     5 
     6class Utils_Image extends Singleton { 
    67    function __construct() { 
    78        $this->reset(); 
    89    } 
    9      
     10 
     11    public static function getInstance() { 
     12        return self::_getInstance(__CLASS__); 
     13    } 
     14 
    1015    function reset() { 
    1116        $this->extraPadding = 0; 
  • branches/1.8/interface/i/imageResizer/index.php

    r8198 r8663  
    1818            $imageInfo = getimagesize($imagePath); 
    1919            $cropSize = $_GET['m']; 
    20             $objThumbnail = new Image(); 
     20            $objThumbnail = new Utils_Image(); 
    2121            if ($imageInfo[0] > $imageInfo[1]) 
    2222                list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize); 
  • branches/1.8/library/function/image.php

    r8662 r8663  
    120120    } 
    121121 
    122     requireComponent('Textcube.Function.Image'); 
    123     $objResize = new Image(); 
     122    $objResize = new Utils_Image(); 
    124123    $objResize->imageFile = $originSrc; 
    125124    if (isset($options['size']) && is_numeric($options['size'])) { 
  • branches/1.8/library/view/iphoneView.php

    r8612 r8663  
    322322    $thumbnailSrc = ROOT . "/cache/thumbnail/{$blogid}/iphoneThumbnail/th_{$filename}"; 
    323323    if (file_exists($originSrc)) { 
    324         requireComponent('Textcube.Function.Image'); 
    325324        $imageInfo = getimagesize($originSrc); 
    326325 
    327         $objThumbnail = new Image(); 
     326        $objThumbnail = new Utils_Image(); 
    328327        if ($imageInfo[0] > $imageInfo[1]) 
    329328            list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize); 
  • branches/1.8/plugins/FM_Markdown/ttml.php

    r8555 r8663  
    11<?php 
    22// PHP TTML parser 
    3 // Version 1.6 (2008.1.20) 
     3// Version 1.8 (2010.7.6) 
    44// 2004-2009 Needlworks / TNF / Tatter and Company 
    55// Original TTML is created by JH, 2004.4 
     
    77// TTML Module port for Tattertools 1.1 by lifthrasiir, 2007.1 
    88// TTML External library for Textcube 1.6 by inureyes, 2008.1 
     9// TTML External library for Textcube 1.8 by inureyes, 2010.7 
    910 
    1011function FM_TTML_bindTags($id, $content) { 
     
    2829} 
    2930 
    30 function FM_TTML_bindAttachments($entryId, $folderPath, $folderURL, $content, $useAbsolutePath = true, $bRssMode = false) { 
     31function FM_TTML_bindAttachments($entryId, $folderPath, $folderURL, $content, $useAbsolutePath = false, $bRssMode = false) { 
    3132    global $service, $hostURL, $blogURL, $serviceURL; 
    3233    requireModel('blog.attachment'); 
    33     requireComponent('Textcube.Function.misc'); 
    3434    $blogid = getBlogId(); 
    3535    getAttachments($blogid, $entryId); // For attachment caching. 
     
    6161                for ($i = 1; $i < sizeof($attributes) - 2; $i += 2) 
    6262                    array_push($items, array($attributes[$i], $attributes[$i + 1])); 
    63                 $galleryAttributes = misc::getAttributesFromString($attributes[sizeof($attributes) - 1]); 
     63                $galleryAttributes = Misc::getAttributesFromString($attributes[sizeof($attributes) - 1]); 
    6464                 
    6565                $images = array_slice($attributes, 1, count($attributes) - 2); 
     
    9696                $id = "gallery$entryId$count"; 
    9797                $cssId = "tt-gallery-$entryId-$count"; 
    98                 $contentWidth = misc::getContentWidth(); 
     98                $contentWidth = Misc::getContentWidth(); 
    9999                 
    100100                $items = array(); 
    101101                for ($i = 1; $i < sizeof($attributes) - 2; $i += 2) 
    102102                    array_push($items, array($attributes[$i], $attributes[$i + 1])); 
    103                 $galleryAttributes = misc::getAttributesFromString($attributes[sizeof($attributes) - 1]); 
     103                $galleryAttributes = Misc::getAttributesFromString($attributes[sizeof($attributes) - 1]); 
    104104                 
    105105                if (!isset($galleryAttributes['width'])) 
     
    183183                $buf .= $attributes[count($attributes) - 1]; 
    184184            } else { 
    185                 $params = misc::getAttributesFromString($attributes[sizeof($attributes) - 2]); 
     185                $params = Misc::getAttributesFromString($attributes[sizeof($attributes) - 2]); 
    186186                $id = $entryId . $count; 
    187187                $imgs = array_slice($attributes, 1, count($attributes) - 3); 
     
    199199                    $caption = ''; 
    200200                } 
    201                 $buf .= '<div style="clear: both; text-align: center"><img src="' . ($useAbsolutePath ? $serviceURL : $service['path']) . '/image/gallery/gallery_enlarge.gif" alt="' . _text('확대') . '" style="cursor:pointer" onclick="openFullScreen(\'' . $service['path'] . '/iMazing?d=' . urlencode($id) . '&f=' . urlencode($params['frame']) . '&t=' . urlencode($params['transition']) . '&n=' . urlencode($params['navigation']) . '&si=' . urlencode($params['slideshowinterval']) . '&p=' . urlencode($params['page']) . '&a=' . urlencode($params['align']) . '&o=' . $blogid . '&i=' . $imgStr . '\',\'' . htmlspecialchars(str_replace("'", "&#39;", $attributes[count($attributes) - 1])) . '\',\'' . $service['path'] . '\')" />'; 
     201                $buf .= '<div style="clear: both; text-align: center"><img src="' . ($useAbsolutePath ? $serviceURL : $service['path']) . '/resources/image/gallery/gallery_enlarge.gif" alt="' . _text('확대') . '" style="cursor:pointer" onclick="openFullScreen(\'' . $service['path'] . '/iMazing?d=' . urlencode($id) . '&f=' . urlencode($params['frame']) . '&t=' . urlencode($params['transition']) . '&n=' . urlencode($params['navigation']) . '&si=' . urlencode($params['slideshowinterval']) . '&p=' . urlencode($params['page']) . '&a=' . urlencode($params['align']) . '&o=' . $blogid . '&i=' . $imgStr . '\',\'' . htmlspecialchars(str_replace("'", "&#39;", $attributes[count($attributes) - 1])) . '\',\'' . $service['path'] . '\')" />'; 
    202202                $buf .= '<div id="iMazingContainer'.$id.'" class="iMazingContainer" style="width:'.$params['width'].'px; height:'.$params['height'].'px;"></div><script type="text/javascript">//<![CDATA['.CRLF; 
    203                 $buf .= 'iMazing' . $id . 'Str = getEmbedCode(\'' . $service['path'] . '/script/gallery/iMazing/main.swf\',\'100%\',\'100%\',\'iMazing' . $id . '\',\'#FFFFFF\',"image=' . $imgStr . '&amp;frame=' . $params['frame'] . '&amp;transition=' . $params['transition'] . '&amp;navigation=' . $params['navigation'] . '&amp;slideshowInterval=' . $params['slideshowinterval'] . '&amp;page=' . $params['page'] . '&amp;align=' . $params['align'] . '&amp;skinPath=' . $service['path'] . '/script/gallery/iMazing/&amp;","false"); writeCode(iMazing' . $id . 'Str, "iMazingContainer'.$id.'");'; 
     203                $buf .= 'iMazing' . $id . 'Str = getEmbedCode(\'' . $service['path'] . '/resources/script/gallery/iMazing/main.swf\',\'100%\',\'100%\',\'iMazing' . $id . '\',\'#FFFFFF\',"image=' . $imgStr . '&amp;frame=' . $params['frame'] . '&amp;transition=' . $params['transition'] . '&amp;navigation=' . $params['navigation'] . '&amp;slideshowInterval=' . $params['slideshowinterval'] . '&amp;page=' . $params['page'] . '&amp;align=' . $params['align'] . '&amp;skinPath=' . $service['path'] . '/resources/script/gallery/iMazing/&amp;","false"); writeCode(iMazing' . $id . 'Str, "iMazingContainer'.$id.'");'; 
    204204                $buf .= '//]]></script><noscript>'; 
    205205                for ($i = 0; $i < count($imgs); $i += 2) 
     
    216216                } 
    217217            } else { 
    218                 $params = misc::getAttributesFromString($attributes[sizeof($attributes) - 2]); 
     218                $params = Misc::getAttributesFromString($attributes[sizeof($attributes) - 2]); 
    219219                foreach ($params as $key => $value) { 
    220220                    if ($key == 'autoPlay') { 
     
    252252                $buf .= '<div id="jukeBox' . $id . 'Div" style="margin-left: auto; margin-right: auto; width:' . $width . '; height:' . $height . ';"><div id="jukeBoxContainer'.$id.'" style="width:' . $width . '; height:' . $height . ';"></div>'; 
    253253                $buf .= '<script type="text/javascript">//<![CDATA['.CRLF; 
    254                 $buf .= 'writeCode(getEmbedCode(\'' . $service['path'] . '/script/jukebox/flash/main.swf\',\'100%\',\'100%\',\'jukeBox' . $id . 'Flash\',\'#FFFFFF\',"sounds=' . $imgStr . '&amp;autoplay=' . $params['autoplay'] . '&amp;visible=' . $params['visible'] . '&amp;id=' . $id . '","false"), "jukeBoxContainer'.$id.'")'; 
     254                $buf .= 'writeCode(getEmbedCode(\'' . $service['path'] . '/resources/script/jukebox/flash/main.swf\',\'100%\',\'100%\',\'jukeBox' . $id . 'Flash\',\'#FFFFFF\',"sounds=' . $imgStr . '&amp;autoplay=' . $params['autoplay'] . '&amp;visible=' . $params['visible'] . '&amp;id=' . $id . '","false"), "jukeBoxContainer'.$id.'")'; 
    255255                $buf .= '//]]></script><noscript>'; 
    256256                for ($i = 0; $i < count($imgs); $i++) { 
     
    264264            } 
    265265        } else { 
    266             $contentWidth = misc::getContentWidth(); 
     266            $contentWidth = Misc::getContentWidth(); 
    267267 
    268268            switch (count($attributes)) { 
     
    342342function FM_TTML_getAttachmentBinder($filename, $property, $folderPath, $folderURL, $imageBlocks = 1, $useAbsolutePath = true, $bRssMode = false, $onclickFlag=false) { 
    343343    global $database, $skinSetting, $service, $blogURL, $hostURL, $serviceURL; 
    344     requireComponent('Textcube.Function.misc'); 
    345344    $blogid = getBlogId(); 
    346345    $path = "$folderPath/$filename"; 
     
    350349        $url = "$folderURL/$filename"; 
    351350    $fileInfo = getAttachmentByOnlyName($blogid, $filename); 
    352     switch (misc::getFileExtension($filename)) { 
     351    switch (Misc::getFileExtension($filename)) { 
    353352        case 'jpg':case 'jpeg':case 'gif':case 'png':case 'bmp': 
    354353            $bPassing = false; 
     
    399398            break; 
    400399        default: 
    401             if (file_exists(ROOT . '/image/extension/' . misc::getFileExtension($fileInfo['label']) . '.gif')) { 
    402                 return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $hostURL : '') . $blogURL . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $serviceURL : $service['path']) . '/image/extension/' . misc::getFileExtension($fileInfo['label']) . '.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>'; 
     400            if (file_exists(ROOT . '/resources/image/extension/' . Misc::getFileExtension($fileInfo['label']) . '.gif')) { 
     401                return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $hostURL : '') . $blogURL . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $serviceURL : $service['path']) . '/resources/image/extension/' . Misc::getFileExtension($fileInfo['label']) . '.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>'; 
    403402            } else { 
    404                 return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $hostURL : '') . $blogURL . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $serviceURL : $service['path']) . '/image/extension/unknown.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>'; 
     403                return '<a class="extensionIcon" href="' . ($useAbsolutePath ? $hostURL : '') . $blogURL . '/attachment/' . $filename . '">' . fireEvent('ViewAttachedFileExtension', '<img src="' . ($useAbsolutePath ? $serviceURL : $service['path']) . '/resources/image/extension/unknown.gif" alt="" />') . ' ' . htmlspecialchars($fileInfo['label']) . '</a>'; 
    405404            } 
    406405            break; 
     
    410409function FM_TTML_createNewProperty($filename, $imageWidth, $property) { 
    411410    $blogid = getBlogId(); 
    412     requireComponent('Textcube.Function.Image'); 
    413     if (in_array(Image::getImageType(ROOT."/attach/$blogid/$filename"), array('gif', 'png', 'jpg', 'bmp'))) 
    414         return Image::resizeImageToContent($property, ROOT."/attach/$blogid/$filename", $imageWidth); 
     411    $image = Utils_Image::getInstance(); 
     412    if (in_array($image->getImageType(ROOT."/attach/$blogid/$filename"), array('gif', 'png', 'jpg', 'bmp'))) 
     413        return $image->resizeImageToContent($property, ROOT."/attach/$blogid/$filename", $imageWidth); 
    415414    else 
    416415        return array($property, false); 
  • branches/1.8/plugins/FM_TTML/ttml.php

    r8555 r8663  
    11<?php 
    22// PHP TTML parser 
    3 // Version 1.6 (2008.1.20) 
     3// Version 1.8 (2010.7.6) 
    44// 2004-2009 Needlworks / TNF / Tatter and Company 
    55// Original TTML is created by JH, 2004.4 
     
    77// TTML Module port for Tattertools 1.1 by lifthrasiir, 2007.1 
    88// TTML External library for Textcube 1.6 by inureyes, 2008.1 
     9// TTML External library for Textcube 1.8 by inureyes, 2010.7 
    910 
    1011function FM_TTML_bindTags($id, $content) { 
     
    3132    global $service, $hostURL, $blogURL, $serviceURL; 
    3233    requireModel('blog.attachment'); 
    33     requireComponent('Textcube.Function.misc'); 
    3434    $blogid = getBlogId(); 
    3535    getAttachments($blogid, $entryId); // For attachment caching. 
     
    342342function FM_TTML_getAttachmentBinder($filename, $property, $folderPath, $folderURL, $imageBlocks = 1, $useAbsolutePath = true, $bRssMode = false, $onclickFlag=false) { 
    343343    global $database, $skinSetting, $service, $blogURL, $hostURL, $serviceURL; 
    344     requireComponent('Textcube.Function.misc'); 
    345344    $blogid = getBlogId(); 
    346345    $path = "$folderPath/$filename"; 
     
    410409function FM_TTML_createNewProperty($filename, $imageWidth, $property) { 
    411410    $blogid = getBlogId(); 
    412     requireComponent('Textcube.Function.Image'); 
    413     if (in_array(Image::getImageType(ROOT."/attach/$blogid/$filename"), array('gif', 'png', 'jpg', 'bmp'))) 
    414         return Image::resizeImageToContent($property, ROOT."/attach/$blogid/$filename", $imageWidth); 
     411    $image = Utils_Image::getInstance(); 
     412    if (in_array($image->getImageType(ROOT."/attach/$blogid/$filename"), array('gif', 'png', 'jpg', 'bmp'))) 
     413        return $image->resizeImageToContent($property, ROOT."/attach/$blogid/$filename", $imageWidth); 
    415414    else 
    416415        return array($property, false); 
  • branches/1.8/plugins/FM_Textile/ttml.php

    r8555 r8663  
    11<?php 
    22// PHP TTML parser 
    3 // Version 1.6 (2008.1.20) 
     3// Version 1.8 (2010.7.6) 
    44// 2004-2009 Needlworks / TNF / Tatter and Company 
    55// Original TTML is created by JH, 2004.4 
     
    77// TTML Module port for Tattertools 1.1 by lifthrasiir, 2007.1 
    88// TTML External library for Textcube 1.6 by inureyes, 2008.1 
     9// TTML External library for Textcube 1.8 by inureyes, 2010.7 
    910 
    1011function FM_TTML_bindTags($id, $content) { 
     
    3132    global $service, $hostURL, $blogURL, $serviceURL; 
    3233    requireModel('blog.attachment'); 
    33     requireComponent('Textcube.Function.misc'); 
    3434    $blogid = getBlogId(); 
    3535    getAttachments($blogid, $entryId); // For attachment caching. 
     
    342342function FM_TTML_getAttachmentBinder($filename, $property, $folderPath, $folderURL, $imageBlocks = 1, $useAbsolutePath = true, $bRssMode = false, $onclickFlag=false) { 
    343343    global $database, $skinSetting, $service, $blogURL, $hostURL, $serviceURL; 
    344     requireComponent('Textcube.Function.misc'); 
    345344    $blogid = getBlogId(); 
    346345    $path = "$folderPath/$filename"; 
     
    410409function FM_TTML_createNewProperty($filename, $imageWidth, $property) { 
    411410    $blogid = getBlogId(); 
    412     requireComponent('Textcube.Function.Image'); 
    413     if (in_array(Image::getImageType(ROOT."/attach/$blogid/$filename"), array('gif', 'png', 'jpg', 'bmp'))) 
    414         return Image::resizeImageToContent($property, ROOT."/attach/$blogid/$filename", $imageWidth); 
     411    $image = Utils_Image::getInstance(); 
     412    if (in_array($image->getImageType(ROOT."/attach/$blogid/$filename"), array('gif', 'png', 'jpg', 'bmp'))) 
     413        return $image->resizeImageToContent($property, ROOT."/attach/$blogid/$filename", $imageWidth); 
    415414    else 
    416415        return array($property, false); 
  • branches/1.8/plugins/MT_Meta_RecentPS_Default/index.php

    r8502 r8663  
    183183        $imageInfo = getimagesize($originSrc); 
    184184 
    185         $objThumbnail = new Image(); 
     185        $objThumbnail = new Utils_Image(); 
    186186        if ($imageInfo[0] > $imageInfo[1]) 
    187187            list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize);