`
haohappy2
  • 浏览: 326536 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

how to create a action and hook

 
阅读更多
/**
  how to write our own action. this action have those functions.
  1. tell the drupal. this action support which trigger
  2. creat a action function
*/
//action_info is the hook's name
//system mean can use everywhere
//configuration mean whether we can get the paramter from another places
function beep_action_info(){
   $info['beep_beep_action']= array(
     'type'=>'system',
     'description'=>'t("Beep"),
     'configurable'=>FALSE,
     'hooks' => array(
'nodeapi' => array('view', 'insert', 'update', 'delete'),
'comment' => array('view', 'insert', 'update', 'delete'),
'user' => array('view', 'insert', 'update', 'delete', 'login'),
'taxonomy' => array('insert', 'update', 'delete'),
    );
   return $info;
}
//this mean this action can use any hooks
function beep_action_info(){
   $info['beep_beep_action']= array(
     'type'=>'system',
     'description'=>'t("Beep"),
     'configurable'=>FALSE,
     'hooks' => array(
'any'=>TRUE
    );
   return $info;
}
// create a form that can store many time
function beep_multiple_beep_action_form($context) {
    $form['beeps'] = array(
'#type' => 'textfield',
'#title' => t('Number of beeps'),
'#description' => t('Enter the number of times to beep when this action executes.'),
'#default_value' => isset($context['beeps']) ? $context['beeps'] : '1',
'#required' => TRUE,
    );
    return $form;
}
function beep_multiple_beep_action_validate($form, $form_state) {
    $beeps = $form_state['values']['beeps'];
    if (!is_numeric($beeps)) {
        form_set_error('beeps', t('Please enter a numeric value.'));
    }
    else if ((int) $beeps > 10) {
form_set_error('beeps', t('That would be too annoying. Please choose fewer than 10 beeps.'));
    }
}
function beep_multiple_beep_action_submit($form, $form_state) {
    return array(
   'beeps' => (int) $form_state['values']['beeps']
    );
}
/**
* Configurable action. Beeps a specified number of times.
*/
function beep_multiple_beep_action($object, $context) {
for ($i = 1; $i < $context['beeps']; $i++) {
beep_beep();
}
}
分享到:
评论

相关推荐

    linux howto中文合集

    HOWTO-html&lt;br&gt;News-HOWTO-html&lt;br&gt;News-Leafsite-html&lt;br&gt;Oracle-HOWTO-html&lt;br&gt;Plug-and-Play-HOWTO-html&lt;br&gt;PPP-HOWTO-html&lt;br&gt;Printing-HOWTO-html&lt;br&gt;QT 3.3 中文白皮书.pdf Quota RCS-...

    Linux Howto 中文文档

    /TD&gt; PCMCIA-HOWTO (39KB) 安装及使用 PCMCIA 卡服务程式 Plug-and-Play-HOWTO (12KB) 帮助你理解和使用 PnP 设备. PPP-HOWTO (53KB) 如何把你的 Linux PC 连接到一台 PPP 伺服器上. RPM-HOWTO (15...

    Softgroup Components.NET Subclass and Hook Objects v2.0.3870

    However, to wrap subclassing and hooking into virtual function overriding it is an obscure technique unknown to a large population of Windows programmers. This is unfortunate, because there are many ...

    Express in Action: Writing, building, and testing Node.js applications

    By the end of the book, you'll be able to use Express to build a Node app and know how to test it, hook it up to a database, and automate the dev process. What's Inside Simplify Node app setup ...

    Mobile Game Development with Unity

    Create a 3D space combat simulator with projectile shooting and respawning objects, and learn how to manage the appearance of 3D models Dive into Unity’s advanced features, such as precomputed ...

    create-react-hook:LICLI可轻松创建可重复使用的React钩子

    npm install -g create-react-hook创建一个新的钩子create-react-hook 回答有关模块的一些基本提示,然后CLI将执行以下步骤: 复制模板通过yarn或npm安装依赖项将软件包链接在一起以进行本地开发初始化本地git回购...

    Hook Api,hook ReadFile,hook WriteFile,hook LoadLibrary

    在IT行业中,Hook API是一种广泛使用的技术,它允许开发者拦截并控制特定函数的调用,以便在函数执行前后插入自定义的行为。这个技术在软件调试、性能监控、系统安全和功能扩展等方面都有重要应用。本篇文章将深入...

    DELPHI编写的HOOK API实现DLL全局钩子启动记事本的程序-DELPHI prepared HOOK API to a

    DELPHI编写的HOOK API实现DLL全局钩子启动记事本的程序-DELPHI prepared HOOK API to achieve the overall hook DLL procedures start Notepad

    Advanced Apple Debugging & Reverse Engineering v0.9.5

    The LLDB command command regex acts much like command alias, except you can provide a regular expression for input which will be parsed and applied to the action part of the command. 10. Assembly ...

    Building Android Apps with HTML,CSS,and.JavaScript(2nd,2012.01)

    You'll learn how to create an Android-friendly web app on the platform of your choice, and then convert it to a native Android app with the free PhoneGap framework. Discover why device-agnostic mobile...

    Building Android Apps with HTML, CSS, and JavaScript

    You’ll learn how to create an Android-friendly web app on the platform of your choice, and then convert it to a native Android app with the free PhoneGap framework. Discover why device-agnostic ...

    Raspberry Pi Gaming(PACKT,2ed,2015)

    This book teaches you how to hook up your Raspberry Pi computer, install different games from a variety of genres, and set up emulators so you can play hundreds of classic arcade and console games....

    EasyHook-2.7.6270.0.zip_c# easy hook_easyhook_easyhook 2.7_eas

    EasyHook是一款强大的、开源的.NET库,用于在托管代码中实现远程函数钩子(Remote Function Hooking)。在标题和描述中提到的"EasyHook-2.7.6270.0.zip"是一个包含EasyHook库版本2.7.6270.0的压缩包,适用于C#开发者...

    Blog-Drawing in [ideal customer] with Strong Headline and Hook

    这个提示旨在帮助您创建一篇... Your task is now to teach me how to craft an engaging story about my product/service that highlights how it has helped a customer achieve their goals. To better understand

    Building iPhone Apps with HTML, CSS, and JavaScript

    Device-agnostic mobile apps are the wave of the future, and this book shows you how to create one product for several platforms. You’ll find guidelines for converting your product into a native ...

    .NET Easy Hook Library and Sample

    .NET Easy Hook Library and Sample 是一个专为.NET开发者设计的库,它简化了在Windows系统中实现钩子(Hook)技术的过程。Hook技术是Windows编程中的一种常见手法,用于拦截和处理系统或应用程序级别的消息和调用,...

    winspy hook源程序

    Replace the WH_CALLWNDPROC hook (its behavior differs on Win9x and WinNt) with WH_GETMESSAGE. 2.. Make some other minor changes, such as replace the appropriate SendMessage with PostMessage, and so...

    HookAPI.rar_Hook Api rmxp_hook a_hook api_好学习Hook_注册表 hook

    "HookAPI.rar_Hook Api rmxp_hook a_hook api_好学习Hook_注册表 hook"这个压缩包似乎包含了一系列关于Hook API的实践教程和示例,特别关注于RMXP(RPG Maker XP)平台,以及注册表相关的Hook应用。 RMXP是一款流行...

Global site tag (gtag.js) - Google Analytics