<?php

/* ========================================================================
 * $Id: setting.php 2365 2017-03-22 13:39:06Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onezphp.com
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
$G['title']='设计应用';

$ptoken=onez()->gp('ptoken');

$type=onez()->gp('type');
$types=array();
if(method_exists(onez($ptoken),'setting')){
  $types['setting']='设置';
}
if(file_exists(onez($ptoken)->path.'/manage/menu.inc.php')){
  $menu=include(onez($ptoken)->path.'/manage/menu.inc.php');
  if($menu){
    foreach($menu as $v){
      $types[$v['href']]=$v['name'];
    }
  }
}

!$type && $type=key($types);

$types_html='';
foreach($types as $k=>$v){
  $types_html.='<a href="'.onez('store')->href('/manage/setting.php?ptoken='.$ptoken.'&type='.$k).'" class="btn btn-'.($k==$type?'info':'default').'">
        '.$v.'
      </a>';
}

if($type!='setting'){
  if(file_exists(onez($ptoken)->path.'/manage/'.$type.'.php')){
    include(onez($ptoken)->path.'/manage/'.$type.'.php');
  }
  return;
}


#初始化表单
$form=onez('admin')->widget('form')
  ->set('title',$G['title'])
  ->set('values',$G['this']->option())
;

#创建表单项
$form->add(array('type'=>'hidden','key'=>'action','value'=>'save'));

onez($ptoken)->setting($form);

#处理提交
if($onez=$form->submit()){
  $G['this']->option_set($onez);
  onez()->ok('操作成功','reload');
}
$xxx="";
onez('admin')->header();
?>
<section class="content-header">
  <h1>
    <?php echo $G['title']?><small></small>
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="<?php echo onez()->href('/')?>">
        <i class="fa fa-dashboard">
        </i>
        管理首页
      </a>
    </li>
    <li class="active">
      <?php echo $G['title']?>
    </li>
  </ol>
</section>
<section class="content">
  <form id="form-common" method="post">
  <div class="btns" style="padding-bottom: 10px">
    <div class="pull-left">
      <?php echo $types_html?>
    </div>
    <div class="pull-right">
      
    </div>
    <div class="clearfix"></div>
  </div>
  <div class="box box-info">
    <div class="box-header with-border">
      <h3 class="box-title">
        <?php echo $G['title']?>
      </h3>
      <div class="box-tools pull-right">
      </div>
    </div>
      <div class="box-body">
        <?php echo $form->code();?>
      </div>
      <div class="box-footer clearfix">
        <button type="submit" class="btn btn-primary">
          保存修改
        </button>
      </div>
    </div>
  </form>
</section>
<?php
echo $form->js();
onez('admin')->footer();
?>