dever пре 3 година
родитељ
комит
e1a0c009fc
5 измењених фајлова са 70 додато и 11 уклоњено
  1. 4 2
      database/model.php
  2. 44 4
      database/template.php
  3. BIN
      fonts/simsun.ttc
  4. 2 0
      lib/Img.php
  5. 20 5
      src/Api.php

+ 4 - 2
database/model.php

@@ -22,7 +22,9 @@ $position_type = array
 	5 => '居中',
 	6 => '上居中',
 	7 => '下居中',
-	8 => '自定义',
+	8 => '左居中',
+	9 => '右居住',
+	10 => '自定义',
 );
 
 return array
@@ -131,7 +133,7 @@ return array
 			'desc' 		=> '模块定位',
 			'match' 	=> 'is_string',
 			'update'	=> 'text',
-			'show'		=> 'position_type=8',
+			'show'		=> 'position_type=10',
 		),
 
 		'offset'		=> array

+ 44 - 4
database/template.php

@@ -12,6 +12,12 @@ $update = array
 	2 => '仅生成一次',
 );
 
+$create = array
+(
+	1 => '自动生成空白图',
+	2 => '手动上传',
+);
+
 return array
 (
 	# 表名
@@ -82,6 +88,41 @@ return array
 			'option'	=> $update,
 		),
 
+		'create'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '模板背景图',
+			'default' 	=> '2',
+			'desc' 		=> '模板背景图',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $create,
+			'search'	=> 'select',
+			'control'	=> 'create',
+		),
+
+		'width'		=> array
+		(
+			'type' 		=> 'varchar-11',
+			'name' 		=> '背景图宽度',
+			'default' 	=> '300',
+			'desc' 		=> '背景图宽度',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'create=1',
+		),
+
+		'height'		=> array
+		(
+			'type' 		=> 'varchar-11',
+			'name' 		=> '背景图高度',
+			'default' 	=> '300',
+			'desc' 		=> '背景图高度',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'create=1',
+		),
+
 		'background'		=> array
 		(
 			'type' 		=> 'varchar-150',
@@ -91,19 +132,18 @@ return array
 			'match' 	=> 'option',
 			'update'	=> 'image',
 			'key' 		=> '1',
-			'place'		=> '150',
+			'show'		=> 'create=2',
 		),
 
 		'pic'		=> array
 		(
 			'type' 		=> 'varchar-150',
-			'name' 		=> '模板样例图',
+			'name' 		=> '样例图',
 			'default' 	=> '',
-			'desc' 		=> '模板样例图',
+			'desc' 		=> '样例图',
 			'match' 	=> 'option',
 			'update'	=> 'image',
 			'key' 		=> '1',
-			'place'		=> '150',
 		),
 
 		'state'		=> array


+ 2 - 0
lib/Img.php

@@ -64,6 +64,8 @@ class Img
         $host = str_replace(DEVER_PROJECT . '/' . DEVER_APP_NAME . '/', '', Dever::config('host')->base);
         if (strstr($file, '/share/dc/data/')) {
             return $host . str_replace('/share/dc/data/', '', $file);
+        } else {
+            return Dever::pic($file);
         }
         return $host . str_replace(DEVER_PROJECT_PATH, '', $file);
         $file = Dever::pic($file);

+ 20 - 5
src/Api.php

@@ -80,11 +80,25 @@ class Api
 
 			if ($model) {
 				$config = array();
+				$config['background'] = '';
+				if (isset($set['width']) && $set['width']) {
+					$template['width'] = $set['width'];
+				}
+				if (isset($set['height']) && $set['height']) {
+					$template['height'] = $set['height'];
+				}
+				
 				if (isset($set['background']) && $set['background']) {
 					$config['background'] = Dever::local($set['background']);
 					unset($set['background']);
-				} else {
+				} elseif ($template['create'] == 2 && $template['background']) {
 					$config['background'] = Dever::local($template['background']);
+				} elseif ($template['create'] == 1) {
+
+					$config['background'] = array
+					(
+						$template['width'], $template['height']
+					);
 				}
 				
 				$config['param'] = array();
@@ -116,7 +130,7 @@ class Api
 			$set[$key] = $value['value'];
 		}
 		if (isset($set[$key])) {
-			if ($value['position_type'] == 8) {
+			if ($value['position_type'] == 10) {
 				$position = explode(',', $value['position']);
 			} else {
 				$position = $value['position_type'];
@@ -150,9 +164,10 @@ class Api
 
 				$fonts = array
 				(
-					1 => 'PingFang_Regular.ttf',
-					2 => 'PingFang_Bold.ttf',
-					3 => 'PingFang_Medium.ttf',
+					1 => 'simsun.ttc',
+					//1 => 'PingFang_Regular.ttf',
+					//2 => 'PingFang_Bold.ttf',
+					//3 => 'PingFang_Medium.ttf',
 				);
 
 				$param['font'] = dirname(__FILE__) . DIRECTORY_SEPARATOR . '../fonts/'.$fonts[$value['fonts']];