aboutsummaryrefslogtreecommitdiff
path: root/modules/vim/vim.dot.link/snippets/php.snippets
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-02-01 01:25:10 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-02-01 01:25:10 -0200
commit6b9187673ee62d11042832f938913f15131592a7 (patch)
tree9e70016667efe273a72ab351aafaddbdb099e123 /modules/vim/vim.dot.link/snippets/php.snippets
parent25235935e6c90557a4d6791c8d8f3a5cdf89681a (diff)
downloaddotfiles-6b9187673ee62d11042832f938913f15131592a7.tar.gz
dotfiles-6b9187673ee62d11042832f938913f15131592a7.tar.bz2
Adding metadot script
Diffstat (limited to 'modules/vim/vim.dot.link/snippets/php.snippets')
-rw-r--r--modules/vim/vim.dot.link/snippets/php.snippets9397
1 files changed, 9397 insertions, 0 deletions
diff --git a/modules/vim/vim.dot.link/snippets/php.snippets b/modules/vim/vim.dot.link/snippets/php.snippets
new file mode 100644
index 0000000..b122b5f
--- /dev/null
+++ b/modules/vim/vim.dot.link/snippets/php.snippets
@@ -0,0 +1,9397 @@
+snippet php
+ <?php
+ ${1}
+ ?>
+snippet ec
+ echo "${1:string}"${2};
+snippet inc
+ include '${1:file}';${2}
+snippet inc1
+ include_once '${1:file}';${2}
+snippet req
+ require '${1:file}';${2}
+snippet req1
+ require_once '${1:file}';${2}
+# $GLOBALS['...']
+snippet globals
+ $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}
+snippet $_ COOKIE['...']
+ $_COOKIE['${1:variable}']${2}
+snippet $_ ENV['...']
+ $_ENV['${1:variable}']${2}
+snippet $_ FILES['...']
+ $_FILES['${1:variable}']${2}
+snippet $_ Get['...']
+ $_GET['${1:variable}']${2}
+snippet $_ POST['...']
+ $_POST['${1:variable}']${2}
+snippet $_ REQUEST['...']
+ $_REQUEST['${1:variable}']${2}
+snippet $_ SERVER['...']
+ $_SERVER['${1:variable}']${2}
+snippet $_ SESSION['...']
+ $_SESSION['${1:variable}']${2}
+# Start Docblock
+snippet /*
+ /**
+ * ${1}
+ **/
+# Class - post doc
+snippet doc_cp
+ /**
+ * ${1:undocumented class}
+ *
+ * @package ${2:default}
+ * @author ${3:`g:snips_author`}
+ **/${4}
+# Class Variable - post doc
+snippet doc_vp
+ /**
+ * ${1:undocumented class variable}
+ *
+ * @var ${2:string}
+ **/${3}
+# Class Variable
+snippet doc_v
+ /**
+ * ${3:undocumented class variable}
+ *
+ * @var ${4:string}
+ **/
+ ${1:var} $${2};${5}
+# Class
+snippet doc_c
+ /**
+ * ${3:undocumented class}
+ *
+ * @packaged ${4:default}
+ * @author ${5:`g:snips_author`}
+ **/
+ ${1:}class ${2:}
+ {${6}
+ } // END $1class $2
+# Constant Definition - post doc
+snippet doc_dp
+ /**
+ * ${1:undocumented constant}
+ **/${2}
+# Constant Definition
+snippet doc_d
+ /**
+ * ${3:undocumented constant}
+ **/
+ define(${1}, ${2});${4}
+# Function - post doc
+snippet doc_fp
+ /**
+ * ${1:undocumented function}
+ *
+ * @return ${2:void}
+ * @author ${3:`g:snips_author`}
+ **/${4}
+# Function signature
+snippet doc_s
+ /**
+ * ${4:undocumented function}
+ *
+ * @return ${5:void}
+ * @author ${6:`g:snips_author`}
+ **/
+ ${1}function ${2}(${3});${7}
+# Function
+snippet doc_f
+ /**
+ * ${4:undocumented function}
+ *
+ * @return ${5:void}
+ * @author ${6:`g:snips_author`}
+ **/
+ ${1}function ${2}(${3})
+ {${7}
+ }
+# Header
+snippet doc_h
+ /**
+ * ${1}
+ *
+ * @author ${2:`g:snips_author`}
+ * @version ${3:$Id$}
+ * @copyright ${4:$2}, `strftime('%d %B, %Y')`
+ * @package ${5:default}
+ **/
+
+ /**
+ * Define DocBlock
+ *//
+# Interface
+snippet doc_i
+ /**
+ * ${2:undocumented class}
+ *
+ * @package ${3:default}
+ * @author ${4:`g:snips_author`}
+ **/
+ interface ${1:}
+ {${5}
+ } // END interface $1
+# class ...
+snippet class
+ /**
+ * ${1}
+ **/
+ class ${2:ClassName}
+ {
+ ${3}
+ function ${4:__construct}(${5:argument})
+ {
+ ${6:// code...}
+ }
+ }
+# define(...)
+snippet def
+ define('${1}'${2});${3}
+# defined(...)
+snippet def?
+ ${1}defined('${2}')${3}
+snippet wh
+ while (${1:/* condition */}) {
+ ${2:// code...}
+ }
+# do ... while
+snippet do
+ do {
+ ${2:// code... }
+ } while (${1:/* condition */});
+snippet if
+ if (${1:/* condition */}) {
+ ${2:// code...}
+ }
+snippet ife
+ if (${1:/* condition */}) {
+ ${2:// code...}
+ } else {
+ ${3:// code...}
+ }
+ ${4}
+snippet else
+ else {
+ ${1:// code...}
+ }
+snippet elseif
+ elseif (${1:/* condition */}) {
+ ${2:// code...}
+ }
+# Tertiary conditional
+snippet t
+ $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
+snippet switch
+ switch ($${1:variable}) {
+ case '${2:value}':
+ ${3:// code...}
+ break;
+ ${5}
+ default:
+ ${4:// code...}
+ break;
+ }
+snippet case
+ case '${1:value}':
+ ${2:// code...}
+ break;${3}
+snippet for
+ for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
+ ${4: // code...}
+ }
+snippet foreach
+ foreach ($${1:variable} as $${2:key}) {
+ ${3:// code...}
+ }
+snippet fun
+ ${1:public }function ${2:FunctionName}(${3})
+ {
+ ${4:// code...}
+ }
+# $... = array (...)
+snippet array
+ $${1:arrayName} = array('${2}' => ${3});${4}
+# DRUPAL 7 Hooks
+snippet h_simpletest_alter
+ /**
+ * Implements hook_simpletest_alter()
+ */
+ function `Filename()`_simpletest_alter(&$groups) {
+ ${1:/* Your code here */}
+ }
+snippet h_test_group_started
+ /**
+ * Implements hook_test_group_started()
+ */
+ function `Filename()`_test_group_started() {
+ ${1:/* Your code here */}
+ }
+snippet h_test_group_finished
+ /**
+ * Implements hook_test_group_finished()
+ */
+ function `Filename()`_test_group_finished() {
+ ${1:/* Your code here */}
+ }
+snippet h_test_finished
+ /**
+ * Implements hook_test_finished()
+ */
+ function `Filename()`_test_finished($results) {
+ ${1:/* Your code here */}
+ }
+snippet h_aggregator_fetch
+ /**
+ * Implements hook_aggregator_fetch()
+ */
+ function `Filename()`_aggregator_fetch($feed) {
+ ${1:/* Your code here */}
+ }
+snippet h_aggregator_fetch_info
+ /**
+ * Implements hook_aggregator_fetch_info()
+ */
+ function `Filename()`_aggregator_fetch_info() {
+ return array(
+ 'title' => t('${1}'),
+ 'description' => t('${2}'),
+ );
+ }
+snippet h_aggregator_parse
+ /**
+ * Implements hook_aggregator_parse()
+ */
+ function `Filename()`_aggregator_parse($feed) {
+ ${1:/* Your code here */}
+ }
+snippet h_aggregator_parse_info
+ /**
+ * Implements hook_aggregator_parse_info()
+ */
+ function `Filename()`_aggregator_parse_info() {
+ return array(
+ 'title' => t('${1}'),
+ 'description' => t('${2}'),
+ );
+ }
+snippet h_aggregator_process
+ /**
+ * Implements hook_aggregator_process()
+ */
+ function `Filename()`_aggregator_process($feed) {
+ ${1:/* Your code here */}
+ }
+snippet h_aggregator_process_info
+ /**
+ * Implements hook_aggregator_process_info()
+ */
+ function `Filename()`_aggregator_process_info($feed) {
+ return array(
+ 'title' => t('${1}'),
+ 'description' => t('${2}'),
+ );
+ }
+snippet h_aggregator_remove
+ /**
+ * Implements hook_aggregator_remove()
+ */
+ function `Filename()`_aggregator_remove($feed) {
+ ${1:/* Your code here */}
+ }
+snippet h_overlay_parent_initialize
+ /**
+ * Implements hook_overlay_parent_initialize()
+ */
+ function `Filename()`_overlay_parent_initialize() {
+ ${1:/* Your code here */}
+ }
+snippet h_overlay_child_initialize
+ /**
+ * Implements hook_overlay_child_initialize()
+ */
+ function `Filename()`_overlay_child_initialize() {
+ ${1:/* Your code here */}
+ }
+snippet h_entity_info
+ /**
+ * Implements hook_entity_info()
+ */
+ function `Filename()`_entity_info() {
+ 'node' => array(
+ 'label' => t('${1}'),
+ 'controller class' => '${2}',
+ 'base table' => '${3}',
+ 'revision table' => '${4}',
+ 'uri callback' => '${5}',
+ 'fieldable' => ${6},
+ 'translation' => array(
+ 'locale' => ${7},
+ ),
+ 'entity keys' => array(
+ 'id' => '${8}',
+ 'revision' => '${9}',
+ 'bundle' => '${10}',
+ ),
+ 'bundle keys' => array(
+ 'bundle' => '${11}',
+ ),
+ 'bundles' => array(),
+ 'view modes' => array(
+ '${12}' => array(
+ 'label' => t('${13}'),
+ 'custom settings' => ${14},
+ ),
+ ),
+ ),
+ );
+ return $return;
+ }
+snippet h_entity_info_alter
+ /**
+ * Implements hook_entity_info_alter()
+ */
+ function `Filename()`_entity_info_alter(&$entity_info) {
+ ${1:/* Your code here */}
+ }
+snippet h_entity_load
+ /**
+ * Implements hook_entity_load()
+ */
+ function `Filename()`_entity_load($entities, $type) {
+ foreach ($entities as $entity) {
+ $entity->${1} = mymodule_add_something($entity, $type);
+ }
+ }
+snippet h_entity_insert
+ /**
+ * Implements hook_entity_insert()
+ */
+ function `Filename()`_entity_insert($entity, $type) {
+ ${1:/* Your code here */}
+ }
+snippet h_entity_update
+ /**
+ * Implements hook_entity_update()
+ */
+ function `Filename()`_entity_update($entity, $type) {
+ ${1:/* Your code here */}
+ }
+snippet h_entity_query_alter
+ /**
+ * Implements hook_entity_query_alter()
+ */
+ function `Filename()`_entity_query_alter($query) {
+ $query->${1} = 'my_module_query_callback';
+ }
+snippet h_admin_paths
+ /**
+ * Implements hook_admin_paths()
+ */
+ function `Filename()`_admin_paths() {
+ $paths = array(
+ ${1:/* Your code here */}
+ );
+ return $paths;
+ }
+snippet h_admin_paths_alter
+ /**
+ * Implements hook_admin_paths_alter()
+ */
+ function `Filename()`_admin_paths_alter(&$paths) {
+ $paths['${1}'] = ${2};
+ }
+snippet h_entity_prepare_view
+ /**
+ * Implements hook_entity_prepare_view()
+ */
+ function `Filename()`_entity_prepare_view($entities, $type) {
+ ${1:/* Your code here */}
+ }
+snippet h_cron
+ /**
+ * Implements hook_cron()
+ */
+ function `Filename()`_cron() {
+ ${1:/* Your code here */}
+ }
+snippet h_cron_queue_info
+ /**
+ * Implements hook_cron_queue_info()
+ */
+ function `Filename()`_cron_queue_info() {
+ $queues['${1}'] = array(
+ 'worker callback' => '${2}',
+ 'time' => ${3},
+ );
+ return $queues;
+ }
+snippet h_cron_queue_info_alter
+ /**
+ * Implements hook_cron_queue_info_alter()
+ */
+ function `Filename()`_cron_queue_info_alter(&$queues) {
+ $queues['${1}']['time'] = ${2};
+ }
+snippet h_element_info
+ /**
+ * Implements hook_element_info()
+ */
+ function `Filename()`_element_info() {
+ $types['${1}'] = array(
+ ${2:/* Your code here */}
+ );
+ return $types;
+ }
+snippet h_element_info_alter
+ /**
+ * Implements hook_element_info_alter()
+ */
+ function `Filename()`_element_info_alter(&$type) {
+ if (isset($type['${1}'])) {
+ $type['${2}'] = ${3};
+ }
+ }
+snippet h_exit
+ /**
+ * Implements hook_exit()
+ */
+ function `Filename()`_exit($destination = NULL) {
+ ${1:/* Your code here */}
+ }
+snippet h_js_alter
+ /**
+ * Implements hook_js_alter()
+ */
+ function `Filename()`_js_alter(&$javascript) {
+ ${1:/* Your code here */}
+ }
+snippet h_library
+ /**
+ * Implements hook_library()
+ */
+ function `Filename()`_library() {
+ $libraries['${1}'] = array(
+ 'title' => '${2}',
+ 'website' => '${3}',
+ 'version' => '${4}',
+ 'js' => array(
+ drupal_get_path('module', 'my_module') . '/${5}' => array(),
+ ),
+ 'css' => array(
+ drupal_get_path('module', 'my_module') . '/${6}' => array(
+ 'type' => 'file',
+ 'media' => '${7}',
+ ),
+ ),
+ 'dependencies' => array(
+ array('system', 'ui'),
+ ),
+ );
+ return $libraries;
+ }
+snippet h_library_alter
+ /**
+ * Implements hook_library_alter()
+ */
+ function `Filename()`_library_alter(&$libraries, $module) {
+ ${1:/* Your code here */}
+ }
+snippet h_css_alter
+ /**
+ * Implements hook_css_alter()
+ */
+ function `Filename()`_css_alter(&$css) {
+ ${1:/* Your code here */}
+ }
+snippet h_ajax_render_alter
+ /**
+ * Implements hook_ajax_render_alter()
+ */
+ function `Filename()`_ajax_render_alter($commands) {
+ $commands[] = ${1}
+ }
+snippet h_page_build
+ /**
+ * Implements hook_page_build()
+ */
+ function `Filename()`_page_build(&$page) {
+ $page['${1}']['${2}'] = array(
+ '#markup' => t('${3}'),
+ '#weight' => ${4},
+ );
+ }
+snippet h_menu
+ /**
+ * Implements hook_menu()
+ */
+ function `Filename()`_menu() {
+ $items['${1}'] = array(
+ 'title' => '${2}',
+ 'page callback' => '${3}',
+ 'page arguments' => array('${4}'),
+ 'access arguments' => array('${5}'),
+ 'type' => ${6},
+ 'file' => ${7},
+ );
+
+ return $items;
+ }
+snippet h_menu_alter
+ /**
+ * Implements hook_menu_alter()
+ */
+ function `Filename()`_menu_alter(&$items) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_link_alter
+ /**
+ * Implements hook_menu_link_alter()
+ */
+ function `Filename()`_menu_link_alter(&$item) {
+ ${1:/* Your code here */}
+ }
+snippet h_translated_menu_link_alter
+ /**
+ * Implements hook_translated_menu_link_alter()
+ */
+ function `Filename()`_translated_menu_link_alter(&$item, $map) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_link_insert
+ /**
+ * Implements hook_menu_link_insert()
+ */
+ function `Filename()`_menu_link_insert($link) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_link_update
+ /**
+ * Implements hook_menu_link_update()
+ */
+ function `Filename()`_menu_link_update($link) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_link_delete
+ /**
+ * Implements hook_menu_link_delete()
+ */
+ function `Filename()`_menu_link_delete($link) {
+ db_delete('${1}')
+ ->condition('mlid', $link['mlid'])
+ ->execute();
+ }
+snippet h_menu_local_tasks_alter
+ /**
+ * Implements hook_menu_local_tasks_alter()
+ */
+ function `Filename()`_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_breadcrumb_alter
+ /**
+ * Implements hook_menu_breadcrumb_alter()
+ */
+ function `Filename()`_menu_breadcrumb_alter(&$active_trail, $item) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_contextual_links_alter
+ /**
+ * Implements hook_menu_contextual_links_alter()
+ */
+ function `Filename()`_menu_contextual_links_alter(&$links, $router_item, $root_path) {
+ if ($root_path == '${1}') {
+ $links['${2}'] = array(
+ 'title' => t('${3}'),
+ 'href' => '${4}',
+ 'localized_options' => array(
+ 'query' => array(
+ '${5}' => '${6}',
+ ),
+ ),
+ );
+ }
+ }
+snippet h_page_alter
+ /**
+ * Implements hook_page_alter()
+ */
+ function `Filename()`_page_alter(&$page) {
+ ${1:/* Your code here */}
+ }
+snippet h_form_alter
+ /**
+ * Implements hook_form_alter()
+ */
+ function `Filename()`_form_alter(&$form, &$form_state, $form_id) {
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ }
+snippet h_forms
+ /**
+ * Implements hook_forms()
+ */
+ function `Filename()`_forms($form_id, $args) {
+ $forms['${1}'] = array(
+ 'callback' => '${2}',
+ 'callback arguments' => array('${3}'),
+ );
+
+ return $forms;
+ }
+snippet h_boot
+ /**
+ * Implements hook_boot()
+ */
+ function `Filename()`_boot() {
+ ${1:/* Your code here */}
+ }
+snippet h_init
+ /**
+ * Implements hook_init()
+ */
+ function `Filename()`_init() {
+ ${1:/* Your code here */}
+ }
+snippet h_image_toolkits
+ /**
+ * Implements hook_image_toolkits()
+ */
+ function `Filename()`_image_toolkits() {
+ return array(
+ '${1}' => array(
+ 'title' => t('${2}'),
+ 'available' => TRUE,
+ ),
+ );
+ }
+snippet h_mail_alter
+ /**
+ * Implements hook_mail_alter()
+ */
+ function `Filename()`_mail_alter(&$message) {
+ if ($message['id'] == '${1}') {
+ $message['body'][] = "${2}";
+ }
+ }
+snippet h_module_implements_alter
+ /**
+ * Implements hook_module_implements_alter()
+ */
+ function `Filename()`_module_implements_alter(&$implementations, $hook) {
+ if ($hook == '${1}') {
+ ${2:/* Your code here */}
+ }
+ }
+snippet h_system_info_alter
+ /**
+ * Implements hook_system_info_alter()
+ */
+ function `Filename()`_system_info_alter(&$info, $file, $type) {
+ ${1:/* Your code here */}
+ }
+snippet h_permission
+ /**
+ * Implements hook_permission()
+ */
+ function `Filename()`_permission() {
+ return array(
+ '${1}' => array(
+ 'title' => t('${2}'),
+ 'description' => t('${3}'),
+ ),
+ );
+ }
+snippet h_theme
+ /**
+ * Implements hook_theme()
+ */
+ function `Filename()`_theme($existing, $type, $theme, $path) {
+ return array(
+ '${1}' => array(
+ 'render element' => '${2}',
+ 'file' => '${3}',
+ 'variables' => array('${4}' => NULL, '${5}' => NULL${6}),
+ ),
+ );
+ }
+snippet h_theme_registry_alter
+ /**
+ * Implements hook_theme_registry_alter()
+ */
+ function `Filename()`_theme_registry_alter(&$theme_registry) {
+ ${1:/* Your code here */}
+ }
+snippet h_custom_theme
+ /**
+ * Implements hook_custom_theme()
+ */
+ function `Filename()`_custom_theme() {
+ ${1:/* Your code here */}
+ }
+snippet h_xmlrpc
+ /**
+ * Implements hook_xmlrpc()
+ */
+ function `Filename()`_xmlrpc() {
+ ${1:/* Your code here */}
+ }
+snippet h_xmlrpc_alter
+ /**
+ * Implements hook_xmlrpc_alter()
+ */
+ function `Filename()`_xmlrpc_alter(&$methods) {
+ ${1:/* Your code here */}
+ }
+snippet h_watchdog
+ /**
+ * Implements hook_watchdog()
+ */
+ function `Filename()`_watchdog(array $log_entry) {
+ ${1:/* Your code here */}
+ }
+snippet h_mail
+ /**
+ * Implements hook_mail()
+ */
+ function `Filename()`_mail($key, &$message, $params) {
+ ${1:/* Your code here */}
+ }
+snippet h_flush_caches
+ /**
+ * Implements hook_flush_caches()
+ */
+ function `Filename()`_flush_caches() {
+ return array('${1}');
+ }
+snippet h_modules_installed
+ /**
+ * Implements hook_modules_installed()
+ */
+ function `Filename()`_modules_installed($modules) {
+ ${1:/* Your code here */}
+ }
+snippet h_modules_enabled
+ /**
+ * Implements hook_modules_enabled()
+ */
+ function `Filename()`_modules_enabled($modules) {
+ ${1:/* Your code here */}
+ }
+snippet h_modules_disabled
+ /**
+ * Implements hook_modules_disabled()
+ */
+ function `Filename()`_modules_disabled($modules) {
+ ${1:/* Your code here */}
+ }
+snippet h_modules_uninstalled
+ /**
+ * Implements hook_modules_uninstalled()
+ */
+ function `Filename()`_modules_uninstalled($modules) {
+ foreach ($modules as $module) {
+ db_delete('${1}')
+ ->condition('module', $module)
+ ->execute();
+ }
+ ${2}_cache_rebuild();
+ }
+snippet h_stream_wrappers
+ /**
+ * Implements hook_stream_wrappers()
+ */
+ function `Filename()`_stream_wrappers() {
+ return array(
+ '${1}' => array(
+ 'name' => t('${2}'),
+ 'class' => '${3}',
+ 'description' => t('${4}'),
+ ),
+ )
+ );
+ }
+snippet h_stream_wrappers_alter
+ /**
+ * Implements hook_stream_wrappers_alter()
+ */
+ function `Filename()`_stream_wrappers_alter(&$wrappers) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_load
+ /**
+ * Implements hook_file_load()
+ */
+ function `Filename()`_file_load($files) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_validate
+ /**
+ * Implements hook_file_validate()
+ */
+ function `Filename()`_file_validate(&$file) {
+ $errors = array();
+ if (${1}) {
+ $errors[] = t("${2}");
+ }
+
+ return $errors;
+ }
+snippet h_file_insert
+ /**
+ * Implements hook_file_insert()
+ */
+ function `Filename()`_file_insert($file) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_update
+ /**
+ * Implements hook_file_update()
+ */
+ function `Filename()`_file_update($file) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_copy
+ /**
+ * Implements hook_file_copy()
+ */
+ function `Filename()`_file_copy($file, $source) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_move
+ /**
+ * Implements hook_file_move()
+ */
+ function `Filename()`_file_move($file, $source) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_delete
+ /**
+ * Implements hook_file_delete()
+ */
+ function `Filename()`_file_delete($file) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_download
+ /**
+ * Implements hook_file_download()
+ */
+ function `Filename()`_file_download($uri) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_url_alter
+ /**
+ * Implements hook_file_url_alter()
+ */
+ function `Filename()`_file_url_alter(&$uri) {
+ ${1:/* Your code here */}
+ }
+snippet h_requirements
+ /**
+ * Implements hook_requirements()
+ */
+ function `Filename()`_requirements($phase) {
+ $requirements = array();
+ ${1:/* Your code here */}
+
+ return $requirements;
+ }
+snippet h_schema
+ /**
+ * Implements hook_schema()
+ */
+ function `Filename()`_schema() {
+ $schema['${1}'] = array(
+ 'description' => '${2}',
+ 'fields' => array(
+ '${3}' => array(
+ 'description' => '${4}',
+ 'type' => '${5}',
+ 'unsigned' => ${6},
+ 'not null' => ${7},
+ 'default' => ${8}),
+ ),
+ 'indexes' => array(
+ '${9}' => array('${10}'),
+ ),
+ 'unique keys' => array(
+ '${11}' => array('${12}')
+ ),
+ 'foreign keys' => array(
+ '${13}' => array(
+ 'table' => '${14}',
+ 'columns' => array('${15}' => '${16}'),
+ ),
+ ),
+ 'primary key' => array('${17}'),
+ );
+ return $schema;
+ }
+snippet h_schema_alter
+ /**
+ * Implements hook_schema_alter()
+ */
+ function `Filename()`_schema_alter(&$schema) {
+ ${1:/* Your code here */}
+ }
+snippet h_query_alter
+ /**
+ * Implements hook_query_alter()
+ */
+ function `Filename()`_query_alter(QueryAlterableInterface $query) {
+ if ($query->hasTag('${1}')) {
+ ${2:/* Your code here */}
+ }
+ }
+snippet h_install
+ /**
+ * Implements hook_install()
+ */
+ function `Filename()`_install() {
+ ${1:/* Your code here */}
+ }
+snippet h_update_dependencies
+ /**
+ * Implements hook_update_dependencies()
+ */
+ function `Filename()`_update_dependencies() {
+ $dependencies['${1}']['${2}'] = array(
+ '${3}' => ${4},
+ );
+
+ return $dependencies;
+ }
+snippet h_update_last_removed
+ /**
+ * Implements hook_update_last_removed()
+ */
+ function `Filename()`_update_last_removed() {
+ ${1:/* Your code here */}
+ }
+snippet h_uninstall
+ /**
+ * Implements hook_uninstall()
+ */
+ function `Filename()`_uninstall() {
+ variable_del('${1}');
+ }
+snippet h_enable
+ /**
+ * Implements hook_enable()
+ */
+ function `Filename()`_enable() {
+ ${1:/* Your code here */}
+ }
+snippet h_disable
+ /**
+ * Implements hook_disable()
+ */
+ function `Filename()`_disable() {
+ ${1:/* Your code here */}
+ }
+snippet h_registry_files_alter
+ /**
+ * Implements hook_registry_files_alter()
+ */
+ function `Filename()`_registry_files_alter(&$files, $modules) {
+ ${1:/* Your code here */}
+ }
+snippet h_install_tasks
+ /**
+ * Implements hook_install_tasks()
+ */
+ function `Filename()`_install_tasks() {
+ $tasks = array(
+ ${1:/* Your code here */}
+ );
+ return $tasks;
+ }
+snippet h_drupal_goto_alter
+ /**
+ * Implements hook_drupal_goto_alter()
+ */
+ function `Filename()`_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+ ${1:/* Your code here */}
+ }
+snippet h_html_head_alter
+ /**
+ * Implements hook_html_head_alter()
+ */
+ function `Filename()`_html_head_alter(&$head_elements) {
+ foreach ($head_elements as $key => $element) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_install_tasks_alter
+ /**
+ * Implements hook_install_tasks_alter()
+ */
+ function `Filename()`_install_tasks_alter(&$tasks, $install_state) {
+ $tasks['${1}']['${2}'] = '${3}';
+ }
+snippet h_file_mimetype_mapping_alter
+ /**
+ * Implements hook_file_mimetype_mapping_alter()
+ */
+ function `Filename()`_file_mimetype_mapping_alter(&$mapping) {
+ $mapping['${1}']['${2}'] = '${3}';
+ }
+snippet h_action_info
+ /**
+ * Implements hook_action_info()
+ */
+ function `Filename()`_action_info() {
+ return array(
+ '${1}' => array(
+ 'type' => '${2}',
+ 'label' => t('${3}'),
+ 'configurable' => ${4},
+ 'behavior' => array('${5}'),
+ 'triggers' => array('${6}', ${7}),
+ ),
+ );
+ }
+snippet h_actions_delete
+ /**
+ * Implements hook_actions_delete()
+ */
+ function `Filename()`_actions_delete($aid) {
+ db_delete('${1}')
+ ->condition('aid', $aid)
+ ->execute();
+ }
+snippet h_action_info_alter
+ /**
+ * Implements hook_action_info_alter()
+ */
+ function `Filename()`_action_info_alter(&$actions) {
+ $actions['${1}']['${2}'] = t('${3}');
+ }
+snippet h_archiver_info
+ /**
+ * Implements hook_archiver_info()
+ */
+ function `Filename()`_archiver_info() {
+ return array(
+ '${1}' => array(
+ 'class' => '${2}',
+ 'extensions' => array('${3}'${4}),
+ ),
+ );
+ }
+snippet h_archiver_info_alter
+ /**
+ * Implements hook_archiver_info_alter()
+ */
+ function `Filename()`_archiver_info_alter(&$info) {
+ $info['${1}']['${2}'][] = '${3}';
+ }
+snippet h_date_format_types
+ /**
+ * Implements hook_date_format_types()
+ */
+ function `Filename()`_date_format_types() {
+ return array(
+ '${1}' => t('${2}'),
+ );
+ }
+snippet h_date_format_types_alter
+ /**
+ * Implements hook_date_format_types_alter()
+ */
+ function `Filename()`_date_format_types_alter(&$types) {
+ foreach ($types as $type_name => $type) {
+ $types[$type_name]['${1}'] = ${2};
+ }
+ }
+snippet h_date_formats
+ /**
+ * Implements hook_date_formats()
+ */
+ function `Filename()`_date_formats() {
+ return array(
+ array(
+ 'type' => '${1}',
+ 'format' => '${2}',
+ 'locales' => array('${3}'),
+ ),
+ );
+ }
+snippet h_date_formats_alter
+ /**
+ * Implements hook_date_formats_alter()
+ */
+ function `Filename()`_date_formats_alter(&$formats) {
+ foreach ($formats as $id => $format) {
+ $formats[$id]['${1}'][] = '${2}';
+ }
+ }
+snippet h_page_delivery_callback_alter
+ /**
+ * Implements hook_page_delivery_callback_alter()
+ */
+ function `Filename()`_page_delivery_callback_alter(&$callback) {
+ ${1:/* Your code here */}
+ }
+snippet h_system_themes_page_alter
+ /**
+ * Implements hook_system_themes_page_alter()
+ */
+ function `Filename()`_system_themes_page_alter(&$theme_groups) {
+ foreach ($theme_groups as $state => &$group) {
+ foreach ($theme_groups[$state] as &$theme) {
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet h_url_inbound_alter
+ /**
+ * Implements hook_url_inbound_alter()
+ */
+ function `Filename()`_url_inbound_alter(&$path, $original_path, $path_language) {
+ ${1:/* Your code here */}
+ }
+snippet h_url_outbound_alter
+ /**
+ * Implements hook_url_outbound_alter()
+ */
+ function `Filename()`_url_outbound_alter(&$path, &$options, $original_path) {
+ ${1:/* Your code here */}
+ }
+snippet h_username_alter
+ /**
+ * Implements hook_username_alter()
+ */
+ function `Filename()`_username_alter(&$name, $account) {
+ ${1:/* Your code here */}
+ }
+snippet h_tokens($type, $tokens, array $data = array(), array $options = array
+ /**
+ * Implements hook_tokens($type, $tokens, array $data = array(), array $options = array()
+ */
+ function `Filename()`_tokens($type, $tokens, array $data = array(), array $options = array()) {
+ $replacements = array();
+ ${1:/* Your code here */}
+
+ return $replacements;
+ }
+snippet h_token_info
+ /**
+ * Implements hook_token_info()
+ */
+ function `Filename()`_token_info() {
+ $type = array(
+ 'name' => t('${1}'),
+ 'description' => t('${2}'),
+ 'needs-data' => '${3}',
+ );
+ $${4}['${5}'] = array(
+ 'name' => t("${6}"),
+ 'description' => t("${7}"),
+ );
+ return array(
+ 'types' => array('${8}' => $type),
+ 'tokens' => array('${9}' => $${10}),
+ );
+ }
+snippet h_batch_alter
+ /**
+ * Implements hook_batch_alter()
+ */
+ function `Filename()`_batch_alter(&$batch) {
+ ${1:/* Your code here */}
+ }
+snippet h_token_info_alter
+ /**
+ * Implements hook_token_info_alter()
+ */
+ function `Filename()`_token_info_alter(&$data) {
+ $data['tokens']['${1}']['${2}'] = array(
+ 'name' => t("${3}"),
+ 'description' => t("${4}"),
+ );
+ }
+snippet h_updater_info
+ /**
+ * Implements hook_updater_info()
+ */
+ function `Filename()`_updater_info() {
+ return array(
+ '${1}' => array(
+ 'class' => '${2}',
+ 'name' => t('${3}'),
+ 'weight' => ${4},
+ ),
+ );
+ }
+snippet h_updater_info_alter
+ /**
+ * Implements hook_updater_info_alter()
+ */
+ function `Filename()`_updater_info_alter(&$updaters) {
+ ${1:/* Your code here */}
+ }
+snippet h_countries_alter
+ /**
+ * Implements hook_countries_alter()
+ */
+ function `Filename()`_countries_alter(&$countries) {
+ ${1:/* Your code here */}
+ }
+snippet h_filetransfer_backends
+ /**
+ * Implements hook_filetransfer_backends()
+ */
+ function `Filename()`_filetransfer_backends() {
+ $backends = array();
+ ${1:/* Your code here */}
+ return $backends;
+ }
+snippet h_menu_site_status_alter
+ /**
+ * Implements hook_menu_site_status_alter()
+ */
+ function `Filename()`_menu_site_status_alter(&$menu_site_status, $path) {
+ ${1:/* Your code here */}
+ }
+snippet h_form_system_theme_settings_alter
+ /**
+ * Implements hook_form_system_theme_settings_alter()
+ */
+ function `Filename()`_form_system_theme_settings_alter(&$form, &$form_state) {
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => theme_get_setting('${4}'),
+ '#description' => t('${5}'),
+ );
+ }
+snippet h_preprocess
+ /**
+ * Implements hook_preprocess()
+ */
+ function `Filename()`_preprocess(&$variables, $hook) {
+ static $hooks;
+ ${1:/* Your code here */}
+ }
+snippet h_process
+ /**
+ * Implements hook_process()
+ */
+ function `Filename()`_process(&$variables, $hook) {
+ ${1:/* Your code here */}
+ }
+snippet h_themes_enabled
+ /**
+ * Implements hook_themes_enabled()
+ */
+ function `Filename()`_themes_enabled($theme_list) {
+ foreach ($theme_list as $theme) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_themes_disabled
+ /**
+ * Implements hook_themes_disabled()
+ */
+ function `Filename()`_themes_disabled($theme_list) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_download_access
+ /**
+ * Implements hook_file_download_access()
+ */
+ function `Filename()`_file_download_access($field, $entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_file_download_access_alter
+ /**
+ * Implements hook_file_download_access_alter()
+ */
+ function `Filename()`_file_download_access_alter(&$grants, $field, $entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_help
+ /**
+ * Implements hook_help()
+ */
+ function `Filename()`_help($path, $arg) {
+ switch ($path) {
+ case '${1}':
+ return '<p>' . t('${2}', array('${3}' => ${4})) . '</p>';
+ }
+ }
+snippet h_comment_presave
+ /**
+ * Implements hook_comment_presave()
+ */
+ function `Filename()`_comment_presave($comment) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_insert
+ /**
+ * Implements hook_comment_insert()
+ */
+ function `Filename()`_comment_insert($comment) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_update
+ /**
+ * Implements hook_comment_update()
+ */
+ function `Filename()`_comment_update($comment) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_load
+ /**
+ * Implements hook_comment_load()
+ */
+ function `Filename()`_comment_load($comments) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_view
+ /**
+ * Implements hook_comment_view()
+ */
+ function `Filename()`_comment_view($comment, $view_mode, $langcode) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_view_alter
+ /**
+ * Implements hook_comment_view_alter()
+ */
+ function `Filename()`_comment_view_alter(&$build) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_publish
+ /**
+ * Implements hook_comment_publish()
+ */
+ function `Filename()`_comment_publish($comment) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_unpublish
+ /**
+ * Implements hook_comment_unpublish()
+ */
+ function `Filename()`_comment_unpublish($comment) {
+ ${1:/* Your code here */}
+ }
+snippet h_comment_delete
+ /**
+ * Implements hook_comment_delete()
+ */
+ function `Filename()`_comment_delete($comment) {
+ ${1:/* Your code here */}
+ }
+snippet h_update_projects_alter
+ /**
+ * Implements hook_update_projects_alter()
+ */
+ function `Filename()`_update_projects_alter(&$projects) {
+ ${1:/* Your code here */}
+ }
+snippet h_update_status_alter
+ /**
+ * Implements hook_update_status_alter()
+ */
+ function `Filename()`_update_status_alter(&$projects) {
+ ${1:/* Your code here */}
+ }
+snippet h_verify_update_archive
+ /**
+ * Implements hook_verify_update_archive()
+ */
+ function `Filename()`_verify_update_archive($project, $archive_file, $directory) {
+ if (!file_exists($directory)) {
+ return TRUE;
+ }
+ ${1:/* Add other checks on the archive integrity here */}
+ }
+snippet h_node_grants
+ /**
+ * Implements hook_node_grants()
+ */
+ function `Filename()`_node_grants($account, $op) {
+ ${1:/* Your code here */}
+
+ return $grants;
+ }
+snippet h_node_access_records
+ /**
+ * Implements hook_node_access_records()
+ */
+ function `Filename()`_node_access_records($node) {
+ $grants[] = array(
+ 'realm' => '${1}',
+ 'gid' => ${2},
+ 'grant_view' => ${3},
+ 'grant_update' => ${4},
+ 'grant_delete' => ${5},
+ 'priority' => ${6},
+ );
+
+ return $grants;
+ }
+ }
+snippet h_node_access_records_alter
+ /**
+ * Implements hook_node_access_records_alter()
+ */
+ function `Filename()`_node_access_records_alter(&$grants, $node) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_grants_alter
+ /**
+ * Implements hook_node_grants_alter()
+ */
+ function `Filename()`_node_grants_alter(&$grants, $account, $op) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_operations
+ /**
+ * Implements hook_node_operations()
+ */
+ function `Filename()`_node_operations() {
+ $operations = array(
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'callback' => '${3}',
+ 'callback arguments' => array('${4}' => array('${5}' => ${6})),
+ ),
+ );
+ return $operations;
+ }
+snippet h_node_delete
+ /**
+ * Implements hook_node_delete()
+ */
+ function `Filename()`_node_delete($node) {
+ db_delete('${1}')
+ ->condition('nid', $node->nid)
+ ->execute();
+ }
+snippet h_node_revision_delete
+ /**
+ * Implements hook_node_revision_delete()
+ */
+ function `Filename()`_node_revision_delete($node) {
+ db_delete('${1}')
+ ->condition('vid', $node->vid)
+ ->execute();
+ }
+snippet h_node_insert
+ /**
+ * Implements hook_node_insert()
+ */
+ function `Filename()`_node_insert($node) {
+ db_insert('${1}')
+ ->fields(array(
+ 'nid' => $node->nid,
+ 'extra' => $node->extra,
+ ))
+ ->execute();
+ }
+snippet h_node_load
+ /**
+ * Implements hook_node_load()
+ */
+ function `Filename()`_node_load($nodes, $types) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_access
+ /**
+ * Implements hook_node_access()
+ */
+ function `Filename()`_node_access($node, $op, $account) {
+ $type = is_string($node) ? $node : $node->type;
+ ${1:/* Your code here */}
+ return NODE_ACCESS_IGNORE;
+ }
+snippet h_node_prepare
+ /**
+ * Implements hook_node_prepare()
+ */
+ function `Filename()`_node_prepare($node) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_search_result
+ /**
+ * Implements hook_node_search_result()
+ */
+ function `Filename()`_node_search_result($node) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_presave
+ /**
+ * Implements hook_node_presave()
+ */
+ function `Filename()`_node_presave($node) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_update
+ /**
+ * Implements hook_node_update()
+ */
+ function `Filename()`_node_update($node) {
+ db_update('${1}')
+ ->fields(array('${2}' => ${3})
+ ->condition('nid', $node->nid)
+ ->execute();
+ }
+snippet h_node_update_index
+ /**
+ * Implements hook_node_update_index()
+ */
+ function `Filename()`_node_update_index($node) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_validate
+ /**
+ * Implements hook_node_validate()
+ */
+ function `Filename()`_node_validate($node, $form, &$form_state) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_submit
+ /**
+ * Implements hook_node_submit()
+ */
+ function `Filename()`_node_submit($node, $form, &$form_state) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_view
+ /**
+ * Implements hook_node_view()
+ */
+ function `Filename()`_node_view($node, $view_mode, $langcode) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_view_alter
+ /**
+ * Implements hook_node_view_alter()
+ */
+ function `Filename()`_node_view_alter(&$build) {
+ }
+snippet h_node_info
+ /**
+ * Implements hook_node_info()
+ */
+ function `Filename()`_node_info() {
+ return array(
+ '${1}' => array(
+ 'name' => t('${2}'),
+ 'base' => '${3}',
+ 'description' => t('${4}'),
+ )
+ );
+ }
+snippet h_ranking
+ /**
+ * Implements hook_ranking()
+ */
+ function `Filename()`_ranking() {
+ ${1:/* Your code here */}
+ }
+snippet h_node_type_insert
+ /**
+ * Implements hook_node_type_insert()
+ */
+ function `Filename()`_node_type_insert($info) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_type_update
+ /**
+ * Implements hook_node_type_update()
+ */
+ function `Filename()`_node_type_update($info) {
+ ${1:/* Your code here */}
+ }
+snippet h_node_type_delete
+ /**
+ * Implements hook_node_type_delete()
+ */
+ function `Filename()`_node_type_delete($info) {
+ ${1:/* Your code here */}
+ }
+snippet h_delete
+ /**
+ * Implements hook_delete()
+ */
+ function `Filename()`_delete($node) {
+ db_delete('${1}')
+ ->condition('nid', $nid->nid)
+ ->execute();
+ }
+snippet h_prepare
+ /**
+ * Implements hook_prepare()
+ */
+ function `Filename()`_prepare($node) {
+ ${1:/* Your code here */}
+ }
+snippet h_form
+ /**
+ * Implements hook_form()
+ */
+ function `Filename()`_form($node, &$form_state) {
+ $type = node_type_get_type($node);
+
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $node->${4},
+ '#${5}' => ${6},
+ );
+
+ return $form;
+ }
+snippet h_insert
+ /**
+ * Implements hook_insert()
+ */
+ function `Filename()`_insert($node) {
+ db_insert('${1}')
+ ->fields(array(
+ 'nid' => $node->nid,
+ 'extra' => $node->extra,
+ ))
+ ->execute();
+ }
+snippet h_load
+ /**
+ * Implements hook_load()
+ */
+ function `Filename()`_load($nodes) {
+ ${1:/* Your code here */}
+ }
+snippet h_update
+ /**
+ * Implements hook_update()
+ */
+ function `Filename()`_update($node) {
+ db_update('${1}')
+ ->fields(array('extra' => $node->extra))
+ ->condition('nid', $node->nid)
+ ->execute();
+ }
+snippet h_validate
+ /**
+ * Implements hook_validate()
+ */
+ function `Filename()`_validate($node, $form, &$form_state) {
+ ${1:/* Your code here */}
+ }
+snippet h_view
+ /**
+ * Implements hook_view()
+ */
+ function `Filename()`_view($node, $view_mode) {
+ ${1:/* Your code here */}
+
+ return $node;
+ }
+snippet h_block_info
+ /**
+ * Implements hook_block_info()
+ */
+ function `Filename()`_block_info() {
+ $blocks['${1}'] = array(
+ 'info' => t('${2}'),
+ 'cache' => ${3}DRUPAL_NO_CACHE
+ );
+
+ return $blocks;
+ }
+snippet h_block_info_alter
+ /**
+ * Implements hook_block_info_alter()
+ */
+ function `Filename()`_block_info_alter(&$blocks, $theme, $code_blocks) {
+ ${1:/* Your code here */}
+ }
+snippet h_block_configure
+ /**
+ * Implements hook_block_configure()
+ */
+ function `Filename()`_block_configure($delta = '') {
+ $form = array();
+ if ($delta == '${1}') {
+ $form['${2}'] = array(
+ '#type' => '${3}',
+ '#title' => t('${4}'),
+ '#default_value' => variable_get('${5}', ${6}),
+ '#${7}' => ${8},
+ );
+ }
+ return $form;
+ }
+snippet h_block_save($delta = '', $edit = array
+ /**
+ * Implements hook_block_save($delta = '', $edit = array()
+ */
+ function `Filename()`_block_save($delta = '', $edit = array()) {
+ ${1:/* Your code here */}
+ }
+snippet h_block_view
+ /**
+ * Implements hook_block_view()
+ */
+ function `Filename()`_block_view($delta = '') {
+ $block = array();
+
+ switch ($delta) {
+ case '${1}':
+ $block['subject'] = t('${2}');
+ $block['content'] = theme('${3}', array('${4}' =>${5}));
+ break;
+ ${6}
+ }
+ return $block;
+ }
+snippet h_block_view_alter
+ /**
+ * Implements hook_block_view_alter()
+ */
+ function `Filename()`_block_view_alter(&$data, $block) {
+ ${1:/* Your code here */}
+ }
+snippet h_block_list_alter
+ /**
+ * Implements hook_block_list_alter()
+ */
+ function `Filename()`_block_list_alter(&$blocks) {
+ ${1:/* Your code here */}
+ }
+snippet h_user_load
+ /**
+ * Implements hook_user_load()
+ */
+ function `Filename()`_user_load($users) {
+ ${1:/* Your code here */}
+ }
+snippet h_user_delete
+ /**
+ * Implements hook_user_delete()
+ */
+ function `Filename()`_user_delete($account) {
+ db_delete('${1}')
+ ->condition('uid', $account->uid)
+ ->execute();
+ }
+snippet h_user_cancel
+ /**
+ * Implements hook_user_cancel()
+ */
+ function `Filename()`_user_cancel($edit, $account, $method) {
+ switch ($method) {
+ case '${1}':
+ ${2:/* Your code here */}
+ break;
+ }
+ }
+snippet h_user_cancel_methods_alter
+ /**
+ * Implements hook_user_cancel_methods_alter()
+ */
+ function `Filename()`_user_cancel_methods_alter(&$methods) {
+ $methods['${1}']${2}
+ }
+snippet h_user_operations
+ /**
+ * Implements hook_user_operations()
+ */
+ function `Filename()`_user_operations() {
+ $operations = array(
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'callback' => '${3}',
+ ),
+ );
+ return $operations;
+ }
+snippet h_user_categories
+ /**
+ * Implements hook_user_categories()
+ */
+ function `Filename()`_user_categories() {
+ return array(array(
+ 'name' => '${1}',
+ 'title' => t('${2}'),
+ 'weight' => ${3},
+ ));
+ }
+snippet h_user_presave
+ /**
+ * Implements hook_user_presave()
+ */
+ function `Filename()`_user_presave(&$edit, $account, $category) {
+ ${1:/* your code here */}
+ }
+snippet h_user_insert
+ /**
+ * Implements hook_user_insert()
+ */
+ function `Filename()`_user_insert(&$edit, $account, $category) {
+ db_insert('${1}')
+ ->fields(array(
+ '${2}' => $edit['${3}'],
+ 'uid' => $account->uid,
+ ))
+ ->execute();
+ }
+snippet h_user_update
+ /**
+ * Implements hook_user_update()
+ */
+ function `Filename()`_user_update(&$edit, $account, $category) {
+ db_insert('${1}')
+ ->fields(array(
+ 'uid' => $account->uid,
+ 'changed' => time(),
+ ))
+ ->execute();
+ }
+snippet h_user_login
+ /**
+ * Implements hook_user_login()
+ */
+ function `Filename()`_user_login(&$edit, $account) {
+ ${1:/* Your code here */}
+ }
+snippet h_user_logout
+ /**
+ * Implements hook_user_logout()
+ */
+ function `Filename()`_user_logout($account) {
+ db_insert('${1}')
+ ->fields(array(
+ 'uid' => $account->uid,
+ 'time' => time(),
+ ))
+ ->execute();
+ }
+snippet h_user_view
+ /**
+ * Implements hook_user_view()
+ */
+ function `Filename()`_user_view($account, $view_mode, $langcode) {
+ ${1:/* Your code here */}
+ }
+snippet h_user_view_alter
+ /**
+ * Implements hook_user_view_alter()
+ */
+ function `Filename()`_user_view_alter(&$build) {
+ ${1:/* Your code here */}
+ }
+snippet h_user_role_insert
+ /**
+ * Implements hook_user_role_insert()
+ */
+ function `Filename()`_user_role_insert($role) {
+ db_insert('${1}')
+ ->fields(array(
+ 'rid' => $role->rid,
+ 'role_description' => $role->description,
+ ))
+ ->execute();
+ }
+snippet h_user_role_update
+ /**
+ * Implements hook_user_role_update()
+ */
+ function `Filename()`_user_role_update($role) {
+ db_merge('${1}')
+ ->key(array('rid' => $role->rid))
+ ->fields(array(
+ 'role_description' => $role->description
+ ))
+ ->execute();
+ }
+snippet h_user_role_delete
+ /**
+ * Implements hook_user_role_delete()
+ */
+ function `Filename()`_user_role_delete($role) {
+ db_delete('${1}')
+ ->condition('rid', $role->rid)
+ ->execute();
+ }
+snippet h_taxonomy_vocabulary_load
+ /**
+ * Implements hook_taxonomy_vocabulary_load()
+ */
+ function `Filename()`_taxonomy_vocabulary_load($vocabularies) {
+ foreach ($vocabularies as $vocabulary) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_taxonomy_vocabulary_presave
+ /**
+ * Implements hook_taxonomy_vocabulary_presave()
+ */
+ function `Filename()`_taxonomy_vocabulary_presave($vocabulary) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_vocabulary_insert
+ /**
+ * Implements hook_taxonomy_vocabulary_insert()
+ */
+ function `Filename()`_taxonomy_vocabulary_insert($vocabulary) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_vocabulary_update
+ /**
+ * Implements hook_taxonomy_vocabulary_update()
+ */
+ function `Filename()`_taxonomy_vocabulary_update($vocabulary) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_vocabulary_delete
+ /**
+ * Implements hook_taxonomy_vocabulary_delete()
+ */
+ function `Filename()`_taxonomy_vocabulary_delete($vocabulary) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_term_load
+ /**
+ * Implements hook_taxonomy_term_load()
+ */
+ function `Filename()`_taxonomy_term_load($terms) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_term_presave
+ /**
+ * Implements hook_taxonomy_term_presave()
+ */
+ function `Filename()`_taxonomy_term_presave($term) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_term_insert
+ /**
+ * Implements hook_taxonomy_term_insert()
+ */
+ function `Filename()`_taxonomy_term_insert($term) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_term_update
+ /**
+ * Implements hook_taxonomy_term_update()
+ */
+ function `Filename()`_taxonomy_term_update($term) {
+ ${1:/* Your code here */}
+ }
+snippet h_taxonomy_term_delete
+ /**
+ * Implements hook_taxonomy_term_delete()
+ */
+ function `Filename()`_taxonomy_term_delete($term) {
+ ${1:/* Your code here */}
+ }
+snippet h_openid
+ /**
+ * Implements hook_openid()
+ */
+ function `Filename()`_openid($op, $request) {
+ ${1:/* Your code here */}
+
+ return $request;
+ }
+snippet h_openid_response
+ /**
+ * Implements hook_openid_response()
+ */
+ function `Filename()`_openid_response($response, $account) {
+ ${1:/* Your code here */}
+ }
+snippet h_openid_discovery_method_info
+ /**
+ * Implements hook_openid_discovery_method_info()
+ */
+ function `Filename()`_openid_discovery_method_info() {
+ return array(
+ '${1}' => '${2}',
+ );
+ }
+snippet h_openid_discovery_method_info_alter
+ /**
+ * Implements hook_openid_discovery_method_info_alter()
+ */
+ function `Filename()`_openid_discovery_method_info_alter(&$methods) {
+ ${1:/* Your code here */}
+ }
+snippet h_openid_normalization_method_info
+ /**
+ * Implements hook_openid_normalization_method_info()
+ */
+ function `Filename()`_openid_normalization_method_info() {
+ return array(
+ '${1}' => '${2}',
+ );
+ }
+snippet h_openid_normalization_method_info_alter
+ /**
+ * Implements hook_openid_normalization_method_info_alter()
+ */
+ function `Filename()`_openid_normalization_method_info_alter(&$methods) {
+ ${1:/* Your code here */}
+ }
+snippet h_filter_info
+ /**
+ * Implements hook_filter_info()
+ */
+ function `Filename()`_filter_info() {
+ $filters['${1}'] = array(
+ 'title' => t('${2}'),
+ 'description' => t('${3}'),
+ 'process callback' => '${4}',
+ 'settings callback' => '${5}',
+ 'default settings' => array(
+ 'allowed_html' => '${6}',
+ 'filter_html_help' => ${7},
+ 'filter_html_nofollow' => ${8},
+ ),
+ 'tips callback' => '${9}',
+ );
+ return $filters;
+ }
+snippet h_filter_info_alter
+ /**
+ * Implements hook_filter_info_alter()
+ */
+ function `Filename()`_filter_info_alter(&$info) {
+ ${1:/* Your code here */}
+ }
+snippet h_filter_format_insert
+ /**
+ * Implements hook_filter_format_insert()
+ */
+ function `Filename()`_filter_format_insert($format) {
+ ${1:/* Your code here */}
+ }
+snippet h_filter_format_update
+ /**
+ * Implements hook_filter_format_update()
+ */
+ function `Filename()`_filter_format_update($format) {
+ ${1:/* Your code here */}
+ }
+snippet h_filter_format_disable
+ /**
+ * Implements hook_filter_format_disable()
+ */
+ function `Filename()`_filter_format_disable($format) {
+ ${1:/* Your code here */}
+ }
+snippet h_rdf_mapping
+ /**
+ * Implements hook_rdf_mapping()
+ */
+ function `Filename()`_rdf_mapping() {
+ return array(
+ array(
+ 'type' => '${1}',
+ 'bundle' => '${2}',
+ 'mapping' => array(
+ 'rdftype' => array('${3}'),
+ 'title' => array(
+ 'predicates' => array('${4}'),
+ ),
+ 'created' => array(
+ 'predicates' => array('${5}'),
+ 'datatype' => '${6}',
+ 'callback' => '${7}',
+ ),
+ 'body' => array(
+ 'predicates' => array('${8}'),
+ ),
+ 'uid' => array(
+ 'predicates' => array('${9}'),
+ 'type' => '${10}',
+ ),
+ 'name' => array(
+ 'predicates' => array('${11}'),
+ ),
+ ),
+ ),
+ );
+ }
+snippet h_rdf_namespaces
+ /**
+ * Implements hook_rdf_namespaces()
+ */
+ function `Filename()`_rdf_namespaces() {
+ return array(
+ '${1}' => '${2}',
+ );
+ }
+snippet h_field_settings_form
+ /**
+ * Implements hook_field_settings_form()
+ */
+ function `Filename()`_field_settings_form($field, $instance, $has_data) {
+ $settings = $field['settings'];
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ return $form;
+ }
+snippet h_field_instance_settings_form
+ /**
+ * Implements hook_field_instance_settings_form()
+ */
+ function `Filename()`_field_instance_settings_form($field, $instance) {
+ $settings = $instance['settings'];
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ return $form;
+ }
+snippet h_field_widget_settings_form
+ /**
+ * Implements hook_field_widget_settings_form()
+ */
+ function `Filename()`_field_widget_settings_form($field, $instance) {
+ $widget = $instance['widget'];
+ $settings = $widget['settings'];
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ return $form;
+ }
+snippet h_field_formatter_settings_form
+ /**
+ * Implements hook_field_formatter_settings_form()
+ */
+ function `Filename()`_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
+ $display = $instance['display'][$view_mode];
+ $settings = $display['settings'];
+ $element['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+
+ return $element;
+
+ }
+snippet h_field_formatter_settings_summary
+ /**
+ * Implements hook_field_formatter_settings_summary()
+ */
+ function `Filename()`_field_formatter_settings_summary($field, $instance, $view_mode) {
+ ${1:/* Your code here */}
+
+ return $summary;
+ }
+snippet h_field_extra_fields
+ /**
+ * Implements hook_field_extra_fields()
+ */
+ function `Filename()`_field_extra_fields() {
+ $extra['${1}']['${2}'] = array(
+ 'form' => array(
+ '${3}' => array(
+ 'label' => t('${4}'),
+ 'description' => t('${5}'),
+ 'weight' => ${6},
+ ),
+ ),
+ 'display' => array(
+ '${7}' => array(
+ 'label' => t('${8}'),
+ 'description' => t('${9}'),
+ 'weight' => ${10},
+ ),
+ )
+ );
+
+ return $extra;
+ }
+snippet h_field_extra_fields_alter
+ /**
+ * Implements hook_field_extra_fields_alter()
+ */
+ function `Filename()`_field_extra_fields_alter(&$info) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_info
+ /**
+ * Implements hook_field_info()
+ */
+ function `Filename()`_field_info() {
+ return array(
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'description' => t('${3}'),
+ 'settings' => array('${4}' => ${5}),
+ 'instance_settings' => array('${6}' => ${7}),
+ 'default_widget' => '${8}',
+ 'default_formatter' => '${9}',
+ ),
+ );
+ }
+snippet h_field_info_alter
+ /**
+ * Implements hook_field_info_alter()
+ */
+ function `Filename()`_field_info_alter(&$info) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_schema
+ /**
+ * Implements hook_field_schema()
+ */
+ function `Filename()`_field_schema($field) {
+ $columns = array(
+ '${1}' => array(
+ 'type' => '${2}',
+ 'length' => ${3},
+ 'unsigned' => ${4},
+ 'not null' => ${5},
+ ),
+ );
+ $columns = array(
+ '${6}' => array(
+ 'type' => '${7}',
+ 'length' => ${8},
+ 'unsigned' => ${9},
+ 'not null' => ${10},
+ ),
+ );
+ return array(
+ 'columns' => $columns,
+ 'indexes' => array(
+ '${11}' => array('${12}'),
+ ),
+ );
+ }
+snippet h_field_load
+ /**
+ * Implements hook_field_load()
+ */
+ function `Filename()`_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_prepare_view
+ /**
+ * Implements hook_field_prepare_view()
+ */
+ function `Filename()`_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_validate
+ /**
+ * Implements hook_field_validate()
+ */
+ function `Filename()`_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+ foreach ($items as $delta => $item) {
+ if (!empty($item['value'])) {
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet h_field_presave
+ /**
+ * Implements hook_field_presave()
+ */
+ function `Filename()`_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ if ($field['type'] == '${1}') {
+ foreach ($items as $delta => $item) {
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet h_field_insert
+ /**
+ * Implements hook_field_insert()
+ */
+ function `Filename()`_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_update
+ /**
+ * Implements hook_field_update()
+ */
+ function `Filename()`_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_update_field
+ /**
+ * Implements hook_field_storage_update_field()
+ */
+ function `Filename()`_field_storage_update_field($field, $prior_field, $has_data) {
+ if (!$has_data) {
+ ${1:/* Your code here */}
+ }
+ else {
+ ${2:/* Your code here */}
+ }
+ drupal_get_schema(NULL, TRUE);
+ }
+snippet h_field_delete
+ /**
+ * Implements hook_field_delete()
+ */
+ function `Filename()`_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ foreach ($items as $delta => $item) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_field_delete_revision
+ /**
+ * Implements hook_field_delete_revision()
+ */
+ function `Filename()`_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ foreach ($items as $delta => $item) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_field_prepare_translation
+ /**
+ * Implements hook_field_prepare_translation()
+ */
+ function `Filename()`_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_is_empty
+ /**
+ * Implements hook_field_is_empty()
+ */
+ function `Filename()`_field_is_empty($item, $field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_widget_info
+ /**
+ * Implements hook_field_widget_info()
+ */
+ function `Filename()`_field_widget_info() {
+ return array(
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'field types' => array('${3}'),
+ 'settings' => array('${4}' => ${5}),
+ 'behaviors' => array(
+ 'multiple values' => ${6}FIELD_BEHAVIOR_DEFAULT,
+ 'default value' => ${7}FIELD_BEHAVIOR_DEFAULT,
+ ),
+ ),
+ );
+ }
+snippet h_field_widget_info_alter
+ /**
+ * Implements hook_field_widget_info_alter()
+ */
+ function `Filename()`_field_widget_info_alter(&$info) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_widget_form
+ /**
+ * Implements hook_field_widget_form()
+ */
+ function `Filename()`_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
+ $element += array(
+ '#type' => ${1},
+ '#default_value' => ${2},
+ );
+ return $element;
+ }
+snippet h_field_widget_error
+ /**
+ * Implements hook_field_widget_error()
+ */
+ function `Filename()`_field_widget_error($element, $error, $form, &$form_state) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_formatter_info
+ /**
+ * Implements hook_field_formatter_info()
+ */
+ function `Filename()`_field_formatter_info() {
+ return array(
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'field types' => array('${3}'),
+ ),
+ );
+ }
+snippet h_field_formatter_info_alter
+ /**
+ * Implements hook_field_formatter_info_alter()
+ */
+ function `Filename()`_field_formatter_info_alter(&$info) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_formatter_prepare_view
+ /**
+ * Implements hook_field_formatter_prepare_view()
+ */
+ function `Filename()`_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_formatter_view
+ /**
+ * Implements hook_field_formatter_view()
+ */
+ function `Filename()`_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
+ $element = array();
+ $settings = $display['settings'];
+
+ switch ($display['type']) {
+ case '${1}':
+ foreach ($items as $delta => $item) {
+ $element[$delta] = array(
+ '#theme' => '${2}',
+ '#data' => $item['value'],
+ '#markup' => ${3},
+ '#${4}' => $settings['${5}'],
+ );
+ }
+ break;
+ }
+
+ return $element;
+ }
+snippet h_field_attach_form
+ /**
+ * Implements hook_field_attach_form()
+ */
+ function `Filename()`_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_load
+ /**
+ * Implements hook_field_attach_load()
+ */
+ function `Filename()`_field_attach_load($entity_type, &$entities, $age, $options) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_validate
+ /**
+ * Implements hook_field_attach_validate()
+ */
+ function `Filename()`_field_attach_validate($entity_type, $entity, &$errors) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_submit
+ /**
+ * Implements hook_field_attach_submit()
+ */
+ function `Filename()`_field_attach_submit($entity_type, $entity, $form, &$form_state) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_presave
+ /**
+ * Implements hook_field_attach_presave()
+ */
+ function `Filename()`_field_attach_presave($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_insert
+ /**
+ * Implements hook_field_attach_insert()
+ */
+ function `Filename()`_field_attach_insert($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_update
+ /**
+ * Implements hook_field_attach_update()
+ */
+ function `Filename()`_field_attach_update($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_preprocess_alter
+ /**
+ * Implements hook_field_attach_preprocess_alter()
+ */
+ function `Filename()`_field_attach_preprocess_alter(&$variables, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_delete
+ /**
+ * Implements hook_field_attach_delete()
+ */
+ function `Filename()`_field_attach_delete($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_delete_revision
+ /**
+ * Implements hook_field_attach_delete_revision()
+ */
+ function `Filename()`_field_attach_delete_revision($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_purge
+ /**
+ * Implements hook_field_attach_purge()
+ */
+ function `Filename()`_field_attach_purge($entity_type, $entity, $field, $instance) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_view_alter
+ /**
+ * Implements hook_field_attach_view_alter()
+ */
+ function `Filename()`_field_attach_view_alter(&$output, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_prepare_translation_alter
+ /**
+ * Implements hook_field_attach_prepare_translation_alter()
+ */
+ function `Filename()`_field_attach_prepare_translation_alter(&$entity, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_language_alter
+ /**
+ * Implements hook_field_language_alter()
+ */
+ function `Filename()`_field_language_alter(&$display_language, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_available_languages_alter
+ /**
+ * Implements hook_field_available_languages_alter()
+ */
+ function `Filename()`_field_available_languages_alter(&$languages, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_create_bundle
+ /**
+ * Implements hook_field_attach_create_bundle()
+ */
+ function `Filename()`_field_attach_create_bundle($entity_type, $bundle) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_rename_bundle
+ /**
+ * Implements hook_field_attach_rename_bundle()
+ */
+ function `Filename()`_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_attach_delete_bundle
+ /**
+ * Implements hook_field_attach_delete_bundle()
+ */
+ function `Filename()`_field_attach_delete_bundle($entity_type, $bundle, $instances) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_info
+ /**
+ * Implements hook_field_storage_info()
+ */
+ function `Filename()`_field_storage_info() {
+ return array(
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'description' => t('${3}'),
+ 'settings' => array('${4}'${5}),
+ ),
+ );
+ }
+snippet h_field_storage_info_alter
+ /**
+ * Implements hook_field_storage_info_alter()
+ */
+ function `Filename()`_field_storage_info_alter(&$info) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_details
+ /**
+ * Implements hook_field_storage_details()
+ */
+ function `Filename()`_field_storage_details($field) {
+ $details = array();
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_details_alter
+ /**
+ * Implements hook_field_storage_details_alter()
+ */
+ function `Filename()`_field_storage_details_alter(&$details, $field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_load
+ /**
+ * Implements hook_field_storage_load()
+ */
+ function `Filename()`_field_storage_load($entity_type, &$entities, $age, $fields, $options) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_write
+ /**
+ * Implements hook_field_storage_write()
+ */
+ function `Filename()`_field_storage_write($entity_type, $entity, $op, $fields) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ $etid = _field_sql_storage_etid($entity_type);
+
+ foreach ($fields as $field_id) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_field_storage_delete
+ /**
+ * Implements hook_field_storage_delete()
+ */
+ function `Filename()`_field_storage_delete($entity_type, $entity, $fields) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ $etid = _field_sql_storage_etid($entity_type);
+
+ foreach (field_info_instances($entity_type, $bundle) as $instance) {
+ ${1:/* Your code here */}
+ }
+ }
+snippet h_field_storage_delete_revision
+ /**
+ * Implements hook_field_storage_delete_revision()
+ */
+ function `Filename()`_field_storage_delete_revision($entity_type, $entity, $fields) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ $etid = _field_sql_storage_etid($entity_type);
+
+ if (isset($vid)) {
+ foreach ($fields as $field_id) {
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet h_field_storage_query
+ /**
+ * Implements hook_field_storage_query()
+ */
+ function `Filename()`_field_storage_query($query) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_create_field
+ /**
+ * Implements hook_field_storage_create_field()
+ */
+ function `Filename()`_field_storage_create_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_delete_field
+ /**
+ * Implements hook_field_storage_delete_field()
+ */
+ function `Filename()`_field_storage_delete_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_delete_instance
+ /**
+ * Implements hook_field_storage_delete_instance()
+ */
+ function `Filename()`_field_storage_delete_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_pre_load
+ /**
+ * Implements hook_field_storage_pre_load()
+ */
+ function `Filename()`_field_storage_pre_load($entity_type, $entities, $age, &$skip_fields, $options) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_pre_insert
+ /**
+ * Implements hook_field_storage_pre_insert()
+ */
+ function `Filename()`_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_pre_update
+ /**
+ * Implements hook_field_storage_pre_update()
+ */
+ function `Filename()`_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_info_max_weight
+ /**
+ * Implements hook_field_info_max_weight()
+ */
+ function `Filename()`_field_info_max_weight($entity_type, $bundle, $context) {
+ $weights = array();
+ ${1:/* Your code here */}
+
+ return $weights ? max($weights) : NULL;
+ }
+snippet h_field_display_alter
+ /**
+ * Implements hook_field_display_alter()
+ */
+ function `Filename()`_field_display_alter(&$display, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_display_ENTITY_TYPE_alter
+ /**
+ * Implements hook_field_display_ENTITY_TYPE_alter()
+ */
+ function `Filename()`_field_display_ENTITY_TYPE_alter(&$display, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_extra_fields_display_alter
+ /**
+ * Implements hook_field_extra_fields_display_alter()
+ */
+ function `Filename()`_field_extra_fields_display_alter(&$displays, $context) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_create_field
+ /**
+ * Implements hook_field_create_field()
+ */
+ function `Filename()`_field_create_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_create_instance
+ /**
+ * Implements hook_field_create_instance()
+ */
+ function `Filename()`_field_create_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_update_forbid
+ /**
+ * Implements hook_field_update_forbid()
+ */
+ function `Filename()`_field_update_forbid($field, $prior_field, $has_data) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_update_field
+ /**
+ * Implements hook_field_update_field()
+ */
+ function `Filename()`_field_update_field($field, $prior_field, $has_data) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_delete_field
+ /**
+ * Implements hook_field_delete_field()
+ */
+ function `Filename()`_field_delete_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_update_instance
+ /**
+ * Implements hook_field_update_instance()
+ */
+ function `Filename()`_field_update_instance($instance, $prior_instance) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_delete_instance
+ /**
+ * Implements hook_field_delete_instance()
+ */
+ function `Filename()`_field_delete_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_read_field
+ /**
+ * Implements hook_field_read_field()
+ */
+ function `Filename()`_field_read_field(&$field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_read_instance
+ /**
+ * Implements hook_field_read_instance()
+ */
+ function `Filename()`_field_read_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_purge_field
+ /**
+ * Implements hook_field_purge_field()
+ */
+ function `Filename()`_field_purge_field($field) {
+ db_delete('${1}')
+ ->condition('id', $field['id'])
+ ->execute();
+ }
+snippet h_field_purge_field_instance
+ /**
+ * Implements hook_field_purge_field_instance()
+ */
+ function `Filename()`_field_purge_field_instance($instance) {
+ db_delete('${1}')
+ ->condition('id', $instance['id'])
+ ->execute();
+ }
+snippet h_field_storage_purge_field
+ /**
+ * Implements hook_field_storage_purge_field()
+ */
+ function `Filename()`_field_storage_purge_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet h_field_storage_purge_field_instance
+ /**
+ * Implements hook_field_storage_purge_field_instance()
+ */
+ function `Filename()`_field_storage_purge_field_instance($instance) {
+ db_delete('${1}')
+ ->condition('id', $instance['id'])
+ ->execute();
+ }
+snippet h_field_storage_purge
+ /**
+ * Implements hook_field_storage_purge()
+ */
+ function `Filename()`_field_storage_purge($entity_type, $entity, $field, $instance) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ ${1:/* Your code here */}
+ }
+snippet h_field_access
+ /**
+ * Implements hook_field_access()
+ */
+ function `Filename()`_field_access($op, $field, $entity_type, $entity, $account) {
+ ${1:/* Your code here */}
+ return TRUE;
+ }
+snippet h_options_list
+ /**
+ * Implements hook_options_list()
+ */
+ function `Filename()`_options_list($field) {
+ $options = array(
+ ${1} => ${2},
+ );
+
+ return $options;
+ }
+snippet h_contextual_links_view_alter
+ /**
+ * Implements hook_contextual_links_view_alter()
+ */
+ function `Filename()`_contextual_links_view_alter(&$element, $items) {
+ ${1:/* Your code here */}
+ }
+snippet h_dashboard_regions
+ /**
+ * Implements hook_dashboard_regions()
+ */
+ function `Filename()`_dashboard_regions() {
+ ${1:/* Your code here */}
+ }
+snippet h_dashboard_regions_alter
+ /**
+ * Implements hook_dashboard_regions_alter()
+ */
+ function `Filename()`_dashboard_regions_alter($regions) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_insert
+ /**
+ * Implements hook_menu_insert()
+ */
+ function `Filename()`_menu_insert($menu) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_update
+ /**
+ * Implements hook_menu_update()
+ */
+ function `Filename()`_menu_update($menu) {
+ ${1:/* Your code here */}
+ }
+snippet h_menu_delete
+ /**
+ * Implements hook_menu_delete()
+ */
+ function `Filename()`_menu_delete($menu) {
+ ${1:/* Your code here */}
+ }
+snippet h_path_insert
+ /**
+ * Implements hook_path_insert()
+ */
+ function `Filename()`_path_insert($path) {
+ ${1:/* Your code here */}
+ }
+snippet h_path_update
+ /**
+ * Implements hook_path_update()
+ */
+ function `Filename()`_path_update($path) {
+ ${1:/* Your code here */}
+ }
+snippet h_path_delete
+ /**
+ * Implements hook_path_delete()
+ */
+ function `Filename()`_path_delete($path) {
+ ${1:/* Your code here */}
+ }
+snippet h_shortcut_default_set
+ /**
+ * Implements hook_shortcut_default_set()
+ */
+ function `Filename()`_shortcut_default_set($account) {
+ ${1:/* Your code here */}
+ }
+snippet h_image_effect_info
+ /**
+ * Implements hook_image_effect_info()
+ */
+ function `Filename()`_image_effect_info() {
+ $effects = array();
+
+ $effects['${1}'] = array(
+ 'label' => t('${2}'),
+ 'help' => t('${3}'),
+ 'effect callback' => '${4}',
+ 'form callback' => '${5}',
+ 'summary theme' => '${6}',
+ );
+
+ return $effects;
+ }
+snippet h_image_effect_info_alter
+ /**
+ * Implements hook_image_effect_info_alter()
+ */
+ function `Filename()`_image_effect_info_alter(&$effects) {
+ ${1:/* Your code here */}
+ }
+snippet h_image_style_save
+ /**
+ * Implements hook_image_style_save()
+ */
+ function `Filename()`_image_style_save($style) {
+ ${1:/* Your code here */}
+ }
+snippet h_image_style_delete
+ /**
+ * Implements hook_image_style_delete()
+ */
+ function `Filename()`_image_style_delete($style) {
+ ${1:/* Your code here */}
+ }
+snippet h_image_style_flush
+ /**
+ * Implements hook_image_style_flush()
+ */
+ function `Filename()`_image_style_flush($style) {
+ ${1:/* Your code here */}
+ }
+snippet h_image_styles_alter
+ /**
+ * Implements hook_image_styles_alter()
+ */
+ function `Filename()`_image_styles_alter(&$styles) {
+ ${1:/* Your code here */}
+ }
+snippet h_image_default_styles
+ /**
+ * Implements hook_image_default_styles()
+ */
+ function `Filename()`_image_default_styles() {
+ $styles = array();
+
+ $styles['${1}'] = array(
+ 'effects' => array(
+ array(
+ 'name' => '${2}',
+ 'data' => array('width' => ${3}, 'height' => ${4}, 'upscale' => ${5}),
+ 'weight' => ${6},
+ ),
+ ),
+ );
+
+ return $styles;
+ }
+snippet h_trigger_info
+ /**
+ * Implements hook_trigger_info()
+ */
+ function `Filename()`_trigger_info() {
+ return array(
+ '${1}' => array(
+ '${2}' => array(
+ 'label' => t('${3}'),
+ ),
+ ),
+ );
+ }
+snippet h_trigger_info_alter
+ /**
+ * Implements hook_trigger_info_alter()
+ */
+ function `Filename()`_trigger_info_alter(&$triggers) {
+ ${1:/* Your code here */}
+ }
+snippet h_search_info
+ /**
+ * Implements hook_search_info()
+ */
+ function `Filename()`_search_info() {
+ return array(
+ 'title' => '${1}',
+ 'path' => '${2}',
+ 'conditions_callback' => '${3}',
+ );
+ }
+snippet h_search_access
+ /**
+ * Implements hook_search_access()
+ */
+ function `Filename()`_search_access() {
+ ${1:/* Your code here */}
+ }
+snippet h_search_reset
+ /**
+ * Implements hook_search_reset()
+ */
+ function `Filename()`_search_reset() {
+ ${1:/* Your code here */}
+ }
+snippet h_search_status
+ /**
+ * Implements hook_search_status()
+ */
+ function `Filename()`_search_status() {
+ ${1:/* Your code here */}
+ }
+snippet h_search_admin
+ /**
+ * Implements hook_search_admin()
+ */
+ function `Filename()`_search_admin() {
+ $form['${1}'] = array(
+ '#title' => t('${2}'),
+ '#type' => '${3}',
+ '#theme' => '${4}',
+ '#default_value' => ${5},
+
+ return $form;
+ }
+snippet h_search_execute
+ /**
+ * Implements hook_search_execute()
+ */
+ function `Filename()`_search_execute($keys = NULL, $conditions = NULL) {
+ ${1:/* Your code here */}
+ }
+snippet h_search_page
+ /**
+ * Implements hook_search_page()
+ */
+ function `Filename()`_search_page($results) {
+ $output['prefix']['#markup'] = '<ol class="search-results">';
+
+ foreach ($results as $entry) {
+ $output[] = array(
+ '#theme' => '${1}',
+ '#result' => $entry,
+ '#module' => '${2}',
+ );
+ }
+ $output['suffix']['#markup'] = '</ol>' . theme('pager');
+
+ return $output;
+ }
+snippet h_search_preprocess
+ /**
+ * Implements hook_search_preprocess()
+ */
+ function `Filename()`_search_preprocess($text) {
+ ${1:/* Your code here */}
+ }
+snippet h_update_index
+ /**
+ * Implements hook_update_index()
+ */
+ function `Filename()`_update_index() {
+ ${1:/* Your code here */}
+ }
+snippet h_locale
+ /**
+ * Implements hook_locale()
+ */
+ function `Filename()`_locale($op = 'groups') {
+ switch ($op) {
+ case '${1}':
+ return array('${2}' => t('${3}'));
+ }
+ }
+snippet h_language_init
+ /**
+ * Implements hook_language_init()
+ */
+ function `Filename()`_language_init() {
+ global $language, $conf;
+
+ switch ($language->language) {
+ case '${1}':
+ $conf['${2}'] = '${3}';
+ break;
+ }
+ }
+snippet h_language_switch_links_alter
+ /**
+ * Implements hook_language_switch_links_alter()
+ */
+ function `Filename()`_language_switch_links_alter(array &$links, $type, $path) {
+ global $language;
+ ${1:/* Your code here */}
+ }
+snippet h_language_types_info
+ /**
+ * Implements hook_language_types_info()
+ */
+ function `Filename()`_language_types_info() {
+ return array(
+ '${1}' => array(
+ 'name' => t('${2}'),
+ 'description' => t('${3}'),
+ ),
+ );
+ }
+snippet h_language_types_info_alter
+ /**
+ * Implements hook_language_types_info_alter()
+ */
+ function `Filename()`_language_types_info_alter(array &$language_types) {
+ ${1:/* Your code here */}
+ }
+snippet h_language_negotiation_info
+ /**
+ * Implements hook_language_negotiation_info()
+ */
+ function `Filename()`_language_negotiation_info() {
+ return array(
+ '${1}' => array(
+ 'callbacks' => array(
+ 'language' => '${2}',
+ 'switcher' => '${3}',
+ 'url_rewrite' => '${4}',
+ ),
+ 'file' => drupal_get_path('module', '${5}') . '/${6}',
+ 'weight' => ${7},
+ 'types' => array('${8}'),
+ 'name' => t('${9}'),
+ 'description' => t('${10}'),
+ 'cache' => ${11},
+ ),
+ );
+ }
+snippet h_language_negotiation_info_alter
+ /**
+ * Implements hook_language_negotiation_info_alter()
+ */
+ function `Filename()`_language_negotiation_info_alter(array &$language_providers) {
+ ${1:/* Your code here */}
+ }
+snippet h_multilingual_settings_changed
+ /**
+ * Implements hook_multilingual_settings_changed()
+ */
+ function `Filename()`_multilingual_settings_changed() {
+ ${1:/* Your code here */}
+ }
+snippet h_language_fallback_candidates_alter
+ /**
+ * Implements hook_language_fallback_candidates_alter()
+ */
+ function `Filename()`_language_fallback_candidates_alter(array &$fallback_candidates) {
+ ${1:/* Your code here */}
+ }
+snippet hook_simpletest_alter
+ /**
+ * Implements hook_simpletest_alter()
+ */
+ function `Filename()`_simpletest_alter(&$groups) {
+ // An alternative session handler module would not want to run the original
+ // Session https handling test because it checks the sessions table in the
+ // database.
+ /*
+ *unset($groups['Session']['testHttpsSession']);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_test_group_started
+ /**
+ * Implements hook_test_group_started()
+ */
+ function `Filename()`_test_group_started() {
+ ${1:/* Your code here */}
+ }
+snippet hook_test_group_finished
+ /**
+ * Implements hook_test_group_finished()
+ */
+ function `Filename()`_test_group_finished() {
+ ${1:/* Your code here */}
+ }
+snippet hook_test_finished
+ /**
+ * Implements hook_test_finished()
+ */
+ function `Filename()`_test_finished($results) {
+ ${1:/* Your code here */}
+ }
+snippet hook_aggregator_fetch
+ /**
+ * Implements hook_aggregator_fetch()
+ */
+ function `Filename()`_aggregator_fetch($feed) {
+ /*
+ *$feed->source_string = mymodule_fetch($feed->url);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_aggregator_fetch_info
+ /**
+ * Implements hook_aggregator_fetch_info()
+ */
+ function `Filename()`_aggregator_fetch_info() {
+ return array(
+ 'title' => t('${1}'),
+ 'description' => t('${2}'),
+ );
+ }
+snippet hook_aggregator_parse
+ /**
+ * Implements hook_aggregator_parse()
+ */
+ function `Filename()`_aggregator_parse($feed) {
+ /*
+ *if ($items = mymodule_parse($feed->source_string)) {
+ * $feed->items = $items;
+ * return TRUE;
+ *}
+ *return FALSE;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_aggregator_parse_info
+ /**
+ * Implements hook_aggregator_parse_info()
+ */
+ function `Filename()`_aggregator_parse_info() {
+ return array(
+ 'title' => t('${1}'),
+ 'description' => t('${2}'),
+ );
+ }
+snippet hook_aggregator_process
+ /**
+ * Implements hook_aggregator_process()
+ */
+ function `Filename()`_aggregator_process($feed) {
+ /*
+ *foreach ($feed->items as $item) {
+ * mymodule_save($item);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_aggregator_process_info
+ /**
+ * Implements hook_aggregator_process_info()
+ */
+ function `Filename()`_aggregator_process_info($feed) {
+ return array(
+ 'title' => t('${1}'),
+ 'description' => t('${2}'),
+ );
+ }
+snippet hook_aggregator_remove
+ /**
+ * Implements hook_aggregator_remove()
+ */
+ function `Filename()`_aggregator_remove($feed) {
+ /*
+ *mymodule_remove_items($feed->fid);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_overlay_parent_initialize
+ /**
+ * Implements hook_overlay_parent_initialize()
+ */
+ function `Filename()`_overlay_parent_initialize() {
+ // Add our custom JavaScript.
+ /*
+ *drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay.js');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_overlay_child_initialize
+ /**
+ * Implements hook_overlay_child_initialize()
+ */
+ function `Filename()`_overlay_child_initialize() {
+ // Add our custom JavaScript.
+ /*
+ *drupal_add_js(drupal_get_path('module', 'hook') . '/hook-overlay-child.js');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_entity_info
+ /**
+ * Implements hook_entity_info()
+ */
+ function `Filename()`_entity_info() {
+ /*
+ * $return = array(
+ * 'node' => array(
+ * 'label' => t('Node'),
+ * 'controller class' => 'NodeController',
+ * 'base table' => 'node',
+ * 'revision table' => 'node_revision',
+ * 'uri callback' => 'node_uri',
+ * 'fieldable' => TRUE,
+ * 'translation' => array(
+ * 'locale' => TRUE,
+ * ),
+ * 'entity keys' => array(
+ * 'id' => 'nid',
+ * 'revision' => 'vid',
+ * 'bundle' => 'type',
+ * ),
+ * 'bundle keys' => array(
+ * 'bundle' => 'type',
+ * ),
+ * 'bundles' => array(),
+ * 'view modes' => array(
+ * 'full' => array(
+ * 'label' => t('Full content'),
+ * 'custom settings' => FALSE,
+ * ),
+ * 'teaser' => array(
+ * 'label' => t('Teaser'),
+ * 'custom settings' => TRUE,
+ * ),
+ * 'rss' => array(
+ * 'label' => t('RSS'),
+ * 'custom settings' => FALSE,
+ * ),
+ * ),
+ * ),
+ * );
+ *
+ * // Search integration is provided by node.module, so search-related
+ * // view modes for nodes are defined here and not in search.module.
+ * if (module_exists('search')) {
+ * $return['node']['view modes'] += array(
+ * 'search_index' => array(
+ * 'label' => t('Search index'),
+ * 'custom settings' => FALSE,
+ * ),
+ * 'search_result' => array(
+ * 'label' => t('Search result'),
+ * 'custom settings' => FALSE,
+ * ),
+ * );
+ * }
+ *
+ * // Bundles must provide a human readable name so we can create help and error
+ * // messages, and the path to attach Field admin pages to.
+ * foreach (node_type_get_names() as $type => $name) {
+ * $return['node']['bundles'][$type] = array(
+ * 'label' => $name,
+ * 'admin' => array(
+ * 'path' => 'admin/structure/types/manage/%node_type',
+ * 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type),
+ * 'bundle argument' => 4,
+ * 'access arguments' => array('administer content types'),
+ * ),
+ * );
+ * }
+ */
+ 'node' => array(
+ 'label' => t('${1}'),
+ 'controller class' => '${2}',
+ 'base table' => '${3}',
+ 'revision table' => '${4}',
+ 'uri callback' => '${5}',
+ 'fieldable' => ${6},
+ 'translation' => array(
+ 'locale' => ${7},
+ ),
+ 'entity keys' => array(
+ 'id' => '${8}',
+ 'revision' => '${9}',
+ 'bundle' => '${10}',
+ ),
+ 'bundle keys' => array(
+ 'bundle' => '${11}',
+ ),
+ 'bundles' => array(),
+ 'view modes' => array(
+ '${12}' => array(
+ 'label' => t('${13}'),
+ 'custom settings' => ${14},
+ ),
+ ),
+ ),
+ );
+ return $return;
+ }
+snippet hook_entity_info_alter
+ /**
+ * Implements hook_entity_info_alter()
+ */
+ function `Filename()`_entity_info_alter(&$entity_info) {
+ // Set the controller class for nodes to an alternate implementation of the
+ // DrupalEntityController interface.
+ /*
+ *$entity_info['node']['controller class'] = 'MyCustomNodeController';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_entity_load
+ /**
+ * Implements hook_entity_load()
+ */
+ function `Filename()`_entity_load($entities, $type) {
+ foreach ($entities as $entity) {
+ $entity->${1} = mymodule_add_something($entity, $type);
+ }
+ }
+snippet hook_entity_insert
+ /**
+ * Implements hook_entity_insert()
+ */
+ function `Filename()`_entity_insert($entity, $type) {
+ ${1:/* Your code here */}
+ }
+snippet hook_entity_update
+ /**
+ * Implements hook_entity_update()
+ */
+ function `Filename()`_entity_update($entity, $type) {
+ ${1:/* Your code here */}
+ }
+snippet hook_entity_query_alter
+ /**
+ * Implements hook_entity_query_alter()
+ */
+ function `Filename()`_entity_query_alter($query) {
+ $query->${1} = 'my_module_query_callback';
+ }
+snippet hook_admin_paths
+ /**
+ * Implements hook_admin_paths()
+ */
+ function `Filename()`_admin_paths() {
+ $paths = array(
+ /*
+ *'mymodule/* /add' => TRUE,
+ *'mymodule/* /edit' => TRUE,
+ */
+ ${1:/* Your code here */}
+ );
+ return $paths;
+ }
+snippet hook_admin_paths_alter
+ /**
+ * Implements hook_admin_paths_alter()
+ */
+ function `Filename()`_admin_paths_alter(&$paths) {
+ // Treat all user pages as administrative.
+ /*
+ *$paths['user'] = TRUE;
+ *$paths['user/*'] = TRUE;
+ */
+ // Treat the forum topic node form as a non-administrative page.
+ /*
+ *$paths['node/add/forum'] = FALSE;
+ */
+ $paths['${1}'] = ${2};
+ }
+snippet hook_entity_prepare_view
+ /**
+ * Implements hook_entity_prepare_view()
+ */
+ function `Filename()`_entity_prepare_view($entities, $type) {
+ // Load a specific node into the user object for later theming.
+ /*
+ *if ($type == 'user') {
+ * $nodes = mymodule_get_user_nodes(array_keys($entities));
+ * foreach ($entities as $uid => $entity) {
+ * $entity->user_node = $nodes[$uid];
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_cron
+ /**
+ * Implements hook_cron()
+ */
+ function `Filename()`_cron() {
+ /*
+ * // Short-running operation example, not using a queue:
+ * // Delete all expired records since the last cron run.
+ * $expires = variable_get('mymodule_cron_last_run', REQUEST_TIME);
+ * db_delete('mymodule_table')
+ * ->condition('expires', $expires, '>=')
+ * ->execute();
+ * variable_set('mymodule_cron_last_run', REQUEST_TIME);
+ *
+ * // Long-running operation example, leveraging a queue:
+ * // Fetch feeds from other sites.
+ * $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh != :never', array(
+ * ':time' => REQUEST_TIME,
+ * ':never' => AGGREGATOR_CLEAR_NEVER,
+ * ));
+ * $queue = DrupalQueue::get('aggregator_feeds');
+ * foreach ($result as $feed) {
+ * $queue->createItem($feed);
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_cron_queue_info
+ /**
+ * Implements hook_cron_queue_info()
+ */
+ function `Filename()`_cron_queue_info() {
+ /*
+ *$queues['aggregator_feeds'] = array(
+ * 'worker callback' => 'aggregator_refresh',
+ * 'time' => 60,
+ *);
+ */
+ $queues['${1}'] = array(
+ 'worker callback' => '${2}',
+ 'time' => ${3},
+ );
+ return $queues;
+ }
+snippet hook_cron_queue_info_alter
+ /**
+ * Implements hook_cron_queue_info_alter()
+ */
+ function `Filename()`_cron_queue_info_alter(&$queues) {
+ // This site has many feeds so let's spend 90 seconds on each cron run
+ // updating feeds instead of the default 60.
+ /*
+ *$queues['aggregator_feeds']['time'] = 90;
+ */
+ $queues['${1}']['time'] = ${2};
+ }
+snippet hook_element_info
+ /**
+ * Implements hook_element_info()
+ */
+ function `Filename()`_element_info() {
+ $types['${1}'] = array(
+ ${2:/* Your code here */}
+ );
+ return $types;
+ }
+snippet hook_element_info_alter
+ /**
+ * Implements hook_element_info_alter()
+ */
+ function `Filename()`_element_info_alter(&$type) {
+ // Decrease the default size of textfields.
+ /*
+ *if (isset($type['textfield']['#size'])) {
+ * $type['textfield']['#size'] = 40;
+ *}
+ */
+ if (isset($type['${1}'])) {
+ $type['${2}'] = ${3};
+ }
+ }
+snippet hook_exit
+ /**
+ * Implements hook_exit()
+ */
+ function `Filename()`_exit($destination = NULL) {
+ /*
+ *db_update('counter')
+ * ->expression('hits', 'hits + 1')
+ * ->condition('type', 1)
+ * ->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_js_alter
+ /**
+ * Implements hook_js_alter()
+ */
+ function `Filename()`_js_alter(&$javascript) {
+ // Swap out jQuery to use an updated version of the library.
+ /*
+ *$javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_library
+ /**
+ * Implements hook_library()
+ */
+ function `Filename()`_library() {
+ // Library One.
+ /*
+ *$libraries['library-1'] = array(
+ * 'title' => 'Library One',
+ * 'website' => 'http://example.com/library-1',
+ * 'version' => '1.2',
+ * 'js' => array(
+ * drupal_get_path('module', 'my_module') . '/library-1.js' => array(),
+ * ),
+ * 'css' => array(
+ * drupal_get_path('module', 'my_module') . '/library-2.css' => array(
+ * 'type' => 'file',
+ * 'media' => 'screen',
+ * ),
+ * ),
+ *);
+ */
+ // Library Two.
+ /*
+ *$libraries['library-2'] = array(
+ * 'title' => 'Library Two',
+ * 'website' => 'http://example.com/library-2',
+ * 'version' => '3.1-beta1',
+ * 'js' => array(
+ * // JavaScript settings may use the 'data' key.
+ * array(
+ * 'type' => 'setting',
+ * 'data' => array('library2' => TRUE),
+ * ),
+ * ),
+ * 'dependencies' => array(
+ * // Require jQuery UI core by System module.
+ * array('system', 'ui'),
+ * // Require our other library.
+ * array('my_module', 'library-1'),
+ * // Require another library.
+ * array('other_module', 'library-3'),
+ * ),
+ *);
+ */
+ $libraries['${1}'] = array(
+ 'title' => '${2}',
+ 'website' => '${3}',
+ 'version' => '${4}',
+ 'js' => array(
+ drupal_get_path('module', 'my_module') . '/${5}' => array(),
+ ),
+ 'css' => array(
+ drupal_get_path('module', 'my_module') . '/${6}' => array(
+ 'type' => 'file',
+ 'media' => '${7}',
+ ),
+ ),
+ 'dependencies' => array(
+ // Require jQuery UI core by System module.
+ array('system', 'ui'),
+ ),
+ );
+ return $libraries;
+ }
+snippet hook_library_alter
+ /**
+ * Implements hook_library_alter()
+ */
+ function `Filename()`_library_alter(&$libraries, $module) {
+ // Update Farbtastic to version 2.0.
+ /*
+ *if ($module == 'system' && isset($libraries['farbtastic'])) {
+ * // Verify existing version is older than the one we are updating to.
+ * if (version_compare($libraries['farbtastic']['version'], '2.0', '<')) {
+ * // Update the existing Farbtastic to version 2.0.
+ * $libraries['farbtastic']['version'] = '2.0';
+ * $libraries['farbtastic']['js'] = array(
+ * drupal_get_path('module', 'farbtastic_update') . '/farbtastic-2.0.js' => array(),
+ * );
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_css_alter
+ /**
+ * Implements hook_css_alter()
+ */
+ function `Filename()`_css_alter(&$css) {
+ // Remove defaults.css file.
+ /*
+ *unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_ajax_render_alter
+ /**
+ * Implements hook_ajax_render_alter()
+ */
+ function `Filename()`_ajax_render_alter($commands) {
+ // Inject any new status messages into the content area.
+ /*
+ *$commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
+ */
+ $commands[] = ${1}
+ }
+snippet hook_page_build
+ /**
+ * Implements hook_page_build()
+ */
+ function `Filename()`_page_build(&$page) {
+ /*
+ *if (menu_get_object('node', 1)) {
+ * // We are on a node detail page. Append a standard disclaimer to the
+ * // content region.
+ * $page['content']['disclaimer'] = array(
+ * '#markup' => t('Acme, Inc. is not responsible for the contents of this sample code.'),
+ * '#weight' => 25,
+ * );
+ *}
+ */
+ $page['${1}']['${2}'] = array(
+ '#markup' => t('${3}'),
+ '#weight' => ${4},
+ );
+ }
+snippet hook_menu
+ /**
+ * Implements hook_menu()
+ */
+ function `Filename()`_menu() {
+ /*
+ *$items['blog'] = array(
+ * 'title' => 'blogs',
+ * 'page callback' => 'blog_page',
+ * 'access arguments' => array('access content'),
+ * 'type' => MENU_SUGGESTED_ITEM,
+ *);
+ */
+ $items['${1}'] = array(
+ 'title' => '${2}',
+ 'page callback' => '${3}',
+ 'page arguments' => array('${4}'),
+ 'access arguments' => array('${5}'),
+ 'type' => ${6},
+ 'file' => ${7},
+ );
+
+ return $items;
+ }
+snippet hook_menu_alter
+ /**
+ * Implements hook_menu_alter()
+ */
+ function `Filename()`_menu_alter(&$items) {
+ // Example - disable the page at node/add
+ /*
+ *$items['node/add']['access callback'] = FALSE;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_link_alter
+ /**
+ * Implements hook_menu_link_alter()
+ */
+ function `Filename()`_menu_link_alter(&$item) {
+ // Example 1 - make all new admin links hidden (a.k.a disabled).
+ /*
+ *if (strpos($item['link_path'], 'admin') === 0 && empty($item['mlid'])) {
+ * $item['hidden'] = 1;
+ *}
+ */
+ // Example 2 - flag a link to be altered by hook_translated_menu_link_alter()
+ /*
+ *if ($item['link_path'] == 'devel/cache/clear') {
+ * $item['options']['alter'] = TRUE;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_translated_menu_link_alter
+ /**
+ * Implements hook_translated_menu_link_alter()
+ */
+ function `Filename()`_translated_menu_link_alter(&$item, $map) {
+ /*
+ *if ($item['href'] == 'devel/cache/clear') {
+ * $item['localized_options']['query'] = drupal_get_destination();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_link_insert
+ /**
+ * Implements hook_menu_link_insert()
+ */
+ function `Filename()`_menu_link_insert($link) {
+ // In our sample case, we track menu items as editing sections
+ // of the site. These are stored in our table as 'disabled' items.
+ /*
+ *$record['mlid'] = $link['mlid'];
+ *$record['menu_name'] = $link['menu_name'];
+ *$record['status'] = 0;
+ *drupal_write_record('menu_example', $record);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_link_update
+ /**
+ * Implements hook_menu_link_update()
+ */
+ function `Filename()`_menu_link_update($link) {
+ // If the parent menu has changed, update our record.
+ /*
+ *$menu_name = db_result(db_query("SELECT mlid, menu_name, status FROM {menu_example} WHERE mlid = :mlid", array(':mlid' => $link['mlid'])));
+ *if ($menu_name != $link['menu_name']) {
+ * db_update('menu_example')
+ * ->fields(array('menu_name' => $link['menu_name']))
+ * ->condition('mlid', $link['mlid'])
+ * ->execute();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_link_delete
+ /**
+ * Implements hook_menu_link_delete()
+ */
+ function `Filename()`_menu_link_delete($link) {
+ // Delete the record from our table.
+ db_delete('${1}')
+ ->condition('mlid', $link['mlid'])
+ ->execute();
+ }
+snippet hook_menu_local_tasks_alter
+ /**
+ * Implements hook_menu_local_tasks_alter()
+ */
+ function `Filename()`_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+ // Add an action to all pages.
+ // $data['actions']['output'][] = array(
+ //
+ // Add a tab to all pages.
+ /*
+ *$data['tabs'][0]['output'][] = array(
+ * '#theme' => 'menu_local_task',
+ * '#link' => array(
+ * 'title' => t('${1}'),
+ * 'href' => '${2}',
+ * 'localized_options' => array(
+ * 'attributes' => array(
+ * 'title' => t('${3}'),
+ * ),
+ * ),
+ * ),
+ * // Define whether this link is active. This can be omitted for
+ * // implementations that add links to pages outside of the current page
+ * // context.
+ * '#active' => ($router_item['path'] == $root_path),
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_breadcrumb_alter
+ /**
+ * Implements hook_menu_breadcrumb_alter()
+ */
+ function `Filename()`_menu_breadcrumb_alter(&$active_trail, $item) {
+ // Always display a link to the current page by duplicating the last link in
+ // the active trail. This means that menu_get_active_breadcrumb() will remove
+ // the last link (for the current page), but since it is added once more here,
+ // it will appear.
+ /*
+ *if (!drupal_is_front_page()) {
+ * $end = end($active_trail);
+ * if ($item['href'] == $end['href']) {
+ * $active_trail[] = $end;
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_contextual_links_alter
+ /**
+ * Implements hook_menu_contextual_links_alter()
+ */
+ function `Filename()`_menu_contextual_links_alter(&$links, $router_item, $root_path) {
+ // Add a link to all contextual links for nodes.
+ /*
+ *if ($root_path == 'node/%') {
+ * $links['foo'] = array(
+ * 'title' => t('Do fu'),
+ * 'href' => 'foo/do',
+ * 'localized_options' => array(
+ * 'query' => array(
+ * 'foo' => 'bar',
+ * ),
+ * ),
+ * );
+ *}
+ */
+ if ($root_path == '${1}') {
+ $links['${2}'] = array(
+ 'title' => t('${3}'),
+ 'href' => '${4}',
+ 'localized_options' => array(
+ 'query' => array(
+ '${5}' => '${6}',
+ ),
+ ),
+ );
+ }
+ }
+snippet hook_page_alter
+ /**
+ * Implements hook_page_alter()
+ */
+ function `Filename()`_page_alter(&$page) {
+ // Add help text to the user login block.
+ /*
+ *$page['sidebar_first']['user_login']['help'] = array(
+ * '#weight' => -10,
+ * '#markup' => t('To post comments or add new content, you first have to log in.'),
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_form_alter
+ /**
+ * Implements hook_form_alter()
+ */
+ function `Filename()`_form_alter(&$form, &$form_state, $form_id) {
+ /*
+ *if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
+ * $form['workflow']['upload_' . $form['type']['#value']] = array(
+ * '#type' => 'radios',
+ * '#title' => t('Attachments'),
+ * '#default_value' => variable_get('upload_' . $form['type']['#value'], 1),
+ * '#options' => array(t('Disabled'), t('Enabled')),
+ * );
+ *}
+ */
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ }
+snippet hook_forms
+ /**
+ * Implements hook_forms()
+ */
+ function `Filename()`_forms($form_id, $args) {
+ // Simply reroute the (non-existing) $form_id 'mymodule_first_form' to
+ // 'mymodule_main_form'.
+ /*
+ *$forms['mymodule_first_form'] = array(
+ * 'callback' => 'mymodule_main_form',
+ *);
+ */
+ // Reroute the $form_id and prepend an additional argument that gets passed to
+ // the 'mymodule_main_form' form builder function.
+ /*
+ *$forms['mymodule_second_form'] = array(
+ * 'callback' => 'mymodule_main_form',
+ * 'callback arguments' => array('some parameter'),
+ *);
+ */
+ // Reroute the $form_id, but invoke the form builder function
+ // 'mymodule_main_form_wrapper' first, so we can prepopulate the $form array
+ // that is passed to the actual form builder 'mymodule_main_form'.
+ /*
+ *$forms['mymodule_wrapped_form'] = array(
+ * 'callback' => 'mymodule_main_form',
+ * 'wrapper_callback' => 'mymodule_main_form_wrapper',
+ *);
+ */
+ $forms['${1}'] = array(
+ 'callback' => '${2}',
+ 'callback arguments' => array('${3}'),
+ );
+
+ return $forms;
+ }
+snippet hook_boot
+ /**
+ * Implements hook_boot()
+ */
+ function `Filename()`_boot() {
+ // we need user_access() in the shutdown function. make sure it gets loaded
+ /*
+ *drupal_load('module', 'user');
+ *drupal_register_shutdown_function('devel_shutdown');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_init
+ /**
+ * Implements hook_init()
+ */
+ function `Filename()`_init() {
+ /*
+ *drupal_add_css(drupal_get_path('module', 'book') . '/book.css');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_toolkits
+ /**
+ * Implements hook_image_toolkits()
+ */
+ function `Filename()`_image_toolkits() {
+ return array(
+ '${1}' => array(
+ 'title' => t('${2}'),
+ 'available' => TRUE,
+ ),
+ );
+ }
+snippet hook_mail_alter
+ /**
+ * Implements hook_mail_alter()
+ */
+ function `Filename()`_mail_alter(&$message) {
+ /*
+ *if ($message['id'] == 'modulename_messagekey') {
+ * $message['body'][] = "--\nMail sent out from " . variable_get('sitename', t('Drupal'));
+ *}
+ */
+ if ($message['id'] == '${1}') {
+ $message['body'][] = "${2}";
+ }
+ }
+snippet hook_module_implements_alter
+ /**
+ * Implements hook_module_implements_alter()
+ */
+ function `Filename()`_module_implements_alter(&$implementations, $hook) {
+ /*
+ *if ($hook == 'rdf_mapping') {
+ * // Move my_module_rdf_mapping() to the end of the list. module_implements()
+ * // iterates through $implementations with a foreach loop which PHP iterates
+ * // in the order that the items were added, so to move an item to the end of
+ * // the array, we remove it and then add it.
+ * $group = $implementations['my_module'];
+ * unset($implementations['my_module']);
+ * $implementations['my_module'] = $group;
+ *}
+ */
+ if ($hook == '${1}') {
+ ${2:/* Your code here */}
+ }
+ }
+snippet hook_system_info_alter
+ /**
+ * Implements hook_system_info_alter()
+ */
+ function `Filename()`_system_info_alter(&$info, $file, $type) {
+ // Only fill this in if the .info file does not define a 'datestamp'.
+ /*
+ *if (empty($info['datestamp'])) {
+ * $info['datestamp'] = filemtime($file->filename);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_permission
+ /**
+ * Implements hook_permission()
+ */
+ function `Filename()`_permission() {
+ return array(
+ /*
+ *'administer my module' => array(
+ * 'title' => t('Administer my module'),
+ * 'description' => t('Perform administration tasks for my module.'),
+ *),
+ */
+ '${1}' => array(
+ 'title' => t('${2}'),
+ 'description' => t('${3}'),
+ ),
+ );
+ }
+snippet hook_theme
+ /**
+ * Implements hook_theme()
+ */
+ function `Filename()`_theme($existing, $type, $theme, $path) {
+ return array(
+ /*
+ *'forum_icon' => array(
+ * 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
+ *),
+ *'status_report' => array(
+ * 'render element' => 'requirements',
+ * 'file' => 'system.admin.inc',
+ *),
+ */
+ '${1}' => array(
+ 'render element' => '${2}',
+ 'file' => '${3}',
+ 'variables' => array('${4}' => NULL, '${5}' => NULL${6}),
+ ),
+ );
+ }
+snippet hook_theme_registry_alter
+ /**
+ * Implements hook_theme_registry_alter()
+ */
+ function `Filename()`_theme_registry_alter(&$theme_registry) {
+ // Kill the next/previous forum topic navigation links.
+ /*
+ *foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
+ * if ($value = 'template_preprocess_forum_topic_navigation') {
+ * unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_custom_theme
+ /**
+ * Implements hook_custom_theme()
+ */
+ function `Filename()`_custom_theme() {
+ // Allow the user to request a particular theme via a query parameter.
+ /*
+ *if (isset($_GET['theme'])) {
+ * return $_GET['theme'];
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_xmlrpc
+ /**
+ * Implements hook_xmlrpc()
+ */
+ function `Filename()`_xmlrpc() {
+ /*
+ *return array(
+ * 'drupal.login' => 'drupal_login',
+ * array(
+ * 'drupal.site.ping',
+ * 'drupal_directory_ping',
+ * array('boolean', 'string', 'string', 'string', 'string', 'string'),
+ * t('Handling ping request'))
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_xmlrpc_alter
+ /**
+ * Implements hook_xmlrpc_alter()
+ */
+ function `Filename()`_xmlrpc_alter(&$methods) {
+ // Directly change a simple method.
+ /*
+ *$methods['drupal.login'] = 'mymodule_login';
+ */
+ // Alter complex definitions.
+ /*
+ *foreach ($methods as $key => &$method) {
+ * // Skip simple method definitions.
+ * if (!is_int($key)) {
+ * continue;
+ * }
+ * // Perform the wanted manipulation.
+ * if ($method[0] == 'drupal.site.ping') {
+ * $method[1] = 'mymodule_directory_ping';
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_watchdog
+ /**
+ * Implements hook_watchdog()
+ */
+ function `Filename()`_watchdog(array $log_entry) {
+ /*
+ * global $base_url, $language;
+ *
+ * $severity_list = array(
+ * WATCHDOG_EMERGENCY => t('Emergency'),
+ * WATCHDOG_ALERT => t('Alert'),
+ * WATCHDOG_CRITICAL => t('Critical'),
+ * WATCHDOG_ERROR => t('Error'),
+ * WATCHDOG_WARNING => t('Warning'),
+ * WATCHDOG_NOTICE => t('Notice'),
+ * WATCHDOG_INFO => t('Info'),
+ * WATCHDOG_DEBUG => t('Debug'),
+ * );
+ *
+ * $to = 'someone@example.com';
+ * $params = array();
+ * $params['subject'] = t('[@site_name] @severity_desc: Alert from your web site', array(
+ * '@site_name' => variable_get('site_name', 'Drupal'),
+ * '@severity_desc' => $severity_list[$log_entry['severity']],
+ * ));
+ *
+ * $params['message'] = "\nSite: @base_url";
+ * $params['message'] .= "\nSeverity: (@severity) @severity_desc";
+ * $params['message'] .= "\nTimestamp: @timestamp";
+ * $params['message'] .= "\nType: @type";
+ * $params['message'] .= "\nIP Address: @ip";
+ * $params['message'] .= "\nRequest URI: @request_uri";
+ * $params['message'] .= "\nReferrer URI: @referer_uri";
+ * $params['message'] .= "\nUser: (@uid) @name";
+ * $params['message'] .= "\nLink: @link";
+ * $params['message'] .= "\nMessage: \n\n@message";
+ *
+ * $params['message'] = t($params['message'], array(
+ * '@base_url' => $base_url,
+ * '@severity' => $log_entry['severity'],
+ * '@severity_desc' => $severity_list[$log_entry['severity']],
+ * '@timestamp' => format_date($log_entry['timestamp']),
+ * '@type' => $log_entry['type'],
+ * '@ip' => $log_entry['ip'],
+ * '@request_uri' => $log_entry['request_uri'],
+ * '@referer_uri' => $log_entry['referer'],
+ * '@uid' => $log_entry['user']->uid,
+ * '@name' => $log_entry['user']->name,
+ * '@link' => strip_tags($log_entry['link']),
+ * '@message' => strip_tags($log_entry['message']),
+ * ));
+ *
+ * drupal_mail('emaillog', 'entry', $to, $language, $params);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_mail
+ /**
+ * Implements hook_mail()
+ */
+ function `Filename()`_mail($key, &$message, $params) {
+ /*
+ * $account = $params['account'];
+ * $context = $params['context'];
+ * $variables = array(
+ * '%site_name' => variable_get('site_name', 'Drupal'),
+ * '%username' => format_username($account),
+ * );
+ * if ($context['hook'] == 'taxonomy') {
+ * $entity = $params['entity'];
+ * $vocabulary = taxonomy_vocabulary_load($entity->vid);
+ * $variables += array(
+ * '%term_name' => $entity->name,
+ * '%term_description' => $entity->description,
+ * '%term_id' => $entity->tid,
+ * '%vocabulary_name' => $vocabulary->name,
+ * '%vocabulary_description' => $vocabulary->description,
+ * '%vocabulary_id' => $vocabulary->vid,
+ * );
+ * }
+ *
+ * // Node-based variable translation is only available if we have a node.
+ * if (isset($params['node'])) {
+ * $node = $params['node'];
+ * $variables += array(
+ * '%uid' => $node->uid,
+ * '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)),
+ * '%node_type' => node_type_get_name($node),
+ * '%title' => $node->title,
+ * '%teaser' => $node->teaser,
+ * '%body' => $node->body,
+ * );
+ * }
+ * $subject = strtr($context['subject'], $variables);
+ * $body = strtr($context['message'], $variables);
+ * $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
+ * $message['body'][] = drupal_html_to_text($body);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_flush_caches
+ /**
+ * Implements hook_flush_caches()
+ */
+ function `Filename()`_flush_caches() {
+ /*
+ *return array('cache_example');
+ */
+ return array('${1}');
+ }
+snippet hook_modules_installed
+ /**
+ * Implements hook_modules_installed()
+ */
+ function `Filename()`_modules_installed($modules) {
+ /*
+ *if (in_array('lousy_module', $modules)) {
+ * variable_set('lousy_module_conflicting_variable', FALSE);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_modules_enabled
+ /**
+ * Implements hook_modules_enabled()
+ */
+ function `Filename()`_modules_enabled($modules) {
+ /*
+ *if (in_array('lousy_module', $modules)) {
+ * drupal_set_message(t('mymodule is not compatible with lousy_module'), 'error');
+ * mymodule_disable_functionality();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_modules_disabled
+ /**
+ * Implements hook_modules_disabled()
+ */
+ function `Filename()`_modules_disabled($modules) {
+ /*
+ *if (in_array('lousy_module', $modules)) {
+ * mymodule_enable_functionality();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_modules_uninstalled
+ /**
+ * Implements hook_modules_uninstalled()
+ */
+ function `Filename()`_modules_uninstalled($modules) {
+ foreach ($modules as $module) {
+ db_delete('${1}')
+ ->condition('module', $module)
+ ->execute();
+ }
+ ${2}_cache_rebuild();
+ }
+snippet hook_stream_wrappers
+ /**
+ * Implements hook_stream_wrappers()
+ */
+ function `Filename()`_stream_wrappers() {
+ return array(
+ /*
+ *'public' => array(
+ * 'name' => t('Public files'),
+ * 'class' => 'DrupalPublicStreamWrapper',
+ * 'description' => t('Public local files served by the webserver.'),
+ *),
+ */
+ '${1}' => array(
+ 'name' => t('${2}'),
+ 'class' => '${3}',
+ 'description' => t('${4}'),
+ ),
+ )
+ );
+ }
+snippet hook_stream_wrappers_alter
+ /**
+ * Implements hook_stream_wrappers_alter()
+ */
+ function `Filename()`_stream_wrappers_alter(&$wrappers) {
+ // Change the name of private files to reflect the performance.
+ /*
+ *$wrappers['private']['name'] = t('Slow files');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_file_load
+ /**
+ * Implements hook_file_load()
+ */
+ function `Filename()`_file_load($files) {
+ // Add the upload specific data into the file object.
+ /*
+ *$result = db_query('SELECT * FROM {upload} u WHERE u.fid IN (:fids)', array(':fids' => array_keys($files)))->fetchAll(PDO::FETCH_ASSOC);
+ *foreach ($result as $record) {
+ * foreach ($record as $key => $value) {
+ * $files[$record['fid']]->$key = $value;
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_file_validate
+ /**
+ * Implements hook_file_validate()
+ */
+ function `Filename()`_file_validate(&$file) {
+ $errors = array();
+
+ /*
+ *if (empty($file->filename)) {
+ * $errors[] = t("The file's name is empty. Please give a name to the file.");
+ *}
+ *if (strlen($file->filename) > 255) {
+ * $errors[] = t("The file's name exceeds the 255 characters limit. Please rename the file and try again.");
+ *}
+ */
+ if (${1}) {
+ $errors[] = t("${2}");
+ }
+
+ return $errors;
+ }
+snippet hook_file_insert
+ /**
+ * Implements hook_file_insert()
+ */
+ function `Filename()`_file_insert($file) {
+ ${1:/* Your code here */}
+ }
+snippet hook_file_update
+ /**
+ * Implements hook_file_update()
+ */
+ function `Filename()`_file_update($file) {
+ ${1:/* Your code here */}
+ }
+snippet hook_file_copy
+ /**
+ * Implements hook_file_copy()
+ */
+ function `Filename()`_file_copy($file, $source) {
+ ${1:/* Your code here */}
+ }
+snippet hook_file_move
+ /**
+ * Implements hook_file_move()
+ */
+ function `Filename()`_file_move($file, $source) {
+ ${1:/* Your code here */}
+ }
+snippet hook_file_delete
+ /**
+ * Implements hook_file_delete()
+ */
+ function `Filename()`_file_delete($file) {
+ // Delete all information associated with the file.
+ /*
+ *db_delete('upload')->condition('fid', $file->fid)->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_file_download
+ /**
+ * Implements hook_file_download()
+ */
+ function `Filename()`_file_download($uri) {
+ // Check if the file is controlled by the current module.
+ /*
+ *if (!file_prepare_directory($uri)) {
+ * $uri = FALSE;
+ *}
+ *$result = db_query("SELECT f.* FROM {file_managed} f INNER JOIN {upload} u ON f.fid = u.fid WHERE uri = :uri", array('uri' => $uri));
+ *foreach ($result as $file) {
+ * if (!user_access('view uploaded files')) {
+ * return -1;
+ * }
+ * return array(
+ * 'Content-Type' => $file->filemime,
+ * 'Content-Length' => $file->filesize,
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_file_url_alter
+ /**
+ * Implements hook_file_url_alter()
+ */
+ function `Filename()`_file_url_alter(&$uri) {
+ /*
+ * global $user;
+ *
+ * // User 1 will always see the local file in this example.
+ * if ($user->uid == 1) {
+ * return;
+ * }
+ *
+ * $cdn1 = 'http://cdn1.example.com';
+ * $cdn2 = 'http://cdn2.example.com';
+ * $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png');
+ *
+ * // Most CDNs don't support private file transfers without a lot of hassle,
+ * // so don't support this in the common case.
+ * $schemes = array('public');
+ *
+ * $scheme = file_uri_scheme($uri);
+ *
+ * // Only serve shipped files and public created files from the CDN.
+ * if (!$scheme || in_array($scheme, $schemes)) {
+ * // Shipped files.
+ * if (!$scheme) {
+ * $path = $uri;
+ * }
+ * // Public created files.
+ * else {
+ * $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
+ * $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);
+ * }
+ *
+ * // Clean up Windows paths.
+ * $path = str_replace('\\', '/', $path);
+ *
+ * // Serve files with one of the CDN extensions from CDN 1, all others from
+ * // CDN 2.
+ * $pathinfo = pathinfo($path);
+ * if (array_key_exists('extension', $pathinfo) && in_array($pathinfo['extension'], $cdn_extensions)) {
+ * $uri = $cdn1 . '/' . $path;
+ * }
+ * else {
+ * $uri = $cdn2 . '/' . $path;
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_requirements
+ /**
+ * Implements hook_requirements()
+ */
+ function `Filename()`_requirements($phase) {
+ $requirements = array();
+
+ /*
+ * // Ensure translations don't break at install time
+ * $t = get_t();
+ *
+ * // Report Drupal version
+ * if ($phase == 'runtime') {
+ * $requirements['drupal'] = array(
+ * 'title' => $t('Drupal'),
+ * 'value' => VERSION,
+ * 'severity' => REQUIREMENT_INFO
+ * );
+ * }
+ *
+ * // Test PHP version
+ * $requirements['php'] = array(
+ * 'title' => $t('PHP'),
+ * 'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/logs/status/php') : phpversion(),
+ * );
+ * if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
+ * $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
+ * $requirements['php']['severity'] = REQUIREMENT_ERROR;
+ * }
+ *
+ * // Report cron status
+ * if ($phase == 'runtime') {
+ * $cron_last = variable_get('cron_last');
+ *
+ * if (is_numeric($cron_last)) {
+ * $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
+ * }
+ * else {
+ * $requirements['cron'] = array(
+ * 'description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron')),
+ * 'severity' => REQUIREMENT_ERROR,
+ * 'value' => $t('Never run'),
+ * );
+ * }
+ *
+ * $requirements['cron']['description'] .= ' ' . t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/logs/status/run-cron')));
+ *
+ * $requirements['cron']['title'] = $t('Cron maintenance tasks');
+ * }
+ */
+ ${1:/* Your code here */}
+
+ return $requirements;
+ }
+snippet hook_schema
+ /**
+ * Implements hook_schema()
+ */
+ function `Filename()`_schema() {
+ /*
+ *$schema['node'] = array(
+ * // example (partial) specification for table "node"
+ * 'description' => 'The base table for nodes.',
+ * 'fields' => array(
+ * 'nid' => array(
+ * 'description' => 'The primary identifier for a node.',
+ * 'type' => 'serial',
+ * 'unsigned' => TRUE,
+ * 'not null' => TRUE),
+ * 'vid' => array(
+ * 'description' => 'The current {node_revision}.vid version identifier.',
+ * 'type' => 'int',
+ * 'unsigned' => TRUE,
+ * 'not null' => TRUE,
+ * 'default' => 0),
+ * 'type' => array(
+ * 'description' => 'The {node_type} of this node.',
+ * 'type' => 'varchar',
+ * 'length' => 32,
+ * 'not null' => TRUE,
+ * 'default' => ''),
+ * 'title' => array(
+ * 'description' => 'The title of this node, always treated as non-markup plain text.',
+ * 'type' => 'varchar',
+ * 'length' => 255,
+ * 'not null' => TRUE,
+ * 'default' => ''),
+ * ),
+ * 'indexes' => array(
+ * 'node_changed' => array('changed'),
+ * 'node_created' => array('created'),
+ * ),
+ * 'unique keys' => array(
+ * 'nid_vid' => array('nid', 'vid'),
+ * 'vid' => array('vid')
+ * ),
+ * 'foreign keys' => array(
+ * 'node_revision' => array(
+ * 'table' => 'node_revision',
+ * 'columns' => array('vid' => 'vid'),
+ * ),
+ * 'node_author' => array(
+ * 'table' => 'users',
+ * 'columns' => array('uid' => 'uid')
+ * ),
+ * ),
+ * 'primary key' => array('nid'),
+ *);
+ */
+ $schema['${1}'] = array(
+ 'description' => '${2}',
+ 'fields' => array(
+ '${3}' => array(
+ 'description' => '${4}',
+ 'type' => '${5}',
+ 'unsigned' => ${6},
+ 'not null' => ${7},
+ 'default' => ${8}),
+ ),
+ 'indexes' => array(
+ '${9}' => array('${10}'),
+ ),
+ 'unique keys' => array(
+ '${11}' => array('${12}')
+ ),
+ 'foreign keys' => array(
+ '${13}' => array(
+ 'table' => '${14}',
+ 'columns' => array('${15}' => '${16}'),
+ ),
+ ),
+ 'primary key' => array('${17}'),
+ );
+ return $schema;
+ }
+snippet hook_schema_alter
+ /**
+ * Implements hook_schema_alter()
+ */
+ function `Filename()`_schema_alter(&$schema) {
+ // Add field to existing schema.
+ /*
+ *$schema['users']['fields']['timezone_id'] = array(
+ * 'type' => 'int',
+ * 'not null' => TRUE,
+ * 'default' => 0,
+ * 'description' => 'Per-user timezone configuration.',
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_query_alter
+ /**
+ * Implements hook_query_alter()
+ */
+ function `Filename()`_query_alter(QueryAlterableInterface $query) {
+ if ($query->hasTag('${1}')) {
+ /*
+ *$query->range(0, 2);
+ */
+ ${2:/* Your code here */}
+ }
+ }
+snippet hook_install
+ /**
+ * Implements hook_install()
+ */
+ function `Filename()`_install() {
+ // Populate the default {node_access} record.
+ /*
+ *db_insert('node_access')
+ * ->fields(array(
+ * 'nid' => 0,
+ * 'gid' => 0,
+ * 'realm' => 'all',
+ * 'grant_view' => 1,
+ * 'grant_update' => 0,
+ * 'grant_delete' => 0,
+ * ))
+ * ->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_update_dependencies
+ /**
+ * Implements hook_update_dependencies()
+ */
+ function `Filename()`_update_dependencies() {
+ // Indicate that the mymodule_update_7000() function provided by this module
+ // must run after the another_module_update_7002() function provided by the
+ // 'another_module' module.
+ /*
+ *$dependencies['mymodule'][7000] = array(
+ * 'another_module' => 7002,
+ *);
+ */
+ // Indicate that the mymodule_update_7001() function provided by this module
+ // must run before the yet_another_module_update_7004() function provided by
+ // the 'yet_another_module' module. (Note that declaring dependencies in this
+ // direction should be done only in rare situations, since it can lead to the
+ // following problem: If a site has already run the yet_another_module
+ // module's database updates before it updates its codebase to pick up the
+ // newest mymodule code, then the dependency declared here will be ignored.)
+ /*
+ *$dependencies['yet_another_module'][7004] = array(
+ * 'mymodule' => 7001,
+ *);
+ *return $dependencies;
+ */
+ $dependencies['${1}']['${2}'] = array(
+ '${3}' => ${4},
+ );
+
+ return $dependencies;
+ }
+snippet hook_update_last_removed
+ /**
+ * Implements hook_update_last_removed()
+ */
+ function `Filename()`_update_last_removed() {
+ ${1:/* Your code here */}
+ }
+snippet hook_uninstall
+ /**
+ * Implements hook_uninstall()
+ */
+ function `Filename()`_uninstall() {
+ /*
+ *variable_del('upload_file_types');
+ */
+ variable_del('${1}');
+ }
+snippet hook_enable
+ /**
+ * Implements hook_enable()
+ */
+ function `Filename()`_enable() {
+ /*
+ *mymodule_cache_rebuild();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_disable
+ /**
+ * Implements hook_disable()
+ */
+ function `Filename()`_disable() {
+ /*
+ *mymodule_cache_rebuild();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_registry_files_alter
+ /**
+ * Implements hook_registry_files_alter()
+ */
+ function `Filename()`_registry_files_alter(&$files, $modules) {
+ /*
+ *foreach ($modules as $module) {
+ * // Only add test files for disabled modules, as enabled modules should
+ * // already include any test files they provide.
+ * if (!$module->status) {
+ * $dir = $module->dir;
+ * foreach ($module->info['files'] as $file) {
+ * if (substr($file, -5) == '.test') {
+ * $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
+ * }
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_install_tasks
+ /**
+ * Implements hook_install_tasks()
+ */
+ function `Filename()`_install_tasks() {
+ // Here, we define a variable to allow tasks to indicate that a particular,
+ // processor-intensive batch process needs to be triggered later on in the
+ // installation.
+ /*
+ *$myprofile_needs_batch_processing = variable_get('myprofile_needs_batch_processing', FALSE);
+ *$tasks = array(
+ * // This is an example of a task that defines a form which the user who is
+ * // installing the site will be asked to fill out. To implement this task,
+ * // your profile would define a function named myprofile_data_import_form()
+ * // as a normal form API callback function, with associated validation and
+ * // submit handlers. In the submit handler, in addition to saving whatever
+ * // other data you have collected from the user, you might also call
+ * // variable_set('myprofile_needs_batch_processing', TRUE) if the user has
+ * // entered data which requires that batch processing will need to occur
+ * // later on.
+ * 'myprofile_data_import_form' => array(
+ * 'display_name' => st('Data import options'),
+ * 'type' => 'form',
+ * ),
+ * // Similarly, to implement this task, your profile would define a function
+ * // named myprofile_settings_form() with associated validation and submit
+ * // handlers. This form might be used to collect and save additional
+ * // information from the user that your profile needs. There are no extra
+ * // steps required for your profile to act as an "installation wizard"; you
+ * // can simply define as many tasks of type 'form' as you wish to execute,
+ * // and the forms will be presented to the user, one after another.
+ * 'myprofile_settings_form' => array(
+ * 'display_name' => st('Additional options'),
+ * 'type' => 'form',
+ * ),
+ * // This is an example of a task that performs batch operations. To
+ * // implement this task, your profile would define a function named
+ * // myprofile_batch_processing() which returns a batch API array definition
+ * // that the installer will use to execute your batch operations. Due to the
+ * // 'myprofile_needs_batch_processing' variable used here, this task will be
+ * // hidden and skipped unless your profile set it to TRUE in one of the
+ * // previous tasks.
+ * 'myprofile_batch_processing' => array(
+ * 'display_name' => st('Import additional data'),
+ * 'display' => $myprofile_needs_batch_processing,
+ * 'type' => 'batch',
+ * 'run' => $myprofile_needs_batch_processing ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
+ * ),
+ * // This is an example of a task that will not be displayed in the list that
+ * // the user sees. To implement this task, your profile would define a
+ * // function named myprofile_final_site_setup(), in which additional,
+ * // automated site setup operations would be performed. Since this is the
+ * // last task defined by your profile, you should also use this function to
+ * // call variable_del('myprofile_needs_batch_processing') and clean up the
+ * // variable that was used above. If you want the user to pass to the final
+ * // Drupal installation tasks uninterrupted, return no output from this
+ * // function. Otherwise, return themed output that the user will see (for
+ * // example, a confirmation page explaining that your profile's tasks are
+ * // complete, with a link to reload the current page and therefore pass on
+ * // to the final Drupal installation tasks when the user is ready to do so).
+ * 'myprofile_final_site_setup' => array(
+ * ),
+ *);
+ */
+ $tasks = array(
+ ${1:/* Your code here */}
+ );
+ return $tasks;
+ }
+snippet hook_drupal_goto_alter
+ /**
+ * Implements hook_drupal_goto_alter()
+ */
+ function `Filename()`_drupal_goto_alter(&$path, &$options, &$http_response_code) {
+ ${1:/* Your code here */}
+ }
+snippet hook_html_head_alter
+ /**
+ * Implements hook_html_head_alter()
+ */
+ function `Filename()`_html_head_alter(&$head_elements) {
+ foreach ($head_elements as $key => $element) {
+ /*
+ *if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
+ * // I want a custom canonical url.
+ * $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_install_tasks_alter
+ /**
+ * Implements hook_install_tasks_alter()
+ */
+ function `Filename()`_install_tasks_alter(&$tasks, $install_state) {
+ // Replace the "Choose language" installation task provided by Drupal core
+ // with a custom callback function defined by this installation profile.
+ /*
+ *$tasks['install_select_locale']['function'] = 'myprofile_locale_selection';
+ */
+ $tasks['${1}']['${2}'] = '${3}';
+ }
+snippet hook_file_mimetype_mapping_alter
+ /**
+ * Implements hook_file_mimetype_mapping_alter()
+ */
+ function `Filename()`_file_mimetype_mapping_alter(&$mapping) {
+ // Add new MIME type 'drupal/info'.
+ /*
+ *$mapping['mimetypes']['example_info'] = 'drupal/info';
+ */
+ // Add new extension '.info' and map it to the 'drupal/info' MIME type.
+ /*
+ *$mapping['extensions']['info'] = 'example_info';
+ */
+ // Override existing extension mapping for '.ogg' files.
+ /*
+ *$mapping['extensions']['ogg'] = 189;
+ */
+ $mapping['${1}']['${2}'] = '${3}';
+ }
+snippet hook_action_info
+ /**
+ * Implements hook_action_info()
+ */
+ function `Filename()`_action_info() {
+ return array(
+ /*
+ *'comment_unpublish_action' => array(
+ * 'type' => 'comment',
+ * 'label' => t('Unpublish comment'),
+ * 'configurable' => FALSE,
+ * 'behavior' => array('changes_property'),
+ * 'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
+ *),
+ */
+ '${1}' => array(
+ 'type' => '${2}',
+ 'label' => t('${3}'),
+ 'configurable' => ${4},
+ 'behavior' => array('${5}'),
+ 'triggers' => array('${6}', ${7}),
+ ),
+ );
+ }
+snippet hook_actions_delete
+ /**
+ * Implements hook_actions_delete()
+ */
+ function `Filename()`_actions_delete($aid) {
+ db_delete('${1}')
+ ->condition('aid', $aid)
+ ->execute();
+ }
+snippet hook_action_info_alter
+ /**
+ * Implements hook_action_info_alter()
+ */
+ function `Filename()`_action_info_alter(&$actions) {
+ $actions['${1}']['${2}'] = t('${3}');
+ }
+snippet hook_archiver_info
+ /**
+ * Implements hook_archiver_info()
+ */
+ function `Filename()`_archiver_info() {
+ return array(
+ /*
+ *'tar' => array(
+ * 'class' => 'ArchiverTar',
+ * 'extensions' => array('tar', 'tar.gz', 'tar.bz2'),
+ */
+ '${1}' => array(
+ 'class' => '${2}',
+ 'extensions' => array('${3}'${4}),
+ ),
+ );
+ }
+snippet hook_archiver_info_alter
+ /**
+ * Implements hook_archiver_info_alter()
+ */
+ function `Filename()`_archiver_info_alter(&$info) {
+ /*
+ *$info['tar']['extensions'][] = 'tgz';
+ */
+ $info['${1}']['${2}'][] = '${3}';
+ }
+snippet hook_date_format_types
+ /**
+ * Implements hook_date_format_types()
+ */
+ function `Filename()`_date_format_types() {
+ return array(
+ /*
+ *'long' => t('Long'),
+ *'medium' => t('Medium'),
+ *'short' => t('Short'),
+ */
+ '${1}' => t('${2}'),
+ );
+ }
+snippet hook_date_format_types_alter
+ /**
+ * Implements hook_date_format_types_alter()
+ */
+ function `Filename()`_date_format_types_alter(&$types) {
+ foreach ($types as $type_name => $type) {
+ /*
+ *$types[$type_name]['locked'] = 1;
+ */
+ $types[$type_name]['${1}'] = ${2};
+ }
+ }
+snippet hook_date_formats
+ /**
+ * Implements hook_date_formats()
+ */
+ function `Filename()`_date_formats() {
+ return array(
+ /*
+ *array(
+ * 'type' => 'mymodule_extra_long',
+ * 'format' => 'l jS F Y H:i:s e',
+ * 'locales' => array('en-ie'),
+ *),
+ */
+ array(
+ 'type' => '${1}',
+ 'format' => '${2}',
+ 'locales' => array('${3}'),
+ ),
+ );
+ }
+snippet hook_date_formats_alter
+ /**
+ * Implements hook_date_formats_alter()
+ */
+ function `Filename()`_date_formats_alter(&$formats) {
+ foreach ($formats as $id => $format) {
+ /*
+ *$formats[$id]['locales'][] = 'en-ca';
+ */
+ $formats[$id]['${1}'][] = '${2}';
+ }
+ }
+snippet hook_page_delivery_callback_alter
+ /**
+ * Implements hook_page_delivery_callback_alter()
+ */
+ function `Filename()`_page_delivery_callback_alter(&$callback) {
+ // jQuery sets a HTTP_X_REQUESTED_WITH header of 'XMLHttpRequest'.
+ // If a page would normally be delivered as an html page, and it is called
+ // from jQuery, deliver it instead as an AJAX response.
+ /*
+ *if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && $callback == 'drupal_deliver_html_page') {
+ * $callback = 'ajax_deliver';
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_system_themes_page_alter
+ /**
+ * Implements hook_system_themes_page_alter()
+ */
+ function `Filename()`_system_themes_page_alter(&$theme_groups) {
+ foreach ($theme_groups as $state => &$group) {
+ foreach ($theme_groups[$state] as &$theme) {
+ // Add a foo link to each list of theme operations.
+ /*
+ *$theme->operations[] = l(t('Foo'), 'admin/appearance/foo', array('query' => array('theme' => $theme->name)));
+ */
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet hook_url_inbound_alter
+ /**
+ * Implements hook_url_inbound_alter()
+ */
+ function `Filename()`_url_inbound_alter(&$path, $original_path, $path_language) {
+ // Create the path user/me/edit, which allows a user to edit their account.
+ /*
+ *if (preg_match('|^user/me/edit(/.*)?|', $path, $matches)) {
+ * global $user;
+ * $path = 'user/' . $user->uid . '/edit' . $matches[1];
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_url_outbound_alter
+ /**
+ * Implements hook_url_outbound_alter()
+ */
+ function `Filename()`_url_outbound_alter(&$path, &$options, $original_path) {
+ // Instead of pointing to user/[uid]/edit, point to user/me/edit.
+ /*
+ *if (preg_match('|^user/([0-9]*)/edit(/.*)?|', $path, $matches)) {
+ * global $user;
+ * if ($user->uid == $matches[1]) {
+ * $path = 'user/me/edit' . $matches[2];
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_username_alter
+ /**
+ * Implements hook_username_alter()
+ */
+ function `Filename()`_username_alter(&$name, $account) {
+ // Display the user's uid instead of name.
+ /*
+ *if (isset($account->uid)) {
+ * $name = t('User !uid', array('!uid' => $account->uid));
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_tokens($type, $tokens, array $data = array(), array $options = array
+ /**
+ * Implements hook_tokens($type, $tokens, array $data = array(), array $options = array()
+ */
+ function `Filename()`_tokens($type, $tokens, array $data = array(), array $options = array()) {
+ $replacements = array();
+
+ /*
+ * $url_options = array('absolute' => TRUE);
+ * if (isset($options['language'])) {
+ * $url_options['language'] = $options['language'];
+ * $language_code = $options['language']->language;
+ * }
+ * else {
+ * $language_code = NULL;
+ * }
+ * $sanitize = !empty($options['sanitize']);
+ *
+ * $replacements = array();
+ *
+ * if ($type == 'node' && !empty($data['node'])) {
+ * $node = $data['node'];
+ *
+ * foreach ($tokens as $name => $original) {
+ * switch ($name) {
+ * // Simple key values on the node.
+ * case 'nid':
+ * $replacements[$original] = $node->nid;
+ * break;
+ *
+ * case 'title':
+ * $replacements[$original] = $sanitize ? check_plain($node->title) : $node->title;
+ * break;
+ *
+ * case 'edit-url':
+ * $replacements[$original] = url('node/' . $node->nid . '/edit', $url_options);
+ * break;
+ *
+ * // Default values for the chained tokens handled below.
+ * case 'author':
+ * $name = ($node->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $node->name;
+ * $replacements[$original] = $sanitize ? filter_xss($name) : $name;
+ * break;
+ *
+ * case 'created':
+ * $replacements[$original] = format_date($node->created, 'medium', '', NULL, $language_code);
+ * break;
+ * }
+ * }
+ *
+ * if ($author_tokens = token_find_with_prefix($tokens, 'author')) {
+ * $author = user_load($node->uid);
+ * $replacements += token_generate('user', $author_tokens, array('user' => $author), $options);
+ * }
+ *
+ * if ($created_tokens = token_find_with_prefix($tokens, 'created')) {
+ * $replacements += token_generate('date', $created_tokens, array('date' => $node->created), $options);
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+
+ return $replacements;
+ }
+snippet hook_token_info
+ /**
+ * Implements hook_token_info()
+ */
+ function `Filename()`_token_info() {
+ /*
+ *$type = array(
+ * 'name' => t('Nodes'),
+ * 'description' => t('Tokens related to individual nodes.'),
+ * 'needs-data' => 'node',
+ *);
+ */
+ $type = array(
+ 'name' => t('${1}'),
+ 'description' => t('${2}'),
+ 'needs-data' => '${3}',
+ );
+
+ // Core tokens for nodes.
+ /*
+ *$node['nid'] = array(
+ * 'name' => t("Node ID"),
+ * 'description' => t("The unique ID of the node."),
+ *);
+ */
+ $${4}['${5}'] = array(
+ 'name' => t("${6}"),
+ 'description' => t("${7}"),
+ );
+
+ /*
+ *return array(
+ * 'types' => array('node' => $type),
+ * 'tokens' => array('node' => $node),
+ *);
+ */
+ return array(
+ 'types' => array('${8}' => $type),
+ 'tokens' => array('${9}' => $${10}),
+ );
+ }
+snippet hook_batch_alter
+ /**
+ * Implements hook_batch_alter()
+ */
+ function `Filename()`_batch_alter(&$batch) {
+ // If the current page request is inside the overlay, add ?render=overlay to
+ // the success callback URL, so that it appears correctly within the overlay.
+ /*
+ *if (overlay_get_mode() == 'child') {
+ * if (isset($batch['url_options']['query'])) {
+ * $batch['url_options']['query']['render'] = 'overlay';
+ * }
+ * else {
+ * $batch['url_options']['query'] = array('render' => 'overlay');
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_token_info_alter
+ /**
+ * Implements hook_token_info_alter()
+ */
+ function `Filename()`_token_info_alter(&$data) {
+ // Modify description of node tokens for our site.
+ /*
+ *$data['tokens']['node']['nid'] = array(
+ * 'name' => t("Node ID"),
+ * 'description' => t("The unique ID of the article."),
+ *);
+ *$data['tokens']['node']['title'] = array(
+ * 'name' => t("Title"),
+ * 'description' => t("The title of the article."),
+ *);
+ */
+ // Chained tokens for nodes.
+ /*
+ *$data['tokens']['node']['created'] = array(
+ * 'name' => t("Date created"),
+ * 'description' => t("The date the article was posted."),
+ * 'type' => 'date',
+ *);
+ */
+ $data['tokens']['${1}']['${2}'] = array(
+ 'name' => t("${3}"),
+ 'description' => t("${4}"),
+ );
+ }
+snippet hook_updater_info
+ /**
+ * Implements hook_updater_info()
+ */
+ function `Filename()`_updater_info() {
+ /*
+ *return array(
+ * 'module' => array(
+ * 'class' => 'ModuleUpdater',
+ * 'name' => t('Update modules'),
+ * 'weight' => 0,
+ * ),
+ * 'theme' => array(
+ * 'class' => 'ThemeUpdater',
+ * 'name' => t('Update themes'),
+ * 'weight' => 0,
+ * ),
+ *);
+ */
+ return array(
+ '${1}' => array(
+ 'class' => '${2}',
+ 'name' => t('${3}'),
+ 'weight' => ${4},
+ ),
+ );
+ }
+snippet hook_updater_info_alter
+ /**
+ * Implements hook_updater_info_alter()
+ */
+ function `Filename()`_updater_info_alter(&$updaters) {
+ // Adjust weight so that the theme Updater gets a chance to handle a given
+ // update task before module updaters.
+ /*
+ *$updaters['theme']['weight'] = -1;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_countries_alter
+ /**
+ * Implements hook_countries_alter()
+ */
+ function `Filename()`_countries_alter(&$countries) {
+ // Elbonia is now independent, so add it to the country list.
+ /*
+ *$countries['EB'] = 'Elbonia';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_filetransfer_backends
+ /**
+ * Implements hook_filetransfer_backends()
+ */
+ function `Filename()`_filetransfer_backends() {
+ $backends = array();
+
+ // This is the default, will be available on most systems.
+ /*
+ *if (function_exists('ftp_connect')) {
+ * $backends['ftp'] = array(
+ * 'title' => t('FTP'),
+ * 'class' => 'FileTransferFTP',
+ * 'settings_form' => 'system_filetransfer_backend_form_ftp',
+ * 'weight' => 0,
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ return $backends;
+ }
+snippet hook_menu_site_status_alter
+ /**
+ * Implements hook_menu_site_status_alter()
+ */
+ function `Filename()`_menu_site_status_alter(&$menu_site_status, $path) {
+ // Allow access to my_module/authentication even if site is in offline mode.
+ /*
+ *if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'my_module/authentication') {
+ * $menu_site_status = MENU_SITE_ONLINE;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_form_system_theme_settings_alter
+ /**
+ * Implements hook_form_system_theme_settings_alter()
+ */
+ function `Filename()`_form_system_theme_settings_alter(&$form, &$form_state) {
+ // Add a checkbox to toggle the breadcrumb trail.
+ /*
+ *$form['toggle_breadcrumb'] = array(
+ * '#type' => 'checkbox',
+ * '#title' => t('Display the breadcrumb'),
+ * '#default_value' => theme_get_setting('toggle_breadcrumb'),
+ * '#description' => t('Show a trail of links from the homepage to the current page.'),
+ *);
+ */
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => theme_get_setting('${4}'),
+ '#description' => t('${5}'),
+ );
+ }
+snippet hook_preprocess
+ /**
+ * Implements hook_preprocess()
+ */
+ function `Filename()`_preprocess(&$variables, $hook) {
+ static $hooks;
+
+ /*
+ * // Add contextual links to the variables, if the user has permission.
+ *
+ * if (!user_access('access contextual links')) {
+ * return;
+ * }
+ *
+ * if (!isset($hooks)) {
+ * $hooks = theme_get_registry();
+ * }
+ *
+ * // Determine the primary theme function argument.
+ * if (isset($hooks[$hook]['variables'])) {
+ * $keys = array_keys($hooks[$hook]['variables']);
+ * $key = $keys[0];
+ * }
+ * else {
+ * $key = $hooks[$hook]['render element'];
+ * }
+ *
+ * if (isset($variables[$key])) {
+ * $element = $variables[$key];
+ * }
+ *
+ * if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
+ * $variables['title_suffix']['contextual_links'] = contextual_links_view($element);
+ * if (!empty($variables['title_suffix']['contextual_links'])) {
+ * $variables['classes_array'][] = 'contextual-links-region';
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_process
+ /**
+ * Implements hook_process()
+ */
+ function `Filename()`_process(&$variables, $hook) {
+ // Wraps variables in RDF wrappers.
+ /*
+ *if (!empty($variables['rdf_template_variable_attributes_array'])) {
+ * foreach ($variables['rdf_template_variable_attributes_array'] as $variable_name => $attributes) {
+ * $context = array(
+ * 'hook' => $hook,
+ * 'variable_name' => $variable_name,
+ * 'variables' => $variables,
+ * );
+ * $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context));
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_themes_enabled
+ /**
+ * Implements hook_themes_enabled()
+ */
+ function `Filename()`_themes_enabled($theme_list) {
+ foreach ($theme_list as $theme) {
+ /*
+ *block_theme_initialize($theme);
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_themes_disabled
+ /**
+ * Implements hook_themes_disabled()
+ */
+ function `Filename()`_themes_disabled($theme_list) {
+ // Clear all update module caches.
+ /*
+ *_update_cache_clear();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_file_download_access
+ /**
+ * Implements hook_file_download_access()
+ */
+ function `Filename()`_file_download_access($field, $entity_type, $entity) {
+ /*
+ *if ($entity_type == 'node') {
+ * return node_access('view', $entity);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_file_download_access_alter
+ /**
+ * Implements hook_file_download_access_alter()
+ */
+ function `Filename()`_file_download_access_alter(&$grants, $field, $entity_type, $entity) {
+ // For our example module, we always enforce the rules set by node module.
+ /*
+ *if (isset($grants['node'])) {
+ * $grants = array('node' => $grants['node']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_help
+ /**
+ * Implements hook_help()
+ */
+ function `Filename()`_help($path, $arg) {
+ switch ($path) {
+ // Main module help for the block module
+ /*
+ *case 'admin/help#block':
+ * return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href="@blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', array('@blocks' => url('admin/structure/block'))) . '</p>';
+ */
+ case '${1}':
+ return '<p>' . t('${2}', array('${3}' => ${4})) . '</p>';
+ }
+ }
+snippet hook_comment_presave
+ /**
+ * Implements hook_comment_presave()
+ */
+ function `Filename()`_comment_presave($comment) {
+ // Remove leading & trailing spaces from the comment subject.
+ /*
+ *$comment->subject = trim($comment->subject);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_insert
+ /**
+ * Implements hook_comment_insert()
+ */
+ function `Filename()`_comment_insert($comment) {
+ // Reindex the node when comments are added.
+ /*
+ *search_touch_node($comment->nid);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_update
+ /**
+ * Implements hook_comment_update()
+ */
+ function `Filename()`_comment_update($comment) {
+ // Reindex the node when comments are updated.
+ /*
+ *search_touch_node($comment->nid);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_load
+ /**
+ * Implements hook_comment_load()
+ */
+ function `Filename()`_comment_load($comments) {
+ /*
+ *$result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments)));
+ *foreach ($result as $record) {
+ * $comments[$record->cid]->foo = $record->foo;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_view
+ /**
+ * Implements hook_comment_view()
+ */
+ function `Filename()`_comment_view($comment, $view_mode, $langcode) {
+ // how old is the comment
+ /*
+ *$comment->time_ago = time() - $comment->changed;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_view_alter
+ /**
+ * Implements hook_comment_view_alter()
+ */
+ function `Filename()`_comment_view_alter(&$build) {
+ // Check for the existence of a field added by another module.
+ /*
+ *if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
+ * // Change its weight.
+ * $build['an_additional_field']['#weight'] = -10;
+ *}
+ */
+ // Add a #post_render callback to act on the rendered HTML of the comment.
+ /*
+ *$build['#post_render'][] = 'my_module_comment_post_render';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_publish
+ /**
+ * Implements hook_comment_publish()
+ */
+ function `Filename()`_comment_publish($comment) {
+ /*
+ *drupal_set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject)));
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_unpublish
+ /**
+ * Implements hook_comment_unpublish()
+ */
+ function `Filename()`_comment_unpublish($comment) {
+ /*
+ *drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject)));
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_comment_delete
+ /**
+ * Implements hook_comment_delete()
+ */
+ function `Filename()`_comment_delete($comment) {
+ /*
+ *drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject)));
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_update_projects_alter
+ /**
+ * Implements hook_update_projects_alter()
+ */
+ function `Filename()`_update_projects_alter(&$projects) {
+ // Hide a site-specific module from the list.
+ /*
+ *unset($projects['site_specific_module']);
+ */
+ // Add a disabled module to the list.
+ // The key for the array should be the machine-readable project "short name".
+ /*
+ *$projects['disabled_project_name'] = array(
+ * // Machine-readable project short name (same as the array key above).
+ * 'name' => 'disabled_project_name',
+ * // Array of values from the main .info file for this project.
+ * 'info' => array(
+ * 'name' => 'Some disabled module',
+ * 'description' => 'A module not enabled on the site that you want to see in the available updates report.',
+ * 'version' => '7.x-1.0',
+ * 'core' => '7.x',
+ * // The maximum file change time (the "ctime" returned by the filectime()
+ * // PHP method) for all of the .info files included in this project.
+ * '_info_file_ctime' => 1243888165,
+ * ),
+ * // The date stamp when the project was released, if known. If the disabled
+ * // project was an officially packaged release from drupal.org, this will
+ * // be included in the .info file as the 'datestamp' field. This only
+ * // really matters for development snapshot releases that are regenerated,
+ * // so it can be left undefined or set to 0 in most cases.
+ * 'datestamp' => 1243888185,
+ * // Any modules (or themes) included in this project. Keyed by machine-
+ * // readable "short name", value is the human-readable project name printed
+ * // in the UI.
+ * 'includes' => array(
+ * 'disabled_project' => 'Disabled module',
+ * 'disabled_project_helper' => 'Disabled module helper module',
+ * 'disabled_project_foo' => 'Disabled module foo add-on module',
+ * ),
+ * // Does this project contain a 'module', 'theme', 'disabled-module', or
+ * // 'disabled-theme'?
+ * 'project_type' => 'disabled-module',
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_update_status_alter
+ /**
+ * Implements hook_update_status_alter()
+ */
+ function `Filename()`_update_status_alter(&$projects) {
+ /*
+ *$settings = variable_get('update_advanced_project_settings', array());
+ *foreach ($projects as $project => $project_info) {
+ * if (isset($settings[$project]) && isset($settings[$project]['check']) &&
+ * ($settings[$project]['check'] == 'never' ||
+ * (isset($project_info['recommended']) &&
+ * $settings[$project]['check'] === $project_info['recommended']))) {
+ * $projects[$project]['status'] = UPDATE_NOT_CHECKED;
+ * $projects[$project]['reason'] = t('Ignored from settings');
+ * if (!empty($settings[$project]['notes'])) {
+ * $projects[$project]['extra'][] = array(
+ * 'class' => array('admin-note'),
+ * 'label' => t('Administrator note'),
+ * 'data' => $settings[$project]['notes'],
+ * );
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_verify_update_archive
+ /**
+ * Implements hook_verify_update_archive()
+ */
+ function `Filename()`_verify_update_archive($project, $archive_file, $directory) {
+ if (!file_exists($directory)) {
+ return TRUE;
+ }
+ ${1:/* Add other checks on the archive integrity here */}
+ }
+snippet hook_node_grants
+ /**
+ * Implements hook_node_grants()
+ */
+ function `Filename()`_node_grants($account, $op) {
+ /*
+ *if (user_access('access private content', $account)) {
+ * $grants['example'] = array(1);
+ *}
+ *$grants['example_owner'] = array($account->uid);
+ */
+ ${1:/* Your code here */}
+
+ return $grants;
+ }
+snippet hook_node_access_records
+ /**
+ * Implements hook_node_access_records()
+ */
+ function `Filename()`_node_access_records($node) {
+ // We only care about the node if it has been marked private. If not, it is
+ // treated just like any other node and we completely ignore it.
+ /*
+ * if ($node->private) {
+ * $grants = array();
+ * // Only published nodes should be viewable to all users. If we allow access
+ * // blindly here, then all users could view an unpublished node.
+ * if ($node->status) {
+ * $grants[] = array(
+ * 'realm' => 'example',
+ * 'gid' => 1,
+ * 'grant_view' => 1,
+ * 'grant_update' => 0,
+ * 'grant_delete' => 0,
+ * 'priority' => 0,
+ * );
+ * }
+ * // For the example_author array, the GID is equivalent to a UID, which
+ * // means there are many groups of just 1 user.
+ * // Note that an author can always view his or her nodes, even if they
+ * // have status unpublished.
+ * $grants[] = array(
+ * 'realm' => 'example_author',
+ * 'gid' => $node->uid,
+ * 'grant_view' => 1,
+ * 'grant_update' => 1,
+ * 'grant_delete' => 1,
+ * 'priority' => 0,
+ * );
+ *
+ * return $grants;
+ * }
+ */
+ $grants[] = array(
+ 'realm' => '${1}',
+ 'gid' => ${2},
+ 'grant_view' => ${3},
+ 'grant_update' => ${4},
+ 'grant_delete' => ${5},
+ 'priority' => ${6},
+ );
+
+ return $grants;
+ }
+ }
+snippet hook_node_access_records_alter
+ /**
+ * Implements hook_node_access_records_alter()
+ */
+ function `Filename()`_node_access_records_alter(&$grants, $node) {
+ // Our module allows editors to mark specific articles with the 'is_preview'
+ // field. If the node being saved has a TRUE value for that field, then only
+ // our grants are retained, and other grants are removed. Doing so ensures
+ // that our rules are enforced no matter what priority other grants are given.
+ /*
+ *if ($node->is_preview) {
+ * // Our module grants are set in $grants['example'].
+ * $temp = $grants['example'];
+ * // Now remove all module grants but our own.
+ * $grants = array('example' => $temp);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_grants_alter
+ /**
+ * Implements hook_node_grants_alter()
+ */
+ function `Filename()`_node_grants_alter(&$grants, $account, $op) {
+ // Our sample module never allows certain roles to edit or delete
+ // content. Since some other node access modules might allow this
+ // permission, we expressly remove it by returning an empty $grants
+ // array for roles specified in our variable setting.
+ //
+ // Get our list of banned roles.
+ /*
+ *$restricted = variable_get('example_restricted_roles', array());
+ *
+ *if ($op != 'view' && !empty($restricted)) {
+ * // Now check the roles for this account against the restrictions.
+ * foreach ($restricted as $role_id) {
+ * if (isset($user->roles[$role_id])) {
+ * $grants = array();
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_operations
+ /**
+ * Implements hook_node_operations()
+ */
+ function `Filename()`_node_operations() {
+ $operations = array(
+ /*
+ *'publish' => array(
+ * 'label' => t('Publish selected content'),
+ * 'callback' => 'node_mass_update',
+ * 'callback arguments' => array('updates' => array('status' => NODE_PUBLISHED)),
+ *),
+ */
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'callback' => '${3}',
+ 'callback arguments' => array('${4}' => array('${5}' => ${6})),
+ ),
+ );
+ return $operations;
+ }
+snippet hook_node_delete
+ /**
+ * Implements hook_node_delete()
+ */
+ function `Filename()`_node_delete($node) {
+ db_delete('${1}')
+ ->condition('nid', $node->nid)
+ ->execute();
+ }
+snippet hook_node_revision_delete
+ /**
+ * Implements hook_node_revision_delete()
+ */
+ function `Filename()`_node_revision_delete($node) {
+ db_delete('${1}')
+ ->condition('vid', $node->vid)
+ ->execute();
+ }
+snippet hook_node_insert
+ /**
+ * Implements hook_node_insert()
+ */
+ function `Filename()`_node_insert($node) {
+ db_insert('${1}')
+ ->fields(array(
+ 'nid' => $node->nid,
+ 'extra' => $node->extra,
+ ))
+ ->execute();
+ }
+snippet hook_node_load
+ /**
+ * Implements hook_node_load()
+ */
+ function `Filename()`_node_load($nodes, $types) {
+ /*
+ *$result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN(:nids)', array(':nids' => array_keys($nodes)));
+ *foreach ($result as $record) {
+ * $nodes[$record->nid]->foo = $record->foo;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_access
+ /**
+ * Implements hook_node_access()
+ */
+ function `Filename()`_node_access($node, $op, $account) {
+ $type = is_string($node) ? $node : $node->type;
+
+ /*
+ *if (in_array($type, node_permissions_get_configured_types())) {
+ * if ($op == 'create' && user_access('create ' . $type . ' content', $account)) {
+ * return NODE_ACCESS_ALLOW;
+ * }
+ *
+ * if ($op == 'update') {
+ * if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
+ * return NODE_ACCESS_ALLOW;
+ * }
+ * }
+ *
+ * if ($op == 'delete') {
+ * if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $node->uid))) {
+ * return NODE_ACCESS_ALLOW;
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+
+ // Returning nothing from this function would have the same effect.
+ return NODE_ACCESS_IGNORE;
+ }
+snippet hook_node_prepare
+ /**
+ * Implements hook_node_prepare()
+ */
+ function `Filename()`_node_prepare($node) {
+ /*
+ *if (!isset($node->comment)) {
+ * $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_search_result
+ /**
+ * Implements hook_node_search_result()
+ */
+ function `Filename()`_node_search_result($node) {
+ /*
+ *$comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();
+ *return format_plural($comments, '1 comment', '@count comments');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_presave
+ /**
+ * Implements hook_node_presave()
+ */
+ function `Filename()`_node_presave($node) {
+ /*
+ *if ($node->nid && $node->moderate) {
+ * // Reset votes when node is updated:
+ * $node->score = 0;
+ * $node->users = '';
+ * $node->votes = 0;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_update
+ /**
+ * Implements hook_node_update()
+ */
+ function `Filename()`_node_update($node) {
+ db_update('${1}')
+ ->fields(array('${2}' => ${3})
+ ->condition('nid', $node->nid)
+ ->execute();
+ }
+snippet hook_node_update_index
+ /**
+ * Implements hook_node_update_index()
+ */
+ function `Filename()`_node_update_index($node) {
+ /*
+ *$text = '';
+ *$comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
+ *foreach ($comments as $comment) {
+ * $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
+ *}
+ *return $text;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_validate
+ /**
+ * Implements hook_node_validate()
+ */
+ function `Filename()`_node_validate($node, $form, &$form_state) {
+ /*
+ *if (isset($node->end) && isset($node->start)) {
+ * if ($node->start > $node->end) {
+ * form_set_error('time', t('An event may not end before it starts.'));
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_submit
+ /**
+ * Implements hook_node_submit()
+ */
+ function `Filename()`_node_submit($node, $form, &$form_state) {
+ // Decompose the selected menu parent option into 'menu_name' and 'plid', if
+ // the form used the default parent selection widget.
+ /*
+ *if (!empty($form_state['values']['menu']['parent'])) {
+ * list($node->menu['menu_name'], $node->menu['plid']) = explode(':', $form_state['values']['menu']['parent']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_view
+ /**
+ * Implements hook_node_view()
+ */
+ function `Filename()`_node_view($node, $view_mode, $langcode) {
+ /*
+ *$node->content['my_additional_field'] = array(
+ * '#markup' => $additional_field,
+ * '#weight' => 10,
+ * '#theme' => 'mymodule_my_additional_field',
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_view_alter
+ /**
+ * Implements hook_node_view_alter()
+ */
+ function `Filename()`_node_view_alter(&$build) {
+ /*
+ *if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
+ * // Change its weight.
+ * $build['an_additional_field']['#weight'] = -10;
+ *}
+ *
+ * // Add a #post_render callback to act on the rendered HTML of the node.
+ * $build['#post_render'][] = 'my_module_node_post_render';
+ */
+ }
+snippet hook_node_info
+ /**
+ * Implements hook_node_info()
+ */
+ function `Filename()`_node_info() {
+ return array(
+ /*
+ *'blog' => array(
+ * 'name' => t('Blog entry'),
+ * 'base' => 'blog',
+ * 'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
+ *)
+ */
+ '${1}' => array(
+ 'name' => t('${2}'),
+ 'base' => '${3}',
+ 'description' => t('${4}'),
+ )
+ );
+ }
+snippet hook_ranking
+ /**
+ * Implements hook_ranking()
+ */
+ function `Filename()`_ranking() {
+ // If voting is disabled, we can avoid returning the array, no hard feelings.
+ /*
+ *if (variable_get('vote_node_enabled', TRUE)) {
+ * return array(
+ * 'vote_average' => array(
+ * 'title' => t('Average vote'),
+ * // Note that we use i.sid, the search index's search item id, rather than
+ * // n.nid.
+ * 'join' => 'LEFT JOIN {vote_node_data} vote_node_data ON vote_node_data.nid = i.sid',
+ * // The highest possible score should be 1, and the lowest possible score,
+ * // always 0, should be 0.
+ * 'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
+ * // Pass in the highest possible voting score as a decimal argument.
+ * 'arguments' => array(variable_get('vote_score_max', 5)),
+ * ),
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_type_insert
+ /**
+ * Implements hook_node_type_insert()
+ */
+ function `Filename()`_node_type_insert($info) {
+ ${1:/* Your code here */}
+ }
+snippet hook_node_type_update
+ /**
+ * Implements hook_node_type_update()
+ */
+ function `Filename()`_node_type_update($info) {
+ /*
+ *if (!empty($info->old_type) && $info->old_type != $info->type) {
+ * $setting = variable_get('comment_' . $info->old_type, COMMENT_NODE_OPEN);
+ * variable_del('comment_' . $info->old_type);
+ * variable_set('comment_' . $info->type, $setting);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_node_type_delete
+ /**
+ * Implements hook_node_type_delete()
+ */
+ function `Filename()`_node_type_delete($info) {
+ /*
+ *variable_del('comment_' . $info->type);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_delete
+ /**
+ * Implements hook_delete()
+ */
+ function `Filename()`_delete($node) {
+ db_delete('${1}')
+ ->condition('nid', $nid->nid)
+ ->execute();
+ }
+snippet hook_prepare
+ /**
+ * Implements hook_prepare()
+ */
+ function `Filename()`_prepare($node) {
+ /*
+ *if ($file = file_check_upload($field_name)) {
+ * $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
+ * if ($file) {
+ * if (!image_get_info($file->uri)) {
+ * form_set_error($field_name, t('Uploaded file is not a valid image'));
+ * return;
+ * }
+ * }
+ * else {
+ * return;
+ * }
+ * $node->images['_original'] = $file->uri;
+ * _image_build_derivatives($node, TRUE);
+ * $node->new_file = TRUE;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_form
+ /**
+ * Implements hook_form()
+ */
+ function `Filename()`_form($node, &$form_state) {
+ $type = node_type_get_type($node);
+
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $node->${4},
+ '#${5}' => ${6},
+ );
+
+ return $form;
+ }
+snippet hook_insert
+ /**
+ * Implements hook_insert()
+ */
+ function `Filename()`_insert($node) {
+ db_insert('${1}')
+ ->fields(array(
+ 'nid' => $node->nid,
+ 'extra' => $node->extra,
+ ))
+ ->execute();
+ }
+snippet hook_load
+ /**
+ * Implements hook_load()
+ */
+ function `Filename()`_load($nodes) {
+ /*
+ *$result = db_query('SELECT nid, foo FROM {mytable} WHERE nid IN (:nids)', array(':nids' => array_keys($nodes)));
+ *foreach ($result as $record) {
+ * $nodes[$record->nid]->foo = $record->foo;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_update
+ /**
+ * Implements hook_update()
+ */
+ function `Filename()`_update($node) {
+ db_update('${1}')
+ ->fields(array('extra' => $node->extra))
+ ->condition('nid', $node->nid)
+ ->execute();
+ }
+snippet hook_validate
+ /**
+ * Implements hook_validate()
+ */
+ function `Filename()`_validate($node, $form, &$form_state) {
+ /*
+ *if (isset($node->end) && isset($node->start)) {
+ * if ($node->start > $node->end) {
+ * form_set_error('time', t('An event may not end before it starts.'));
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_view
+ /**
+ * Implements hook_view()
+ */
+ function `Filename()`_view($node, $view_mode) {
+ /*
+ *if ($view_mode == 'full' && node_is_page($node)) {
+ * $breadcrumb = array();
+ * $breadcrumb[] = l(t('Home'), NULL);
+ * $breadcrumb[] = l(t('Example'), 'example');
+ * $breadcrumb[] = l($node->field1, 'example/' . $node->field1);
+ * drupal_set_breadcrumb($breadcrumb);
+ *}
+ *
+ *$node->content['myfield'] = array(
+ * '#value' => theme('mymodule_myfield', $node->myfield),
+ * '#weight' => 1,
+ *);
+ */
+ ${1:/* Your code here */}
+
+ return $node;
+ }
+snippet hook_block_info
+ /**
+ * Implements hook_block_info()
+ */
+ function `Filename()`_block_info() {
+ // This example comes from node.module.
+ /*
+ *$blocks['syndicate'] = array(
+ * 'info' => t('Syndicate'),
+ * 'cache' => DRUPAL_NO_CACHE
+ *);
+ */
+ $blocks['${1}'] = array(
+ 'info' => t('${2}'),
+ 'cache' => ${3}DRUPAL_NO_CACHE
+ );
+
+ return $blocks;
+ }
+snippet hook_block_info_alter
+ /**
+ * Implements hook_block_info_alter()
+ */
+ function `Filename()`_block_info_alter(&$blocks, $theme, $code_blocks) {
+ // Disable the login block.
+ /*
+ *$blocks['user']['login']['status'] = 0;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_block_configure
+ /**
+ * Implements hook_block_configure()
+ */
+ function `Filename()`_block_configure($delta = '') {
+ // This example comes from node.module.
+ /*
+ *$form = array();
+ *if ($delta == 'recent') {
+ * $form['node_recent_block_count'] = array(
+ * '#type' => 'select',
+ * '#title' => t('Number of recent content items to display'),
+ * '#default_value' => variable_get('node_recent_block_count', 10),
+ * '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ * );
+ *}
+ */
+ $form = array();
+ if ($delta == '${1}') {
+ $form['${2}'] = array(
+ '#type' => '${3}',
+ '#title' => t('${4}'),
+ '#default_value' => variable_get('${5}', ${6}),
+ '#${7}' => ${8},
+ );
+ }
+ return $form;
+ }
+snippet hook_block_save($delta = '', $edit = array
+ /**
+ * Implements hook_block_save($delta = '', $edit = array()
+ */
+ function `Filename()`_block_save($delta = '', $edit = array()) {
+ // This example comes from node.module.
+ /*
+ *if ($delta == 'recent') {
+ * variable_set('node_recent_block_count', $edit['node_recent_block_count']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_block_view
+ /**
+ * Implements hook_block_view()
+ */
+ function `Filename()`_block_view($delta = '') {
+ $block = array();
+
+ switch ($delta) {
+ /*
+ *case 'syndicate':
+ * $block['subject'] = t('Syndicate');
+ * $block['content'] = theme('feed_icon', array('url' => url('rss.xml'), 'title' => t('Syndicate')));
+ * break;
+ *
+ *case 'recent':
+ * if (user_access('access content')) {
+ * $block['subject'] = t('Recent content');
+ * if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
+ * $block['content'] = theme('node_recent_block', array(
+ * 'nodes' => $nodes,
+ * ));
+ * } else {
+ * $block['content'] = t('No content available.');
+ * }
+ * }
+ * break;
+ */
+ case '${1}':
+ $block['subject'] = t('${2}');
+ $block['content'] = theme('${3}', array('${4}' =>${5}));
+ break;
+ ${6}
+ }
+ return $block;
+ }
+snippet hook_block_view_alter
+ /**
+ * Implements hook_block_view_alter()
+ */
+ function `Filename()`_block_view_alter(&$data, $block) {
+ // Remove the contextual links on all blocks that provide them.
+ /*
+ *if (is_array($data['content']) && isset($data['content']['#contextual_links'])) {
+ * unset($data['content']['#contextual_links']);
+ *}
+ */
+ // Add a theme wrapper function defined by the current module to all blocks
+ // provided by the "somemodule" module.
+ /*
+ *if (is_array($data['content']) && $block->module == 'somemodule') {
+ * $data['content']['#theme_wrappers'][] = 'mymodule_special_block';
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_block_list_alter
+ /**
+ * Implements hook_block_list_alter()
+ */
+ function `Filename()`_block_list_alter(&$blocks) {
+ // This example shows how to achieve language specific visibility setting for
+ // blocks.
+ /*
+ *global $language, $theme_key;
+ *$result = db_query('SELECT module, delta, language FROM {my_table}');
+ *$block_languages = array();
+ *foreach ($result as $record) {
+ * $block_languages[$record->module][$record->delta][$record->language] = TRUE;
+ *}
+ *
+ *foreach ($blocks as $key => $block) {
+ * // Any module using this alter should inspect the data before changing it,
+ * // to ensure it is what they expect.
+ * if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
+ * // This block was added by a contrib module, leave it in the list.
+ * continue;
+ * }
+ *
+ * if (!isset($block_languages[$block->module][$block->delta])) {
+ * // No language setting for this block, leave it in the list.
+ * continue;
+ * }
+ *
+ * if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
+ * // This block should not be displayed with the active language, remove
+ * // from the list.
+ * unset($blocks[$key]);
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_user_load
+ /**
+ * Implements hook_user_load()
+ */
+ function `Filename()`_user_load($users) {
+ /*
+ *$result = db_query('SELECT * FROM {my_table} WHERE uid IN (:uids)', array(':uids' => array_keys($users)));
+ *foreach ($result as $record) {
+ * $users[$record->uid]->foo = $result->foo;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_user_delete
+ /**
+ * Implements hook_user_delete()
+ */
+ function `Filename()`_user_delete($account) {
+ db_delete('${1}')
+ ->condition('uid', $account->uid)
+ ->execute();
+ }
+snippet hook_user_cancel
+ /**
+ * Implements hook_user_cancel()
+ */
+ function `Filename()`_user_cancel($edit, $account, $method) {
+ switch ($method) {
+ /*
+ *case 'user_cancel_block_unpublish':
+ * // Unpublish nodes (current revisions).
+ * module_load_include('inc', 'node', 'node.admin');
+ * $nodes = db_select('node', 'n')
+ * ->fields('n', array('nid'))
+ * ->condition('uid', $account->uid)
+ * ->execute()
+ * ->fetchCol();
+ * node_mass_update($nodes, array('status' => 0));
+ * break;
+ */
+ case '${1}':
+ ${2:/* Your code here */}
+ break;
+ }
+ }
+snippet hook_user_cancel_methods_alter
+ /**
+ * Implements hook_user_cancel_methods_alter()
+ */
+ function `Filename()`_user_cancel_methods_alter(&$methods) {
+ // Limit access to disable account and unpublish content method.
+ /*
+ *$methods['user_cancel_block_unpublish']['access'] = user_access('administer site configuration');
+ */
+ // Remove the content re-assigning method.
+ /*
+ *unset($methods['user_cancel_reassign']);
+ */
+ // Add a custom zero-out method.
+ /*
+ *$methods['mymodule_zero_out'] = array(
+ * 'title' => t('Delete the account and remove all content.'),
+ * 'description' => t('All your content will be replaced by empty strings.'),
+ * // access should be used for administrative methods only.
+ * 'access' => user_access('access zero-out account cancellation method'),
+ *);
+ */
+ $methods['${1}']${2}
+ }
+snippet hook_user_operations
+ /**
+ * Implements hook_user_operations()
+ */
+ function `Filename()`_user_operations() {
+ $operations = array(
+ /*
+ *'unblock' => array(
+ * 'label' => t('Unblock the selected users'),
+ * 'callback' => 'user_user_operations_unblock',
+ *),
+ */
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'callback' => '${3}',
+ ),
+ );
+ return $operations;
+ }
+snippet hook_user_categories
+ /**
+ * Implements hook_user_categories()
+ */
+ function `Filename()`_user_categories() {
+ return array(array(
+ /*
+ *'name' => 'account',
+ *'title' => t('Account settings'),
+ *'weight' => 1,
+ */
+ 'name' => '${1}',
+ 'title' => t('${2}'),
+ 'weight' => ${3},
+ ));
+ }
+snippet hook_user_presave
+ /**
+ * Implements hook_user_presave()
+ */
+ function `Filename()`_user_presave(&$edit, $account, $category) {
+ // make sure that our form value 'mymodule_foo' is stored as 'mymodule_bar'.
+ /*
+ *if (isset($edit['mymodule_foo'])) {
+ * $edit['data']['my_module_foo'] = $edit['my_module_foo'];
+ *}
+ */
+ ${1:/* your code here */}
+ }
+snippet hook_user_insert
+ /**
+ * Implements hook_user_insert()
+ */
+ function `Filename()`_user_insert(&$edit, $account, $category) {
+ db_insert('${1}')
+ ->fields(array(
+ '${2}' => $edit['${3}'],
+ 'uid' => $account->uid,
+ ))
+ ->execute();
+ }
+snippet hook_user_update
+ /**
+ * Implements hook_user_update()
+ */
+ function `Filename()`_user_update(&$edit, $account, $category) {
+ db_insert('${1}')
+ ->fields(array(
+ 'uid' => $account->uid,
+ 'changed' => time(),
+ ))
+ ->execute();
+ }
+snippet hook_user_login
+ /**
+ * Implements hook_user_login()
+ */
+ function `Filename()`_user_login(&$edit, $account) {
+ // If the user has a NULL time zone, notify them to set a time zone.
+ /*
+ *if (!$user->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
+ * drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$user->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_user_logout
+ /**
+ * Implements hook_user_logout()
+ */
+ function `Filename()`_user_logout($account) {
+ db_insert('${1}')
+ ->fields(array(
+ 'uid' => $account->uid,
+ 'time' => time(),
+ ))
+ ->execute();
+ }
+snippet hook_user_view
+ /**
+ * Implements hook_user_view()
+ */
+ function `Filename()`_user_view($account, $view_mode, $langcode) {
+ /*
+ *if (user_access('create blog content', $account)) {
+ * $account->content['summary']['blog'] = array(
+ * '#type' => 'user_profile_item',
+ * '#title' => t('Blog'),
+ * '#markup' => l(t('View recent blog entries'), "blog/$account->uid", array('attributes' => array('title' => t("Read !username's latest blog entries.", array('!username' => format_username($account)))))),
+ * '#attributes' => array('class' => array('blog')),
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_user_view_alter
+ /**
+ * Implements hook_user_view_alter()
+ */
+ function `Filename()`_user_view_alter(&$build) {
+ // Check for the existence of a field added by another module.
+ /*
+ *if (isset($build['an_additional_field'])) {
+ * // Change its weight.
+ * $build['an_additional_field']['#weight'] = -10;
+ *}
+ */
+ // Add a #post_render callback to act on the rendered HTML of the user.
+ /*
+ *$build['#post_render'][] = 'my_module_user_post_render';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_user_role_insert
+ /**
+ * Implements hook_user_role_insert()
+ */
+ function `Filename()`_user_role_insert($role) {
+ // Save extra fields provided by the module to user roles.
+ db_insert('${1}')
+ ->fields(array(
+ 'rid' => $role->rid,
+ 'role_description' => $role->description,
+ ))
+ ->execute();
+ }
+snippet hook_user_role_update
+ /**
+ * Implements hook_user_role_update()
+ */
+ function `Filename()`_user_role_update($role) {
+ // Save extra fields provided by the module to user roles.
+ db_merge('${1}')
+ ->key(array('rid' => $role->rid))
+ ->fields(array(
+ 'role_description' => $role->description
+ ))
+ ->execute();
+ }
+snippet hook_user_role_delete
+ /**
+ * Implements hook_user_role_delete()
+ */
+ function `Filename()`_user_role_delete($role) {
+ // Delete existing instances of the deleted role.
+ db_delete('${1}')
+ ->condition('rid', $role->rid)
+ ->execute();
+ }
+snippet hook_taxonomy_vocabulary_load
+ /**
+ * Implements hook_taxonomy_vocabulary_load()
+ */
+ function `Filename()`_taxonomy_vocabulary_load($vocabularies) {
+ foreach ($vocabularies as $vocabulary) {
+ /*
+ *$vocabulary->synonyms = variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE);
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_taxonomy_vocabulary_presave
+ /**
+ * Implements hook_taxonomy_vocabulary_presave()
+ */
+ function `Filename()`_taxonomy_vocabulary_presave($vocabulary) {
+ /*
+ *$vocabulary->foo = 'bar';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_vocabulary_insert
+ /**
+ * Implements hook_taxonomy_vocabulary_insert()
+ */
+ function `Filename()`_taxonomy_vocabulary_insert($vocabulary) {
+ /*
+ *if ($vocabulary->synonyms) {
+ * variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', TRUE);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_vocabulary_update
+ /**
+ * Implements hook_taxonomy_vocabulary_update()
+ */
+ function `Filename()`_taxonomy_vocabulary_update($vocabulary) {
+ /*
+ *$status = $vocabulary->synonyms ? TRUE : FALSE;
+ *if ($vocabulary->synonyms) {
+ * variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', $status);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_vocabulary_delete
+ /**
+ * Implements hook_taxonomy_vocabulary_delete()
+ */
+ function `Filename()`_taxonomy_vocabulary_delete($vocabulary) {
+ /*
+ *if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) {
+ * variable_del('taxonomy_' . $vocabulary->vid . '_synonyms');
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_term_load
+ /**
+ * Implements hook_taxonomy_term_load()
+ */
+ function `Filename()`_taxonomy_term_load($terms) {
+ /*
+ *$result = db_query('SELECT tid, foo FROM {mytable} WHERE tid IN (:tids)', array(':tids' => array_keys($terms)));
+ *foreach ($result as $record) {
+ * $terms[$record->tid]->foo = $record->foo;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_term_presave
+ /**
+ * Implements hook_taxonomy_term_presave()
+ */
+ function `Filename()`_taxonomy_term_presave($term) {
+ /*
+ *$term->foo = 'bar';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_term_insert
+ /**
+ * Implements hook_taxonomy_term_insert()
+ */
+ function `Filename()`_taxonomy_term_insert($term) {
+ /*
+ *if (!empty($term->synonyms)) {
+ * foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
+ * if ($synonym) {
+ * db_insert('taxonomy_term_synonym')
+ * ->fields(array(
+ * 'tid' => $term->tid,
+ * 'name' => rtrim($synonym),
+ * ))
+ * ->execute();
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_term_update
+ /**
+ * Implements hook_taxonomy_term_update()
+ */
+ function `Filename()`_taxonomy_term_update($term) {
+ /*
+ *hook_taxonomy_term_delete($term);
+ *if (!empty($term->synonyms)) {
+ * foreach (explode ("\n", str_replace("\r", '', $term->synonyms)) as $synonym) {
+ * if ($synonym) {
+ * db_insert('taxonomy_term_synonym')
+ * ->fields(array(
+ * 'tid' => $term->tid,
+ * 'name' => rtrim($synonym),
+ * ))
+ * ->execute();
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_taxonomy_term_delete
+ /**
+ * Implements hook_taxonomy_term_delete()
+ */
+ function `Filename()`_taxonomy_term_delete($term) {
+ /*
+ *db_delete('term_synoynm')->condition('tid', $term->tid)->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_openid
+ /**
+ * Implements hook_openid()
+ */
+ function `Filename()`_openid($op, $request) {
+ /*
+ *if ($op == 'request') {
+ * $request['openid.identity'] = 'http://myname.myopenid.com/';
+ *}
+ */
+ ${1:/* Your code here */}
+
+ return $request;
+ }
+snippet hook_openid_response
+ /**
+ * Implements hook_openid_response()
+ */
+ function `Filename()`_openid_response($response, $account) {
+ /*
+ *if (isset($response['openid.ns.ax'])) {
+ * _mymodule_store_ax_fields($response, $account);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_openid_discovery_method_info
+ /**
+ * Implements hook_openid_discovery_method_info()
+ */
+ function `Filename()`_openid_discovery_method_info() {
+ return array(
+ '${1}' => '${2}',
+ );
+ }
+snippet hook_openid_discovery_method_info_alter
+ /**
+ * Implements hook_openid_discovery_method_info_alter()
+ */
+ function `Filename()`_openid_discovery_method_info_alter(&$methods) {
+ // Remove XRI discovery scheme.
+ /*
+ *unset($methods['xri']);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_openid_normalization_method_info
+ /**
+ * Implements hook_openid_normalization_method_info()
+ */
+ function `Filename()`_openid_normalization_method_info() {
+ return array(
+ /*
+ *'new_discovery_idea' => '_my_discovery_method',
+ */
+ '${1}' => '${2}',
+ );
+ }
+snippet hook_openid_normalization_method_info_alter
+ /**
+ * Implements hook_openid_normalization_method_info_alter()
+ */
+ function `Filename()`_openid_normalization_method_info_alter(&$methods) {
+ // Remove Google IDP normalization.
+ /*
+ *unset($methods['google_idp']);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_filter_info
+ /**
+ * Implements hook_filter_info()
+ */
+ function `Filename()`_filter_info() {
+ /*
+ *$filters['filter_html'] = array(
+ * 'title' => t('Limit allowed HTML tags'),
+ * 'description' => t('Allows you to restrict the HTML tags the user can use. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.'),
+ * 'process callback' => '_filter_html',
+ * 'settings callback' => '_filter_html_settings',
+ * 'default settings' => array(
+ * 'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>',
+ * 'filter_html_help' => 1,
+ * 'filter_html_nofollow' => 0,
+ * ),
+ * 'tips callback' => '_filter_html_tips',
+ *);
+ *$filters['filter_autop'] = array(
+ * 'title' => t('Convert line breaks'),
+ * 'description' => t('Converts line breaks into HTML (i.e. &lt;br&gt; and &lt;p&gt;) tags.'),
+ * 'process callback' => '_filter_autop',
+ * 'tips callback' => '_filter_autop_tips',
+ *);
+ *return $filters;
+ */
+ $filters['${1}'] = array(
+ 'title' => t('${2}'),
+ 'description' => t('${3}'),
+ 'process callback' => '${4}',
+ 'settings callback' => '${5}',
+ 'default settings' => array(
+ 'allowed_html' => '${6}',
+ 'filter_html_help' => ${7},
+ 'filter_html_nofollow' => ${8},
+ ),
+ 'tips callback' => '${9}',
+ );
+ return $filters;
+ }
+snippet hook_filter_info_alter
+ /**
+ * Implements hook_filter_info_alter()
+ */
+ function `Filename()`_filter_info_alter(&$info) {
+ // Replace the PHP evaluator process callback with an improved
+ // PHP evaluator provided by a module.
+ /*
+ *$info['php_code']['process callback'] = 'my_module_php_evaluator';
+ */
+ // Alter the default settings of the URL filter provided by core.
+ /*
+ *$info['filter_url']['default settings'] = array(
+ * 'filter_url_length' => 100,
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_filter_format_insert
+ /**
+ * Implements hook_filter_format_insert()
+ */
+ function `Filename()`_filter_format_insert($format) {
+ /*
+ *mymodule_cache_rebuild();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_filter_format_update
+ /**
+ * Implements hook_filter_format_update()
+ */
+ function `Filename()`_filter_format_update($format) {
+ /*
+ *mymodule_cache_rebuild();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_filter_format_disable
+ /**
+ * Implements hook_filter_format_disable()
+ */
+ function `Filename()`_filter_format_disable($format) {
+ /*
+ *mymodule_cache_rebuild();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_rdf_mapping
+ /**
+ * Implements hook_rdf_mapping()
+ */
+ function `Filename()`_rdf_mapping() {
+ return array(
+ array(
+ /*
+ *'type' => 'node',
+ *'bundle' => 'blog',
+ *'mapping' => array(
+ * 'rdftype' => array('sioct:Weblog'),
+ * 'title' => array(
+ * 'predicates' => array('dc:title'),
+ * ),
+ * 'created' => array(
+ * 'predicates' => array('dc:date', 'dc:created'),
+ * 'datatype' => 'xsd:dateTime',
+ * 'callback' => 'date_iso8601',
+ * ),
+ * 'body' => array(
+ * 'predicates' => array('content:encoded'),
+ * ),
+ * 'uid' => array(
+ * 'predicates' => array('sioc:has_creator'),
+ * 'type' => 'rel',
+ * ),
+ * 'name' => array(
+ * 'predicates' => array('foaf:name'),
+ * ),
+ */
+ 'type' => '${1}',
+ 'bundle' => '${2}',
+ 'mapping' => array(
+ 'rdftype' => array('${3}'),
+ 'title' => array(
+ 'predicates' => array('${4}'),
+ ),
+ 'created' => array(
+ 'predicates' => array('${5}'),
+ 'datatype' => '${6}',
+ 'callback' => '${7}',
+ ),
+ 'body' => array(
+ 'predicates' => array('${8}'),
+ ),
+ 'uid' => array(
+ 'predicates' => array('${9}'),
+ 'type' => '${10}',
+ ),
+ 'name' => array(
+ 'predicates' => array('${11}'),
+ ),
+ ),
+ ),
+ );
+ }
+snippet hook_rdf_namespaces
+ /**
+ * Implements hook_rdf_namespaces()
+ */
+ function `Filename()`_rdf_namespaces() {
+ return array(
+ /*
+ *'content' => 'http://purl.org/rss/1.0/modules/content/',
+ *'dc' => 'http://purl.org/dc/terms/',
+ *'foaf' => 'http://xmlns.com/foaf/0.1/',
+ *'og' => 'http://ogp.me/ns#',
+ *'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
+ *'sioc' => 'http://rdfs.org/sioc/ns#',
+ *'sioct' => 'http://rdfs.org/sioc/types#',
+ *'skos' => 'http://www.w3.org/2004/02/skos/core#',
+ *'xsd' => 'http://www.w3.org/2001/XMLSchema#',
+ */
+ '${1}' => '${2}',
+ );
+ }
+snippet hook_field_settings_form
+ /**
+ * Implements hook_field_settings_form()
+ */
+ function `Filename()`_field_settings_form($field, $instance, $has_data) {
+ /*
+ *$settings = $field['settings'];
+ *$form['max_length'] = array(
+ * '#type' => 'textfield',
+ * '#title' => t('Maximum length'),
+ * '#default_value' => $settings['max_length'],
+ * '#required' => FALSE,
+ * '#element_validate' => array('_element_validate_integer_positive'),
+ * '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
+ *);
+ */
+ $settings = $field['settings'];
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ return $form;
+ }
+snippet hook_field_instance_settings_form
+ /**
+ * Implements hook_field_instance_settings_form()
+ */
+ function `Filename()`_field_instance_settings_form($field, $instance) {
+ /*
+ * $settings = $instance['settings'];
+ *
+ * $form['text_processing'] = array(
+ * '#type' => 'radios',
+ * '#title' => t('Text processing'),
+ * '#default_value' => $settings['text_processing'],
+ * '#options' => array(
+ * t('Plain text'),
+ * t('Filtered text (user selects text format)'),
+ * ),
+ * );
+ * if ($field['type'] == 'text_with_summary') {
+ * $form['display_summary'] = array(
+ * '#type' => 'select',
+ * '#title' => t('Display summary'),
+ * '#options' => array(
+ * t('No'),
+ * t('Yes'),
+ * ),
+ * '#description' => t('Display the summary to allow the user to input a summary value. Hide the summary to automatically fill it with a trimmed portion from the main post. '),
+ * '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0,
+ * );
+ * }
+ */
+ $settings = $instance['settings'];
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ return $form;
+ }
+snippet hook_field_widget_settings_form
+ /**
+ * Implements hook_field_widget_settings_form()
+ */
+ function `Filename()`_field_widget_settings_form($field, $instance) {
+ $widget = $instance['widget'];
+ $settings = $widget['settings'];
+
+ /*
+ *if ($widget['type'] == 'text_textfield') {
+ * $form['size'] = array(
+ * '#type' => 'textfield',
+ * '#title' => t('Size of textfield'),
+ * '#default_value' => $settings['size'],
+ * '#element_validate' => array('_element_validate_integer_positive'),
+ * '#required' => TRUE,
+ * );
+ *}
+ *else {
+ * $form['rows'] = array(
+ * '#type' => 'textfield',
+ * '#title' => t('Rows'),
+ * '#default_value' => $settings['rows'],
+ * '#element_validate' => array('_element_validate_integer_positive'),
+ * '#required' => TRUE,
+ * );
+ *}
+ */
+ $form['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+ return $form;
+ }
+snippet hook_field_formatter_settings_form
+ /**
+ * Implements hook_field_formatter_settings_form()
+ */
+ function `Filename()`_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
+ $display = $instance['display'][$view_mode];
+ $settings = $display['settings'];
+
+ /*
+ *if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
+ * $element['trim_length'] = array(
+ * '#title' => t('Length'),
+ * '#type' => 'textfield',
+ * '#size' => 20,
+ * '#default_value' => $settings['trim_length'],
+ * '#element_validate' => array('_element_validate_integer_positive'),
+ * '#required' => TRUE,
+ * );
+ *}
+ */
+ $element['${1}'] = array(
+ '#type' => '${2}',
+ '#title' => t('${3}'),
+ '#default_value' => $settings['${4}'],
+ '#required' => ${5},
+ '#element_validate' => array('${6}'),
+ '#description' => t('${7}'),
+ '#${8}' => ${9}
+ );
+
+ return $element;
+
+ }
+snippet hook_field_formatter_settings_summary
+ /**
+ * Implements hook_field_formatter_settings_summary()
+ */
+ function `Filename()`_field_formatter_settings_summary($field, $instance, $view_mode) {
+ /*
+ *$display = $instance['display'][$view_mode];
+ *$settings = $display['settings'];
+ *
+ *$summary = '';
+ *
+ *if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {
+ * $summary = t('Length: @chars chars', array('@chars' => $settings['trim_length']));
+ *}
+ */
+ ${1:/* Your code here */}
+
+ return $summary;
+ }
+snippet hook_field_extra_fields
+ /**
+ * Implements hook_field_extra_fields()
+ */
+ function `Filename()`_field_extra_fields() {
+ /*
+ *$extra['node']['poll'] = array(
+ * 'form' => array(
+ * 'choice_wrapper' => array(
+ * 'label' => t('Poll choices'),
+ * 'description' => t('Poll choices'),
+ * 'weight' => -4,
+ * ),
+ * 'settings' => array(
+ * 'label' => t('Poll settings'),
+ * 'description' => t('Poll module settings'),
+ * 'weight' => -3,
+ * ),
+ * ),
+ * 'display' => array(
+ * 'poll_view_voting' => array(
+ * 'label' => t('Poll vote'),
+ * 'description' => t('Poll vote'),
+ * 'weight' => 0,
+ * ),
+ * 'poll_view_results' => array(
+ * 'label' => t('Poll results'),
+ * 'description' => t('Poll results'),
+ * 'weight' => 0,
+ * ),
+ * )
+ *);
+ */
+ $extra['${1}']['${2}'] = array(
+ 'form' => array(
+ '${3}' => array(
+ 'label' => t('${4}'),
+ 'description' => t('${5}'),
+ 'weight' => ${6},
+ ),
+ ),
+ 'display' => array(
+ '${7}' => array(
+ 'label' => t('${8}'),
+ 'description' => t('${9}'),
+ 'weight' => ${10},
+ ),
+ )
+ );
+
+ return $extra;
+ }
+snippet hook_field_extra_fields_alter
+ /**
+ * Implements hook_field_extra_fields_alter()
+ */
+ function `Filename()`_field_extra_fields_alter(&$info) {
+ // Force node title to always be at the top of the list by default.
+ /*
+ *foreach (node_type_get_types() as $bundle) {
+ * if (isset($info['node'][$bundle]['title'])) {
+ * $info['node'][$bundle]['title']['weight'] = -20;
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_info
+ /**
+ * Implements hook_field_info()
+ */
+ function `Filename()`_field_info() {
+ return array(
+ /*
+ *'text' => array(
+ * 'label' => t('Text'),
+ * 'description' => t('This field stores varchar text in the database.'),
+ * 'settings' => array('max_length' => 255),
+ * 'instance_settings' => array('text_processing' => 0),
+ * 'default_widget' => 'text_textfield',
+ * 'default_formatter' => 'text_default',
+ *),
+ */
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'description' => t('${3}'),
+ 'settings' => array('${4}' => ${5}),
+ 'instance_settings' => array('${6}' => ${7}),
+ 'default_widget' => '${8}',
+ 'default_formatter' => '${9}',
+ ),
+ );
+ }
+snippet hook_field_info_alter
+ /**
+ * Implements hook_field_info_alter()
+ */
+ function `Filename()`_field_info_alter(&$info) {
+ // Add a setting to all field types.
+ /*
+ *foreach ($info as $field_type => $field_type_info) {
+ * $info[$field_type]['settings'] += array(
+ * 'mymodule_additional_setting' => 'default value',
+ * );
+ *}
+ */
+ // Change the default widget for fields of type 'foo'.
+ /*
+ *if (isset($info['foo'])) {
+ * $info['foo']['default widget'] = 'mymodule_widget';
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_schema
+ /**
+ * Implements hook_field_schema()
+ */
+ function `Filename()`_field_schema($field) {
+ /*
+ *if ($field['type'] == 'text_long') {
+ * $columns = array(
+ * 'value' => array(
+ * 'type' => 'text',
+ * 'size' => 'big',
+ * 'not null' => FALSE,
+ * ),
+ * );
+ *}
+ *else {
+ * $columns = array(
+ * 'value' => array(
+ * 'type' => 'varchar',
+ * 'length' => $field['settings']['max_length'],
+ * 'not null' => FALSE,
+ * ),
+ * );
+ *}
+ *$columns += array(
+ * 'format' => array(
+ * 'type' => 'int',
+ * 'unsigned' => TRUE,
+ * 'not null' => FALSE,
+ * ),
+ *);
+ *return array(
+ * 'columns' => $columns,
+ * 'indexes' => array(
+ * 'format' => array('format'),
+ * ),
+ *);
+ */
+ $columns = array(
+ '${1}' => array(
+ 'type' => '${2}',
+ 'length' => ${3},
+ 'unsigned' => ${4},
+ 'not null' => ${5},
+ ),
+ );
+ $columns = array(
+ '${6}' => array(
+ 'type' => '${7}',
+ 'length' => ${8},
+ 'unsigned' => ${9},
+ 'not null' => ${10},
+ ),
+ );
+ return array(
+ 'columns' => $columns,
+ 'indexes' => array(
+ '${11}' => array('${12}'),
+ ),
+ );
+ }
+snippet hook_field_load
+ /**
+ * Implements hook_field_load()
+ */
+ function `Filename()`_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
+ // Sample code from text.module: precompute sanitized strings so they are
+ // stored in the field cache.
+ /*
+ *foreach ($entities as $id => $entity) {
+ * foreach ($items[$id] as $delta => $item) {
+ * // Only process items with a cacheable format, the rest will be handled
+ * // by formatters if needed.
+ * if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
+ * $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
+ * if ($field['type'] == 'text_with_summary') {
+ * $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
+ * }
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_prepare_view
+ /**
+ * Implements hook_field_prepare_view()
+ */
+ function `Filename()`_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
+ // Sample code from image.module: if there are no images specified at all,
+ // use the default image.
+ /*
+ *foreach ($entities as $id => $entity) {
+ * if (empty($items[$id]) && $field['settings']['default_image']) {
+ * if ($file = file_load($field['settings']['default_image'])) {
+ * $items[$id][0] = (array) $file + array(
+ * 'is_default' => TRUE,
+ * 'alt' => '',
+ * 'title' => '',
+ * );
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_validate
+ /**
+ * Implements hook_field_validate()
+ */
+ function `Filename()`_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+ foreach ($items as $delta => $item) {
+ if (!empty($item['value'])) {
+ /*
+ *if (!empty($field['settings']['max_length']) && drupal_strlen($item['value']) > $field['settings']['max_length']) {
+ * $errors[$field['field_name']][$delta][] = array(
+ * 'error' => 'text_max_length',
+ * 'message' => t('%name: the value may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length'])),
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet hook_field_presave
+ /**
+ * Implements hook_field_presave()
+ */
+ function `Filename()`_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ if ($field['type'] == '${1}') {
+ // Let PHP round the value to ensure consistent behavior across storage
+ // backends.
+ foreach ($items as $delta => $item) {
+ /*
+ *if (isset($item['value'])) {
+ * $items[$delta]['value'] = round($item['value'], $field['settings']['scale']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet hook_field_insert
+ /**
+ * Implements hook_field_insert()
+ */
+ function `Filename()`_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ /*
+ *if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
+ * $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
+ * foreach ($items as $item) {
+ * $query->values(array(
+ * 'nid' => $entity->nid,
+ * 'tid' => $item['tid'],
+ * 'sticky' => $entity->sticky,
+ * 'created' => $entity->created,
+ * ));
+ * }
+ * $query->execute();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_update
+ /**
+ * Implements hook_field_update()
+ */
+ function `Filename()`_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ /*
+ *if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') {
+ * $first_call = &drupal_static(__FUNCTION__, array());
+ *
+ * // We don't maintain data for old revisions, so clear all previous values
+ * // from the table. Since this hook runs once per field, per object, make
+ * // sure we only wipe values once.
+ * if (!isset($first_call[$entity->nid])) {
+ * $first_call[$entity->nid] = FALSE;
+ * db_delete('taxonomy_index')->condition('nid', $entity->nid)->execute();
+ * }
+ * // Only save data to the table if the node is published.
+ * if ($entity->status) {
+ * $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created'));
+ * foreach ($items as $item) {
+ * $query->values(array(
+ * 'nid' => $entity->nid,
+ * 'tid' => $item['tid'],
+ * 'sticky' => $entity->sticky,
+ * 'created' => $entity->created,
+ * ));
+ * }
+ * $query->execute();
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_update_field
+ /**
+ * Implements hook_field_storage_update_field()
+ */
+ function `Filename()`_field_storage_update_field($field, $prior_field, $has_data) {
+ if (!$has_data) {
+ // There is no data. Re-create the tables completely.
+ /*
+ *$prior_schema = _field_sql_storage_schema($prior_field);
+ *foreach ($prior_schema as $name => $table) {
+ * db_drop_table($name, $table);
+ *}
+ *$schema = _field_sql_storage_schema($field);
+ *foreach ($schema as $name => $table) {
+ * db_create_table($name, $table);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+ else {
+ // There is data. See field_sql_storage_field_storage_update_field() for
+ // an example of what to do to modify the schema in place, preserving the
+ // old data as much as possible.
+ ${2:/* Your code here */}
+ }
+ drupal_get_schema(NULL, TRUE);
+ }
+snippet hook_field_delete
+ /**
+ * Implements hook_field_delete()
+ */
+ function `Filename()`_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ foreach ($items as $delta => $item) {
+ // For hook_file_references(), remember that this is being deleted.
+ /*
+ *$item['file_field_name'] = $field['field_name'];
+ */
+ // Pass in the ID of the object that is being removed so all references can
+ // be counted in hook_file_references().
+ /*
+ *$item['file_field_type'] = $entity_type;
+ *$item['file_field_id'] = $id;
+ *file_field_delete_file($item, $field);
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_field_delete_revision
+ /**
+ * Implements hook_field_delete_revision()
+ */
+ function `Filename()`_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ foreach ($items as $delta => $item) {
+ // For hook_file_references, remember that this file is being deleted.
+ /*
+ *$item['file_field_name'] = $field['field_name'];
+ *if (file_field_delete_file($item, $field)) {
+ * $items[$delta] = NULL;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_field_prepare_translation
+ /**
+ * Implements hook_field_prepare_translation()
+ */
+ function `Filename()`_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
+ // If the translating user is not permitted to use the assigned text format,
+ // we must not expose the source values.
+ /*
+ *$field_name = $field['field_name'];
+ *$formats = filter_formats();
+ *$format_id = $source_entity->{$field_name}[$source_langcode][0]['format'];
+ *if (!filter_access($formats[$format_id])) {
+ * $items = array();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_is_empty
+ /**
+ * Implements hook_field_is_empty()
+ */
+ function `Filename()`_field_is_empty($item, $field) {
+ /*
+ *if (empty($item['value']) && (string) $item['value'] !== '0') {
+ * return TRUE;
+ *}
+ *return FALSE;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_widget_info
+ /**
+ * Implements hook_field_widget_info()
+ */
+ function `Filename()`_field_widget_info() {
+ return array(
+ /*
+ *'text_textfield' => array(
+ * 'label' => t('Text field'),
+ * 'field types' => array('text'),
+ * 'settings' => array('size' => 60),
+ * 'behaviors' => array(
+ * 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
+ * 'default value' => FIELD_BEHAVIOR_DEFAULT,
+ * ),
+ *),
+ */
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'field types' => array('${3}'),
+ 'settings' => array('${4}' => ${5}),
+ 'behaviors' => array(
+ 'multiple values' => ${6}FIELD_BEHAVIOR_DEFAULT,
+ 'default value' => ${7}FIELD_BEHAVIOR_DEFAULT,
+ ),
+ ),
+ );
+ }
+snippet hook_field_widget_info_alter
+ /**
+ * Implements hook_field_widget_info_alter()
+ */
+ function `Filename()`_field_widget_info_alter(&$info) {
+ // Add a setting to a widget type.
+ /*
+ *$info['text_textfield']['settings'] += array(
+ * 'mymodule_additional_setting' => 'default value',
+ *);
+ */
+ // Let a new field type re-use an existing widget.
+ /*
+ *$info['options_select']['field types'][] = 'my_field_type';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_widget_form
+ /**
+ * Implements hook_field_widget_form()
+ */
+ function `Filename()`_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
+ /*
+ *$element += array(
+ * '#type' => $instance['widget']['type'],
+ * '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
+ *);
+ */
+ $element += array(
+ '#type' => ${1},
+ '#default_value' => ${2},
+ );
+ return $element;
+ }
+snippet hook_field_widget_error
+ /**
+ * Implements hook_field_widget_error()
+ */
+ function `Filename()`_field_widget_error($element, $error, $form, &$form_state) {
+ /*
+ *form_error($element['value'], $error['message']);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_formatter_info
+ /**
+ * Implements hook_field_formatter_info()
+ */
+ function `Filename()`_field_formatter_info() {
+ return array(
+ /*
+ *'text_default' => array(
+ * 'label' => t('Default'),
+ * 'field types' => array('text', 'text_long', 'text_with_summary'),
+ *),
+ */
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'field types' => array('${3}'),
+ ),
+ );
+ }
+snippet hook_field_formatter_info_alter
+ /**
+ * Implements hook_field_formatter_info_alter()
+ */
+ function `Filename()`_field_formatter_info_alter(&$info) {
+ // Add a setting to a formatter type.
+ /*
+ *$info['text_default']['settings'] += array(
+ * 'mymodule_additional_setting' => 'default value',
+ *);
+ */
+ // Let a new field type re-use an existing formatter.
+ /*
+ *$info['text_default']['field types'][] = 'my_field_type';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_formatter_prepare_view
+ /**
+ * Implements hook_field_formatter_prepare_view()
+ */
+ function `Filename()`_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
+ /*
+ * $tids = array();
+ *
+ * // Collect every possible term attached to any of the fieldable entities.
+ * foreach ($entities as $id => $entity) {
+ * foreach ($items[$id] as $delta => $item) {
+ * // Force the array key to prevent duplicates.
+ * $tids[$item['tid']] = $item['tid'];
+ * }
+ * }
+ *
+ * if ($tids) {
+ * $terms = taxonomy_term_load_multiple($tids);
+ *
+ * // Iterate through the fieldable entities again to attach the loaded term
+ * // data.
+ * foreach ($entities as $id => $entity) {
+ * $rekey = FALSE;
+ *
+ * foreach ($items[$id] as $delta => $item) {
+ * // Check whether the taxonomy term field instance value could be loaded.
+ * if (isset($terms[$item['tid']])) {
+ * // Replace the instance value with the term data.
+ * $items[$id][$delta]['taxonomy_term'] = $terms[$item['tid']];
+ * }
+ * // Otherwise, unset the instance value, since the term does not exist.
+ * else {
+ * unset($items[$id][$delta]);
+ * $rekey = TRUE;
+ * }
+ * }
+ *
+ * if ($rekey) {
+ * // Rekey the items array.
+ * $items[$id] = array_values($items[$id]);
+ * }
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_formatter_view
+ /**
+ * Implements hook_field_formatter_view()
+ */
+ function `Filename()`_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
+ $element = array();
+ $settings = $display['settings'];
+
+ switch ($display['type']) {
+ /*
+ *case 'sample_field_formatter_simple':
+ * // Common case: each value is displayed individually in a sub-element
+ * // keyed by delta. The field.tpl.php template specifies the markup
+ * // wrapping each value.
+ * foreach ($items as $delta => $item) {
+ * $element[$delta] = array('#markup' => $settings['some_setting'] . $item['value']);
+ * }
+ * break;
+ *
+ *case 'sample_field_formatter_themeable':
+ * // More elaborate formatters can defer to a theme function for easier
+ * // customization.
+ * foreach ($items as $delta => $item) {
+ * $element[$delta] = array(
+ * '#theme' => 'mymodule_theme_sample_field_formatter_themeable',
+ * '#data' => $item['value'],
+ * '#some_setting' => $settings['some_setting'],
+ * );
+ * }
+ * break;
+ *
+ *case 'sample_field_formatter_combined':
+ * // Some formatters might need to display all values within a single piece
+ * // of markup.
+ * $rows = array();
+ * foreach ($items as $delta => $item) {
+ * $rows[] = array($delta, $item['value']);
+ * }
+ * $element[0] = array(
+ * '#theme' => 'table',
+ * '#header' => array(t('Delta'), t('Value')),
+ * '#rows' => $rows,
+ * );
+ * break;
+ */
+ case '${1}':
+ foreach ($items as $delta => $item) {
+ $element[$delta] = array(
+ '#theme' => '${2}',
+ '#data' => $item['value'],
+ '#markup' => ${3},
+ '#${4}' => $settings['${5}'],
+ );
+ }
+ break;
+ }
+
+ return $element;
+ }
+snippet hook_field_attach_form
+ /**
+ * Implements hook_field_attach_form()
+ */
+ function `Filename()`_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_load
+ /**
+ * Implements hook_field_attach_load()
+ */
+ function `Filename()`_field_attach_load($entity_type, &$entities, $age, $options) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_validate
+ /**
+ * Implements hook_field_attach_validate()
+ */
+ function `Filename()`_field_attach_validate($entity_type, $entity, &$errors) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_submit
+ /**
+ * Implements hook_field_attach_submit()
+ */
+ function `Filename()`_field_attach_submit($entity_type, $entity, $form, &$form_state) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_presave
+ /**
+ * Implements hook_field_attach_presave()
+ */
+ function `Filename()`_field_attach_presave($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_insert
+ /**
+ * Implements hook_field_attach_insert()
+ */
+ function `Filename()`_field_attach_insert($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_update
+ /**
+ * Implements hook_field_attach_update()
+ */
+ function `Filename()`_field_attach_update($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_preprocess_alter
+ /**
+ * Implements hook_field_attach_preprocess_alter()
+ */
+ function `Filename()`_field_attach_preprocess_alter(&$variables, $context) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_delete
+ /**
+ * Implements hook_field_attach_delete()
+ */
+ function `Filename()`_field_attach_delete($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_delete_revision
+ /**
+ * Implements hook_field_attach_delete_revision()
+ */
+ function `Filename()`_field_attach_delete_revision($entity_type, $entity) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_purge
+ /**
+ * Implements hook_field_attach_purge()
+ */
+ function `Filename()`_field_attach_purge($entity_type, $entity, $field, $instance) {
+ // find the corresponding data in mymodule and purge it
+ /*
+ *if($entity_type == 'node' && $field->field_name == 'my_field_name') {
+ * mymodule_remove_mydata($entity->nid);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_view_alter
+ /**
+ * Implements hook_field_attach_view_alter()
+ */
+ function `Filename()`_field_attach_view_alter(&$output, $context) {
+ // Append RDF term mappings on displayed taxonomy links.
+ /*
+ *foreach (element_children($output) as $field_name) {
+ * $element = &$output[$field_name];
+ * if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_reference_link') {
+ * foreach ($element['#items'] as $delta => $item) {
+ * $term = $item['taxonomy_term'];
+ * if (!empty($term->rdf_mapping['rdftype'])) {
+ * $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
+ * }
+ * if (!empty($term->rdf_mapping['name']['predicates'])) {
+ * $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
+ * }
+ * }
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_prepare_translation_alter
+ /**
+ * Implements hook_field_attach_prepare_translation_alter()
+ */
+ function `Filename()`_field_attach_prepare_translation_alter(&$entity, $context) {
+ /*
+ *if ($context['entity_type'] == 'custom_entity_type') {
+ * $entity->custom_field = $context['source_entity']->custom_field;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_language_alter
+ /**
+ * Implements hook_field_language_alter()
+ */
+ function `Filename()`_field_language_alter(&$display_language, $context) {
+ // Do not apply core language fallback rules if they are disabled or if Locale
+ // is not registered as a translation handler.
+ /*
+ *if (variable_get('locale_field_language_fallback', TRUE) && field_has_translation_handler($context['entity_type'], 'locale')) {
+ * locale_field_language_fallback($display_language, $context['entity'], $context['language']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_available_languages_alter
+ /**
+ * Implements hook_field_available_languages_alter()
+ */
+ function `Filename()`_field_available_languages_alter(&$languages, $context) {
+ // Add an unavailable language.
+ /*
+ *$languages[] = 'xx';
+ */
+ // Remove an available language.
+ /*
+ *$index = array_search('yy', $languages);
+ *unset($languages[$index]);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_create_bundle
+ /**
+ * Implements hook_field_attach_create_bundle()
+ */
+ function `Filename()`_field_attach_create_bundle($entity_type, $bundle) {
+ // When a new bundle is created, the menu needs to be rebuilt to add the
+ // Field UI menu item tabs.
+ /*
+ *variable_set('menu_rebuild_needed', TRUE);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_rename_bundle
+ /**
+ * Implements hook_field_attach_rename_bundle()
+ */
+ function `Filename()`_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
+ // Update the extra weights variable with new information.
+ /*
+ *if ($bundle_old !== $bundle_new) {
+ * $extra_weights = variable_get('field_extra_weights', array());
+ * if (isset($info[$entity_type][$bundle_old])) {
+ * $extra_weights[$entity_type][$bundle_new] = $extra_weights[$entity_type][$bundle_old];
+ * unset($extra_weights[$entity_type][$bundle_old]);
+ * variable_set('field_extra_weights', $extra_weights);
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_attach_delete_bundle
+ /**
+ * Implements hook_field_attach_delete_bundle()
+ */
+ function `Filename()`_field_attach_delete_bundle($entity_type, $bundle, $instances) {
+ // Remove the extra weights variable information for this bundle.
+ /*
+ *$extra_weights = variable_get('field_extra_weights', array());
+ *if (isset($extra_weights[$entity_type][$bundle])) {
+ * unset($extra_weights[$entity_type][$bundle]);
+ * variable_set('field_extra_weights', $extra_weights);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_info
+ /**
+ * Implements hook_field_storage_info()
+ */
+ function `Filename()`_field_storage_info() {
+ return array(
+ /*
+ *'field_sql_storage' => array(
+ * 'label' => t('Default SQL storage'),
+ * 'description' => t('Stores fields in the local SQL database, using per-field tables.'),
+ * 'settings' => array(),
+ *),
+ */
+ '${1}' => array(
+ 'label' => t('${2}'),
+ 'description' => t('${3}'),
+ 'settings' => array('${4}'${5}),
+ ),
+ );
+ }
+snippet hook_field_storage_info_alter
+ /**
+ * Implements hook_field_storage_info_alter()
+ */
+ function `Filename()`_field_storage_info_alter(&$info) {
+ // Add a setting to a storage type.
+ /*
+ *$info['field_sql_storage']['settings'] += array(
+ * 'mymodule_additional_setting' => 'default value',
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_details
+ /**
+ * Implements hook_field_storage_details()
+ */
+ function `Filename()`_field_storage_details($field) {
+ $details = array();
+
+ // Add field columns.
+ /*
+ *foreach ((array) $field['columns'] as $column_name => $attributes) {
+ * $real_name = _field_sql_storage_columnname($field['field_name'], $column_name);
+ * $columns[$column_name] = $real_name;
+ *}
+ *return array(
+ * 'sql' => array(
+ * FIELD_LOAD_CURRENT => array(
+ * _field_sql_storage_tablename($field) => $columns,
+ * ),
+ * FIELD_LOAD_REVISION => array(
+ * _field_sql_storage_revision_tablename($field) => $columns,
+ * ),
+ * ),
+ *);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_details_alter
+ /**
+ * Implements hook_field_storage_details_alter()
+ */
+ function `Filename()`_field_storage_details_alter(&$details, $field) {
+ /*
+ *if ($field['field_name'] == 'field_of_interest') {
+ * $columns = array();
+ * foreach ((array) $field['columns'] as $column_name => $attributes) {
+ * $columns[$column_name] = $column_name;
+ * }
+ * $details['drupal_variables'] = array(
+ * FIELD_LOAD_CURRENT => array(
+ * 'moon' => $columns,
+ * ),
+ * FIELD_LOAD_REVISION => array(
+ * 'mars' => $columns,
+ * ),
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_load
+ /**
+ * Implements hook_field_storage_load()
+ */
+ function `Filename()`_field_storage_load($entity_type, &$entities, $age, $fields, $options) {
+ /*
+ * $field_info = field_info_field_by_ids();
+ * $etid = _field_sql_storage_etid($entity_type);
+ * $load_current = $age == FIELD_LOAD_CURRENT;
+ *
+ * foreach ($fields as $field_id => $ids) {
+ * $field = $field_info[$field_id];
+ * $field_name = $field['field_name'];
+ * $table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
+ *
+ * $query = db_select($table, 't')
+ * ->fields('t')
+ * ->condition('etid', $etid)
+ * ->condition($load_current ? 'entity_id' : 'revision_id', $ids, 'IN')
+ * ->condition('language', field_available_languages($entity_type, $field), 'IN')
+ * ->orderBy('delta');
+ *
+ * if (empty($options['deleted'])) {
+ * $query->condition('deleted', 0);
+ * }
+ *
+ * $results = $query->execute();
+ *
+ * $delta_count = array();
+ * foreach ($results as $row) {
+ * if (!isset($delta_count[$row->entity_id][$row->language])) {
+ * $delta_count[$row->entity_id][$row->language] = 0;
+ * }
+ *
+ * if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $delta_count[$row->entity_id][$row->language] < $field['cardinality']) {
+ * $item = array();
+ * // For each column declared by the field, populate the item
+ * // from the prefixed database column.
+ * foreach ($field['columns'] as $column => $attributes) {
+ * $column_name = _field_sql_storage_columnname($field_name, $column);
+ * $item[$column] = $row->$column_name;
+ * }
+ *
+ * // Add the item to the field values for the entity.
+ * $entities[$row->entity_id]->{$field_name}[$row->language][] = $item;
+ * $delta_count[$row->entity_id][$row->language]++;
+ * }
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_write
+ /**
+ * Implements hook_field_storage_write()
+ */
+ function `Filename()`_field_storage_write($entity_type, $entity, $op, $fields) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ $etid = _field_sql_storage_etid($entity_type);
+
+ foreach ($fields as $field_id) {
+ /*
+ * $field = field_info_field_by_id($field_id);
+ * $field_name = $field['field_name'];
+ * $table_name = _field_sql_storage_tablename($field);
+ * $revision_name = _field_sql_storage_revision_tablename($field);
+ *
+ * $all_languages = field_available_languages($entity_type, $field);
+ * $field_languages = array_intersect($all_languages, array_keys((array) $entity->$field_name));
+ *
+ * // Delete and insert, rather than update, in case a value was added.
+ * if ($op == FIELD_STORAGE_UPDATE) {
+ * // Delete languages present in the incoming $entity->$field_name.
+ * // Delete all languages if $entity->$field_name is empty.
+ * $languages = !empty($entity->$field_name) ? $field_languages : $all_languages;
+ * if ($languages) {
+ * db_delete($table_name)
+ * ->condition('etid', $etid)
+ * ->condition('entity_id', $id)
+ * ->condition('language', $languages, 'IN')
+ * ->execute();
+ * if (isset($vid)) {
+ * db_delete($revision_name)
+ * ->condition('etid', $etid)
+ * ->condition('entity_id', $id)
+ * ->condition('revision_id', $vid)
+ * ->condition('language', $languages, 'IN')
+ * ->execute();
+ * }
+ * }
+ * }
+ *
+ * // Prepare the multi-insert query.
+ * $do_insert = FALSE;
+ * $columns = array('etid', 'entity_id', 'revision_id', 'bundle', 'delta', 'language');
+ * foreach ($field['columns'] as $column => $attributes) {
+ * $columns[] = _field_sql_storage_columnname($field_name, $column);
+ * }
+ * $query = db_insert($table_name)->fields($columns);
+ * if (isset($vid)) {
+ * $revision_query = db_insert($revision_name)->fields($columns);
+ * }
+ *
+ * foreach ($field_languages as $langcode) {
+ * $items = (array) $entity->{$field_name}[$langcode];
+ * $delta_count = 0;
+ * foreach ($items as $delta => $item) {
+ * // We now know we have someting to insert.
+ * $do_insert = TRUE;
+ * $record = array(
+ * 'etid' => $etid,
+ * 'entity_id' => $id,
+ * 'revision_id' => $vid,
+ * 'bundle' => $bundle,
+ * 'delta' => $delta,
+ * 'language' => $langcode,
+ * );
+ * foreach ($field['columns'] as $column => $attributes) {
+ * $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL;
+ * }
+ * $query->values($record);
+ * if (isset($vid)) {
+ * $revision_query->values($record);
+ * }
+ *
+ * if ($field['cardinality'] != FIELD_CARDINALITY_UNLIMITED && ++$delta_count == $field['cardinality']) {
+ * break;
+ * }
+ * }
+ * }
+ *
+ * // Execute the query if we have values to insert.
+ * if ($do_insert) {
+ * $query->execute();
+ * if (isset($vid)) {
+ * $revision_query->execute();
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_field_storage_delete
+ /**
+ * Implements hook_field_storage_delete()
+ */
+ function `Filename()`_field_storage_delete($entity_type, $entity, $fields) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ $etid = _field_sql_storage_etid($entity_type);
+
+ foreach (field_info_instances($entity_type, $bundle) as $instance) {
+ /*
+ *if (isset($fields[$instance['field_id']])) {
+ * $field = field_info_field_by_id($instance['field_id']);
+ * field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+ }
+snippet hook_field_storage_delete_revision
+ /**
+ * Implements hook_field_storage_delete_revision()
+ */
+ function `Filename()`_field_storage_delete_revision($entity_type, $entity, $fields) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ $etid = _field_sql_storage_etid($entity_type);
+
+ if (isset($vid)) {
+ foreach ($fields as $field_id) {
+ /*
+ *$field = field_info_field_by_id($field_id);
+ *$revision_name = _field_sql_storage_revision_tablename($field);
+ *db_delete($revision_name)
+ * ->condition('etid', $etid)
+ * ->condition('entity_id', $id)
+ * ->condition('revision_id', $vid)
+ * ->execute();
+ */
+ ${1:/* Your code here */}
+ }
+ }
+ }
+snippet hook_field_storage_query
+ /**
+ * Implements hook_field_storage_query()
+ */
+ function `Filename()`_field_storage_query($query) {
+ /*
+ * $load_current = $options['age'] == FIELD_LOAD_CURRENT;
+ *
+ * $field = field_info_field_by_id($field_id);
+ * $field_name = $field['field_name'];
+ * $table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
+ * $field_columns = array_keys($field['columns']);
+ *
+ * // Build the query.
+ * $query = db_select($table, 't');
+ * $query->join('field_config_entity_type', 'e', 't.etid = e.etid');
+ *
+ * // Add conditions.
+ * foreach ($conditions as $condition) {
+ * // A condition is either a (column, value, operator) triple, or a
+ * // (column, value) pair with implied operator.
+ * @list($column, $value, $operator) = $condition;
+ * // Translate operator and value if needed.
+ * switch ($operator) {
+ * case 'STARTS_WITH':
+ * $operator = 'LIKE';
+ * $value = db_like($value) . '%';
+ * break;
+ *
+ * case 'ENDS_WITH':
+ * $operator = 'LIKE';
+ * $value = '%' . db_like($value);
+ * break;
+ *
+ * case 'CONTAINS':
+ * $operator = 'LIKE';
+ * $value = '%' . db_like($value) . '%';
+ * break;
+ * }
+ * // Translate field columns into prefixed db columns.
+ * if (in_array($column, $field_columns)) {
+ * $column = _field_sql_storage_columnname($field_name, $column);
+ * }
+ * // Translate entity types into numeric ids. Expressing the condition on the
+ * // local 'etid' column rather than the JOINed 'type' column avoids a
+ * // filesort.
+ * if ($column == 'type') {
+ * $column = 't.etid';
+ * if (is_array($value)) {
+ * foreach (array_keys($value) as $key) {
+ * $value[$key] = _field_sql_storage_etid($value[$key]);
+ * }
+ * }
+ * else {
+ * $value = _field_sql_storage_etid($value);
+ * }
+ * }
+ * // Track condition on 'deleted'.
+ * if ($column == 'deleted') {
+ * $condition_deleted = TRUE;
+ * }
+ *
+ * $query->condition($column, $value, $operator);
+ * }
+ *
+ * // Exclude deleted data unless we have a condition on it.
+ * if (!isset($condition_deleted)) {
+ * $query->condition('deleted', 0);
+ * }
+ *
+ * // For a count query, return the count now.
+ * if ($options['count']) {
+ * return $query
+ * ->fields('t', array('etid', 'entity_id', 'revision_id'))
+ * ->distinct()
+ * ->countQuery()
+ * ->execute()
+ * ->fetchField();
+ * }
+ *
+ * // For a data query, add fields.
+ * $query
+ * ->fields('t', array('bundle', 'entity_id', 'revision_id'))
+ * ->fields('e', array('type'))
+ * // We need to ensure entities arrive in a consistent order for the
+ * // range() operation to work.
+ * ->orderBy('t.etid')
+ * ->orderBy('t.entity_id');
+ *
+ * // Initialize results array
+ * $return = array();
+ *
+ * // Getting $count entities possibly requires reading more than $count rows
+ * // since fields with multiple values span over several rows. We query for
+ * // batches of $count rows until we've either read $count entities or received
+ * // less rows than asked for.
+ * $entity_count = 0;
+ * do {
+ * if ($options['limit'] != FIELD_QUERY_NO_LIMIT) {
+ * $query->range($options['cursor'], $options['limit']);
+ * }
+ * $results = $query->execute();
+ *
+ * $row_count = 0;
+ * foreach ($results as $row) {
+ * $row_count++;
+ * $options['cursor']++;
+ * // If querying all revisions and the entity type has revisions, we need
+ * // to key the results by revision_ids.
+ * $entity_type = entity_get_info($row->type);
+ * $id = ($load_current || empty($entity_type['entity keys']['revision'])) ? $row->entity_id : $row->revision_id;
+ *
+ * if (!isset($return[$row->type][$id])) {
+ * $return[$row->type][$id] = entity_create_stub_entity($row->type, array($row->entity_id, $row->revision_id, $row->bundle));
+ * $entity_count++;
+ * }
+ * }
+ * } while ($options['limit'] != FIELD_QUERY_NO_LIMIT && $row_count == $options['limit'] && $entity_count < $options['limit']);
+ *
+ * // The query is complete when the last batch returns less rows than asked
+ * // for.
+ * if ($row_count < $options['limit']) {
+ * $options['cursor'] = FIELD_QUERY_COMPLETE;
+ * }
+ *
+ * return $return;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_create_field
+ /**
+ * Implements hook_field_storage_create_field()
+ */
+ function `Filename()`_field_storage_create_field($field) {
+ /*
+ *$schema = _field_sql_storage_schema($field);
+ *foreach ($schema as $name => $table) {
+ * db_create_table($name, $table);
+ *}
+ *drupal_get_schema(NULL, TRUE);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_delete_field
+ /**
+ * Implements hook_field_storage_delete_field()
+ */
+ function `Filename()`_field_storage_delete_field($field) {
+ // Mark all data associated with the field for deletion.
+ /*
+ *$field['deleted'] = 0;
+ *$table = _field_sql_storage_tablename($field);
+ *$revision_table = _field_sql_storage_revision_tablename($field);
+ *db_update($table)
+ * ->fields(array('deleted' => 1))
+ * ->execute();
+ */
+ // Move the table to a unique name while the table contents are being deleted.
+ /*
+ *$field['deleted'] = 1;
+ *$new_table = _field_sql_storage_tablename($field);
+ *$revision_new_table = _field_sql_storage_revision_tablename($field);
+ *db_rename_table($table, $new_table);
+ *db_rename_table($revision_table, $revision_new_table);
+ *drupal_get_schema(NULL, TRUE);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_delete_instance
+ /**
+ * Implements hook_field_storage_delete_instance()
+ */
+ function `Filename()`_field_storage_delete_instance($instance) {
+ /*
+ *$etid = _field_sql_storage_etid($instance['entity_type']);
+ *$field = field_info_field($instance['field_name']);
+ *$table_name = _field_sql_storage_tablename($field);
+ *$revision_name = _field_sql_storage_revision_tablename($field);
+ *db_update($table_name)
+ * ->fields(array('deleted' => 1))
+ * ->condition('etid', $etid)
+ * ->condition('bundle', $instance['bundle'])
+ * ->execute();
+ *db_update($revision_name)
+ * ->fields(array('deleted' => 1))
+ * ->condition('etid', $etid)
+ * ->condition('bundle', $instance['bundle'])
+ * ->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_pre_load
+ /**
+ * Implements hook_field_storage_pre_load()
+ */
+ function `Filename()`_field_storage_pre_load($entity_type, $entities, $age, &$skip_fields, $options) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_pre_insert
+ /**
+ * Implements hook_field_storage_pre_insert()
+ */
+ function `Filename()`_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
+ /*
+ *if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
+ * $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
+ * foreach ($entity->taxonomy_forums as $language) {
+ * foreach ($language as $delta) {
+ * $query->values(array(
+ * 'nid' => $entity->nid,
+ * 'title' => $entity->title,
+ * 'tid' => $delta['value'],
+ * 'sticky' => $entity->sticky,
+ * 'created' => $entity->created,
+ * 'comment_count' => 0,
+ * 'last_comment_timestamp' => $entity->created,
+ * ));
+ * }
+ * }
+ * $query->execute();
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_pre_update
+ /**
+ * Implements hook_field_storage_pre_update()
+ */
+ function `Filename()`_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
+ /*
+ * $first_call = &drupal_static(__FUNCTION__, array());
+ *
+ * if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
+ * // We don't maintain data for old revisions, so clear all previous values
+ * // from the table. Since this hook runs once per field, per entity, make
+ * // sure we only wipe values once.
+ * if (!isset($first_call[$entity->nid])) {
+ * $first_call[$entity->nid] = FALSE;
+ * db_delete('forum_index')->condition('nid', $entity->nid)->execute();
+ * }
+ * // Only save data to the table if the node is published.
+ * if ($entity->status) {
+ * $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
+ * foreach ($entity->taxonomy_forums as $language) {
+ * foreach ($language as $delta) {
+ * $query->values(array(
+ * 'nid' => $entity->nid,
+ * 'title' => $entity->title,
+ * 'tid' => $delta['value'],
+ * 'sticky' => $entity->sticky,
+ * 'created' => $entity->created,
+ * 'comment_count' => 0,
+ * 'last_comment_timestamp' => $entity->created,
+ * ));
+ * }
+ * }
+ * $query->execute();
+ * // The logic for determining last_comment_count is fairly complex, so
+ * // call _forum_update_forum_index() too.
+ * _forum_update_forum_index($entity->nid);
+ * }
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_info_max_weight
+ /**
+ * Implements hook_field_info_max_weight()
+ */
+ function `Filename()`_field_info_max_weight($entity_type, $bundle, $context) {
+ $weights = array();
+
+ /*
+ *foreach (my_module_entity_additions($entity_type, $bundle, $context) as $addition) {
+ * $weights[] = $addition['weight'];
+ *}
+ */
+ ${1:/* Your code here */}
+
+ return $weights ? max($weights) : NULL;
+ }
+snippet hook_field_display_alter
+ /**
+ * Implements hook_field_display_alter()
+ */
+ function `Filename()`_field_display_alter(&$display, $context) {
+ // Leave field labels out of the search index.
+ // Note: The check against $context['entity_type'] == 'node' could be avoided
+ // by using hook_field_display_node_alter() instead of
+ // hook_field_display_alter(), resulting in less function calls when
+ // rendering non-node entities.
+ /*
+ *if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
+ * $display['label'] = 'hidden';
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_display_ENTITY_TYPE_alter
+ /**
+ * Implements hook_field_display_ENTITY_TYPE_alter()
+ */
+ function `Filename()`_field_display_ENTITY_TYPE_alter(&$display, $context) {
+ // Leave field labels out of the search index.
+ /*
+ *if ($context['view_mode'] == 'search_index') {
+ * $display['label'] = 'hidden';
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_extra_fields_display_alter
+ /**
+ * Implements hook_field_extra_fields_display_alter()
+ */
+ function `Filename()`_field_extra_fields_display_alter(&$displays, $context) {
+ /*
+ *if ($context['entity_type'] == 'taxonomy_term' && $context['view_mode'] == 'full') {
+ * $displays['description']['visibility'] = FALSE;
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_create_field
+ /**
+ * Implements hook_field_create_field()
+ */
+ function `Filename()`_field_create_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_create_instance
+ /**
+ * Implements hook_field_create_instance()
+ */
+ function `Filename()`_field_create_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_update_forbid
+ /**
+ * Implements hook_field_update_forbid()
+ */
+ function `Filename()`_field_update_forbid($field, $prior_field, $has_data) {
+ // A 'list' field stores integer keys mapped to display values. If
+ // the new field will have fewer values, and any data exists for the
+ // abandoned keys, the field will have no way to display them. So,
+ // forbid such an update.
+ /*
+ *if ($has_data && count($field['settings']['allowed_values']) < count($prior_field['settings']['allowed_values'])) {
+ * // Identify the keys that will be lost.
+ * $lost_keys = array_diff(array_keys($field['settings']['allowed_values']), array_keys($prior_field['settings']['allowed_values']));
+ * // If any data exist for those keys, forbid the update.
+ * $query = new EntityFieldQuery();
+ * $found = $query
+ * ->fieldCondition($prior_field['field_name'], 'value', $lost_keys)
+ * ->range(0, 1)
+ * ->execute();
+ * if ($found) {
+ * throw new FieldUpdateForbiddenException("Cannot update a list field not to include keys with existing data");
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_update_field
+ /**
+ * Implements hook_field_update_field()
+ */
+ function `Filename()`_field_update_field($field, $prior_field, $has_data) {
+ // Reset the static value that keeps track of allowed values for list fields.
+ /*
+ *drupal_static_reset('list_allowed_values');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_delete_field
+ /**
+ * Implements hook_field_delete_field()
+ */
+ function `Filename()`_field_delete_field($field) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_update_instance
+ /**
+ * Implements hook_field_update_instance()
+ */
+ function `Filename()`_field_update_instance($instance, $prior_instance) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_delete_instance
+ /**
+ * Implements hook_field_delete_instance()
+ */
+ function `Filename()`_field_delete_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_read_field
+ /**
+ * Implements hook_field_read_field()
+ */
+ function `Filename()`_field_read_field(&$field) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_read_instance
+ /**
+ * Implements hook_field_read_instance()
+ */
+ function `Filename()`_field_read_instance($instance) {
+ ${1:/* Your code here */}
+ }
+snippet hook_field_purge_field
+ /**
+ * Implements hook_field_purge_field()
+ */
+ function `Filename()`_field_purge_field($field) {
+ db_delete('${1}')
+ ->condition('id', $field['id'])
+ ->execute();
+ }
+snippet hook_field_purge_field_instance
+ /**
+ * Implements hook_field_purge_field_instance()
+ */
+ function `Filename()`_field_purge_field_instance($instance) {
+ db_delete('${1}')
+ ->condition('id', $instance['id'])
+ ->execute();
+ }
+snippet hook_field_storage_purge_field
+ /**
+ * Implements hook_field_storage_purge_field()
+ */
+ function `Filename()`_field_storage_purge_field($field) {
+ /*
+ *$table_name = _field_sql_storage_tablename($field);
+ *$revision_name = _field_sql_storage_revision_tablename($field);
+ *db_drop_table($table_name);
+ *db_drop_table($revision_name);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_storage_purge_field_instance
+ /**
+ * Implements hook_field_storage_purge_field_instance()
+ */
+ function `Filename()`_field_storage_purge_field_instance($instance) {
+ db_delete('${1}')
+ ->condition('id', $instance['id'])
+ ->execute();
+ }
+snippet hook_field_storage_purge
+ /**
+ * Implements hook_field_storage_purge()
+ */
+ function `Filename()`_field_storage_purge($entity_type, $entity, $field, $instance) {
+ list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
+ /*
+ *$etid = _field_sql_storage_etid($entity_type);
+ *
+ *$table_name = _field_sql_storage_tablename($field);
+ *$revision_name = _field_sql_storage_revision_tablename($field);
+ *db_delete($table_name)
+ * ->condition('etid', $etid)
+ * ->condition('entity_id', $id)
+ * ->execute();
+ *db_delete($revision_name)
+ * ->condition('etid', $etid)
+ * ->condition('entity_id', $id)
+ * ->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_field_access
+ /**
+ * Implements hook_field_access()
+ */
+ function `Filename()`_field_access($op, $field, $entity_type, $entity, $account) {
+ /*
+ *if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
+ * return user_access('edit field of interest', $account);
+ *}
+ */
+ ${1:/* Your code here */}
+ return TRUE;
+ }
+snippet hook_options_list
+ /**
+ * Implements hook_options_list()
+ */
+ function `Filename()`_options_list($field) {
+ // Sample structure.
+ /*
+ *$options = array(
+ * 0 => t('Zero'),
+ * 1 => t('One'),
+ * 2 => t('Two'),
+ * 3 => t('Three'),
+ *);
+ */
+ // Sample structure with groups. Only one level of nesting is allowed. This
+ // is only supported by the 'options_select' widget. Other widgets will
+ // flatten the array.
+ /*
+ *$options = array(
+ * t('First group') => array(
+ * 0 => t('Zero'),
+ * ),
+ * t('Second group') => array(
+ * 1 => t('One'),
+ * 2 => t('Two'),
+ * ),
+ * 3 => t('Three'),
+ *);
+ */
+ // In actual implementations, the array of options will most probably depend
+ // on properties of the field. Example from taxonomy.module:
+ /*
+ *$options = array();
+ *foreach ($field['settings']['allowed_values'] as $tree) {
+ * $terms = taxonomy_get_tree($tree['vid'], $tree['parent']);
+ * if ($terms) {
+ * foreach ($terms as $term) {
+ * $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
+ * }
+ * }
+ *}
+ */
+ $options = array(
+ ${1} => ${2},
+ );
+
+ return $options;
+ }
+snippet hook_contextual_links_view_alter
+ /**
+ * Implements hook_contextual_links_view_alter()
+ */
+ function `Filename()`_contextual_links_view_alter(&$element, $items) {
+ // Add another class to all contextual link lists to facilitate custom
+ // styling.
+ /*
+ *$element['#attributes']['class'][] = 'custom-class';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_dashboard_regions
+ /**
+ * Implements hook_dashboard_regions()
+ */
+ function `Filename()`_dashboard_regions() {
+ // Define a new dashboard region. Your module can also then define
+ // theme_mymodule_dashboard_region() as a theme wrapper function to control
+ // the region's appearance.
+ /*
+ *return array('mymodule_dashboard_region' => "My module's dashboard region");
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_dashboard_regions_alter
+ /**
+ * Implements hook_dashboard_regions_alter()
+ */
+ function `Filename()`_dashboard_regions_alter($regions) {
+ // Remove the sidebar region defined by the core dashboard module.
+ /*
+ *unset($regions['dashboard_sidebar']);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_insert
+ /**
+ * Implements hook_menu_insert()
+ */
+ function `Filename()`_menu_insert($menu) {
+ // For example, we track available menus in a variable.
+ /*
+ *$my_menus = variable_get('my_module_menus', array());
+ *$my_menus[$menu['menu_name']] = $menu['menu_name'];
+ *variable_set('my_module_menus', $my_menus);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_update
+ /**
+ * Implements hook_menu_update()
+ */
+ function `Filename()`_menu_update($menu) {
+ // For example, we track available menus in a variable.
+ /*
+ *$my_menus = variable_get('my_module_menus', array());
+ *$my_menus[$menu['menu_name']] = $menu['menu_name'];
+ *variable_set('my_module_menus', $my_menus);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_menu_delete
+ /**
+ * Implements hook_menu_delete()
+ */
+ function `Filename()`_menu_delete($menu) {
+ // Delete the record from our variable.
+ /*
+ *$my_menus = variable_get('my_module_menus', array());
+ *unset($my_menus[$menu['menu_name']]);
+ *variable_set('my_module_menus', $my_menus);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_path_insert
+ /**
+ * Implements hook_path_insert()
+ */
+ function `Filename()`_path_insert($path) {
+ ${1:/* Your code here */}
+ }
+snippet hook_path_update
+ /**
+ * Implements hook_path_update()
+ */
+ function `Filename()`_path_update($path) {
+ ${1:/* Your code here */}
+ }
+snippet hook_path_delete
+ /**
+ * Implements hook_path_delete()
+ */
+ function `Filename()`_path_delete($path) {
+ ${1:/* Your code here */}
+ }
+snippet hook_shortcut_default_set
+ /**
+ * Implements hook_shortcut_default_set()
+ */
+ function `Filename()`_shortcut_default_set($account) {
+ // Use a special set of default shortcuts for administrators only.
+ /*
+ *if (in_array(variable_get('user_admin_role', 0), $account->roles)) {
+ * return variable_get('mymodule_shortcut_admin_default_set');
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_effect_info
+ /**
+ * Implements hook_image_effect_info()
+ */
+ function `Filename()`_image_effect_info() {
+ $effects = array();
+
+ $effects['${1}'] = array(
+ 'label' => t('${2}'),
+ 'help' => t('${3}'),
+ 'effect callback' => '${4}',
+ 'form callback' => '${5}',
+ 'summary theme' => '${6}',
+ );
+
+ return $effects;
+ }
+snippet hook_image_effect_info_alter
+ /**
+ * Implements hook_image_effect_info_alter()
+ */
+ function `Filename()`_image_effect_info_alter(&$effects) {
+ // override the image module's crop effect with more options.
+ /*
+ *$effect['image_crop']['effect callback'] = 'mymodule_crop_effect';
+ *$effect['image_crop']['form callback'] = 'mymodule_crop_form';
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_style_save
+ /**
+ * Implements hook_image_style_save()
+ */
+ function `Filename()`_image_style_save($style) {
+ // if a module defines an image style and that style is renamed by the user
+ // the module should update any references to that style.
+ /*
+ *if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) {
+ * variable_set('mymodule_image_style', $style['name']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_style_delete
+ /**
+ * Implements hook_image_style_delete()
+ */
+ function `Filename()`_image_style_delete($style) {
+ // Administrators can choose an optional replacement style when deleting.
+ // Update the modules style variable accordingly.
+ /*
+ *if (isset($style['old_name']) && $style['old_name'] == variable_get('mymodule_image_style', '')) {
+ * variable_set('mymodule_image_style', $style['name']);
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_style_flush
+ /**
+ * Implements hook_image_style_flush()
+ */
+ function `Filename()`_image_style_flush($style) {
+ // Empty cached data that contains information about the style.
+ /*
+ *cache_clear_all('*', 'cache_mymodule', TRUE);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_styles_alter
+ /**
+ * Implements hook_image_styles_alter()
+ */
+ function `Filename()`_image_styles_alter(&$styles) {
+ // Check that we only affect a default style.
+ /*
+ *if ($styles['thumbnail']['storage'] == IMAGE_STORAGE_DEFAULT) {
+ * // Add an additional effect to the thumbnail style.
+ * $styles['thumbnail']['effects'][] = array(
+ * 'name' => 'image_desaturate',
+ * 'data' => array(),
+ * 'weight' => 1,
+ * 'effect callback' => 'image_desaturate_effect',
+ * );
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_image_default_styles
+ /**
+ * Implements hook_image_default_styles()
+ */
+ function `Filename()`_image_default_styles() {
+ $styles = array();
+
+ $styles['${1}'] = array(
+ 'effects' => array(
+ array(
+ 'name' => '${2}',
+ 'data' => array('width' => ${3}, 'height' => ${4}, 'upscale' => ${5}),
+ 'weight' => ${6},
+ ),
+ ),
+ );
+
+ return $styles;
+ }
+snippet hook_trigger_info
+ /**
+ * Implements hook_trigger_info()
+ */
+ function `Filename()`_trigger_info() {
+ return array(
+ '${1}' => array(
+ /*
+ *'node_presave' => array(
+ * 'label' => t('When either saving new content or updating existing content'),
+ *),
+ */
+ '${2}' => array(
+ 'label' => t('${3}'),
+ ),
+ ),
+ );
+ }
+snippet hook_trigger_info_alter
+ /**
+ * Implements hook_trigger_info_alter()
+ */
+ function `Filename()`_trigger_info_alter(&$triggers) {
+ /*
+ *$triggers['node']['node_insert']['label'] = t('When content is saved');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_search_info
+ /**
+ * Implements hook_search_info()
+ */
+ function `Filename()`_search_info() {
+ return array(
+ 'title' => '${1}',
+ 'path' => '${2}',
+ 'conditions_callback' => '${3}',
+ );
+ }
+snippet hook_search_access
+ /**
+ * Implements hook_search_access()
+ */
+ function `Filename()`_search_access() {
+ /*
+ *return user_access('access content');
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_search_reset
+ /**
+ * Implements hook_search_reset()
+ */
+ function `Filename()`_search_reset() {
+ /*
+ *db_update('search_dataset')
+ * ->fields(array('reindex' => REQUEST_TIME))
+ * ->condition('type', 'node')
+ * ->execute();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_search_status
+ /**
+ * Implements hook_search_status()
+ */
+ function `Filename()`_search_status() {
+ /*
+ *$total = db_query('SELECT COUNT(*) FROM {node} WHERE status = 1')->fetchField();
+ *$remaining = db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")->fetchField();
+ *return array('remaining' => $remaining, 'total' => $total);
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_search_admin
+ /**
+ * Implements hook_search_admin()
+ */
+ function `Filename()`_search_admin() {
+ // Output form for defining rank factor weights.
+ /*
+ *$form['content_ranking'] = array(
+ * '#type' => 'fieldset',
+ * '#title' => t('Content ranking'),
+ *);
+ *$form['content_ranking']['#theme'] = 'node_search_admin';
+ *$form['content_ranking']['info'] = array(
+ * '#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>'
+ *);
+ */
+ // Note: reversed to reflect that higher number = higher ranking.
+ /*
+ *$options = drupal_map_assoc(range(0, 10));
+ *foreach (module_invoke_all('ranking') as $var => $values) {
+ * $form['content_ranking']['factors']['node_rank_' . $var] = array(
+ * '#title' => $values['title'],
+ * '#type' => 'select',
+ * '#options' => $options,
+ * '#default_value' => variable_get('node_rank_' . $var, 0),
+ * );
+ *}
+ */
+ $form['${1}'] = array(
+ '#title' => t('${2}'),
+ '#type' => '${3}',
+ '#theme' => '${4}',
+ '#default_value' => ${5},
+
+ return $form;
+ }
+snippet hook_search_execute
+ /**
+ * Implements hook_search_execute()
+ */
+ function `Filename()`_search_execute($keys = NULL, $conditions = NULL) {
+ /*
+ * // Build matching conditions
+ * $query = db_select('search_index', 'i', array('target' => 'slave'))->extend('SearchQuery')->extend('PagerDefault');
+ * $query->join('node', 'n', 'n.nid = i.sid');
+ * $query
+ * ->condition('n.status', 1)
+ * ->addTag('node_access')
+ * ->searchExpression($keys, 'node');
+ *
+ * // Insert special keywords.
+ * $query->setOption('type', 'n.type');
+ * $query->setOption('language', 'n.language');
+ * if ($query->setOption('term', 'ti.tid')) {
+ * $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid');
+ * }
+ * // Only continue if the first pass query matches.
+ * if (!$query->executeFirstPass()) {
+ * return array();
+ * }
+ *
+ * // Add the ranking expressions.
+ * _node_rankings($query);
+ *
+ * // Load results.
+ * $find = $query
+ * ->limit(10)
+ * ->execute();
+ * $results = array();
+ * foreach ($find as $item) {
+ * // Build the node body.
+ * $node = node_load($item->sid);
+ * node_build_content($node, 'search_result');
+ * $node->body = drupal_render($node->content);
+ *
+ * // Fetch comments for snippet.
+ * $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node);
+ * // Fetch terms for snippet.
+ * $node->rendered .= ' ' . module_invoke('taxonomy', 'node_update_index', $node);
+ *
+ * $extra = module_invoke_all('node_search_result', $node);
+ *
+ * $results[] = array(
+ * 'link' => url('node/' . $item->sid, array('absolute' => TRUE)),
+ * 'type' => check_plain(node_type_get_name($node)),
+ * 'title' => $node->title,
+ * 'user' => theme('username', array('account' => $node)),
+ * 'date' => $node->changed,
+ * 'node' => $node,
+ * 'extra' => $extra,
+ * 'score' => $item->calculated_score,
+ * 'snippet' => search_excerpt($keys, $node->body),
+ * );
+ * }
+ * return $results;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_search_page
+ /**
+ * Implements hook_search_page()
+ */
+ function `Filename()`_search_page($results) {
+ $output['prefix']['#markup'] = '<ol class="search-results">';
+
+ foreach ($results as $entry) {
+ $output[] = array(
+ '#theme' => '${1}',
+ '#result' => $entry,
+ '#module' => '${2}',
+ );
+ }
+ $output['suffix']['#markup'] = '</ol>' . theme('pager');
+
+ return $output;
+ }
+snippet hook_search_preprocess
+ /**
+ * Implements hook_search_preprocess()
+ */
+ function `Filename()`_search_preprocess($text) {
+ // Do processing on $text
+ /*
+ *return $text;
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_update_index
+ /**
+ * Implements hook_update_index()
+ */
+ function `Filename()`_update_index() {
+ /*
+ * $limit = (int)variable_get('search_cron_limit', 100);
+ *
+ * $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
+ *
+ * foreach ($result as $node) {
+ * $node = node_load($node->nid);
+ *
+ * // Save the changed time of the most recent indexed node, for the search
+ * // results half-life calculation.
+ * variable_set('node_cron_last', $node->changed);
+ *
+ * // Render the node.
+ * node_build_content($node, 'search_index');
+ * $node->rendered = drupal_render($node->content);
+ *
+ * $text = '<h1>' . check_plain($node->title) . '</h1>' . $node->rendered;
+ *
+ * // Fetch extra data normally not visible
+ * $extra = module_invoke_all('node_update_index', $node);
+ * foreach ($extra as $t) {
+ * $text .= $t;
+ * }
+ *
+ * // Update index
+ * search_index($node->nid, 'node', $text);
+ * }
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_locale
+ /**
+ * Implements hook_locale()
+ */
+ function `Filename()`_locale($op = 'groups') {
+ switch ($op) {
+ case '${1}':
+ return array('${2}' => t('${3}'));
+ }
+ }
+snippet hook_language_init
+ /**
+ * Implements hook_language_init()
+ */
+ function `Filename()`_language_init() {
+ global $language, $conf;
+
+ switch ($language->language) {
+ /*
+ *case 'it':
+ * $conf['site_name'] = 'Il mio sito Drupal';
+ * break;
+ */
+ case '${1}':
+ $conf['${2}'] = '${3}';
+ break;
+ }
+ }
+snippet hook_language_switch_links_alter
+ /**
+ * Implements hook_language_switch_links_alter()
+ */
+ function `Filename()`_language_switch_links_alter(array &$links, $type, $path) {
+ global $language;
+
+ /*
+ *if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->language])) {
+ * foreach ($links[$language->language] as $link) {
+ * $link['attributes']['class'][] = 'active-language';
+ * }
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_language_types_info
+ /**
+ * Implements hook_language_types_info()
+ */
+ function `Filename()`_language_types_info() {
+ return array(
+ /*
+ *'custom_language_type' => array(
+ * 'name' => t('Custom language'),
+ * 'description' => t('A custom language type.'),
+ *),
+ *'fixed_custom_language_type' => array(
+ * 'fixed' => array('custom_language_provider'),
+ *),
+ */
+ '${1}' => array(
+ 'name' => t('${2}'),
+ 'description' => t('${3}'),
+ ),
+ );
+ }
+snippet hook_language_types_info_alter
+ /**
+ * Implements hook_language_types_info_alter()
+ */
+ function `Filename()`_language_types_info_alter(array &$language_types) {
+ /*
+ *if (isset($language_types['custom_language_type'])) {
+ * $language_types['custom_language_type_custom']['description'] = t('A far better description.');
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_language_negotiation_info
+ /**
+ * Implements hook_language_negotiation_info()
+ */
+ function `Filename()`_language_negotiation_info() {
+ return array(
+ /*
+ *'custom_language_provider' => array(
+ * 'callbacks' => array(
+ * 'language' => 'custom_language_provider_callback',
+ * 'switcher' => 'custom_language_switcher_callback',
+ * 'url_rewrite' => 'custom_language_url_rewrite_callback',
+ * ),
+ * 'file' => drupal_get_path('module', 'custom') . '/custom.module',
+ * 'weight' => -4,
+ * 'types' => array('custom_language_type'),
+ * 'name' => t('Custom language provider'),
+ * 'description' => t('This is a custom language provider.'),
+ * 'cache' => 0,
+ *),
+ */
+ '${1}' => array(
+ 'callbacks' => array(
+ 'language' => '${2}',
+ 'switcher' => '${3}',
+ 'url_rewrite' => '${4}',
+ ),
+ 'file' => drupal_get_path('module', '${5}') . '/${6}',
+ 'weight' => ${7},
+ 'types' => array('${8}'),
+ 'name' => t('${9}'),
+ 'description' => t('${10}'),
+ 'cache' => ${11},
+ ),
+ );
+ }
+snippet hook_language_negotiation_info_alter
+ /**
+ * Implements hook_language_negotiation_info_alter()
+ */
+ function `Filename()`_language_negotiation_info_alter(array &$language_providers) {
+ /*
+ *if (isset($language_providers['custom_language_provider'])) {
+ * $language_providers['custom_language_provider']['config'] = 'admin/config/regional/language/configure/custom-language-provider';
+ *}
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_multilingual_settings_changed
+ /**
+ * Implements hook_multilingual_settings_changed()
+ */
+ function `Filename()`_multilingual_settings_changed() {
+ /*
+ *field_info_cache_clear();
+ */
+ ${1:/* Your code here */}
+ }
+snippet hook_language_fallback_candidates_alter
+ /**
+ * Implements hook_language_fallback_candidates_alter()
+ */
+ function `Filename()`_language_fallback_candidates_alter(array &$fallback_candidates) {
+ /*
+ *$fallback_candidates = array_reverse($fallback_candidates);
+ */
+ ${1:/* Your code here */}
+ }