初始化项目

This commit is contained in:
2016-06-21 17:12:08 +08:00
commit 7ea154d684
903 changed files with 226100 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
return array(
'view_replace_str' => array(
'__ADDONS__' => BASE_PATH . '/addons',
'__PUBLIC__' => BASE_PATH . '/public',
'__STATIC__' => BASE_PATH . '/application/index/static',
'__IMG__' => BASE_PATH . '/application/index/static/images',
'__CSS__' => BASE_PATH . '/application/index/static/css',
'__JS__' => BASE_PATH . '/application/index/static/js',
)
);

View File

@@ -0,0 +1,143 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Fornt;
class Content extends Fornt{
public function _initialize(){
parent::_initialize();
$model_name = $this->request->param('model');
$model_id = $this->request->param('model_id');
$row = db('Model')->select();
foreach ($row as $key => $value) {
$name_list[$value['name']] = $value;
$id_list[$value['id']] = $value;
}
if (empty($name_list[$model_name]) && empty($id_list[$model_id])) {
return $this->error("无此模型!");
}else {
$this->modelInfo = $model_name ? $name_list[$model_name] : $id_list[$model_id];
if ($this->modelInfo['extend'] > 1) {
$this->model = model($this->modelInfo['name']);
}else{
$this->model = model('Document')->extend($this->modelInfo['name']);
}
$this->assign('model_id',$this->modelInfo['id']);
$this->assign('model_list',$name_list);
}
}
//模块频道首页
public function index(){
$id = input('id','','trim,intval');
$name = input('name','','trim');
if ($name) {
$id = db('Category')->where(array('name'=>$name))->getField('id');
}
if (!$id) {
return $this->error("无此频道!");
}
$cate = $this->getCategory($id);
//获得当前栏目的所有子栏目
$ids = get_category_child($id);
$data = array(
'category' => $cate,
'child_cate' => $ids
);
if ($cate['template_index']) {
$teamplate = 'content/'.$this->modelInfo['name'].'/'.$cate['template_index'];
}else{
$teamplate = 'content/'.$this->modelInfo['name'].'/index';
}
$this->assign($data);
return $this->fetch($teamplate);
}
//模块列表页
public function lists($id = '', $name = ''){
if ($name) {
$id = db('Category')->where(array('name'=>$name))->getField('id');
}
if (!$id) {
return $this->error("无此栏目!");
}
$cate = $this->getCategory($id);
//获得当前栏目的所有子栏目
$ids = get_category_child($id);
$map['category_id'] = array('IN',$ids);
$map['model_id'] = $this->modelInfo['id'];
$map['status'] = array('GT',0);
if ($this->modelInfo['extend'] > 1) {
$order = "id desc";
}else{
$order = "is_top desc,id desc";
}
$list = $this->model->where($map)->order($order)->paginate(15);
$data = array(
'list' => $list,
'cate' => $cate,
'page' => $list->render()
);
if ($cate['template_lists']) {
$teamplate = 'content/'.$this->modelInfo['name'].'/'.$cate['template_lists'];
}else{
$teamplate = 'content/'.$this->modelInfo['name'].'/list';
}
$this->setSeo($cate['title']);
$this->assign($data);
return $this->fetch($teamplate);
}
//模块内容详情页
public function detail($id = '', $name = ''){
//当为文章模型时
$info = $this->model->detail($id);
//文档模型数据统计,同一台电脑半小时更新一次
if ($this->modelInfo['extend'] = 1 && (time() - session('set_content_view')) > 1800) {
db('Document')->where(array('id'=>$id))->setInc('view');
session('set_content_view',time());
}
if (empty($info)) {
return $this->error("无此内容!");
}
$data = array(
'info' => $info
);
if ($name) {
$teamplate = 'content/'.$this->modelInfo['name'].'/'.$name;
}else{
$teamplate = 'content/'.$this->modelInfo['name'].'/detail';
}
$this->assign($data);
return $this->fetch($teamplate);
}
protected function getCategory($id){
$data = db('Category')->find($id);
return $data;
}
}

View File

@@ -0,0 +1,19 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Fornt;
class Index extends Fornt{
//网站首页
public function index(){
return $this->fetch();
}
}

View File

@@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Fornt;
class Search extends Fornt{
//文档搜索结果显示
public function index(){
$content = model('Document');
$map = $this->mapBuild();
$list = $content->where($map)->order('create_time desc')->paginate(10);
$data = array(
'list' => $list,
'page' => $list->render()
);
$this->assign($data);
return $this->fetch();
}
//查询条件组装
protected function mapBuild(){
$keyword = input('keyword', '', 'trim');
$map['status'] = array('GT',0);
if ($keyword) {
$map['title'] = array("LIKE","%$keyword%");
}
$search = array(
'keyword'=>$keyword
);
$this->assign('search',$search);
return $map;
}
}

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SentCMS3.0</title>
</head>
<body>
<a href="http://www.tensent.cn" target="_blank">SentCMS3.0</a>
</body>
</html>