Code coverage for /20080809/profiles/default/default.profile

Line #Times calledCode
1
<?php
2
// $Id: default.profile,v 1.26 2008/06/24 21:26:48 dries Exp $
3
4
/**
5
 * Return an array of the modules to be enabled when this profile is
installed.
6
 *
7
 * @return
8
 *   An array of modules to enable.
9
 */
1062
function default_profile_modules() {
1162
  return array('color', 'comment', 'help', 'menu', 'taxonomy', 'dblog');
120
}
13
14
/**
15
 * Return a description of the profile for the initial installation
screen.
16
 *
17
 * @return
18
 *   An array with keys 'name' and 'description' describing this profile,
19
 *   and optional 'language' to override the language selection for
20
 *   language-specific profiles.
21
 */
2262
function default_profile_details() {
23
  return array(
240
    'name' => 'Drupal',
25
    'description' => 'Select this profile to enable some basic Drupal
functionality and the default theme.'
260
  );
270
}
28
29
/**
30
 * Return a list of tasks that this profile supports.
31
 *
32
 * @return
33
 *   A keyed array of tasks the profile will perform during
34
 *   the final stage. The keys of the array will be used internally,
35
 *   while the values will be displayed to the user in the installer
36
 *   task list.
37
 */
3862
function default_profile_task_list() {
390
}
40
41
/**
42
 * Perform any final installation tasks for this profile.
43
 *
44
 * The installer goes through the profile-select -> locale-select
45
 * -> requirements -> database -> profile-install-batch
46
 * -> locale-initial-batch -> configure -> locale-remaining-batch
47
 * -> finished -> done tasks, in this order, if you don't implement
48
 * this function in your profile.
49
 *
50
 * If this function is implemented, you can have any number of
51
 * custom tasks to perform after 'configure', implementing a state
52
 * machine here to walk the user through those tasks. First time,
53
 * this function gets called with $task set to 'profile', and you
54
 * can advance to further tasks by setting $task to your tasks'
55
 * identifiers, used as array keys in the hook_profile_task_list()
56
 * above. You must avoid the reserved tasks listed in
57
 * install_reserved_tasks(). If you implement your custom tasks,
58
 * this function will get called in every HTTP request (for form
59
 * processing, printing your information screens and so on) until
60
 * you advance to the 'profile-finished' task, with which you
61
 * hand control back to the installer. Each custom page you
62
 * return needs to provide a way to continue, such as a form
63
 * submission or a link. You should also set custom page titles.
64
 *
65
 * You should define the list of custom tasks you implement by
66
 * returning an array of them in hook_profile_task_list(), as these
67
 * show up in the list of tasks on the installer user interface.
68
 *
69
 * Remember that the user will be able to reload the pages multiple
70
 * times, so you might want to use variable_set() and variable_get()
71
 * to remember your data and control further processing, if $task
72
 * is insufficient. Should a profile want to display a form here,
73
 * it can; the form should set '#redirect' to FALSE, and rely on
74
 * an action in the submit handler, such as variable_set(), to
75
 * detect submission and proceed to further tasks. See the configuration
76
 * form handling code in install_tasks() for an example.
77
 *
78
 * Important: Any temporary variables should be removed using
79
 * variable_del() before advancing to the 'profile-finished' phase.
80
 *
81
 * @param $task
82
 *   The current $task of the install system. When hook_profile_tasks()
83
 *   is first called, this is 'profile'.
84
 * @param $url
85
 *   Complete URL to be used for a link or form action on a custom page,
86
 *   if providing any, to allow the user to proceed with the installation.
87
 *
88
 * @return
89
 *   An optional HTML string to display to the user. Only used if you
90
 *   modify the $task, otherwise discarded.
91
 */
9262
function default_profile_tasks(&$task, $url) {
93
94
  // Insert default user-defined node types into the database. For a
complete
95
  // list of available node type attributes, refer to the node type API
96
  // documentation at:
http://api.drupal.org/api/HEAD/function/hook_node_info.
97
  $types = array(
98
    array(
9962
      'type' => 'page',
10062
      'name' => st('Page'),
10162
      'module' => 'node',
10262
      'description' => st("A <em>page</em>, similar in form to an
<em>article</em>, is a simple method for creating and displaying
information that rarely changes, such as an \"About us\" section of a
website. By default, a <em>page</em> entry does not allow visitor comments
and is not featured on the site's initial home page."),
10362
      'custom' => TRUE,
10462
      'modified' => TRUE,
10562
      'locked' => FALSE,
10662
      'help' => '',
10762
      'min_word_count' => '',
10862
    ),
109
    array(
11062
      'type' => 'article',
11162
      'name' => st('Article'),
11262
      'module' => 'node',
11362
      'description' => st("An <em>article</em>, similar in form to a
<em>page</em>, is ideal for creating and displaying content that informs or
engages website visitors. Press releases, site announcements, and informal
blog-like entries may all be created with an <em>article</em> entry. By
default, an <em>article</em> entry is automatically featured on the site's
initial home page, and provides the ability to post comments."),
11462
      'custom' => TRUE,
11562
      'modified' => TRUE,
11662
      'locked' => FALSE,
11762
      'help' => '',
11862
      'min_word_count' => '',
11962
    ),
12062
  );
121
12262
  foreach ($types as $type) {
12362
    $type = (object) _node_type_set_defaults($type);
12462
    node_type_save($type);
12562
  }
126
127
  // Default page to not be promoted and have comments disabled.
12862
  variable_set('node_options_page', array('status'));
12962
  variable_set('comment_page', COMMENT_NODE_DISABLED);
130
131
  // Don't display date and author information for page nodes by default.
13262
  $theme_settings = variable_get('theme_settings', array());
13362
  $theme_settings['toggle_node_info_page'] = FALSE;
13462
  variable_set('theme_settings', $theme_settings);
135
136
  // Create a default vocabulary named "Tags", enabled for the 'article'
content type.
13762
  $description = st('Use tags to group articles on similar topics into
categories.');
13862
  $help = st('Enter a comma-separated list of words.');
13962
  db_query("INSERT INTO {vocabulary} VALUES (NULL, 'Tags', '%s', '%s', 0,
0, 0, 0, 1, 'taxonomy', 0)", $description, $help);
14062
  $vid = db_last_insert_id('vocabulary', 'vid');
14162
  db_query("INSERT INTO {vocabulary_node_types} VALUES (%d, 'article')",
$vid);
142
143
  // Update the menu router information.
14462
  menu_rebuild();
14562
}
146
147
/**
148
 * Implementation of hook_form_alter().
149
 *
150
 * Allows the profile to alter the site-configuration form. This is
151
 * called through custom invocation, so $form_state is not populated.
152
 */
15362
function default_form_alter(&$form, $form_state, $form_id) {
1540
  if ($form_id == 'install_configure') {
155
    // Set default for site name field.
1560
    $form['site_information']['site_name']['#default_value'] =
$_SERVER['SERVER_NAME'];
1570
  }
1580
}
15962