OSDN Git Service

v2.3.0
authorhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 2 May 2008 17:23:20 +0000 (17:23 +0000)
committerhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 2 May 2008 17:23:20 +0000 (17:23 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@617 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_TrimImage/NP_TrimImage.php
trunk/NP_TrimImage/sharedlibs/phpthumb/enableLeftTop.patch
trunk/NP_TrimImage/sharedlibs/phpthumb/phpthumb.class.php

index 0c15e6e..3b6c4fa 100644 (file)
@@ -2,10 +2,10 @@
 // vim: tabstop=2:shiftwidth=2
 
 /**
-  * NP_TrimImage ($Revision: 1.10 $)
+  * NP_TrimImage ($Revision: 1.11 $)
   * by nakahara21 ( http://nakahara21.com/ )
   * by hsur ( http://blog.cles.jp/np_cles/ )
-  * $Id: NP_TrimImage.php,v 1.10 2007-04-07 04:10:16 hsur Exp $
+  * $Id: NP_TrimImage.php,v 1.11 2008-05-02 17:23:20 hsur Exp $
   *
   * Based on NP_TrimImage 1.0 by nakahara21
   * http://nakahara21.com/?itemid=512
@@ -13,7 +13,7 @@
 
 /*
   * Copyright (C) 2004-2006 nakahara21 All rights reserved.
-  * Copyright (C) 2006-2007 cles All rights reserved.
+  * Copyright (C) 2006-2008 cles All rights reserved.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -50,7 +50,7 @@
 //                     sql_table support :-P
 //     0.6:    parameter supports blogid and catid
 //     0.7:    supports templatevar
-//                     supports <%popup()%> 
+//                     supports popup() 
 //     0.8:    supports gif
 //     0.9:    doTemplateVar calls DB data for other PreItem Plugin
 //     0.9:    change '&' to '&amp;'
@@ -65,7 +65,9 @@
 //                             Add ENT_QUOTES to htmlspecialchars()
 //                             Add ExtractImageMode
 //  2.2.1:     update phpThumb() 1.7.7 . 
-//              bug fix        
+//             bug fix 
+//  2.2.2:     update enableLeftTop.patch
+//  2.3.0:  add itemcat mode
 
 define('NP_TRIMIMAGE_FORCE_PASSTHRU', true); //passthru(standard)
 //define('NP_TRIMIMAGE_FORCE_PASSTHRU', false); //redirect(advanced)
@@ -91,7 +93,7 @@ class NP_TrimImage extends NucleusPlugin {
        }
 
        function getVersion() {
-               return '2.2.1';
+               return '2.3.0';
        }
 
        function supportsFeature($what) {
@@ -156,6 +158,10 @@ class NP_TrimImage extends NucleusPlugin {
                        'config_prefer_imagemagick' => NP_TRIMIMAGE_PREFER_IMAGEMAGICK,
                );
        }
+
+       function getCategoryIDFromItemID($itemid) {
+               return quickQuery('SELECT icat as result FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid) );
+       }
        
        function doSkinVar($skinType, $amount = 10, $wsize = 80, $hsize = 80, $point = 0, $random = 0, $exmode = '', $titlemode = '', $includeImg = 'true') {
                global $CONF, $manager, $blog;
@@ -193,30 +199,38 @@ class NP_TrimImage extends NucleusPlugin {
 
                                //break;
                        default :
-                               if ($exmode == '') {
-                                       $this->exquery .= ' and iblog = '.intval($b->getID());
-                                       global $catid;
+                               if ($exmode == '' || $exmode == 'itemcat') {
+                                       global $catid, $itemid;
                                        if ($catid)
                                                $this->exquery .= ' and icat = '.intval($catid);
-                               }
-                               elseif ($exmode == 'all') {
+                                       elseif( $exmode == 'itemcat' && $itemid )
+                                               $this->exquery .= ' and icat = '.intval( $this->getCategoryIDFromItemID($itemid) );
+                                       else
+                                               $this->exquery .= ' and iblog = '.intval($b->getID());
+                               } elseif ($exmode == 'all') {
                                        // nothing
                                } else {
-                                       $spid_array = $spbid = $spcid = array ();
+                                       $spbid = $spcid = array ();
                                        $spid_array = explode('/', $exmode);
                                        foreach ($spid_array as $spid) {
-                                               if (substr($spid, 0, 1) == 'b')
-                                                       $spbid[] = intval(substr($spid, 1));
-                                               if (substr($spid, 0, 1) == 'c')
-                                                       $spcid[] = intval(substr($spid, 1));
+                                               $type = substr($spid, 0, 1);
+                                               $type_id = intval(substr($spid, 1));
+                                               if( (!$type) || (!$type_id) ) continue;
+                                               
+                                               switch($type){
+                                                       case 'b':
+                                                               $spbid[] = $type_id;
+                                                               break;
+                                                       case 'c':
+                                                               $spcid[] = $type_id;
+                                                               break;
+                                               }
                                        }
-                                       $spbid = implode(',', $spbid);
-                                       $spcid = implode(',', $spcid);
-                                       if ($spbid) {
-                                               $this->exquery .= ' and iblog IN ('.$spbid.') ';
+                                       if ($spbid){
+                                               $this->exquery .= ' and iblog IN ('.implode(',', $spbid).') ';
                                        }
                                        if ($spcid) {
-                                               $this->exquery .= ' and icat IN ('.$spcid.') ';
+                                               $this->exquery .= ' and icat IN ('.implode(',', $spcid).') ';
                                        }
                                }
                }
index c7e3a10..177eb4e 100644 (file)
@@ -2,6 +2,8 @@ enableLeftTop.patch
 
 Zoom-Cropの際に、sx,syを評価するようにするパッチ
 
+$Id: enableLeftTop.patch,v 1.4 2008-05-02 17:23:20 hsur Exp $
+
 /*
   * Copyright (C) 2006 CLES. All rights reserved.
   *
@@ -31,26 +33,6 @@ Zoom-Cropの際に、sx,syを評価するようにするパッチ
   * this exception statement from your version.
 */
 
---- phpthumb.class.php.org     2006-12-03 02:43:12.965183341 +0900
-+++ phpthumb.class.php 2006-12-03 02:43:52.306561152 +0900
-@@ -2449,12 +2449,16 @@
-                               $this->thumbnailCropW = round($allowable_width);
-                               $this->thumbnailCropX = round(($this->source_width - $allowable_width) / 2);
-+                              // added by cles
-+                              if( $this->zc == 2 ) $this->thumbnailCropX = 0;
-                       } elseif ($scaling_Y > $scaling_X) {
-                               // some of the height will need to be cropped
-                               $allowable_height = $this->source_height / $scaling_Y * $scaling_X;
-                               $this->thumbnailCropH = round($allowable_height);
-                               $this->thumbnailCropY = round(($this->source_height - $allowable_height) / 2);
-+                              // added by cles
-+                              if( $this->zc == 2 ) $this->thumbnailCropY = 0;
-                       } else {
-                               // image fits perfectly, no cropping needed
-                       }
-
 --- phpthumb.functions.php.orig        2007-01-30 17:12:14.901206122 +0900
 +++ phpthumb.functions.php     2007-01-30 17:12:23.220804722 +0900
 @@ -416,7 +416,9 @@
