dever 6 years ago
commit
3f9d090939
6 changed files with 362 additions and 0 deletions
  1. 5 0
      README.md
  2. 167 0
      database/model.php
  3. 105 0
      database/template.php
  4. BIN
      fonts/simsun.ttc
  5. 8 0
      index.php
  6. 77 0
      src/Api.php

+ 5 - 0
README.md

@@ -0,0 +1,5 @@
+# poster
+
+海报管理
+
+

+ 167 - 0
database/model.php

@@ -0,0 +1,167 @@
+<?php
+
+$type = array
+(
+	1 => '图片',
+	2 => '文字',
+);
+
+return array
+(
+	# 表名
+	'name' => 'model',
+	# 显示给用户看的名称
+	'lang' => '模块设置',
+	'menu' => false,
+	'check' => 'template_id,key',
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'template_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属模板',
+			'default' 	=> '1',
+			'desc' 		=> '请选择所属模板',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_template_id')
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '模块名称',
+			'default' 	=> '',
+			'desc' 		=> '模块名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '模块标识-设置模块时,使用该标识来设置模块信息',
+			'default' 	=> '',
+			'desc' 		=> '模块标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '模块类型',
+			'default' 	=> '1',
+			'desc' 		=> '请选择模块类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+			'control'	=> 'type',
+		),
+
+		'position'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '模块位置-位置为top,left,如100,200',
+			'default' 	=> '0,0',
+			'desc' 		=> '模块位置',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'width'		=> array
+		(
+			'type' 		=> 'varchar-11',
+			'name' 		=> '图片宽度',
+			'default' 	=> '200',
+			'desc' 		=> '图片宽度',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'type=1',
+		),
+
+		'height'		=> array
+		(
+			'type' 		=> 'varchar-11',
+			'name' 		=> '图片高度',
+			'default' 	=> '200',
+			'desc' 		=> '图片高度',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'type=1',
+		),
+
+		'color'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '文字颜色',
+			'default' 	=> '#000000',
+			'desc' 		=> '文字颜色',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'type=2',
+		),
+
+		'size'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '文字大小-直接输入像素数字',
+			'default' 	=> '16',
+			'desc' 		=> '文字大小',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'show'		=> 'type=2',
+		),
+
+		'angle'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '角度-直接输入数字',
+			'default' 	=> '0',
+			'desc' 		=> '角度',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'show'		=> 'type=2',
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+);

+ 105 - 0
database/template.php

@@ -0,0 +1,105 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'template',
+	# 显示给用户看的名称
+	'lang' => '模板设置',
+	'order' => 20,
+	'check' => 'key',
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '模板名称',
+			'default' 	=> '',
+			'desc' 		=> '模板名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '模板标识-调用模板时,使用该标识来获取模板信息',
+			'default' 	=> '',
+			'desc' 		=> '模板标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'background'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '模板背景图',
+			'default' 	=> '',
+			'desc' 		=> '模板背景图',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '模板样例图',
+			'default' 	=> '',
+			'desc' 		=> '模板样例图',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 管理功能
+	'manage' => array
+	(
+		# 列表
+		'list_button' => array
+		(
+			'list' => array('模块', '"model&project=poster&search_option_template_id={id}&oper_parent=template&oper_project=poster"'),
+		),
+	),
+);

BIN
fonts/simsun.ttc


+ 8 - 0
index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'poster');
+define('DEVER_APP_LANG', '海报管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', -2);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-warning-sign');
+include(DEVER_APP_PATH . '../boot.php');

+ 77 - 0
src/Api.php

@@ -0,0 +1,77 @@
+<?php
+namespace Poster\Src;
+
+use Dever;
+
+class Api
+{
+	public function test()
+	{
+		return '<img src="' .$this->get('1', 'k1', array
+		(
+			'desc' => '吞吞吐吐',
+			'pic' => '/www/grow/data/upload/1/2018/07/19/46d5b0c5c25c800cf197ea4f64f503f2.jpg',
+			'name' => '毒贩夫妇付',
+		)) . '" />';
+	}
+
+    public function get($name, $key, $set)
+	{
+		$where['key'] = $key;
+		$template = Dever::db('poster/template')->one($where);
+
+		if ($template) {
+			$where = array();
+			$where['template_id'] = $template['id'];
+			$model = Dever::db('poster/model')->state($where);
+
+			if ($model) {
+				$config = array();
+				$config['background'] = Dever::local($template['background']);
+				$config['param'] = array();
+				foreach ($model as $k => $v) {
+					$param = $this->getConfig($v, $set);
+					if ($param) {
+						array_push($config['param'], $param);
+					}
+				}
+
+				if ($config['param']) {
+					$result = Dever::load('upload/view')->create($config, $name, 'im');
+
+					return Dever::pic($result);
+				}
+			}
+		}
+
+		return false;
+	}
+
+	private function getConfig($value, $set)
+	{
+		$key = $value['key'];
+		$param = array();
+		if (isset($set[$key])) {
+			$position = explode(',', $value['position']);
+			if ($value['type'] == 1) {
+				$param['method'] = 'mark';
+				$param['water'] = $set[$key];
+				$param['position'] = $position;
+				$param['width'] = $value['width'];
+				$param['height'] = $value['height'];
+
+			} elseif ($value['type'] == 2) {
+				$param['method'] = 'txt';
+				$param['name'] = $set[$key];
+				$param['color'] = $value['color'];
+				$param['top'] = $position[0];
+				$param['left'] = $position[1];
+				$param['size'] = $value['size'];
+				$param['angle'] = $value['angle'];
+				$param['font'] = dirname(__FILE__) . DIRECTORY_SEPARATOR . '../fonts/simsun.ttc';
+			}
+		}
+
+		return $param;
+	}
+}