当前位置: 首页>>代码示例>>PHP>>正文


PHP ModuleManager::get_data_dir方法代码示例

本文整理汇总了PHP中ModuleManager::get_data_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManager::get_data_dir方法的具体用法?PHP ModuleManager::get_data_dir怎么用?PHP ModuleManager::get_data_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModuleManager的用法示例。


在下文中一共展示了ModuleManager::get_data_dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_observer

 public function update_observer($type, $message, $errfile, $errline, $errcontext, $backtrace)
 {
     $mail = Variable::get('error_mail');
     if ($mail) {
         $backtrace = htmlspecialchars_decode(str_replace(array('<br />', '&nbsp;'), array("\n", ' '), $backtrace));
         $x = "who=" . Base_AclCommon::get_user() . "\ntype=" . $type . "\nmessage=" . $message . "\nerror file=" . $errfile . "\nerror line=" . $errline . "\n" . $backtrace;
         $d = ModuleManager::get_data_dir('Base/Error') . md5($x) . '.txt';
         file_put_contents($d, $x);
         $url = get_epesi_url();
         Base_MailCommon::send($mail, 'Epesi Error - ' . $url, substr($x, 0, strpos($x, "error backtrace")) . "\n" . $url . '/' . $d, null, null, false, true);
     }
     return true;
 }
开发者ID:62BRAINS,项目名称:EPESI,代码行数:13,代码来源:ErrorCommon_0.php

示例2: create_thumb

	/**
	 * Creates thumb of loaded image.
	 * 
	 * @param string path to image
	 * @param int max size.
	 * @param int max height. When specified, first parameter becomes responsible for max width.
	 */
	public static function create_thumb($img, $attr_x = null, $attr_y = null) {
		ini_set("gd.jpeg_ignore_warning", 1);
		
		if(!is_file($img)) {
			$img = Base_ThemeCommon::get_template_file('Utils/Image','error_image_not_found.gif');
		} 
		
		list($width,$height,$type,$attr) = getimagesize($img);
		
		$max_dim = 100;
		if( is_numeric($attr_x) )
			$max_dim = $attr_x;
		if( is_numeric($attr_y) && $width < $height )
			$max_dim = $attr_y;
			
		if($height > $max_dim || $width > $max_dim) {
			if($height < $width) {
				$thumb_width = $max_dim;
				$thumb_height = $height * ( $max_dim / $width );
			} else if($width < $height) {
				$thumb_width = $width * ( $max_dim / $height );
				$thumb_height = $max_dim;
			} else {
				$thumb_width = $max_dim;
				$thumb_height = $max_dim;
			}
		} else {
			$thumb_width = $width;
			$thumb_height = $height;
		}
		
		$thumb = md5($max_dim.$img).strrchr($img,'.');
	
		// check if thumbnail in desired scale already exists
		//  1) it does
		$thumb_real = ModuleManager::get_data_dir('Utils/Image').$thumb;
		if( is_file($thumb_real) && filemtime($img)<filemtime($thumb_real) && filectime($img)<filectime($thumb_real)) {
			//print ModuleManager::get_data_dir('Utils/Image').$thumb." exists<br>";
			list($thumb_width, $thumb_height, $type, $attr) = getimagesize($thumb_real);
		// 2) it does not
		} else { // create thumb
			//$old_err = error_reporting(0);
			//print "typ: ". $type;
			//print ModuleManager::get_data_dir('Utils/Image').$thumb." does not exist<br>";
			// if file is a jpeg graphic
			if( $type == 3 ) {
				$im = imagecreatefrompng($img); /* Attempt to open */
				if( $im ) {
					//constrain proportions if needed
					$t_im = imagecreatetruecolor($thumb_width, $thumb_height);
					
					
					//header("Content-type: image/png");
					//imagesavealpha($t_im, true);
					$background = imagecolorallocate($t_im, 0, 0, 0);
					ImageColorTransparent($t_im, $background); // make the new temp image all transparent
					imagealphablending($t_im, false); // turn off the alpha blending to keep the alpha channel
			 		imagesavealpha($t_im, true);

			 		imagecopyresampled($t_im, $im, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
			
					imagepng($t_im, $thumb_real);
					imagecolordeallocate($t_im,$background);
					imagedestroy($t_im);
					imagedestroy($im);
					//print ModuleManager::get_data_dir('Utils/Image').$thumb." created<br>";
				}
			} elseif( $type == 2 ) {
				$im = imagecreatefromjpeg($img); /* Attempt to open */
				if( $im ) {
					//constrain proportions if needed
					$t_im = imagecreatetruecolor($thumb_width, $thumb_height);
			
					imagecopyresampled($t_im, $im, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
			
					imagejpeg($t_im, $thumb_real, 90);
					imagedestroy($im);
					imagedestroy($t_im);
					//print ModuleManager::get_data_dir('Utils/Image').$thumb." created<br>";
				}
			} elseif( $type == 1 ) {
				$im = imagecreatefromgif($img);
				if( $im ) {
					$imgSource = $im;
					$imgDestination1 = imagecreatetruecolor($thumb_width, $thumb_height); 
					
					$black = imagecolorallocate($imgDestination1, 0, 0, 1); 
					
					imagefill($imgDestination1, 0, 0, $black); 
					imagecolortransparent($imgDestination1, $black); 
					
					imagecopyresampled($imgDestination1, $imgSource, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); 
					
//.........这里部分代码省略.........
开发者ID:62BRAINS,项目名称:EPESI,代码行数:101,代码来源:ImageCommon_0.php


注:本文中的ModuleManager::get_data_dir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。