dever 7 년 전
커밋
591c8c4e73
6개의 변경된 파일507개의 추가작업 그리고 0개의 파일을 삭제
  1. 102 0
      database/cate.php
  2. 125 0
      database/data.php
  3. 172 0
      database/info.php
  4. 8 0
      index.php
  5. 60 0
      src/Api.php
  6. 40 0
      src/Manage.php

+ 102 - 0
database/cate.php

@@ -0,0 +1,102 @@
+<?php
+
+$menu = false;
+$cate = Dever::config('base')->tagCate;
+if (!$cate) {
+	$menu = true;
+}
+
+return array
+(
+	# 表名
+	'name' => 'cate',
+	# 显示给用户看的名称
+	'lang' => '分类管理',
+	# 是否显示在后台菜单
+	'order' => 9,
+	'menu' => $menu,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'asc',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '分类名称',
+			'default' 	=> '',
+			'desc' 		=> '分类名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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
+	(
+
+	),
+
+	# 默认值
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"默认分类",1,' . time(),
+		),
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 125 - 0
database/data.php

@@ -0,0 +1,125 @@
+<?php
+
+$cate = function()
+{
+	$array = array();
+	$info = Dever::load('attr/cate-state');
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'data',
+	# 显示给用户看的名称
+	'lang' => '标签数据关联表',
+	# 是否显示在后台菜单
+	'order' => 10,
+	'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'asc',
+			'list'		=> true,
+		),
+
+		'tag_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '标签ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order',
+			'list'		=> true,
+		),
+
+		'type' 		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '类型',
+			'default' 	=> '',
+			'desc' 		=> '类型',
+			'match' 	=> 'is_string',
+			'list'		=> true,
+		),
+
+		'type_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '关联ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order',
+			'list'		=> true,
+		),
+		
+		'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
+	(
+		# 列表页的类型
+		
+	),
+
+	'request' => array
+	(
+		'deleteByType' => array
+		(
+			'where' => array
+			(
+				'type' => 'yes',
+				'type_id' => 'yes',
+			),
+
+			'type' => 'delete',
+		),
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'info_id' => 'yes',
+				'tag_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('cdate' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		)
+	)
+);

+ 172 - 0
database/info.php

@@ -0,0 +1,172 @@
+<?php
+
+$cate = function()
+{
+	$array = array();
+	$cate = Dever::config('base')->tagCate;
+	if (!$cate) {
+		$cate = 'tag/cate';
+	}
+	$info = Dever::db($cate)->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '标签列表',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'asc',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '标签名称',
+			'default' 	=> '',
+			'desc' 		=> '标签名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'color'		=> array
+		(
+			'type' 		=> 'varchar-10',
+			'name' 		=> '颜色-请填写颜色代码',
+			'default' 	=> '',
+			'desc' 		=> '颜色',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+		),
+
+		'icon'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '图标',
+			'default' 	=> '',
+			'desc' 		=> '请选择图标',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '选择分类',
+			'default' 	=> '1',
+			'desc' 		=> '选择分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'list'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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
+	(
+		# 列表页的类型
+		
+	),
+
+	'request' => array
+	(
+		'getAllByIds' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*',
+		),
+
+		'getAllByName' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'name' => array('yes', 'like'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => '*,name as value,name as label|id',
+		),
+
+		'getAllByCate' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'cate_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'col' => 'id,name',
+		),
+	)
+);

+ 8 - 0
index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'tag');
+define('DEVER_APP_LANG', '标签管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 9);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tags');
+include(DEVER_APP_PATH . '../boot.php');

+ 60 - 0
src/Api.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace Tag\Src;
+
+use Dever;
+
+class Api
+{
+	public function update($id, $name, $data)
+	{	
+    	$tag = Dever::param('tag', $data);
+    	$tag = explode(',', $tag);
+    	foreach ($tag as $k => $v) {
+    		$info = Dever::db('tag/info')->one(array('name' => $v));
+    		if (!$info) {
+    			$insert['name'] = $v;
+    			$tag_id = Dever::db('tag/info')->insert($insert);
+    		} else {
+    			$tag_id = $info['id'];
+    		}
+    		Dever::db('tag/data')->deleteByType(array('where_type' => $name, 'where_type_id' => $id));
+    		$insert['type'] = $name;
+        	$insert['type_id'] = $id;
+        	$insert['tag_id'] = $tag_id;
+        	Dever::db('tag/data')->insert($insert);
+		}
+	}
+
+	public function typeid($tag_id, $type)
+	{
+		$result = Dever::db('tag/data')->state(array('tag_id' => $tag_id, 'type' => $type));
+
+		if (!$result) {
+			return array();
+		}
+		foreach ($result as $k => $v) {	
+			$type_id[] = $v['type_id'];	
+		}
+		return $type_id;
+	}
+
+	public function tag($type_id, $type)
+	{
+		$result = Dever::db('tag/data')->state(array('type_id' => $type_id,'type' => $type));
+		if (!$result) {
+			return array();
+		}
+
+		foreach ($result as $k => $v) {
+			$tag[] = Dever::db('tag/info')->one($v['tag_id']);
+		}
+
+		return $tag;
+	}
+
+	public function tag_content($ids)
+	{
+		return Dever::db('tag/info')->getAll(array('ids'=>$ids));
+	}
+}

+ 40 - 0
src/Manage.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace Tag\Src;
+
+use Dever;
+
+class Manage
+{
+	/**
+     * 获取标签信息:根据名称获取多个标签,一般用于autocomplete
+     *
+     * @return mixed
+     */
+    public function getByName()
+    {
+        $data = Dever::db('tag/info')->getAllByName(array
+            (
+                'name' => Dever::input('term'))
+        );
+        if ($data) {
+            return $data;
+        }
+        return array
+            (
+            0 => array('id' => -1, 'value' => '没有找到您搜索的数据', 'label' => '没有找到您搜索的数据'),
+        );
+    }
+
+    /**
+     * 根据分类id获取标签信息
+     *
+     * @return mixed
+     */
+    public function getByCate()
+    {
+    	$cate = Dever::input('cate');
+    	$data = Dever::db('tag/info')->getAllByCate(array('cate_id' => $cate));
+    	return Dever::load('manage/database')->getAjax($data);
+    }
+}