diff --git a/application/admin/controller/Category.php b/application/admin/controller/Category.php
index a784932b..10ebab7e 100644
--- a/application/admin/controller/Category.php
+++ b/application/admin/controller/Category.php
@@ -248,4 +248,42 @@ class Category extends Admin {
return $this->error("设置失败!");
}
}
+
+ public function add_channel() {
+ if (IS_POST) {
+ $Channel = model('Channel');
+ $data = $this->request->param();
+ if ($data) {
+ $id = $Channel->save($data);
+ if ($id) {
+ $map['id'] = array('IN', $data['mid']);
+ $result = db('Category')->where($map)->setField('ismenu',$Channel->id);
+ return $this->success('生成成功',url('index'));
+ //记录行为
+ action_log('update_channel', 'channel', $id, session('user_auth.uid'));
+ } else {
+ return $this->error('生成失败');
+ }
+ } else {
+ $this->error($Channel->getError());
+ }
+ } else {
+ $data = $this->request->param();
+ $modelname = db('Model')->where( array('id' => $data['model_id']) )->field('id,name')->find();
+ $data['url'] = $modelname['name'].'/list/'.$data['mid'];
+ $pid = input('pid', 0);
+ //获取父导航
+ if (!empty($pid)) {
+ $parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
+ $this->assign('parent', $parent);
+ }
+ $pnav = db('Channel')->where(array('pid' => '0'))->select();
+ $this->assign('pnav', $pnav);
+ $this->assign('pid', $pid);
+ $this->assign('info', $data);
+ $this->assign('data',null );
+ $this->setMeta('生成导航');
+ return $this->fetch('edit_channel');
+ }
+ }
}
\ No newline at end of file
diff --git a/application/admin/controller/Channel.php b/application/admin/controller/Channel.php
index f9e1413e..29dd8cf5 100644
--- a/application/admin/controller/Channel.php
+++ b/application/admin/controller/Channel.php
@@ -140,6 +140,9 @@ class Channel extends Admin {
$map = array('id' => array('in', $id));
if (db('Channel')->where($map)->delete()) {
+ //删除category中的ismenu字段记录
+ $map = array('ismenu' => array('in', $id));
+ db('Category')->where($map)->setField('ismenu',0);
//记录行为
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
return $this->success('删除成功');
diff --git a/application/admin/view/category/edit_channel.html b/application/admin/view/category/edit_channel.html
new file mode 100644
index 00000000..aa1a713e
--- /dev/null
+++ b/application/admin/view/category/edit_channel.html
@@ -0,0 +1,114 @@
+{extend name="public/base"/}
+{block name="body"}
+
+
+{/block}
\ No newline at end of file
diff --git a/application/admin/view/category/index.html b/application/admin/view/category/index.html
index 783a3d36..487c23b3 100644
--- a/application/admin/view/category/index.html
+++ b/application/admin/view/category/index.html
@@ -35,6 +35,7 @@
排序
发布
状态
+ 生成导航
操作
@@ -59,6 +60,13 @@
禁用
{/if}
+
+ {if $list['ismenu']}
+ 已生成
+ {else/}
+ 未生成
+ {/if}
+
编辑
{if $list['status']}
diff --git a/application/admin/view/config/group.html b/application/admin/view/config/group.html
index 5f01097c..bec7485b 100644
--- a/application/admin/view/config/group.html
+++ b/application/admin/view/config/group.html
@@ -59,6 +59,9 @@
{$vo}
{/volist}
+ {/case}
+ {case value="image"}
+ {:widget('common/Form/showConfig',array($item,$item))}
{/case}
{/switch}
{if condition="$item['remark']"}
diff --git a/application/common.php b/application/common.php
index 68b1b924..7a3165e3 100644
--- a/application/common.php
+++ b/application/common.php
@@ -988,6 +988,44 @@ function get_category_child($id) {
return array_unique($ids);
}
+/**
+ * 栏目文章当前位置
+ * @param integer $id 当前栏目ID
+ * @param string $ext 文章标题
+ * @return here 当前栏目树
+ * @author K先森 <77413254@qq.com>
+ **/
+function get_category_pos($id,$ext=''){
+ $cat = db('Category');
+ $here = '首页 ';
+ $uplevels = $cat->field("id,title,pid,model_id")->where("id=$id")->find();
+ if(empty($uplevels)){
+ return '栏目不存在';
+ }
+ if($uplevels['pid'] != 0)
+ $here .= get_category_uplevels($uplevels['pid']);
+ $modelid = $uplevels['model_id'];
+ $modelname = db('Model')->field("name")->where("id = $modelid")->find();
+ $links = url('index/content/lists?model='.$modelname['name'],array('id'=>$uplevels['id']));
+ $here .= ' >> '.$uplevels['title']." ";
+ if($ext != '') $here .= ' >> '.$ext;
+ return $here;
+}
+function get_category_uplevels($id){
+ $cat = db('Category');
+ $here = '';
+ $uplevels = $cat->field("id,title,pid,model_id")->where("id=$id")->find();
+ $modelid = $uplevels['model_id'];
+ $modelname = db('Model')->field("name")->where("id = $modelid")->find();
+ $links = url('index/content/lists?model='.$modelname['name'],array('id'=>$uplevels['id']));
+ $here .= ' >> '.$uplevels['title']." ";
+ if($uplevels['pid'] != 0){
+ $here = get_category_uplevels($uplevels['pid']).$here;
+ }
+ return $here;
+}
+
+
function send_email($to, $subject, $message) {
$config = array(
'protocol' => 'smtp',
diff --git a/application/common/view/default/form/image_Config.html b/application/common/view/default/form/image_Config.html
new file mode 100644
index 00000000..c0171fc9
--- /dev/null
+++ b/application/common/view/default/form/image_Config.html
@@ -0,0 +1,46 @@
+
+
上传图片
+ {if isset($value) && $value}
+
+ {else/}
+
+ {/if}
+
+ {if $value}
+ {php}
+ $images = get_cover($value);
+ {/php}
+
+
+
+
+
上传时间:{$images['create_time']|date='Y-m-d H:i:s',###}
+
+
+
+
+
+
+ {/if}
+
+
+
\ No newline at end of file
diff --git a/application/common/widget/Form.php b/application/common/widget/Form.php
index 80c6e303..2aeb7e81 100644
--- a/application/common/widget/Form.php
+++ b/application/common/widget/Form.php
@@ -37,4 +37,27 @@ class Form {
$view->assign($data);
return $view->fetch('common@default/form/' . $type);
}
+ public function showConfig($field, $info) {
+ $type = isset($field['type']) ? $field['type'].'_Config' : 'text';
+ //类型合并
+ if (in_array($type, array('string'))) {
+ $type = 'text';
+ }
+ if (in_array($type, array('picture'))) {
+ $type = 'image';
+ }
+
+ $data = array(
+ 'type' => $type,
+ 'field' => isset($field['name']) ? $field['name'] : '',
+ 'value' => isset($info[$field['name']]) ? $info[$field['name']] : (isset($field['value']) ? $field['value'] : ''),
+ 'size' => isset($field['size']) ? $field['size'] : 12,
+ 'option' => isset($field['option']) ? $field['option'] : '',
+ );
+ $no_tem = array('readonly', 'text', 'password','checkbox', 'textarea', 'select', 'bind', 'checkbox', 'radio', 'num', 'bool', 'decimal');
+ $type = !in_array($type, $no_tem) ? $type : 'show';
+ $view = new \think\View();
+ $view->assign($data);
+ return $view->fetch('common@default/form/'.$type);
+ }
}
\ No newline at end of file
diff --git a/data/sql.sql b/data/sql.sql
index 12e3de74..0aca17aa 100644
--- a/data/sql.sql
+++ b/data/sql.sql
@@ -337,6 +337,7 @@ CREATE TABLE `sent_category` (
`pid` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '上级分类ID',
`model_id` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '绑定模型ID',
`sort` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '排序(同级有效)',
+ `ismenu` int(100) UNSIGNED NOT NULL DEFAULT '0' COMMENT '生成导航返回的ID',
`list_row` tinyint(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT '列表每页行数',
`meta_title` varchar(50) NOT NULL DEFAULT '' COMMENT 'SEO的网页标题',
`keywords` varchar(255) NOT NULL DEFAULT '' COMMENT '关键字',
@@ -366,10 +367,10 @@ CREATE TABLE `sent_category` (
-- 转存表中的数据 `sent_category`
--
-INSERT INTO `sent_category` (`id`, `name`, `title`, `pid`, `sort`, `list_row`, `meta_title`, `keywords`, `description`, `template_index`, `template_lists`, `template_detail`, `template_edit`, `model`, `model_sub`, `type`, `link_id`, `allow_publish`, `display`, `reply`, `check`, `reply_model`, `extend`, `create_time`, `update_time`, `status`, `icon`, `groups`) VALUES
-(1, 'news', '新闻动态', 0, 0, 10, '', '', '', '', '', '', '', '', '2', '2,1', 0, 0, 1, 0, 0, '1', 'null', 1379474947, 1463561497, 1, 0, ''),
-(2, 'company_news', '国内新闻', 1, 1, 10, '', '', '', '', '', '', '', '2,3', '2', '2,1,3', 0, 1, 1, 0, 1, '1', '', 1379475028, 1386839751, 1, 0, ''),
-(3, '', '国外新闻', 1, 2, 10, '', '', '', '', '', '', '', '', '', '', 0, 1, 1, 0, 0, '', '', 0, 0, 1, 0, '');
+INSERT INTO `sent_category` (`id`, `name`, `title`, `pid`, `ismenu`, `sort`, `list_row`, `meta_title`, `keywords`, `description`, `template_index`, `template_lists`, `template_detail`, `template_edit`, `model`, `model_sub`, `type`, `link_id`, `allow_publish`, `display`, `reply`, `check`, `reply_model`, `extend`, `create_time`, `update_time`, `status`, `icon`, `groups`) VALUES
+(1, 'news', '新闻动态', 0, 1, 0, 10, '', '', '', '', '', '', '', '', '2', '2,1', 0, 0, 1, 0, 0, '1', 'null', 1379474947, 1463561497, 1, 0, ''),
+(2, 'company_news', '国内新闻', 1, 0, 1, 10, '', '', '', '', '', '', '', '2,3', '2', '2,1,3', 0, 1, 1, 0, 1, '1', '', 1379475028, 1386839751, 1, 0, ''),
+(3, '', '国外新闻', 1, 0, 2, 10, '', '', '', '', '', '', '', '', '', '', 0, 1, 1, 0, 0, '', '', 0, 0, 1, 0, '');
-- --------------------------------------------------------