• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP hook函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: activate_plugin

/**
 * Activate a named plugin.
 *
 * Parses the plugins directory to look for a pluginname.yaml
 * file and adds the plugin to the plugins database, setting
 * the inst_version field to the version specified in the yaml file.
 *
 * @param string $name Name of plugin to be activated.
 * @return bool Returns true if plugin directory was found.
 * @see deactivate_plugin
 */
function activate_plugin($name)
{
    $plugins_dir = dirname(__FILE__) . '/../plugins/';
    $plugin_dir = $plugins_dir . $name;
    if (file_exists($plugin_dir)) {
        $plugin_yaml = get_plugin_yaml("{$plugin_dir}/{$name}.yaml", false);
        # If no yaml, or yaml file but no description present, attempt to read an 'about.txt' file
        if ($plugin_yaml['desc'] == '') {
            $about = $plugins_dir . $name . '/about.txt';
            if (file_exists($about)) {
                $plugin_yaml['desc'] = substr(file_get_contents($about), 0, 95) . '...';
            }
        }
        # escape the plugin information
        $plugin_yaml_esc = array();
        foreach (array_keys($plugin_yaml) as $thekey) {
            $plugin_yaml_esc[$thekey] = escape_check($plugin_yaml[$thekey]);
        }
        # Add/Update plugin information.
        # Check if the plugin is already in the table.
        $c = sql_value("SELECT name as value FROM plugins WHERE name='{$name}'", '');
        if ($c == '') {
            sql_query("INSERT INTO plugins(name) VALUE ('{$name}')");
        }
        sql_query("UPDATE plugins SET config_url='{$plugin_yaml_esc['config_url']}', " . "descrip='{$plugin_yaml_esc['desc']}', author='{$plugin_yaml_esc['author']}', " . "inst_version='{$plugin_yaml_esc['version']}', " . "priority='{$plugin_yaml_esc['default_priority']}', " . "update_url='{$plugin_yaml_esc['update_url']}', info_url='{$plugin_yaml_esc['info_url']}' " . "WHERE name='{$plugin_yaml_esc['name']}'");
        hook("after_activate_plugin", "", array($name));
        return true;
    } else {
        return false;
    }
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:42,代码来源:plugin_functions.php


示例2: update

 /**
  * 新增或更新一个文档
  * @param array  $data 手动传入的数据
  * @return boolean fasle 失败 , int  成功 返回完整的数据
  * @author huajie <[email protected]>
  */
 public function update($data = null)
 {
     /* 获取数据对象 */
     $data = $this->token(false)->create($data);
     if (empty($data)) {
         return false;
     }
     /* 添加或新增基础内容 */
     if (empty($data['id'])) {
         //新增数据
         $id = $this->add($_POST);
         //添加基础内容
         if (!$id) {
             $this->error = '新增基础内容出错!';
             return false;
         }
     } else {
         //更新数据
         $status = $this->save();
         //更新基础内容
         if (false === $status) {
             $this->error = '更新基础内容出错!';
             return false;
         }
     }
     hook('documentSaveComplete', array('model_id' => $data['model_id']));
     //行为记录
     if ($id) {
         action_log('add_document', 'document', $id, UID);
     }
     //内容添加或更新完成
     return $data;
 }
开发者ID:LuckyHJH,项目名称:charlie_brown,代码行数:39,代码来源:RecordModel.class.php


示例3: displayHtmlContent

 public function displayHtmlContent($content)
 {
     $content = parse_popup($content);
     $content = parse_at_users($content);
     hook('parseContent', array('content' => &$content));
     return $content;
 }
开发者ID:sunjie20081001,项目名称:sns,代码行数:7,代码来源:ContentHandlerModel.class.php


示例4: init

 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (access('Dev.*') && cogear()->config->development) {
         hook('done', array($this, 'finish'));
     }
 }
开发者ID:brussens,项目名称:cogear2,代码行数:10,代码来源:Gear.php


