snippet php 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 '
' . t('${2}', array('${3}' => ${4})) . '
'; } } 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'] = '' . 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 blocks administration page 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'))) . '
'; */ case '${1}': return '' . t('${2}', array('${3}' => ${4})) . '
'; } } 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 .= ' -
-
- ',
* '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. <br> and <p>) 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' => '' . 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.') . ''
*);
*/
// 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'] = '
';
foreach ($results as $entry) {
$output[] = array(
'#theme' => '${1}',
'#result' => $entry,
'#module' => '${2}',
);
}
$output['suffix']['#markup'] = '
' . 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 = '' . check_plain($node->title) . '
' . $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 */}
}