<?php
/*
 +----------------------------------------------------------------------
 | TEMMOKUMVC [ NO BEST , ONLY BETTER ]
 +----------------------------------------------------------------------
 | Copyright (c) 2018~2019 https://www.temmoku.cn All rights reserved.
 +----------------------------------------------------------------------
 | Author: 张宗强 Email:webmaster@temmoku.cn QQ:158726877 516669373 TEL:17895221001 微信:temmokumvc
 +---------------------------------------------------------------------- 
*/
namespace plugin\wechat\public_class;
use temmoku\db;
use \plugin\wechat\init;
class cache{
	public static function run($data=''){
		self::setting_cache();
		self::import_hook_sql();
	}
	public static function setting_cache(){
		
		$data=db::select('*')->from(init::$table."set")->query();
		$list=[];
		foreach($data AS $key=>$row){
			$list[$row['u_key']]=$row['u_value'];
		}
	
		$array=['wechat'=>$list];
		createconf($array,'setting',init::$dir,true);
	}
	private static function import_hook_sql(){
		$array=[
			'wechat_reg'=>'微信插件注册成功后',
			'wechat_login'=>"微信插件成功登陆后",
			'wechat_bind_begin'=>'微信插件绑定会员前(自行判断是否已经绑定)',
			'wechat_bind_end'=>"微信插件绑定会员后(自行判断是否已经绑定)",
			'wechat_is_attention_reg'=>'微信插件关注后注册并成功后',
			'wechat_subscribe_begin'=>'微信插件关注公众号之前',
			'wechat_subscribe_end'=>'微信插件关注公众号之后',
			'wechat_unsubscribe'=>'微信插件取消关注公众号时',
			'wechat_scan'=>'微信插件扫描带参数二维码时',
			'wechat_event_location'=>'微信插件上报位置时',
			'wechat_click'=>'微信插件自定义菜单事件时',
			'wechat_view'=>'微信插件点击菜单跳转链接时',
			'wechat_text_begin'=>'微信插件接收文本消息之前',
			'wechat_text_end'=>'微信插件接收文本消息之后',
			'wechat_image'=>'微信插件接收图片消息时',
			'wechat_voice_begin'=>'微信插件接收语音信息前',
			'wechat_voice_end'=>'微信插件接收语音信息后',
			'wechat_video'=>'微信插件接收视频消息时',
			'wechat_shortvideo'=>'微信插件接收小视频消息时',
			'wechat_location'=>'微信插件接收位置信息时',
			'wechat_link'=>'微信插件接收链接消息时',
			'wechat_file'=>'微信插件接收文件消息时',
		];
		foreach($array AS $name=>$content){
			$row=db::select('id')->from(jab."hook")->where("name like '$name'")->row();
			if(!$row){
				db::insert(jab."hook")->cols(['name'=>$name,'content'=>$content,'state'=>1])->query();
			}
		}
	}
}
?>