本文整理汇总了PHP中tool::multimerge方法的典型用法代码示例。如果您正苦于以下问题:PHP tool::multimerge方法的具体用法?PHP tool::multimerge怎么用?PHP tool::multimerge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tool
的用法示例。
在下文中一共展示了tool::multimerge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: theme_single_config
/**
* 单体配置站点的全局配置
*/
public function theme_single_config()
{
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented');
$key = $this->input->get('key');
if (empty($key)) {
$return_struct['code'] = 400;
$return_struct['msg'] = Kohana::lang('o_global.bad_request');
exit(json_encode($return_struct));
}
//站点信息
$site = Mysite::instance($this->site_id)->get();
if (!$site['id']) {
$return_struct['code'] = 400;
$return_struct['msg'] = Kohana::lang('o_global.access_denied');
exit(json_encode($return_struct));
}
//站点详细信息
$site_detail = Mysite::instance($this->site_id)->detail();
//模板详情
$theme = Mytheme::instance($site['theme_id'])->get();
//模板配置
$theme_configs = empty($theme['config']) ? array() : unserialize($theme['config']);
//站点模板配置
$site_theme_configs = empty($site_detail['theme_config']) ? array() : unserialize($site_detail['theme_config']);
//得到站点模板标签的配置情况,如果站点中无配置则使用全局模板的配置
$configs = empty($site_theme_configs) ? $theme_configs : tool::multimerge($theme_configs, $site_theme_configs);
if (!count($configs)) {
$return_struct['code'] = 400;
$return_struct['msg'] = Kohana::lang('o_global.access_denied');
exit(json_encode($return_struct));
}
//判断请求,处理业务逻辑
if (request::is_ajax()) {
$return_template = $this->template = new View('template_blank');
//KEY对应的配置信息
$data = array();
$data['name'] = '';
$data['val'] = '';
$data['type'] = '';
$data['key'] = '';
if (isset($configs['name'][$key])) {
$data['name'] = $configs['name'][$key];
$data['val'] = htmlentities($configs['val'][$key]);
$data['type'] = $configs['type'][$key];
$data['description'] = $configs['desc'][$key];
$data['key'] = $key;
} else {
$return_struct['code'] = 400;
$return_struct['msg'] = Kohana::lang('o_global.bad_request');
exit(json_encode($return_struct));
}
$this->template->content = new View('site/theme_single_config');
$this->template->content->key = $key;
$this->template->content->data = $data;
$return_str = $return_template->render();
$return_struct['status'] = 1;
$return_struct['code'] = 200;
$return_struct['msg'] = 'Success';
$return_struct['content'] = $return_str;
exit(json_encode($return_struct));
} else {
if ($_POST) {
//资源名称
$name = $this->input->post('config_name');
//图片链接
$url = $this->input->post('img_url');
//图片链接
$alt = $this->input->post('img_alt');
//资源类型
$config_type = $this->input->post('config_type_value');
//资源文件最大大小(default:1M)
$file_max_size = kohana::config('theme.file_max_size');
$file_max_size = $file_max_size > 0 ? $file_max_size : 1048576;
//根据类型来选取相应的内容
switch ($config_type) {
case 2:
if ($val = $_FILES['img_val']['name']) {
$file_type = kohana::config('theme.image_file_type');
$type = count($file_type) > 0 ? $file_type : array('jpg');
//判断文件类型
if (!in_array(strtolower(tool::fileext($_FILES['img_val']['name'])), $type)) {
remind::set(Kohana::lang('o_site.pic_type_incorrect'), '/manage/theme/config_edit/' . $id . '?key=' . $key);
}
$val = $_FILES['img_val']['name'];
$file_size = filesize($_FILES['img_val']['tmp_name']);
if ($file_size > $file_max_size) {
remind::set(Kohana::lang('o_site.pic_size_out_range'), '/manage/theme/config_edit/' . $id . '?key=' . $key);
}
}
break;
default:
$val = $this->input->post('config_val');
break;
}
//如果修改的是图片,则覆盖站点配置原有的图片
if (!empty($val) && $config_type == 2) {
//文件名的存放用 键值+文件名
//.........这里部分代码省略.........