<?php

/* ========================================================================
 * $Id: setting.php 2649 2020-05-20 07:51:25Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# edit
#请求数据
if($MODE=='$post'){
  $id=onez()->gp('id');
  $action=onez()->gp('action');
  if($action=='data'){
    
    $data=array();
    $data['title']='系统设置';
    $A['pagedata']=$data;
    
    $form=$this->load('form');
    $form->init($G['site']);
    
    $tab='基础';
    
    
    $form->add(array('label'=>'网站状态','type'=>'select','key'=>'status','options'=>$G['this']->siteStatus(),'notempty'=>'','default'=>'','group'=>''),$tab);
    #$form->add(array('label'=>'核心功能','type'=>'select','key'=>'type','options'=>$G['this']->siteTypes(),'notempty'=>'','default'=>'','group'=>'','tip'=>'其他功能可以在创建后通过插件管理添加'));
    $form->add(array('label'=>'网站名称','type'=>'text','key'=>'name','hint'=>'','notempty'=>'网站不能为空','default'=>'','group'=>''));
    $form->add(array('label'=>'网站域名','type'=>'textarea','key'=>'domains','hint'=>'每行填写一个，需要解析后才可以访问','notempty'=>'','default'=>'','group'=>'','tip'=>'每行填写一个'));
    
    $datas=array();
    $T=$G['this']->data()->open('datas')->record("userid='$G[userid]' order by id desc");
    foreach($T as $rs){
      $datas[$rs['id']]=$rs['name'];
    }
    $form->add(array('label'=>'数据体系','type'=>'select','key'=>'data','options'=>$datas,'notempty'=>'','default'=>'','group'=>''));
    $users=array();
    $T=$G['this']->data()->open('users')->record("userid='$G[userid]' order by id desc");
    foreach($T as $rs){
      $users[$rs['id']]=$rs['name'];
    }
    $form->add(array('label'=>'用户体系','type'=>'select','key'=>'user','options'=>$users,'notempty'=>'','default'=>'','group'=>''));
    
    
    $form->add(array('label'=>'备注','type'=>'textarea','key'=>'summary','hint'=>'','notempty'=>'','default'=>'','group'=>''));
    $G['this']->slot('/develop/setting',$form);
    $form->add(array('label'=>'锁定插件','type'=>'text','key'=>'lockPlugin','notempty'=>'','default'=>'','group'=>'','tip'=>'插件标识，即/plugins中的某个目录名。如果设置，则访问站点时以该插件为主。注：可以不是应用市场的应用'));
    
    if($onez=$form->submit()){
      $G['this']->data()->open('sites')->update($onez,"userid='$G[userid]' and id='{$G['site']['id']}'");
      $G['this']->siteUpdate();
      return $this->ok('提交成功','reload2');
    }
    $form->output($A);
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'pageform',
  'name'=>'表单',
  'data'=>'form',
));