示例5: __construct

 /**
  * 构造方法,添加消息提醒的钩子
  */
 function __construct()
 {
     $this->message = new Message();
     $hook = hook();
     $hook->add('FollowManagement_follow', [$this, 'mail_follow_me']);
     $hook->add('FollowManagement_follow', [$this, 'message_follow_me']);
     $hook->add('FollowManagement_follow_gallery', [$this, 'mail_follow_gallery']);
     $hook->add('FollowManagement_follow_gallery', [$this, 'message_follow_gallery']);
     $hook->add('PictureComment_comment', [$this, 'mail_comment_picture']);
     $hook->add('PictureComment_comment', [$this, 'message_comment_picture']);
     $hook->add('GalleryComment_comment', [$this, 'mail_comment_gallery']);
     $hook->add('GalleryComment_comment', [$this, 'message_comment_gallery']);
     $hook->add('Comment_reply', [$this, 'mail_comment_reply']);
     $hook->add('Comment_reply', [$this, 'message_comment_reply']);
     $hook->add('Picture_like', [$this, 'mail_like_pic']);
     $hook->add('Picture_like', [$this, 'message_like_pic']);
     $hook->add('Gallery_like', [$this, 'mail_like_gallery']);
     $hook->add('Gallery_like', [$this, 'message_like_gallery']);
     $hook->add('CommentManagement_like', [$this, 'mail_like_comment']);
     $hook->add('CommentManagement_like', [$this, 'message_like_comment']);
     $hook->add('Message_send_success', [$this, 'mail_send_message']);
     $hook->add('Message_send_success', [$this, 'mail_send_system_message']);
     $hook->add('UserLogin_PostLogin_Success', [$this, 'mail_exception_login']);
     $hook->add('UserLogin_PostLogin_Success', [$this, 'message_exception_login']);
     $hook->add('UserLogin_PostLogin_restrictions', [$this, 'mail_login_restrictions']);
     $hook->add('UserLogin_PostLogin_restrictions', [$this, 'message_login_restrictions']);
 }
开发者ID:ttym7993,项目名称:Linger,代码行数:30,代码来源:NoticeApply.php


示例6: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->clear();
     Template::bindGlobal('scripts', $this->scripts);
     Template::bindGlobal('styles', $this->styles);
     hook('head', array($this, 'output'));
 }
开发者ID:romartyn,项目名称:cogear,代码行数:10,代码来源:Harvester.php


示例7: send_research_request

 function send_research_request()
 {
     # Insert a search request into the requests table.
     # Resolve resource types
     $rt = "";
     $types = get_resource_types();
     for ($n = 0; $n < count($types); $n++) {
         if (getval("resource" . $types[$n]["ref"], "") != "") {
             if ($rt != "") {
                 $rt .= ", ";
             }
             $rt .= $types[$n]["ref"];
         }
     }
     global $userref;
     $as_user = getvalescaped("as_user", $userref, true);
     # If userref submitted, use that, else use this user
     # Insert the request
     sql_query("insert into research_request(created,user,name,description,deadline,contact,email,finaluse,resource_types,noresources,shape)\n\tvalues (now(),'{$as_user}','" . getvalescaped("name", "") . "','" . getvalescaped("description", "") . "'," . (getvalescaped("deadline", "") == "" ? "null" : "'" . getvalescaped("deadline", "") . "'") . ",'" . getvalescaped("contact", "") . "','" . getvalescaped("email", "") . "','" . getvalescaped("finaluse", "") . "','" . $rt . "'," . (getvalescaped("noresources", "") == "" ? "null" : "'" . getvalescaped("noresources", "") . "'") . ",'" . getvalescaped("shape", "") . "')");
     # E-mails a resource request (posted) to the team
     global $applicationname, $email_from, $baseurl, $email_notify, $username, $userfullname, $useremail, $lang;
     $templatevars['ref'] = sql_insert_id();
     $templatevars['teamresearchurl'] = $baseurl . "/pages/team/team_research.php";
     $templatevars['username'] = $username;
     $templatevars['userfullname'] = $userfullname;
     $templatevars['useremail'] = getvalescaped("email", $useremail);
     # Use provided e-mail (for anonymous access) or drop back to user email.
     $templatevars['url'] = $baseurl . "/pages/team/team_research_edit.php?ref=" . $templatevars['ref'];
     $message = "'{$username}' ({$userfullname} - {$useremail}) " . $lang["haspostedresearchrequest"] . ".\n\n";
     $message .= $templatevars['teamresearchurl'];
     hook("modifyresearchrequestemail");
     send_mail($email_notify, $applicationname . ": " . $lang["newresearchrequestwaiting"], $message, $useremail, "", "emailnewresearchrequestwaiting", $templatevars);
 }
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:33,代码来源:research_functions.php


示例8: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     foreach ($files as $key => $file) {
         $ext = strtolower($file['ext']);
         if (in_array($ext, array('jpg', 'jpeg', 'bmp', 'png'))) {
             hook('dealPicture', $file['tmp_name']);
         }
     }
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             /* 记录文件信息 */
             if (strtolower($driver) == 'sae') {
                 $value['path'] = $config['rootPath'] . 'Picture/' . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
             } else {
                 if (strtolower($driver) == 'qiniu') {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 } elseif (strtolower($driver) != 'local') {
                     $value['path'] = $value['url'];
                 } else {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                     //在模板里的url路径
                 }
             }
             $value['type'] = strtolower($driver);
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         foreach ($info as &$t_info) {
             if ($t_info['type'] == 'local') {
                 $t_info['path'] = fixAttachUrl($t_info['path']);
             } else {
                 $t_info['path'] = $t_info['path'];
             }
         }
         /*  dump(getRootUrl());
             dump($info);
             exit;*/
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:chenyongze,项目名称:bighaha,代码行数:67,代码来源:PictureModel.class.php


