// 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
/*
* 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
// 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 '&'
// 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)
}
function getVersion() {
- return '2.2.1';
+ return '2.3.0';
}
function supportsFeature($what) {
'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;
//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).') ';
}
}
}
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.
*
* 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 @@
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
+ }