當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。