You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2006-2013 http://thinkphp.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
// +----------------------------------------------------------------------
|
|
// | Author: liu21st <liu21st@gmail.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace Common\Behavior;
|
|
use Think\Behavior;
|
|
use Think\Hook;
|
|
defined('THINK_PATH') or exit();
|
|
|
|
// 初始化钩子信息
|
|
class InitHookBehavior extends Behavior {
|
|
|
|
// 行为扩展的执行入口必须是run
|
|
public function run(&$content){
|
|
if(defined('BIND_MODULE') && BIND_MODULE === 'Install') return;
|
|
|
|
$data = S('hooks');
|
|
if(!$data){
|
|
$hooks = M('Hooks')->getField('name,addons');
|
|
foreach ($hooks as $key => $value) {
|
|
if($value){
|
|
$map['status'] = 1;
|
|
$names = explode(',',$value);
|
|
$map['name'] = array('IN',$names);
|
|
$data = M('Addons')->where($map)->getField('id,name');
|
|
if($data){
|
|
$addons = array_intersect($names, $data);
|
|
Hook::add($key,array_map('get_addon_class',$addons));
|
|
}
|
|
}
|
|
}
|
|
S('hooks',Hook::get());
|
|
}else{
|
|
Hook::import($data,false);
|
|
}
|
|
}
|
|
} |