[Linpha-cvs] SF.net SVN: linpha: [4886] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2008-02-20 19:01:17
|
Revision: 4886 http://linpha.svn.sourceforge.net/linpha/?rev=4886&view=rev Author: fangehrn Date: 2008-02-20 11:01:10 -0800 (Wed, 20 Feb 2008) Log Message: ----------- Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.color.class.php trunk/linpha2/lib/plugins/watermark/watermark.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-02-20 19:00:48 UTC (rev 4885) +++ trunk/linpha2/ChangeLog 2008-02-20 19:01:10 UTC (rev 4886) @@ -1,4 +1,8 @@ +2008-02-20 flo + * moved func.watermark.php to classes/linpha.color.class.php + they are used at several other places + 2008-02-17 flo * implemented adodb datadict - mysql works Modified: trunk/linpha2/lib/classes/linpha.color.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.color.class.php 2008-02-20 19:00:48 UTC (rev 4885) +++ trunk/linpha2/lib/classes/linpha.color.class.php 2008-02-20 19:01:10 UTC (rev 4886) @@ -19,157 +19,10 @@ if(!defined('LINPHA_DIR')) { exit(1); } -class LinWatermark +class LinColor { /** -* @author flo -* @todo adapt from linpha1 -*/ -static function needWatermark($imgid) -{ - if( $GLOBALS['linpha']->sql->config->value['plugins_active_wm'] - && $GLOBALS['linpha']->sql->config->value['plugins_wm_active'] - && !check_permissions('watermark',$imgid) ) - { - return true; - } else { - return false; - } -} - -/** - * returns array with all the configs and the default values, they are only defined here - */ -static function getWatermarkArray() -{ - return array ( - 'wm_active' => "0", - 'wm_watermark' => "0", - 'wm_text' => "Copyright 2007", - 'wm_font' => "", - 'wm_fontsize' => "20", - 'wm_fontcolor' => "white", - 'wm_align' => "southwest", - 'wm_horizontal' => "0", - 'wm_vertical' => "0", - 'wm_enable_shadow' => "1", - 'wm_shadow_size' => "1", - 'wm_shadow_fontsize' => "20", - 'wm_shadow_color' => "black", - 'wm_enable_rectangle' => "1", - 'wm_rectangle_color' => "darkgrey", - 'wm_height' => "30", - 'wm_width' => "145", - 'wm_img_img' => "", - 'wm_dissolve' => "75%", - 'wm_resize' => "30" - ); -} - -static function readWatermark() -{ - $arr_config = LinWatermark::getWatermarkArray(); - while(list($name,$value) = each($arr_config) ) - { - $arr_read[$name] = $GLOBALS['linpha']->sql->config->value['plugins_'.$name]; - } - return $arr_read; -} - -static function updateWatermark() -{ - $arr_config = LinWatermark::getWatermarkArray(); - while(list($name,$value) = each($arr_config) ) - { - $GLOBALS['linpha']->sql->config->updateConfig($name,$_POST[$name]); - } -} - -/** - * restore watermark settings to initial settings or to examples - */ -static function restoreWatermark() -{ - global $wm_restore_to; - - $arr_config = LinWatermark::getWatermarkArray(); - switch($_POST['setdefault']) - { - case 'initial': - break; - case 'settings1': - $arr_config['wm_watermark'] = 1; - $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; - $arr_config['wm_fontsize'] = "10"; - $arr_config['wm_fontcolor'] = "white"; - $arr_config['wm_align'] = "south"; - $arr_config['wm_horizontal'] = "0"; - $arr_config['wm_vertical'] = "0"; - $arr_config['wm_enable_rectangle'] = "1"; - $arr_config['wm_rectangle_color'] = "darkgrey"; - $arr_config['wm_enable_shadow'] = "2"; - $arr_config['wm_height'] = "20"; - $arr_config['wm_width'] = "2000"; - $arr_config['wm_resize'] = "no"; - break; - case 'settings2': - $arr_config['wm_watermark'] = 2; - $arr_config['wm_dissolve'] = "65%"; - $arr_config['wm_align'] = "southwest"; - $arr_config['wm_img_img'] = "linpha.png"; - $arr_config['wm_horizontal'] = "10"; - $arr_config['wm_vertical'] = "10"; - $arr_config['wm_resize'] = "30"; - - break; - case 'settings3': // maybe better for gd lib than for convert - $arr_config['wm_watermark'] = 1; - $arr_config['wm_dissolve'] = "100%"; - $arr_config['wm_align'] = "southwest"; - $arr_config['wm_text'] = "(C) 2004 linpha.sf.net"; - $arr_config['wm_fontsize'] = "20"; - $arr_config['wm_fontcolor'] = "white"; - $arr_config['wm_horizontal'] = "0"; - $arr_config['wm_vertical'] = "0"; - $arr_config['wm_enable_rectangle'] = "1"; - $arr_config['wm_rectangle_color'] = "darkgrey"; - $arr_config['wm_enable_shadow'] = "1"; - $arr_config['wm_shadow_size'] = "5"; - $arr_config['wm_shadow_fontsize'] = "2"; - $arr_config['wm_height'] = "30"; - $arr_config['wm_width'] = "260"; - $arr_config['wm_resize'] = "no"; - break; - } - while(list($name,$value) = each($arr_config) ) - { - $GLOBALS['linpha']->sql->config->updateConfig($name,$value); - } -} - -/** - * calcs the new height and width of the resized watermark - * $w, $h: size of the big image - * $org_width, $org_height: size of the watermark rectangle/image - * $resize: resize factor in percent - * - */ -static function wmArrResized($w,$h,$org_width,$org_height,$resize) -{ - $arr_resized['w'] = round($w * $resize/100); - $arr_resized['h'] = round($h * $resize/100); - - $no_increase = 0; - $array = LinImage::scaleToFit($org_height,$org_width,$arr_resized['h'],$arr_resized['w'],$no_increase); - - //error_log('w: '.$w.' h: '.$h.' arr_resized_w: '.$arr_resized['w'].' arr_resized_h: '.$arr_resized['h']. - // ' org_w: '.$org_width.' org_h: '.$org_height.' scaleToFit w: '.$array['w'].' h: '.$array['h']); - - return $array; -} - -/** * list with many available colors * http://mail.gnu.org/archive/html/emacs-diffs/2002-06/msg00158.html * @uses getRgbFromAll() @@ -392,13 +245,13 @@ switch(strlen($string)) { case 6: - if(LinWatermark::everyCharIsHex($string)) { + if(LinColor::everyCharIsHex($string)) { return 1; } break; case 7: if(substr($string,0,1)=="#") { - if(LinWatermark::everyCharIsHex(substr($string,1,6))) { + if(LinColor::everyCharIsHex(substr($string,1,6))) { return 1; } } @@ -440,13 +293,13 @@ */ static function getRgbFromAll($string) { - if( isset( LinWatermark::$Colors[$string]) ) + if( isset( LinColor::$Colors[$string]) ) { - return LinWatermark::getRgbFromHtml( LinWatermark::$Colors[$string] ); + return LinColor::getRgbFromHtml( LinColor::$Colors[$string] ); } - elseif(LinWatermark::isHtmlColor($string) ) + elseif(LinColor::isHtmlColor($string) ) { - return LinWatermark::getRgbFromHtml( $string ); + return LinColor::getRgbFromHtml( $string ); } else { @@ -461,7 +314,7 @@ */ static function getHtmlFromAll($string) { - if(LinWatermark::isHtmlColor($string)) + if(LinColor::isHtmlColor($string)) { if(substr($string,0,1)=="#") { @@ -474,9 +327,9 @@ } else { - if( isset( LinWatermark::$Colors[$string]) ) + if( isset( LinColor::$Colors[$string]) ) { - return substr(LinWatermark::$Colors[$string],1,6); + return substr(LinColor::$Colors[$string],1,6); } else { @@ -485,63 +338,5 @@ } } -/** - * @uses watermark_gd() - * calcs the position in pixel with a given align - * src_w, src_h: width and height from the textfield (or the small watermark image) - * dst_w, dst_h: width and height from the image - * pos_x, pos_y: additional adjust for the image - * - */ -static function calcAlign($align, $src_w, $src_h, $dst_w, $dst_h, $pos_x, $pos_y) -{ - - switch($align) - { - case "center": - $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); - $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); - break; - case "east": - $arr_pos['x'] = $dst_w-$src_w+($pos_x); - $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); - break; - case "west": - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = ($dst_h-$src_h)/2+($pos_y); - break; - case "north": - $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); - $arr_pos['y'] = $pos_y; - break; - case "south": - $arr_pos['x'] = ($dst_w-$src_w)/2+($pos_x); - $arr_pos['y'] = $dst_h-$src_h+($pos_y); - break; - case "northeast": - $arr_pos['x'] = $dst_w-$src_w+($pos_x); - $arr_pos['y'] = $pos_y; - break; - case "northwest": - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = $pos_y; - break; - case "southwest": - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = $dst_h-$src_h+($pos_y); - break; - case "southeast": - $arr_pos['x'] = $dst_w-$src_w+($pos_x); - $arr_pos['y'] = $dst_h-$src_h+($pos_y); - break; - default: - $arr_pos['x'] = $pos_x; - $arr_pos['y'] = $pos_y; - break; - - } - return $arr_pos; } - -} ?> \ No newline at end of file Modified: trunk/linpha2/lib/plugins/watermark/watermark.class.php =================================================================== --- trunk/linpha2/lib/plugins/watermark/watermark.class.php 2008-02-20 19:00:48 UTC (rev 4885) +++ trunk/linpha2/lib/plugins/watermark/watermark.class.php 2008-02-20 19:01:10 UTC (rev 4886) @@ -170,323 +170,7 @@ } /** - * list with many available colors - * http://mail.gnu.org/archive/html/emacs-diffs/2002-06/msg00158.html - * @uses getRgbFromAll() - */ -static $Colors = array( - 'aliceblue'=>'#f0f8ff', - 'antiquewhite'=>'#faebd7', - 'aquamarine'=>'#7fffd4', - 'azure'=>'#f0ffff', - 'beige'=>'#f5f5dc', - 'bisque'=>'#ffe4c4', - 'black'=>'#000000', - 'blanchedalmond'=>'#ffebcd', - 'blue'=>'#0000ff', - 'blueviolet'=>'#8a2be2', - 'brown'=>'#a52a2a', - 'burlywood'=>'#deb887', - 'cadetblue'=>'#5f9ea0', - 'chartreuse'=>'#7fff00', - 'chocolate'=>'#d2691e', - 'coral'=>'#ff7f50', - 'cornflowerblue'=>'#6495ed', - 'cornsilk'=>'#fff8dc', - 'cyan'=>'#00ffff', - 'darkblue'=>'#00008b', - 'darkcyan'=>'#008b8b', - 'darkgoldenrod'=>'#b886011', - 'darkgray'=>'#a9a9a9', - 'darkgreen'=>'#006400', - 'darkgrey'=>'#a9a9a9', - 'darkkhaki'=>'#bdb76b', - 'darkmagenta'=>'#8b008b', - 'darkolivegreen'=>'#556b2f', - 'darkorange'=>'#ff8c00', - 'darkorchid'=>'#9932cc', - 'darkred'=>'#8b0000', - 'darksalmon'=>'#e9967a', - 'darkseagreen'=>'#8fbc8f', - 'darkslateblue'=>'#483d8b', - 'darkslategray'=>'#2f4f4f', - 'darkslategrey'=>'#2f4f4f', - 'darkturquoise'=>'#00ced1', - 'darkviolet'=>'#9400d3', - 'deeppink'=>'#ff1493', - 'deepskyblue'=>'#00bfff', - 'dimgray'=>'#696969', - 'dimgrey'=>'#696969', - 'dodgerblue'=>'#1e90ff', - 'firebrick'=>'#b22222', - 'floralwhite'=>'#fffaf0', - 'forestgreen'=>'#228b22', - 'gainsboro'=>'#dcdcdc', - 'ghostwhite'=>'#f8f8ff', - 'gold'=>'#ffd700', - 'goldenrod'=>'#daa520', - 'gray'=>'#bebebe', - 'green'=>'#00ff00', - 'greenyellow'=>'#adff2f', - 'honeydew'=>'#f0fff0', - 'hotpink'=>'#ff69b4', - 'indianred'=>'#cd5c5c', - 'ivory'=>'#fffff0', - 'khaki'=>'#f0e68c', - 'lavender'=>'#e6e6fa', - 'lavenderblush'=>'#fff0f5', - 'lawngreen'=>'#7cfc00', - 'lemonchiffon'=>'#fffacd', - 'lightblue'=>'#add8e6', - 'lightcoral'=>'#f08080', - 'lightcyan'=>'#e0ffff', - 'lightgoldenrod'=>'#eedd82', - 'lightgoldenrodyellow'=>'#fafad2', - 'lightgray'=>'#d3d3d3', - 'lightgreen'=>'#90ee90', - 'lightgrey'=>'#d3d3d3', - 'lightpink'=>'#ffb6c1', - 'lightred'=>'#ffc8c8', - 'lightsalmon'=>'#ffa07a', - 'lightseagreen'=>'#20b2aa', - 'lightskyblue'=>'#87cefa', - 'lightslateblue'=>'#8470ff', - 'lightslategray'=>'#778899', - 'lightsteelblue'=>'#b0c4de', - 'lightyellow'=>'#ffffe0', - 'limegreen'=>'#32cd32', - 'linen'=>'#faf0e6', - 'magenta'=>'#ff00ff', - 'maroon'=>'#b03060', - 'mediumaquamarine'=>'#66cdaa', - 'mediumblue'=>'#0000cd', - 'mediumorchid'=>'#ba55d3', - 'mediumpurple'=>'#9370db', - 'mediumseagreen'=>'#3cb371', - 'mediumslateblue'=>'#7b68ee', - 'mediumspringgreen'=>'#00fa9a', - 'mediumturquoise'=>'#48d1cc', - 'mediumvioletred'=>'#c71585', - 'midnightblue'=>'#191970', - 'mintcream'=>'#f5fffa', - 'mistyrose'=>'#ffe4e1', - 'moccasin'=>'#ffe4b5', - 'navajowhite'=>'#ffdead', - 'navy'=>'#000080', - 'navyblue'=>'#000080', - 'oldlace'=>'#fdf5e6', - 'olivedrab'=>'#6b8e23', - 'orange'=>'#ffa500', - 'orangered'=>'#ff4500', - 'orchid'=>'#da70d6', - 'palegoldenrod'=>'#eee8aa', - 'palegreen'=>'#98fb98', - 'paleturquoise'=>'#afeeee', - 'palevioletred'=>'#db7093', - 'papayawhip'=>'#ffefd5', - 'peachpuff'=>'#ffdab9', - 'peru'=>'#cd853f', - 'pink'=>'#ffc0cb', - 'plum'=>'#dda0dd', - 'powderblue'=>'#b0e0e6', - 'purple'=>'#a020f0', - 'red'=>'#ff0000', - 'rosybrown'=>'#bc8f8f', - 'royalblue'=>'#4169e1', - 'saddlebrown'=>'#8b4513', - 'salmon'=>'#fa8072', - 'sandybrown'=>'#f4a460', - 'seagreen'=>'#2e8b57', - 'seashell'=>'#fff5ee', - 'sienna'=>'#a0522d', - 'skyblue'=>'#87ceeb', - 'slateblue'=>'#6a5acd', - 'slategray'=>'#708090', - 'slategrey'=>'#708090', - 'snow'=>'#fffafa', - 'springgreen'=>'#00ff7f', - 'steelblue'=>'#4682b4', - 'tan'=>'#d2b48c', - 'thistle'=>'#d8bfd8', - 'tomato'=>'#ff6347', - 'turquoise'=>'#40e0d0', - 'violet'=>'#ee82ee', - 'violetred'=>'#d02090', - 'wheat'=>'#f5deb3', - 'white'=>'#ffffff', - 'yellow'=>'#ffff00', - 'yellowgreen'=>'#9acd32' -); - -/** - * not used anymore - */ -static function getHtmlColorFromRgb($r,$g,$b) -{ - if(strlen(dechex($r))==1) { - $r = '0'.$r; - } else { - $r = dechex($r); - } - if(strlen(dechex($g))==1) { - $g = '0'.$g; - } else { - $g = dechex($g); - } - if(strlen(dechex($b))==1) { - $b = '0'.$b; - } else { - $b = dechex($b); - } - - return '#'.$r.$g.$b; -} - -/** - * used to check if it is a valid html color - * @uses isHtmlColor() - */ -static function everyCharIsHex($string) -{ - for($i=0;$i<strlen($string);$i++) - { - $char = substr($string,$i,1); - $valid_color = false; - - if($char == "0") { // zero makes problems... '== 0' and '== "0"' is not the same... - $valid_color = true; - } - for($n=1;$n<=9;$n++) - { - if($char == $n) { - $valid_color = true; - } - } - - for($n='a';$n<='f';$n++) - { - if($char === $n) { - $valid_color = true; - } - } - - for($n='A';$n<='F';$n++) - { - if($char === $n) { - $valid_color = true; - } - } - if(!$valid_color) { - return 0; - } - } - return 1; -} - -/** - * used to check if it is a valid html color - * @uses getRgbFromAll() - */ -static function isHtmlColor($string) -{ - switch(strlen($string)) - { - case 6: - if(LinWatermark::everyCharIsHex($string)) { - return 1; - } - break; - case 7: - if(substr($string,0,1)=="#") { - if(LinWatermark::everyCharIsHex(substr($string,1,6))) { - return 1; - } - } - break; - } - return 0; -} - -/** - * converts a html color to an array with the rgb values - * it doesn't matter if the html color is '#00FF00' or '00FF00' - * @uses getRgbFromAll() - */ -static function getRgbFromHtml($string) -{ - switch(strlen($string)) - { - case 6: - break; - case 7: - $string = substr($string,1,6); - break; - } - $r_hex = substr($string,0,2); - $g_hex = substr($string,2,2); - $b_hex = substr($string,4,2); - $arr['r'] = hexdec($r_hex); - $arr['g'] = hexdec($g_hex); - $arr['b'] = hexdec($b_hex); - return $arr; -} - -/** - * returns an array with the rgb values - * it doesn't matter if the argument is 'darkblue', '#00FF55' or '00FF55' - * if it isn't a correct color, the color (0,0,0) is returned - * * @uses watermark_gd() - */ -static function getRgbFromAll($string) -{ - if( isset( LinWatermark::$Colors[$string]) ) - { - return LinWatermark::getRgbFromHtml( LinWatermark::$Colors[$string] ); - } - elseif(LinWatermark::isHtmlColor($string) ) - { - return LinWatermark::getRgbFromHtml( $string ); - } - else - { - array('r'=>0,'g'=>0,'b'=>0); - } -} - -/** - * return html color without '#' - * - * used in linpha2 - admin - settings_layout - */ -static function getHtmlFromAll($string) -{ - if(LinWatermark::isHtmlColor($string)) - { - if(substr($string,0,1)=="#") - { - return substr($string,1,6); - } - else - { - return $string; - } - } - else - { - if( isset( LinWatermark::$Colors[$string]) ) - { - return substr(LinWatermark::$Colors[$string],1,6); - } - else - { - return 'ffffff'; - } - } -} - -/** - * @uses watermark_gd() * calcs the position in pixel with a given align * src_w, src_h: width and height from the textfield (or the small watermark image) * dst_w, dst_h: width and height from the image This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |