-
Notifications
You must be signed in to change notification settings - Fork 1
/
php-drupal6hooks.snippets
760 lines (663 loc) · 14.1 KB
/
php-drupal6hooks.snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
snippet hook_access
/**
* Implementation of hook_access().
*/
function ${1:`Filename()`}_access($op, $node, $account) {
${2:// code}
}
snippet hook_actions_delete
/**
* Implementation of hook_actions_delete().
*/
function ${1:`Filename()`}_actions_delete($aid) {
${2:// code}
}
snippet hook_action_info
/**
* Implementation of hook_action_info().
*/
function ${1:`Filename()`}_action_info() {
$actions = array();
// Use '__action_item' to insert a action item
${2}
}
snippet __action_item
$actions['${1:action_name}'] = array(
'description' => t('${2:Description}'),
'type' => '${3:type}',
'configurable' => ${4:FALSE},
'hooks' => array(
'hook_name' => array('${5:hook1}', '${6:hook2}'),
),
);
snippet hook_action_info_alter
/**
* Implementation of hook_action_info_alter().
*/
function ${1:`Filename()`}_action_info_alter(&$actions) {
${2:// code}
}
snippet hook_block
/**
* Implementation of hook_block().
*/
function ${1:`Filename()`}_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks['${2:block-name}'] = array(
'info' => t('${3:block title}'),
'cache' => BLOCK_NO_CACHE,
'status' => TRUE,
'weight' => 0,
'region' => '',
'visibility' => 1,
'pages' => 'node/*',
);
return $blocks;
case 'configure':
$form = array();
return $form;
case 'save':
return;
case 'view':
switch ($delta) {
case '$2':
$block['subject'] = ${4:t('Optional Subject')};
$block['content'] = ${5:'block content here'};
break;
}
return $block;
}
}
snippet hook_boot
/**
* Implementation of hook_boot().
*/
function ${1:`Filename()`}_boot() {
${2:// code}
}
snippet hook_comment
/**
* Implementation of hook_comment().
*/
function ${1:`Filename()`}_comment(&$a1, $op) {
${2:// code}
}
snippet hook_cron
/**
* Implementation of hook_cron().
*/
function ${1:`Filename()`}_cron() {
${2:// code}
}
snippet hook_db_rewrite_sql
/**
* Implementation of hook_db_rewrite_sql().
*/
function ${1:`Filename()`}_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
switch ($primary_field) {
case '${2:primary_field}':
$return = array();
${3:// code}
return $return;
break;
}
}
snippet hook_delete
/**
* Implementation of hook_delete().
*/
function ${1:`Filename()`}_load(&$node) {
${2:// code}
}
snippet hook_disable
/**
* Implementation of hook_disable().
*/
function ${1:`Filename()`}_disable() {
${2:// code}
}
snippet hook_elements
/**
* Implementation of hook_elements().
*/
function ${1:`Filename()`}_elementjs() {
${2:// code}
}
snippet hook_enable
/**
* Implementation of hook_enable().
*/
function ${1:`Filename()`}_enable() {
${2:// code}
}
snippet hook_exit
/**
* Implementation of hook_exit().
*/
function ${1:`Filename()`}_exit($destination = NULL) {
${2:// code}
}
snippet hook_file_download
/**
* Implementation of hook_file_download().
*/
function ${1:`Filename()`}_exit($filepath) {
${2:// code}
}
snippet hook_filter
/**
* Implementation of hook_filter().
*/
function ${1:`Filename()`}_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
switch ($op) {
case '${2:operation}':
${3:// code}
break;
}
}
snippet hook_filter_tips
/**
* Implementation of hook_filter_tips().
*/
function ${1:`Filename()`}_filter_tips($delta, $format, $long = false) {
${2:// code}
}
snippet hook_flush_caches
/**
* Implementation of hook_flush_caches().
*/
function ${1:`Filename()`}_flush_caches() {
${2:// code}
}
snippet hook_footer
/**
* Implementation of hook_footer().
*/
function ${1:`Filename()`}_footer($main = 0) {
${2:// code}
}
snippet hook_form
/**
* Implementation of hook_form().
*/
function ${1:`Filename()`}_form(&$node, $form_state) {
$type = node_get_types('type', $node);
$form['title'] = array(
'#type'=> 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
);
$form['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#rows' => 20,
'#required' => TRUE,
);
${2:// more_fields}
return $form;
}
snippet hook_forms
/**
* Implementation of hook_forms().
*/
function ${1:`Filename()`}_forms($form_id, $args) {
${2:// code}
}
snippet hook_form_alter
/**
* Implementation of hook_form_alter().
*/
function ${1:`Filename()`}_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case '${2:formid}':
${3:// code}
break;
}
}
snippet hook_form_form_id_alter
/**
* Implementation of hook_form_form_id_alter().
*/
function ${1:`Filename()`}_form_${2:form_id}_alter(&$form, &$form_state) {
${3:// code}
}
snippet hook_help
/**
* Implementation of hook_help().
*/
function ${1:`Filename()`}_help($path, $arg) {
switch ($path) {
case '${2:path}':
return ${3:help_text};
}
}
snippet hook_hook_info()
/**
* Implementation of hook_hook_info().
*/
function ${1:`Filename()`}_hook_info() {
return array(
${2:// code}
);
}
snippet hook_init
/**
* Implementation of hook_init().
*/
function ${1:`Filename()`}_init() {
${2:// code}
}
snippet hook_insert
/**
* Implementation of hook_insert().
*/
function ${1:`Filename()`}_insert($node) {
${2:// code}
}
snippet hook_install
/**
* Implementation of hook_install().
*/
function ${1:`Filename()`}_install() {
${2:// code}
}
snippet hook_link
/**
* Implementation of hook_link().
*/
function ${1:`Filename()`}_link($type, $object, $teaser = FALSE) {
$links = array();
${2:// code}
return $links;
}
snippet hook_link_alter
/**
* Implementation of hook_link_alter().
*/
function ${1:`Filename()`}_link_alter(&$links, $node) {
${2:// code}
}
snippet hook_load
/**
* Implementation of hook_load().
*/
function ${1:`Filename()`}_load($node) {
${2:// code}
}
snippet hook_locale
/**
* Implementation of hook_locale().
*/
function ${1:`Filename()`}_locale($op = 'groups') {
switch ($op) {
case 'groups':
return array(${3:});
}
}
snippet hook_mail
/**
* Implementation of hook_mail().
*/
function ${1:`Filename()`}_mail($key, &$message, $params) {
${2:// code}
}
snippet hook_mail_alter
/**
* Implementation of hook_mail_alter().
*/
function ${1:`Filename()`}_mail_alter(&$message) {
switch ($message['id']) {
case '${2:message_id}':
${2:// code}
break;
}
}
snippet hook_menu
/**
* Implementation of hook_menu().
*/
function ${1:`Filename()`}_menu() {
$items = array();
// Use '__menu_item' to insert a menu item
${2}
return $items;
}
snippet __menu_item
$items['${1:path}'] = array(
'title' => '${2:menu title}',
'title callback' => '',
'description' => '',
'page callback' => '',
'page arguments' => array(''),
'access callback' => '',
'access arguments' => array(''),
'file' => '',
'file path' => '',
'weight' => 0,
'menu_name' => '',
'type' => ${3:MENU_NORMAL_ITEM},
);
snippet hook_menu_alter
/**
* Implementation of hook_menu_alter().
*/
function ${1:`Filename()`}_menu_alter(&$items) {
${2:// code}
}
snippet hook_menu_link_alter
/**
* Implementation of hook_menu_link_alter().
*/
function ${1:`Filename()`}_menu_link_alter(&$item, $menu) {
${2:// code}
}
snippet hook_nodeapi
/**
* Implementation of hook_nodeapi().
*/
function ${1:`Filename()`}_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case '${2:operation}':
${3:// code}
break;
}
}
snippet hook_node_access_records
/**
* Implementation of hook_node_access_records().
*/
function ${1:`Filename()`}_node_access_records($node) {
${2:// code}
}
snippet hook_node_grants
/**
* Implementation of hook_node_grants().
*/
function ${1:`Filename()`}_node_grants($account, $op) {
$grants = array();
${2:// code}
return $grants;
}
snippet hook_node_info
/**
* Implementation of hook_node_info().
*/
function ${1:`Filename()`}_node_info() {
return array(
'${2:type}' => array(
'name' => t('${3:name}'),
'module' => $2,
'description' => t('${4:description}'),
),
);
}
snippet hook_node_operations
/**
* Implementation of hook_node_operations().
*/
function ${1:`Filename()`}_node_operations() {
$operations = array(
'${2:operation}' => array(
'label' => t('${3:label}'),
'callback' => '${4:callback_function}',
),
);
return $operations;
}
snippet hook_node_type
/**
* Implementation of hook_node_type().
*/
function ${1:`Filename()`}_node_type($op, $info) {
switch ($op) {
case 'delete':
${2:// code}
break;
case 'insert':
${3:// code}
break;
case 'update':
${4:// code}
break;
}
}
snippet hook_perm
/**
* Implementation of hook_perm().
*/
function ${1:`Filename()`}_perm() {
return array('${2:permission names}');
}
snippet hook_ping
/**
* Implementation of hook_ping().
*/
function ${1:`Filename()`}_ping($name = '', $url = '') {
${2:// code}
}
snippet hook_prepare
/**
* Implementation of hook_prepare().
*/
function ${1:`Filename()`}_prepare(&$node) {
${2:// code}
}
snippet hook_profile_alter
/**
* Implementation of hook_profile_alter().
*/
function ${1:`Filename()`}_profile_alter(&$account) {
${2:// code}
}
snippet hook_requirements
/**
* Implementation of hook_requirements().
*/
function ${1:`Filename()`}_requirements($phase) {
$requirements = array();
${2:// code}
return $requirements;
}
snippet hook_schema
/**
* Implementation of hook_schema().
*/
function ${1:`Filename()`}_schema() {
$schema['${2:table}'] = array(
'description' => ${3:description},
'fields' => array(
${4:// fields}
),
'indexes' => array(
${5:// indexes}
),
'unique keys' => array(
${6:// unique_keys}
),
'primary key' => array(
${7:// primary key}
),
);
return $schema;
}
snippet hook_schema_alter
/**
* Implementation of hook_schema_alter().
*/
function ${1:`Filename()`}_schema_alter(&$schema) {
${2:// code}
}
snippet hook_search
/**
* Implementation of hook_search().
*/
function ${1:`Filename()`}_search($op = 'search', $keys = NULL) {
switch ($op) {
case '${2:operation}':
${3:// code}
return ${4:// something}
}
}
snippet hook_search_preprocess
/**
* Implementation of hook_search_preprocess().
*/
function ${1:`Filename()`}_search_preprocess($text) {
${2:// code}
return $text;
}
snippet hook_system_info_alter
/**
* Implementation of hook_system_info_alter().
*/
function ${1:`Filename()`}_system_info_alter(&$info, $file) {
${2:// code}
}
snippet hook_taxonomy
/**
* Implementation of hook_taxonomy().
*/
function ${1:`Filename()`}_taxonomy($op, $type, $array = NULL) {
${2:// code}
}
snippet hook_term_path
/**
* Implementation of hook_term_path().
*/
function ${1:`Filename()`}_term_path($term) {
${2:// code}
}
snippet hook_theme
/**
* Implementation of hook_theme().
*/
function ${1:`Filename()`}_theme($existing, $type, $theme, $path) {
return array(
${2:// code}
);
}
snippet hook_theme_registry_alter
/**
* Implementation of hook_theme_registry_alter().
*/
function ${1:`Filename()`}_theme_registry_alter(&$theme_registry) {
${2:// code}
}
snippet hook_translated_menu_link_alter
/**
* Implementation of hook_translated_menu_link_alter().
*/
function ${1:`Filename()`}_translated_menu_link_alter(&$item, $map) {
${2:// code}
}
snippet hook_translation_link_alter
/**
* Implementation of hook_translation_link_alter().
*/
function ${1:`Filename()`}_translation_link_alter(&$links, $path) {
${2:// code}
}
snippet hook_uninstall
/**
* Implementation of hook_uninstall().
*/
function ${1:`Filename()`}_uninstall() {
${2:// code}
}
snippet hook_update
/**
* Implementation of hook_update().
*/
function ${1:`Filename()`}_update($node) {
${2:// code}
}
snippet hook_update_index
/**
* Implementation of hook_update_index().
*/
function ${1:`Filename()`}_update_index() {
${2:// code}
}
snippet hook_update_last_removed
/**
* Implementation of hook_update_last_removed().
*/
function ${1:`Filename()`}_update_last_removed() {
${2:// code}
}
snippet hook_update_N
/**
* Implementation of hook_update_N().
*/
function ${1:`Filename()`}_update_N(&$sandbox) {
${2:// code}
}
snippet hook_update_projects_alter
/**
* Implementation of hook_update_projects_alter().
*/
function ${1:`Filename()`}_update_projects_alter(&$projects) {
${2:// code}
}
snippet hook_update_status_alter
/**
* Implementation of hook_update_status_alter().
*/
function ${1:`Filename()`}_update_status_alter(&$projects) {
${2:// code}
}
snippet hook_user
/**
* Implementation of hook_user().
*/
function ${1:`Filename()`}_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case '${2:load}':
${3:// code}
break;
}
}
snippet hook_user_operations
/**
* Implementation of hook_user_operations().
*/
function ${1:`Filename()`}_user_operations() {
$operations = array(
'${2:operation}' => array(
'label' => t('${3:label}'),
'callback' => '${4:callback_function}',
),
);
return $operations;
}
snippet hook_validate
/**
* Implementation of hook_validate().
*/
function ${1:`Filename()`}_validate($node, &$form) {
${2:// code}
}
snippet hook_view
/**
* Implementation of hook_view().
*/
function ${1:`Filename()`}_view($node, $teaser = FALSE, $page = FALSE) {
${2:// code}
}
snippet hook_watchdog
/**
* Implementation of hook_watchdog().
*/
function ${1:`Filename()`}_watchdog($log_entry) {
${2:// code}
}
snippet hook_xmlrpc
/**
* Implementation of hook_xmlrpc().
*/
function ${1:`Filename()`}_xmlrpc() {
return array(
${2:// code}
);
}