dzadsod/admin/config.class.php

77 lines
2.1 KiB
PHP

<?php
defined('IN_MET') or exit('No permission');
load::own_class('appadmin');
/*
* 配置
* 包含其他功能初始化
*/
class config extends appadmin
{
public function __construct()
{
global $_M, $_YW;
parent::__construct();
$this->tname = $_M['form']['tname'];
}
public function __destruct()
{
global $_M, $_YW;
if ($this->destruct) {
if (empty($this->appshow)) $this->appshow = 'app/' . $this->tname;
require $this->show($this->appshow, $this->input);
}
}
//页初始化
public function doindex()
{
global $_M, $_YW;
parent::point('config', 'doconfig', 'config');
parent::appurl('index');
parent::appnav(['config__doindex', '基础配置']);
$this->input = $this->input + $_YW;
//城市json
$this->input['url']['city'] = $this->cloud->city_url();
}
//API配置信息保存
public function doconfig()
{
global $_M, $_YW;
$form = $_M['form'];
$form['openid'] = arrayto_string($form['openids'], ',');
self::configsql($form);
$this->destruct = false;
turnover($_M['url']['own_form'] . 'a=do' . $this->tname, '操作成功');
}
//配置信息保存
private function configsql($form = [], $lang = '')
{
global $_M;
if (empty($lang)) $lang = $_M['lang'];
//程序运行必备
$para_a = ['tem_ida', 'tem_idb', 'tem_idc', 'openid'];
$para_b = ['mapkey', 'mapprov', 'mapcity', 'mapdist', 'maplng', 'maplat'];
$para = array_merge($para_a, $para_b);
$arrs = array_intersect_key($form, array_combine($para, $para)); //对比数组
foreach ($arrs as $k => $v) {
$array[] = [$k, $_M['form']['n'], $v, $lang];
}
$this->tsql->table('cloud_config', false)
->qfield('name,m_name,value,lang')
->unique('value=VALUES(value)')
->adup($array);
}
}
?>