Newer
Older
<?php
/**
* @file
* Install, update and uninstall functions for the University of Cambridge installation profile.
*/
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function cambridge_install() {
require_once 'cambridge_lite.install';
cambridge_lite_install();
// Force a main-menu link on Basic Pages.
variable_set('menu_force_page', TRUE);
// Set sensible URL alias pattern defaults.
variable_set('pathauto_node_pattern', '[node:title]');
variable_set('pathauto_node_page_pattern', '[node:menu-link:parent:url:path]/[node:title]');
variable_set('pathauto_node_carousel_item_pattern', 'carousel/[node:title]');
// Set some sensible defaults for the Image javascript crop module.
variable_set('imagecrop_popup', 'imagecrop_popup');
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
variable_set('imagecrop_scale_default', 1);
variable_set('imagecrop_show_cancel_button', 1);
variable_set('imagecrop_ui_controls', 1);
// Replace standard scaling/cropping image style effects and replace them with a Javascript crop effect.
$carousel = image_style_load('carousel');
foreach ($carousel['effects'] as $effect) {
image_effect_delete($effect);
}
image_effect_save(
array(
'name' => 'imagecrop_javascript',
'data' => array(
'width' => 885,
'height' => 432,
'xoffset' => 'center',
'yoffset' => 'center',
'resizable' => 0,
'downscaling' => 0,
'aspect_ratio' => 'CROP',
'disable_if_no_data' => 0,
),
'isid' => $carousel['isid'],
'weight' => 0,
)
);
$instance = field_info_instance('node', 'field_carousel_image', 'carousel_item');
$instance['settings']['imagecrop'] = array('carousel' => 'carousel', 'leading' => 0, 'inline' => 0);
field_update_instance($instance);
$leading = image_style_load('leading');
foreach ($leading['effects'] as $effect) {
image_effect_delete($effect);
}
image_effect_save(
array(
'name' => 'imagecrop_javascript',
'data' => array(
'width' => 590,
'height' => 288,
'xoffset' => 'center',
'yoffset' => 'center',
'resizable' => 0,
'downscaling' => 0,
'aspect_ratio' => 'CROP',
'disable_if_no_data' => 0,
),
'isid' => $leading['isid'],
'weight' => 0,
)
);
$instance = field_info_instance('node', 'field_leading_image', 'page');
$instance['settings']['imagecrop'] = array('leading' => 'leading', 'carousel' => 0, 'inline' => 0);
field_update_instance($instance);
$inline = image_style_load('inline');
foreach ($inline['effects'] as $effect) {
image_effect_delete($effect);
}
image_effect_save(
array(
'name' => 'imagecrop_javascript',
'data' => array(
'width' => 250,
'height' => 250,
'xoffset' => 'center',
'yoffset' => 'center',
'resizable' => 0,
'downscaling' => 0,
'aspect_ratio' => 'CROP',
'disable_if_no_data' => 0,
),
'isid' => $inline['isid'],
'weight' => 0,
)
);
// Use the media module for image field instances.
$instances = array(
field_read_instance('node', 'field_leading_image', 'page'),
field_read_instance('node', 'field_carousel_image', 'carousel_item'),
);
foreach ($instances as $instance) {
$instance['widget']['type'] = 'media_generic';
$instance['widget']['module'] = 'media';
field_update_instance($instance);
}
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
$field = array(
'field_name' => 'field_user_name',
'label' => st('Name'),
'cardinality' => 1,
'type' => 'text',
'settings' => array(
'max_length' => 255,
),
);
field_create_field($field);
$instance = array(
'entity_type' => 'user',
'bundle' => 'user',
'field_name' => 'field_user_name',
'label' => st('Name'),
'description' => st('The user\'s real name.'),
'required' => 1,
'cardinality' => 1,
'type' => 'field_user_name',
'settings' => array(
'size' => 60,
'text_processing' => 0,
'user_register_form' => 1,
),
'widget' => array(
'weight' => -11,
),
'display' => array(
'default' => array(
'label' => 'inline',
'type' => 'text_plain',
'weight' => 1,
),
'teaser' => array(
'label' => 'inline',
'type' => 'text_plain',
'weight' => 1,
),
),
);
field_create_instance($instance);
variable_set('realname_pattern', '[user:field_user_name]');
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
// Give the admin user a real name.
db_insert('field_data_field_user_name')
->fields(
array(
'entity_type' => 'user',
'bundle' => 'user',
'deleted' => 0,
'entity_id' => 1,
'revision_id' => 1,
'language' => 'und',
'delta' => 0,
'field_user_name_value' => 'Administrator',
'field_user_name_format' => NULL,
)
)
->execute();
db_insert('field_revision_field_user_name')
->fields(
array(
'entity_type' => 'user',
'bundle' => 'user',
'deleted' => 0,
'entity_id' => 1,
'revision_id' => 1,
'language' => 'und',
'delta' => 0,
'field_user_name_value' => 'Administrator',
'field_user_name_format' => NULL,
)
)
->execute();
// Transliterate Pathauto aliases.
variable_set('pathauto_transliterate', 1);
$profiles = db_select('ckeditor_settings', 's')
->fields('s')
->condition('name', array('Advanced', 'Full'), 'IN')
->execute()
->fetchAllAssoc('name');
foreach ($profiles as $name => $profile) {
$settings = unserialize($profile->settings);
// Set language to English (United Kingdom).
$settings['lang'] = 'en-uk';
// Turn off Advanced Content Filter.
$settings['js_conf'] = 'config.allowedContent = true;';
db_update('ckeditor_settings')
->fields(array('settings' => serialize($settings)))
->condition('name', $name)
->execute();
}