1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * Documentation for pathauto API. |
---|
6 | * |
---|
7 | * @see hook_token_info |
---|
8 | * @see hook_tokens |
---|
9 | */ |
---|
10 | |
---|
11 | function hook_path_alias_types() { |
---|
12 | } |
---|
13 | |
---|
14 | function hook_pathauto($op) { |
---|
15 | } |
---|
16 | |
---|
17 | /** |
---|
18 | * Alter the pattern to be used before an alias is generated by Pathauto. |
---|
19 | * |
---|
20 | * @param string $pattern |
---|
21 | * The alias pattern for Pathauto to pass to token_replace() to generate the |
---|
22 | * URL alias. |
---|
23 | * @param array $context |
---|
24 | * An associative array of additional options, with the following elements: |
---|
25 | * - 'module': The module or entity type being aliased. |
---|
26 | * - 'op': A string with the operation being performed on the object being |
---|
27 | * aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'. |
---|
28 | * - 'source': A string of the source path for the alias (e.g. 'node/1'). |
---|
29 | * - 'data': An array of keyed objects to pass to token_replace(). |
---|
30 | * - 'type': The sub-type or bundle of the object being aliased. |
---|
31 | * - 'language': A string of the language code for the alias (e.g. 'en'). |
---|
32 | * This can be altered by reference. |
---|
33 | */ |
---|
34 | function hook_pathauto_pattern_alter(&$pattern, array &$context) { |
---|
35 | // Switch out any [mod-DATETOKEN] tokens with [DATETOKEN] on update. |
---|
36 | if ($module == 'node' && ($context['op'] == 'update')) { |
---|
37 | $pattern = preg_replace('/\[mod-([^]]*)?\]/', '[$1]', $pattern); |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | * Alter Pathauto-generated aliases before saving. |
---|
43 | * |
---|
44 | * @param string $alias |
---|
45 | * The automatic alias after token replacement and strings cleaned. |
---|
46 | * @param array $context |
---|
47 | * An associative array of additional options, with the following elements: |
---|
48 | * - 'module': The module or type of object being aliased. |
---|
49 | * - 'op': A string with the operation being performed on the object being |
---|
50 | * aliased. Can be either 'insert', 'update', 'return', or 'bulkupdate'. |
---|
51 | * - 'source': A string of the source path for the alias (e.g. 'node/1'). |
---|
52 | * This can be altered by reference. |
---|
53 | * - 'data': An array of keyed objects to pass to token_replace(). Note this |
---|
54 | * variable may not be consistent in older versions of Pathauto. |
---|
55 | * - 'type': The sub-type or bundle of the object being aliased. |
---|
56 | * - 'language': A string of the language code for the alias (e.g. 'en'). |
---|
57 | * This can be altered by reference. |
---|
58 | * - 'pattern': A string of the pattern used for aliasing the object. |
---|
59 | * |
---|
60 | * @see pathauto_create_alias() |
---|
61 | */ |
---|
62 | function hook_pathauto_alias_alter(&$alias, &$context) { |
---|
63 | // Add a suffix so that all aliases get saved as 'content/my-title.html' |
---|
64 | $alias .= '.html'; |
---|
65 | |
---|
66 | // Force all aliases to be saved as language neutral. |
---|
67 | $context['language'] = ''; |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * Alter the list of punctuation characters for Pathauto control. |
---|
72 | * |
---|
73 | * @param $punctuation |
---|
74 | * An array of punctuation to be controlled by Pathauto during replacement |
---|
75 | * keyed by punctuation name. Each punctuation record should be an array |
---|
76 | * with the following key/value pairs: |
---|
77 | * - value: The raw value of the punctuation mark. |
---|
78 | * - name: The human-readable name of the punctuation mark. This must be |
---|
79 | * translated using t() already. |
---|
80 | */ |
---|
81 | function hook_pathauto_punctuation_chars_alter(array &$punctuation) { |
---|
82 | // Add the trademark symbol. |
---|
83 | $punctuation['trademark'] = array('value' => 'â¢', 'name' => t('Trademark symbol')); |
---|
84 | |
---|
85 | // Remove the dollar sign. |
---|
86 | unset($punctuation['dollar']); |
---|
87 | } |
---|