diff --git a/application/admin/model/Archives.php b/application/admin/model/Archives.php
new file mode 100644
index 00000000..53d46b97
--- /dev/null
+++ b/application/admin/model/Archives.php
@@ -0,0 +1,77 @@
+where('site_id', Session::get("user_site_id"));
+ }
+ //$query->alias('a')->join('counter c', 'c.item_id=a.id')->where('c.item_type','archive')->field('c.views, c.good, c.bad, c.comments');
+ }
+
+ public function Sites()
+ {
+ return $this->belongsTo('Sites', 'site_id')->field('id,name,domain');
+ }
+ public function Channel()
+ {
+ return $this->belongsTo('Channel', 'channel_id')->field('id,name');
+ }
+
+ protected static function init()
+ {
+ self::afterInsert(function ($row) {
+ $pk = $row->getPk();
+ $row->getQuery()->where($pk, $row[$pk])
+ ->update(['weigh' => $row[$pk]]);
+ });
+
+ self::beforeDelete(function($row){
+ if (intval($row->isDelete)==0) {
+ $row->isDelete = time();
+ $row->save();
+ return false;
+ }
+ });
+ }
+
+ public function restore()
+ {
+ return $this->update(['isDelete'=>0]);
+ }
+
+ public function getViewsAttr($value,$data)
+ {
+ if(!isset($data['id'])) return 0;
+ $result = Counter::get(['item_id'=>$data['id']]);
+ return $result?$result['views']:0;
+ }
+
+}
diff --git a/application/admin/model/Channel.php b/application/admin/model/Channel.php
new file mode 100644
index 00000000..e12d43ef
--- /dev/null
+++ b/application/admin/model/Channel.php
@@ -0,0 +1,114 @@
+where(['site_id'=> Session::get("user_site_id")]);
+ }
+ }
+
+
+ public function Sites()
+ {
+ return $this->belongsTo('Sites', 'site_id')->field('id,name');
+ }
+
+ public function Archives()
+ {
+ //return $this->belongsTo('Archives', 'id', 'channel_id')->field('channel_id,count(1) as items');
+ return $this->hasOne('Archives','channel_id','id')->field('channel_id,count(1) as items');
+ }
+
+ /**
+ * 读取分类类型
+ * @return array
+ */
+ public static function getTypeList()
+ {
+ //$typelist = config('site.categorytype');
+ return ['channel'=>__('Channel'), 'list'=>__('List'), 'redirect'=>__('Redirect')];
+ }
+
+
+ public static function getFlagList()
+ {
+ return ['hot' => __('Hot'), 'recommend' => __('Recommend')];
+ }
+
+ public function getFlagTextAttr($value, $data)
+ {
+ if(!isset($data['flag'])) return '';
+ $value = $value ? $value : $data['flag'];
+ $valueArr = explode(',', $value);
+ $list = $this->getFlagList();
+ return implode(',', array_intersect_key($list, array_flip($valueArr)));
+ }
+
+ /**
+ * 读取分类列表
+ * @param string $type 指定类型
+ * @param string $status 指定状态
+ * @return array
+ */
+ public static function getChannelArray($type = NULL, $status = NULL)
+ {
+ $list = collection(self::where(function($query) use($type, $status) {
+ if (!is_null($type))
+ {
+ $query->where('type', '=', $type);
+ }
+ if (!is_null($status))
+ {
+ $query->where('status', '=', $status);
+ }
+ })->order('weigh', 'desc')->select())->toArray();
+ return $list;
+ }
+
+
+ /*
+ protected static function init()
+ {
+ self::afterInsert(function ($row) {
+ $pk = $row->getPk();
+ $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
+ });
+ }
+ */
+
+
+
+
+
+
+
+
+
+}
diff --git a/application/admin/model/Page.php b/application/admin/model/Page.php
new file mode 100644
index 00000000..d2f90bd3
--- /dev/null
+++ b/application/admin/model/Page.php
@@ -0,0 +1,39 @@
+where('site_id', Session::get("user_site_id"));
+ }
+ }
+
+ public function Sites()
+ {
+ return $this->belongsTo('Sites', 'site_id')->field('id,name');
+ }
+
+
+}
diff --git a/application/admin/model/PostsModelx.php b/application/admin/model/PostsModelx.php
new file mode 100644
index 00000000..64940d9c
--- /dev/null
+++ b/application/admin/model/PostsModelx.php
@@ -0,0 +1,302 @@
+ __('String'),
+ 'text' => __('Text'),
+ 'richtext' => __('Richtext'),
+ 'number' => __('Number'),
+ 'datetime' => __('Datetime'),
+ 'select' => __('Select'),
+ 'selects' => __('Selects'),
+ 'image' => __('Image'),
+ 'images' => __('Images'),
+ 'file' => __('File'),
+ 'files' => __('Files'),
+ 'checkbox' => __('Checkbox'),
+ 'radio' => __('Radio'),
+ ];
+ return $typeList;
+ }
+
+ /**
+ * 校验规则名称
+ */
+ public static function getRules(){
+ return [
+ "required" => __('Required'),
+ "digits"=>"数字",
+ "letters"=>"字母",
+ "date"=>"日期",
+ "time"=>"时间",
+ "email"=>"邮箱",
+ "url"=>"网址",
+ "qq"=>"QQ号",
+ "IDcard"=>"身份证",
+ "tel"=>"座机电话",
+ "mobile"=>"手机号",
+ "zipcode"=>"邮编",
+ "chinese"=>"中文",
+ "username"=>"用户名",
+ "password"=>"密码"
+ ];
+ }
+
+ /**
+ * 保存模型数据
+ * @param string $modelname 模型
+ * @param int $archiveid 文章ID
+ * @param array $params 表单数据
+ * @return bool
+ */
+ public static function saveExtraForm($modelname='', $archiveid=0, $params=[])
+ {
+ if (empty($modelname) || $archiveid==0 || empty($params)) return false;
+
+ $mod = self::get(['name' => $modelname]);
+ if (!$mod) return false;
+
+ $fields = json_decode($mod['extra'],true);
+
+ //格式化模型数据
+ foreach ($fields as $k => $v) {
+ if ($v['type']=='file' || $v['type']=='files'){
+ foreach($params[$v['field']] as $item=>&$val){
+ if($val['url']==''){
+ unset($params[$v['field']][$item]);
+ }
+ }
+ $params[$v['field']] = empty($params[$v['field']])? ''
+ : json_encode($params[$v['field']], JSON_UNESCAPED_UNICODE);
+ }
+ }
+
+ foreach ($params as $k => &$v)
+ {
+ $v = is_array($v) ? implode(',', $v) : $v;
+ }
+ $params['item_id'] = $archiveid ;
+
+ $row = model('extra'.$modelname)->get(['item_id'=>$archiveid]);
+ if($row) {
+ $row->allowField(true)->save($params);
+ }else {
+ model('extra'.$modelname)->allowField(true)->save($params);
+ }
+
+ return true;
+ }
+
+ /**
+ * 生成模型表单
+ * @param $modelname 模型名称
+ * @param $archiveid 文章ID
+ * @return string
+ */
+ public static function getExtraForm($modelname, $archiveid=null)
+ {
+ $mod = self::get(['name'=>$modelname]);
+ if(!$mod) return '';
+ if(!isset($mod['extra']) || empty($mod['extra'])) return '';
+
+ $row = empty($archiveid)? null :
+ model('extra'.$mod['name'])->get(['item_id'=> $archiveid]);
+
+ $params = json_decode($mod['extra'], true);
+
+ $controls = $controlid = $cssname = '';
+ $controlPrefix = 'row';
+ $btnUpload = __('Upload'); $btnChoose = __('Choose'); $btnAppend = __('Append');
+ $input = '';
+ $textarea = '';
+ $checkbox = '';
+ $radio = '';
+
+ $html = [];
+ foreach ($params as $k => $v){
+ if(isset($v['status']) && $v['status']=='hidden') continue;
+ $defaultValue = !isset($row[$v['field']]) ? $v['value']
+ : empty($row[$v['field']]) ? $v['value'] : $row[$v['field']] ;
+
+ $controlid = $v['field'] . substr(md5($v['field'].microtime()),0,6);
+
+ switch(strtolower($v['type'])){
+ case 'string':
+ case 'number':
+ case 'datetime':
+ $cssname = $v['type']=='datetime'?'datetimepicker':'';
+ $controls = sprintf($input, ($v['type']=='number'?'number':'text'), $controlid, $v['field'], $defaultValue, $cssname, $v['rule'], $v['tip'], $v['extend']);
+ break;
+ case 'text':
+ case 'richtext':
+ $cssname = $v['type']=='richtext'?'editor':'';
+ $controls = sprintf($textarea, $v['field'], $controlid, $cssname, $v['rule'], $v['tip'], $v['extend'], $defaultValue);
+ break;
+ case 'checkbox':
+ case 'radio':
+ $items = explode('||', $v['vars']);
+ $controls='';
+ $defaultValue=explode(',',$defaultValue);
+ for($i=0;$i%s', $v['type'], $controls);
+ break;
+ case 'select':
+ case 'selects':
+ $items = explode('||', $v['vars']);
+ $options = '';
+ $defaultValue=explode(',',$defaultValue);
+ for($i=0;$i%s', $item[1], $isChecked, $item[0]);
+ }
+
+ $extend = $v['type']=='selects'?'multiple ':' ';
+ $extend .= $v['extend'];
+ $controls = <<
+ {$options}
+
+EOF;
+ break;
+ case 'image':
+ case 'images':
+ $multi = $v['type']=='image'? 'false' : 'true';
+ $controls = <<
+
+
+
+
+
+EOF;
+
+ break;
+ case 'file':
+ case 'files':
+ $mimetype = '*/*';
+ $lab1 = __('Title'); $lab2 = __('File');
+
+ $edit = '';
+ $index=0;
+ if (!empty($defaultValue)){
+ $defaultValue=json_decode($defaultValue, true);
+ foreach($defaultValue as $key => $file)
+ {
+ $controlid = substr($v['type'],0,1).substr(md5($file['id'].microtime()),0,6);
+
+ if ($v['type']=='file'){
+ $btns = <<
+
+EOF;
+ }else {
+ $btns = <<
+EOF;
+ }
+
+ $edit .= <<
+
+
+
+ {$btns}
+
+EOF;
+ $index++;
+ }
+ }
+ else {
+ $controlid = substr($v['type'],0,1).substr(md5(microtime()),0,5);
+ $edit = <<
+
+
+
+
+
+
+EOF;
+ }
+
+ $append = $v['type']=='files'?''.$btnAppend.'':'';
+
+ $controls = <<
+
+ -
+ {$lab1}
+ {$lab2}
+
+ {$edit}
+ {$append}
+
+
+EOF;
+
+ $controlid = 'none';
+ break;
+ }
+
+ $html[] = <<
+
+
+ {$controls}
+
+
+EOF;
+ }
+ return sprintf('%s
', $mod['name'], implode('',$html));
+ }
+
+
+
+
+
+
+}
diff --git a/application/admin/model/Sites.php b/application/admin/model/Sites.php
new file mode 100644
index 00000000..876153cc
--- /dev/null
+++ b/application/admin/model/Sites.php
@@ -0,0 +1,16 @@
+
+ * @Since: 2018/2/5 15:37
+ */
+
+namespace app\admin\model;
+
+
+use think\Model;
+
+class Sites extends Model
+{
+
+}
\ No newline at end of file