示例9: save_themename

function save_themename()
{
    global $baseurl, $link, $themename, $collection_column;
    $sql = "update collection set\t" . $collection_column . "='" . getvalescaped("rename", "") . "' where " . $collection_column . "='" . escape_check($themename) . "'";
    sql_query($sql);
    hook("after_save_themename");
    redirect("pages/" . $link);
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:8,代码来源:theme_edit.php


示例10: catch_selected_project

function catch_selected_project()
{
    if (projectSelected() == true) {
        hook("site_begin", "projectDisplayers");
    } else {
        hook("site_begin", "dirtiness");
    }
}
开发者ID:Codechanic,项目名称:The-Secretary,代码行数:8,代码来源:view.php


示例11: init

 /**
  * Init
  */
 public function init()
 {
     parent::init();
     hook('form.page-createdit.init', array($this, 'extendPageForm'));
     hook('Pages.showPage.after', array($this, 'attachCommentsToPage'));
     hook('stack.Page.info', array($this, 'extendPageInfo'));
     allow_role(array('comments post'), 100);
 }
开发者ID:romartyn,项目名称:cogear,代码行数:11,代码来源:Gear.php


示例12: themeSettings

function themeSettings()
{
    global $manager;
    if (countHooks("design-settings") == 0) {
        hook("big_message", "noDesignSettings");
        return;
    }
}
开发者ID:Codechanic,项目名称:The-Secretary,代码行数:8,代码来源:design_settings.php


示例13: render

 /**
  * Отбражение региона
  *
  * @return string
  */
 public function render()
 {
     // Делаем всё через хуки, чтобы другие тоже могли выводить
     hook($this->options->name, array($this, 'output'));
     ob_start();
     event($this->options->name);
     return ob_get_clean();
 }
开发者ID:brussens,项目名称:cogear2,代码行数:13,代码来源:Region.php


示例14: __construct

 /**
  * Конструктор
  *
  * @param string $path
  * @param string $section
  */
 public function __construct($path = '', $section = '')
 {
     if ($path) {
         $this->file = $path;
         $this->load($path, $section);
         hook('exit', array($this, 'store'));
     }
 }
开发者ID:brussens,项目名称:cogear2,代码行数:14,代码来源:Config.php


示例15: setConfig

 private function setConfig()
 {
     $cfg = hook()->apply("Mail_setConfig", cfg()->get('mail'));
     foreach ($cfg as $name => $value) {
         if (isset($this->{$name})) {
             $this->{$name} = $value;
         }
     }
 }
开发者ID:dalinhuang,项目名称:StudentManage,代码行数:9,代码来源:mail.php


示例16: check

 /**
  * Check cron
  */
 public function check()
 {
     if (time() - $this->get('cron.last_run') > self::STEP) {
         // Set cron execute time
         $this->set('cron.last_run', time());
         // It's highly important to run cron after server response will be sent to user
         hook('after', array($this, 'poorMansCron'));
     }
 }
开发者ID:romartyn,项目名称:cogear,代码行数:12,代码来源:Gear.php


示例17: get_extension

function get_extension($resource, $size)
{
    $pextension = $size == 'original' ? $resource["file_extension"] : 'jpg';
    $replace_extension = hook('replacedownloadextension', '', array($resource, $pextension));
    if (!empty($replace_extension)) {
        return $replace_extension;
    }
    return $pextension;
}
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:9,代码来源:collection_download.php


示例18: init

 /**
  * Init
  */
 public function init()
 {
     parent::init();
     Template::bindGlobal('meta', $this->info);
     title(t(config('site.name', SITE_URL)));
     hook('head', array($this, 'head'), 0);
     hook('menu.setActive', array($this, 'menuTitleHook'));
     hook('Pages.showPage.before', array($this, 'showObjectTitle'));
     hook('admin.gear.request', array($this, 'showObjectTitle'));
 }
开发者ID:romartyn,项目名称:cogear,代码行数:13,代码来源:Gear.php


示例19: index

 public function index()
 {
     hook('homeIndex');
     $default_url = C('DEFUALT_HOME_URL');
     //获得配置,如果为空则显示聚合,否则跳转
     if ($default_url != '') {
         redirect(get_nav_url($default_url));
     }
     $this->display();
 }
开发者ID:fishling,项目名称:chatPro,代码行数:10,代码来源:IndexController.class.php


示例20: getUA

 /**
  * 获取浏览器UA
  * @return string
  */
 public function getUA()
 {
     static $ua = NULL;
     if ($ua !== NULL) {
         return $ua;
     }
     $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     $ua = hook()->apply("Input_getUA", $ua);
     return $ua;
 }
开发者ID:dalinhuang,项目名称:StudentManage,代码行数:14,代码来源:input.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP hook_filter函数代码示例发布时间:2022-05-15
下一篇:
PHP home_url函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap