当前位置: 首页>>代码示例>>PHP>>正文


PHP think\Hook类代码示例

本文整理汇总了PHP中think\Hook的典型用法代码示例。如果您正苦于以下问题:PHP Hook类的具体用法?PHP Hook怎么用?PHP Hook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Hook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run(&$content)
 {
     if (isset($_GET['m']) && $_GET['m'] === '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);
     }
 }
开发者ID:Willshon,项目名称:OLCS,代码行数:25,代码来源:InitHookBehavior.class.php

示例2: 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 = (array) M('addons')->where($map)->getField('id,name');
                 $data_plugin = (array) M('plugin')->where($map)->getField('id,name');
                 $data = array_merge($data, $data_plugin);
                 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);
     }
 }
开发者ID:yxz1025,项目名称:weiphp3.0,代码行数:27,代码来源:InitHookBehavior.class.php

示例3: detail

 /**
  * 查询指定分类的详细信息
  * @param int $info detail 查询的 id 或者slug
  */
 public function detail($info = 1)
 {
     if (get_opinion("auto_channel", false, false)) {
         $this->channel($info);
         Hook::listen('app_end');
         die;
     }
     $CatsLogic = new CatsLogic();
     $PostsLogic = new PostsLogic();
     $cat = $CatsLogic->detail($info);
     //
     $this->assign('cat_id', $cat['cat_id']);
     // 赋值数据集
     $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了");
     //优雅的404
     $posts_id = $CatsLogic->getPostsId($cat['cat_id']);
     $count = sizeof($posts_id);
     $count == 0 ? $res404 = 0 : ($res404 = 1);
     if (!empty($posts_id)) {
         $Page = new GreenPage($count, get_opinion('PAGER'));
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $posts_list = $PostsLogic->getList($limit, 'single', 'post_date desc', true, array(), $posts_id);
     }
     $this->assign('title', '分类 ' . $cat['cat_name'] . ' 所有文章');
     // 赋值数据集
     $this->assign('res404', $res404);
     $this->assign('postslist', $posts_list);
     // 赋值数据集
     $this->assign('pager', $pager_bar);
     // 赋值分页输出
     $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id']));
     $this->display('Archive/single-list');
 }
开发者ID:nomagame,项目名称:Charmy,代码行数:38,代码来源:CatController.class.php

示例4: _initialize

 /**
  * 初始化方法
  * @author jry <598821125@qq.com>
  */
 protected function _initialize()
 {
     // 系统开关
     if (!C('TOGGLE_WEB_SITE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
     // 获取所有模块配置的用户导航
     $mod_con['status'] = 1;
     $_user_nav_main = array();
     $_user_nav_list = D('Admin/Module')->where($mod_con)->getField('user_nav', true);
     foreach ($_user_nav_list as $key => $val) {
         if ($val) {
             $val = json_decode($val, true);
             $_user_nav_main = array_merge($_user_nav_main, $val['main']);
         }
     }
     // 监听行为扩展
     \Think\Hook::listen('corethink_behavior');
     $this->assign('meta_keywords', C('WEB_SITE_KEYWORD'));
     $this->assign('meta_description', C('WEB_SITE_DESCRIPTION'));
     $this->assign('_new_message', cookie('_new_message'));
     // 获取用户未读消息数量
     $this->assign('_user_auth', session('user_auth'));
     // 用户登录信息
     $this->assign('_user_nav_main', $_user_nav_main);
     // 用户导航信息
 }
开发者ID:hujun123qwe,项目名称:plover,代码行数:31,代码来源:HomeController.class.php

示例5: run

 public function run(&$content)
 {
     if (!file_exist(UPLOAD_PATH . 'install.lock')) {
         return true;
     }
     $data = S('common_behavior_hooks');
     if (!$data) {
         $hooks = M('hooks')->where(array('status' => 1))->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('common_behavior_hooks', Hook::get());
     } else {
         Hook::import($data, false);
     }
 }
开发者ID:easytp,项目名称:easytp,代码行数:25,代码来源:InitHookBehavior.class.php

示例6: run

 /**
  * 行为扩展的执行入口必须是run
  * @author jry <598821125@qq.com>
  */
 public function run(&$content)
 {
     // 安装模式下直接返回
     if (defined('BIND_MODULE') && BIND_MODULE === 'Install') {
         return;
     }
     // 添加插件配置
     $addon_config['ADDON_PATH'] = './Addons/';
     $addon_config['AUTOLOAD_NAMESPACE'] = C('AUTOLOAD_NAMESPACE');
     $addon_config['AUTOLOAD_NAMESPACE']['Addons'] = $addon_config['ADDON_PATH'];
     C($addon_config);
     $data = S('hooks');
     if (!$data || APP_DEBUG === true) {
         $hooks = D('Admin/Hook')->getField('name,addons');
         foreach ($hooks as $key => $value) {
             if ($value) {
                 $map['status'] = 1;
                 $names = explode(',', $value);
                 $map['name'] = array('IN', $names);
                 $data = D('Admin/Addon')->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);
     }
 }
开发者ID:applemin,项目名称:tangguo,代码行数:35,代码来源:InitHookBehavior.class.php

示例7: run

 public function run(&$params)
 {
     if (!defined('BUILD_LITE_FILE')) {
         return;
     }
     $litefile = C('RUNTIME_LITE_FILE', null, RUNTIME_PATH . 'lite.php');
     if (is_file($litefile)) {
         return;
     }
     $defs = get_defined_constants(true);
     $content = 'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);';
     if (MEMORY_LIMIT_ON) {
         $content .= '$GLOBALS[\'_startUseMems\'] = memory_get_usage();';
     }
     // 生成数组定义
     unset($defs['user']['BUILD_LITE_FILE']);
     $content .= $this->buildArrayDefine($defs['user']) . '}';
     // 读取编译列表文件
     $filelist = is_file(CONF_PATH . 'lite.php') ? include CONF_PATH . 'lite.php' : array(THINK_PATH . 'Common/functions.php', COMMON_PATH . 'Common/function.php', CORE_PATH . 'Think' . EXT, CORE_PATH . 'Hook' . EXT, CORE_PATH . 'App' . EXT, CORE_PATH . 'Dispatcher' . EXT, CORE_PATH . 'Log' . EXT, CORE_PATH . 'Log/Driver/File' . EXT, CORE_PATH . 'Route' . EXT, CORE_PATH . 'Controller' . EXT, CORE_PATH . 'View' . EXT, CORE_PATH . 'Storage' . EXT, CORE_PATH . 'Storage/Driver/File' . EXT, CORE_PATH . 'Exception' . EXT, BEHAVIOR_PATH . 'ParseTemplateBehavior' . EXT, BEHAVIOR_PATH . 'ContentReplaceBehavior' . EXT);
     // 编译文件
     foreach ($filelist as $file) {
         if (is_file($file)) {
             $content .= compile($file);
         }
     }
     // 处理Think类的start方法
     $content = preg_replace('/\\$runtimefile = RUNTIME_PATH(.+?)(if\\(APP_STATUS)/', '\\2', $content, 1);
     $content .= "\nnamespace { Think\\Think::addMap(" . var_export(\Think\Think::getMap(), true) . ");";
     $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(\Think\Hook::get(), true) . ');Think\\Think::start();}';
     // 生成运行Lite文件
     file_put_contents($litefile, strip_whitespace('<?php ' . $content));
 }
开发者ID:beyondzgz,项目名称:thinkphp,代码行数:32,代码来源:BuildLiteBehavior.class.php

示例8: send

 /**
  * 发送数据到客户端
  * @access public
  * @param mixed $data 数据
  * @param string $type 返回类型
  * @param bool $return 是否返回数据
  * @return mixed
  */
 public function send($data = [], $type = '', $return = false)
 {
     if ('' == $type) {
         $type = $this->type ?: (IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type'));
     }
     $type = strtolower($type);
     $data = $data ?: $this->data;
     if (!headers_sent() && isset($this->contentType[$type])) {
         header('Content-Type:' . $this->contentType[$type] . '; charset=utf-8');
     }
     if (is_callable($this->transform)) {
         $data = call_user_func_array($this->transform, [$data]);
     } else {
         switch ($type) {
             case 'json':
                 // 返回JSON数据格式到客户端 包含状态信息
                 $data = json_encode($data, JSON_UNESCAPED_UNICODE);
                 break;
             case 'jsonp':
                 // 返回JSON数据格式到客户端 包含状态信息
                 $handler = !empty($_GET[Config::get('var_jsonp_handler')]) ? $_GET[Config::get('var_jsonp_handler')] : Config::get('default_jsonp_handler');
                 $data = $handler . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');';
                 break;
         }
     }
     APP_HOOK && Hook::listen('return_data', $data);
     if ($return) {
         return $data;
     }
     echo $data;
     $this->isExit() && exit;
 }
开发者ID:xuyi5918,项目名称:ipensoft,代码行数:40,代码来源:Response.php

示例9: _initialize

 /**
  * 初始化方法
  * @author jry <598821125@qq.com>
  */
 protected function _initialize()
 {
     // 系统开关
     if (!C('TOGGLE_WEB_SITE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
     // 获取所有模块配置的用户导航
     $mod_con['status'] = 1;
     $_user_nav_main = array();
     $_user_nav_list = D('Admin/Module')->where($mod_con)->getField('user_nav', true);
     foreach ($_user_nav_list as $key => $val) {
         if ($val) {
             $val = json_decode($val, true);
             if ($val['main']) {
                 $_user_nav_main = array_merge($_user_nav_main, $val['main']);
             }
         }
     }
     // 监听行为扩展
     \Think\Hook::listen('corethink_behavior');
     $this->assign('meta_keywords', C('WEB_SITE_KEYWORD'));
     $this->assign('meta_description', C('WEB_SITE_DESCRIPTION'));
     $this->assign('_new_message', cookie('_new_message'));
     // 获取用户未读消息数量
     $this->assign('_user_auth', session('user_auth'));
     // 用户登录信息
     $this->assign('_user_nav_main', $_user_nav_main);
     // 用户导航信息
     $this->assign('_user_center_side', C('USER_CENTER_SIDE'));
     // 用户中心侧边
     $this->assign('_user_login_modal', C('USER_LOGIN_MODAL'));
     // 用户登录弹窗
     $this->assign('_home_public_layout', C('HOME_PUBLIC_LAYOUT'));
     // 页面公共继承模版
 }
开发者ID:lipeng-github,项目名称:corethink,代码行数:39,代码来源:HomeController.class.php

示例10: run

 /**
  * @param mixed $content
  */
 public function run(&$content)
 {
     /**
      *  //真不知道说什么好。。。
      *      这里      原因是tp 不能把tag放在项目配置中,只能放在common中,而common模块先于install 初始化
      *     so。。。。。
      *
      */
     if (C('DB_TYPE') == 'GreenCMS_DB_TYPE') {
     } else {
         if (isset($_GET['m']) && strtolower($_GET['m']) == '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, $addons);
                     }
                 }
             }
             S('hooks', Hook::get());
         } else {
             Hook::import($data, false);
         }
     }
 }
开发者ID:zachdary,项目名称:GreenCMS,代码行数:37,代码来源:InitHookBehavior.class.php

示例11: run

 public function run(&$parms)
 {
     //安装时不执行
     if (defined('BIND_MODULE') && BIND_MODULE === 'Install') {
         return;
     }
     $data = S('global_hooks');
     if (!$data) {
         $hooks = M('Hooks', "common_")->getField('name,addons');
         foreach ($hooks as $key => $value) {
             if ($value) {
                 $map['status'] = 1;
                 $names = explode(',', $value);
                 $map['name'] = array('IN', $names);
                 $data = M('Addons', "common_")->where($map)->getField('id,name');
                 if ($data) {
                     $addons = array_intersect($names, $data);
                     Hook::add($key, array_map('get_addon_class', $addons));
                 }
             }
         }
         S('global_hooks', Hook::get());
     } else {
         Hook::import($data, false);
     }
 }
开发者ID:h136799711,项目名称:baseItboye,代码行数:26,代码来源:InitHookBehavior.class.php

示例12: GetUsers

 public function GetUsers($UsersId, $Feild)
 {
     $where['userid'] = array('IN', $UsersId);
     $result = self::where($where)->field($Feild)->select();
     if ($result !== false) {
         return $result;
     } else {
         \Think\Hook::listen('HomeLog', $parm = array('function' => 'GetUsers -> $result', 'logmsg' => 'result is false', 'level' => 'ALERT'));
     }
 }
开发者ID:Anymagic,项目名称:Car-Sticker,代码行数:10,代码来源:AnymagicUserModel.class.php

示例13: SmsReady

 public function SmsReady($mobile, $content)
 {
     $mobileids = $mobile . date('YmdHis');
     $result = self::sendSMS($mobile, $content, $mobileids);
     if ($result != true) {
         \Think\Hook::listen('HomeLog', $parm = array('function' => 'SendSmsModel::SmsReady -> $result', 'logmsg' => 'result is false, ' . "{$result}", 'level' => 'ALERT'));
         return false;
     }
     return true;
 }
开发者ID:Anymagic,项目名称:Car-Sticker,代码行数:10,代码来源:SendSmsModel.class.php

示例14: error404

 /**
  * 显示404页
  * @function 404 ERROR 需要显示错误的信息
  *
  * @param string $message
  */
 public function error404($message = "非常抱歉,你需要的页面暂时不存在,可能它已经躲起来了。.")
 {
     $this->assign("message", $message);
     if (File::file_exists(T('Home@Index/404'))) {
         $this->display('Index/404');
     } else {
         $this->show($message);
     }
     Hook::listen('app_end');
     die;
 }
开发者ID:jackycgq,项目名称:GreenCMS,代码行数:17,代码来源:HomeBaseController.class.php

示例15: BlackNew

 public function BlackNew($RecordId, $UserId)
 {
     $data = array('recordid' => $RecordId, 'userid' => $UserId, 'lasttime' => time());
     $result = self::add($data);
     if ($result !== false) {
         return true;
     } else {
         return false;
         \Think\Hook::listen('HomeLog', $parm = array('function' => 'BlackNew -> $result', 'logmsg' => 'result is false', 'level' => 'ALERT'));
     }
 }
开发者ID:Anymagic,项目名称:Car-Sticker,代码行数:11,代码来源:StickerBlacklistModel.class.php


注:本文中的think\Hook类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。