Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Sep 21, 2016
1 parent 3a49f74 commit a9583d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions helpers/CFunc.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ public static function is_time($time)
# $array为要排序的数组
# $keys为要用来排序的键名,二维数组的key
# $type默认为升序排序
public static function array_sort($array,$keys,$type='asc'){
public static function array_sort($array,$keys,$dir='asc',$isFloat=true){

$keysvalue = $new_array = array();
foreach ($array as $k=>$v){
$keysvalue[$k] = $v[$keys];
if($isFloat){
$keysvalue[$k] = (float)$v[$keys];
}else{
$keysvalue[$k] = $v[$keys];
}
}
if($type == 'asc'){
if($dir == 'asc'){
asort($keysvalue);
}else{
arsort($keysvalue);
Expand Down
8 changes: 6 additions & 2 deletions helpers/CImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,20 @@ class CImage
*/

public static function saveResizeMiddleWaterImg($imgPath,$newPath,$resize,$waterMark=''){

//exit;
$image = static::getImagine()->open($imgPath);
$sourceBox = $image->getSize();
$imgWidth = $sourceBox->getWidth();
$imgHeight = $sourceBox->getHeight();
if(is_array($resize)){
list($resizeWidth,$resizeHeight) = $resize;
}else{
$resizeWidth = $resizeHeight = $resize;
$resizeWidth = $resize;
$resizeHeight = $resizeWidth * $imgHeight / $imgWidth;
}
//echo 22;
//echo $resizeWidth.' && '.$resizeHeight;
//exit;
if(!$resizeWidth && !$resizeHeight){
return false;
}
Expand Down

0 comments on commit a9583d6

Please sign in to comment.