@@ -75,3 +57,34 @@ Zoom-Cropの際に、sx,syを評価するようにするパッチ
                                        ob_end_clean();
                                        break;
                        }
+--- phpthumb.class.php.org     2007-05-19 15:30:16.720948848 +0900
++++ phpthumb.class.php 2007-05-19 15:31:49.196336184 +0900
+@@ -1307,6 +1307,11 @@
+ //print_r($getimagesize);
+ //echo '</pre>';
++                                                      // added by cles
++                                                      if( $this->zc == 2 )
++                                                      $commandline .= ' -gravity NorthWest';
++                                                      else
++
+                                                       $commandline .= ' -gravity center';
+                                                       if (($wAll > 0) && ($hAll > 0)) {
+@@ -2543,12 +2548,16 @@
+                               $this->thumbnailCropW = round($allowable_width);
+                               $this->thumbnailCropX = round(($this->source_width - $allowable_width) / 2);
++                              // added by cles
++                              if( $this->zc == 2 ) $this->thumbnailCropX = 0;
+                       } elseif ($scaling_Y > $scaling_X) {
+                               // some of the height will need to be cropped
+                               $allowable_height = $this->source_height / $scaling_Y * $scaling_X;
+                               $this->thumbnailCropH = round($allowable_height);
+                               $this->thumbnailCropY = round(($this->source_height - $allowable_height) / 2);
++                              // added by cles
++                              if( $this->zc == 2 ) $this->thumbnailCropY = 0;
+                       } else {
+                               // image fits perfectly, no cropping needed
+                       }
index 1c56154..49944c8 100644 (file)
@@ -1307,6 +1307,11 @@ class phpthumb {
 //print_r($getimagesize);
 //echo '</pre>';
 
+                                                       // added by cles
+                                                       if( $this->zc == 2 )
+                                                       $commandline .= ' -gravity NorthWest';
+                                                       else
+
                                                        $commandline .= ' -gravity center';
 
                                                        if (($wAll > 0) && ($hAll > 0)) {
@@ -3625,4 +3630,4 @@ exit;
 
 }
 
-?>
\ No newline at end of file
+?>