Newer
Older
Angie Byron
committed
<?php
// $Id$
/**
Dries Buytaert
committed
* Implements hook_install().
Angie Byron
committed
*
* Perform actions to set up the site for this profile.
*/
Angie Byron
committed
function standard_install() {
Dries Buytaert
committed
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
// Add text formats.
$filtered_html_format = array(
'name' => 'Filtered HTML',
'weight' => 0,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// HTML filter.
'filter_html' => array(
'weight' => 1,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 2,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$filtered_html_format = (object) $filtered_html_format;
filter_format_save($filtered_html_format);
$full_html_format = array(
'name' => 'Full HTML',
'weight' => 1,
'filters' => array(
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
// Line break filter.
'filter_autop' => array(
'weight' => 1,
'status' => 1,
),
// HTML corrector filter.
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$full_html_format = (object) $full_html_format;
filter_format_save($full_html_format);
Angie Byron
committed
// Enable some standard blocks.
$values = array(
array(
'module' => 'system',
'delta' => 'main',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
Dries Buytaert
committed
array(
'module' => 'search',
'delta' => 'form',
'theme' => 'garland',
'status' => 1,
'weight' => -1,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
),
Angie Byron
committed
array(
'module' => 'node',
'delta' => 'recent',
'theme' => 'seven',
'status' => 1,
'weight' => 10,
'region' => 'dashboard_main',
'pages' => '',
'cache' => -1,
),
Angie Byron
committed
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
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'navigation',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'management',
'theme' => 'garland',
'status' => 1,
'weight' => 1,
'region' => 'sidebar_first',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'powered-by',
'theme' => 'garland',
'status' => 1,
'weight' => 10,
'region' => 'footer',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'garland',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'main',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'system',
'delta' => 'help',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'help',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'user',
'delta' => 'login',
'theme' => 'seven',
'status' => 1,
'weight' => 10,
'region' => 'content',
'pages' => '',
'cache' => -1,
),
Dries Buytaert
committed
array(
'module' => 'user',
'delta' => 'new',
'theme' => 'seven',
'status' => 1,
'weight' => 0,
'region' => 'dashboard_sidebar',
'pages' => '',
'cache' => -1,
),
array(
'module' => 'search',
'delta' => 'form',
'theme' => 'seven',
'status' => 1,
Dries Buytaert
committed
'weight' => -10,
'region' => 'dashboard_sidebar',
'pages' => '',
'cache' => -1,
),
Angie Byron
committed
);
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($values as $record) {
$query->values($record);
}
Dries Buytaert
committed
$query->execute();
Angie Byron
committed
Dries Buytaert
committed
// Insert default pre-defined node types into the database. For a complete
Angie Byron
committed
// list of available node type attributes, refer to the node type API
// documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.
$types = array(
array(
'type' => 'page',
Angie Byron
committed
'name' => st('Basic page'),
Angie Byron
committed
'base' => 'node_content',
Angie Byron
committed
'description' => st("Use <em>basic pages</em> for your static content, such as an 'About us' page."),
Angie Byron
committed
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
array(
'type' => 'article',
'name' => st('Article'),
'base' => 'node_content',
'description' => st('Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.'),
Angie Byron
committed
'custom' => 1,
'modified' => 1,
'locked' => 0,
),
);
foreach ($types as $type) {
$type = node_type_set_defaults($type);
node_type_save($type);
}
Dries Buytaert
committed
// Insert default pre-defined RDF mapping into the database.
$rdf_mappings = array(
array(
'type' => 'node',
'bundle' => 'page',
'mapping' => array(
'rdftype' => array('foaf:Document'),
),
),
array(
'type' => 'node',
'bundle' => 'article',
'mapping' => array(
'rdftype' => array('sioc:Item', 'foaf:Document'),
Dries Buytaert
committed
'field_image' => array(
'predicates' => array('rdfs:seeAlso'),
'type' => 'rel',
),
'field_tags' => array(
Dries Buytaert
committed
'predicates' => array('dc:subject'),
Dries Buytaert
committed
'type' => 'rel',
),
),
),
);
foreach ($rdf_mappings as $rdf_mapping) {
rdf_mapping_save($rdf_mapping);
}
Angie Byron
committed
// Default "Basic page" to not be promoted and have comments disabled.
Angie Byron
committed
variable_set('node_options_page', array('status'));
variable_set('comment_page', COMMENT_NODE_HIDDEN);
Angie Byron
committed
// Don't display date and author information for "Basic page" nodes by default.
Angie Byron
committed
variable_set('node_submitted_page', FALSE);
// Enable user picture support and set the default to a square thumbnail option.
variable_set('user_pictures', '1');
variable_set('user_picture_dimensions', '1024x1024');
variable_set('user_picture_file_size', '800');
variable_set('user_picture_style', 'thumbnail');
// Create a default vocabulary named "Tags", enabled for the 'article' content type.
Angie Byron
committed
$description = st('Use tags to group articles on similar topics into categories.');
$help = st('Enter a comma-separated list of words to describe your content.');
$vocabulary = (object) array(
'name' => 'Tags',
'description' => $description,
'machine_name' => 'tags',
'help' => $help,
Angie Byron
committed
Angie Byron
committed
);
Dries Buytaert
committed
taxonomy_vocabulary_save($vocabulary);
Angie Byron
committed
$field = array(
'field_name' => 'field_' . $vocabulary->machine_name,
Angie Byron
committed
'type' => 'taxonomy_term_reference',
// Set cardinality to unlimited for tagging.
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'settings' => array(
'allowed_values' => array(
array(
'vid' => $vocabulary->vid,
'parent' => 0,
),
),
),
);
field_create_field($field);
Angie Byron
committed
$instance = array(
'field_name' => 'field_' . $vocabulary->machine_name,
'entity_type' => 'node',
Angie Byron
committed
'label' => $vocabulary->name,
'bundle' => 'article',
'description' => $vocabulary->help,
'widget' => array(
'type' => 'taxonomy_autocomplete',
Angie Byron
committed
'weight' => 4,
),
);
field_create_instance($instance);
// Create an image field named "Image", enabled for the 'article' content type.
// Many of the following values will be defaulted, they're included here as an illustrative examples.
Dries Buytaert
committed
// See http://api.drupal.org/api/function/field_create_field/7
Angie Byron
committed
$field = array(
'field_name' => 'field_image',
'type' => 'image',
'cardinality' => 1,
'translatable' => TRUE,
'locked' => FALSE,
'indexes' => array('fid' => array('fid')),
'settings' => array(
'uri_scheme' => 'public',
'default_image' => FALSE,
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
),
);
field_create_field($field);
// Many of the following values will be defaulted, they're included here as an illustrative examples.
Dries Buytaert
committed
// See http://api.drupal.org/api/function/field_create_instance/7
Angie Byron
committed
$instance = array(
'field_name' => 'field_image',
'entity_type' => 'node',
Angie Byron
committed
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
'label' => 'Image',
'bundle' => 'article',
'description' => 'Upload an image to go with this article.',
'required' => FALSE,
'settings' => array(
'file_directory' => 'field/image',
'file_extensions' => 'png gif jpg jpeg',
'max_filesize' => '',
'max_resolution' => '',
'min_resolution' => '',
'alt_field' => TRUE,
'title_field' => '',
),
'widget' => array(
'type' => 'image_image',
'settings' => array(
'progress_indicator' => 'throbber',
'preview_image_style' => 'thumbnail',
),
'weight' => -1,
),
'display' => array(
'full' => array(
'label' => 'hidden',
'type' => 'image__large',
'settings' => array(),
'weight' => -1,
),
'teaser' => array(
'label' => 'hidden',
'type' => 'image_link_content__medium',
'settings' => array(),
'weight' => -1,
),
'rss' => array(
'label' => 'hidden',
'type' => 'image__large',
'settings' => array(),
'weight' => -1,
),
'search_index' => array(
'label' => 'hidden',
'type' => 'image__large',
'settings' => array(),
'weight' => -1,
),
'search_results' => array(
'label' => 'hidden',
'type' => 'image__large',
'settings' => array(),
'weight' => -1,
),
Angie Byron
committed
),
);
field_create_instance($instance);
Angie Byron
committed
Dries Buytaert
committed
// Enable default permissions for system roles.
Dries Buytaert
committed
$filtered_html_permission = filter_permission_name($filtered_html_format);
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', $filtered_html_permission));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'post comments without approval', $filtered_html_permission));
Dries Buytaert
committed
// Create a default role for site administrators, with all available permissions assigned.
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->weight = 2;
Dries Buytaert
committed
user_role_save($admin_role);
Dries Buytaert
committed
user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
Angie Byron
committed
// Set this as the administrator role.
Dries Buytaert
committed
variable_set('user_admin_role', $admin_role->rid);
Angie Byron
committed
// Update the menu router information.
menu_rebuild();
// Enable the admin theme.
db_update('system')
->fields(array('status' => 1))
->condition('type', 'theme')
->condition('name', 'seven')
->execute();
variable_set('admin_theme', 'seven');
variable_set('node_admin_theme', '1');
}