<?php /** * @file * Install, update and uninstall functions for the standard installation profile. */ /** * Implements hook_install(). * * Perform actions to set up the site for this profile. * * @see system_install() */ function cambridge_lite_install() { // Add text formats. $filtered_html_format = array( 'format' => 'filtered_html', '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( 'format' => 'full_html', '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); // Add image styles $carousel = image_style_save(array('name' => 'carousel', 'label' => 'Carousel')); image_effect_save( array( 'name' => 'image_scale', 'data' => array( 'width' => 885, 'height' => NULL, 'upscale' => TRUE, ), 'isid' => $carousel['isid'], 'weight' => 1, ) ); image_effect_save( array( 'name' => 'image_crop', 'data' => array( 'width' => 885, 'height' => 432, 'anchor' => 'center-center', ), 'isid' => $carousel['isid'], 'weight' => 2, ) ); $leading = image_style_save(array('name' => 'leading', 'label' => 'Leading')); image_effect_save( array( 'name' => 'image_scale', 'data' => array( 'width' => 590, 'height' => NULL, 'upscale' => TRUE, ), 'isid' => $leading['isid'], 'weight' => 1, ) ); image_effect_save( array( 'name' => 'image_crop', 'data' => array( 'width' => 590, 'height' => 288, 'anchor' => 'center-center', ), 'isid' => $leading['isid'], 'weight' => 2, ) ); $inline = image_style_save(array('name' => 'inline', 'label' => 'Inline/teaser')); image_effect_save( array( 'name' => 'image_scale', 'data' => array( 'width' => 250, 'height' => NULL, 'upscale' => TRUE, ), 'isid' => $inline['isid'], 'weight' => 1, ) ); image_effect_save( array( 'name' => 'image_crop', 'data' => array( 'width' => 250, 'height' => 250, 'anchor' => 'center-center', ), 'isid' => $inline['isid'], 'weight' => 2, ) ); // Add content types. $types = array( array( 'type' => 'page', 'name' => st('Basic Page'), 'base' => 'node_content', 'description' => st("Use <em>basic pages</em> for your static content, such as an 'About us' page."), 'custom' => 1, 'modified' => 1, 'locked' => 0, ), ); foreach ($types as $type) { $type = node_type_set_defaults($type); node_type_save($type); node_add_body_field($type); } // Default "Basic page" to not be promoted and have comments disabled. variable_set('node_options_page', array('status')); // Don't display date and author information for "Basic page" nodes by default. variable_set('node_submitted_page', FALSE); $fields = array( 'field_leading_image' => array( 'field_name' => 'field_leading_image', 'label' => st('Leading image'), 'cardinality' => 1, 'type' => 'image', 'settings' => array( 'default_image' => 0, 'uri_scheme' => 'public', ), ), ); foreach ($fields as $field) { field_create_field($field); } $instances = array( 'field_leading_image' => array( 'entity_type' => 'node', 'bundle' => 'page', 'field_name' => 'field_leading_image', 'label' => st('Leading image'), 'cardinality' => 1, 'type' => 'field_leading_image', 'settings' => array( 'alt_field' => 1, 'file_directory' => '', 'file_extensions' => 'png gif jpg jpeg', 'max_filesize' => '', 'max_resolution' => '', 'min_resolution' => '', 'title_field' => 1, 'user_register_form' => FALSE, ), 'widget' => array( 'settings' => array( 'preview_image_style' => 'thumbnail', 'progress_indicator' => 'throbber', ), ), 'display' => array( 'default' => array( 'label' => 'hidden', 'type' => 'image', 'settings' => array('image_style' => 'leading', 'image_link' => ''), 'weight' => -1, ), 'teaser' => array( 'label' => 'hidden', 'type' => 'image', 'settings' => array('image_style' => 'inline', 'image_link' => 'content'), 'weight' => -1, ), ), ), ); foreach ($instances as $instance) { field_create_instance($instance); } // Allow visitor account creation with administrative approval. variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); // Enable the default and admin theme. $enable = array( 'theme_default' => 'cambridge_theme', 'admin_theme' => 'seven', ); theme_enable($enable); foreach ($enable as $var => $theme) { if (!is_numeric($var)) { variable_set($var, $theme); } } theme_disable(array('bartik')); // Use the admin theme for creating/editing nodes variable_set('node_admin_theme', 1); // Insert the page_title block required by the theme db_insert('block_custom') ->fields( array( 'body' => "<h1>\n<?php\nprint drupal_get_title();\n?>\n</h1>", 'info' => 'Page title', 'format' => 'php_code', ) ) ->execute(); // Insert the horizontal menu block required by the theme variable_set("menu_block_1_title_link", 0); variable_set("menu_block_1_admin_title", 'Horizontal menu'); variable_set("menu_block_1_parent", 'main-menu:0'); variable_set("menu_block_1_level", 1); variable_set("menu_block_1_follow", 0); variable_set("menu_block_1_depth", 0); variable_set("menu_block_1_expanded", 1); variable_set("menu_block_1_sort", 0); // Insert the vertical menu block required by the theme variable_set("menu_block_2_title_link", 0); variable_set("menu_block_2_admin_title", 'Vertical menu'); variable_set("menu_block_2_parent", 'main-menu:0'); variable_set("menu_block_2_level", 1); variable_set("menu_block_2_follow", 1); variable_set("menu_block_2_depth", 0); variable_set("menu_block_2_expanded", 0); variable_set("menu_block_2_sort", 1); variable_set('menu_block_ids', array(1, 2)); // Hide Drupal's standard menu blocks variable_set('menu_block_suppress_core', 1); $theme = 'cambridge_theme'; $blocks = array( array( 'module' => 'system', 'delta' => 'help', 'theme' => $theme, 'status' => 1, 'weight' => 0, 'region' => 'content', 'pages' => '', 'title' => '', 'cache' => DRUPAL_NO_CACHE, ), array( 'module' => 'user', 'delta' => 'login', 'theme' => $theme, 'status' => 1, 'weight' => 10, 'region' => 'sidebar', 'pages' => '', 'title' => '', 'cache' => DRUPAL_NO_CACHE, ), array( 'module' => 'block', 'delta' => 1, 'theme' => $theme, 'status' => 1, 'weight' => 0, 'region' => 'page_title', 'pages' => '<front>', 'title' => '', 'cache' => DRUPAL_NO_CACHE, ), array( 'module' => 'menu_block', 'delta' => 1, 'theme' => $theme, 'status' => 1, 'weight' => 0, 'region' => 'horizontal_navigation', 'pages' => '', 'title' => '<none>', 'cache' => DRUPAL_NO_CACHE, ), array( 'module' => 'menu_block', 'delta' => 2, 'theme' => $theme, 'status' => 1, 'weight' => 0, 'region' => 'left_navigation', 'pages' => '<front>', 'title' => '<none>', 'cache' => DRUPAL_NO_CACHE, ), ); $query = db_insert('block') ->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'title', 'cache')); foreach ($blocks as $block) { $query->values($block); } $query->execute(); // Insert default pre-defined RDF mapping into the database. $rdf_mappings = array( array( 'type' => 'node', 'bundle' => 'page', 'mapping' => array( 'rdftype' => array('foaf:Document'), ), ), ); foreach ($rdf_mappings as $rdf_mapping) { rdf_mapping_save($rdf_mapping); } // Enable default permissions for system roles. $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', $filtered_html_permission)); // Create a default role for site administrators, with all available permissions assigned. $admin_role = new stdClass(); $admin_role->name = 'administrator'; $admin_role->weight = 2; user_role_save($admin_role); user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission'))); // Set this as the administrator role. variable_set('user_admin_role', $admin_role->rid); // Assign user 1 the "administrator" role. db_insert('users_roles') ->fields(array('uid' => 1, 'rid' => $admin_role->rid)) ->execute(); // Reset anonymous and authenticated user permissions. user_role_grant_permissions(1, array('access content', 'search content')); user_role_grant_permissions(2, array('access content', 'search content')); // Create a Home link in the main menu. $item = array( 'link_title' => st('Home'), 'link_path' => '<front>', 'menu_name' => 'main-menu', ); menu_link_save($item); // Update the menu router information. menu_rebuild(); }