- <?php
- * @file
- * Install/uninstall and update functions for the standard installation profile.
- */
-
- * Implements hook_install().
- *
- * Perform actions to set up the site for this profile.
- *
- * @see system_install()
- */
- function standard_install() {
-
-
-
- $filtered_html_format = array(
- 'format' => 'filtered_html',
- 'name' => 'Basic',
- 'weight' => 0,
- 'editor' => 'ckeditor5',
- 'editor_settings' => array(
- 'image_upload' => array(
- 'status' => 1,
- 'dimensions' => array('max_width' => '', 'max_height' => ''),
- 'max_size' => NULL,
- 'scheme' => 'public',
- 'directory' => 'inline-images',
- ),
- ),
- 'filters' => array(
- 'filter_url' => array(
- 'weight' => 0,
- 'status' => 1,
- ),
- 'filter_html' => array(
- 'weight' => 1,
- 'status' => 1,
- ),
-
- 'filter_autop' => array(
- 'weight' => 2,
- 'status' => 1,
- ),
- 'filter_image_caption' => array(
- 'weight' => 4,
- 'status' => 1,
- ),
- 'filter_image_align' => array(
- 'weight' => 4,
- 'status' => 1,
- ),
- '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' => 'Raw HTML',
- 'weight' => 1,
- 'editor' => NULL,
- 'filters' => array(
- 'filter_url' => array(
- 'weight' => 0,
- 'status' => 1,
- ),
-
- 'filter_autop' => array(
- 'weight' => 1,
- 'status' => 1,
- ),
- 'filter_image_caption' => array(
- 'weight' => 4,
- 'status' => 1,
- ),
- 'filter_image_align' => array(
- 'weight' => 4,
- 'status' => 1,
- ),
- 'filter_htmlcorrector' => array(
- 'weight' => 10,
- 'status' => 1,
- ),
- ),
- );
- $full_html_format = (object) $full_html_format;
- filter_format_save($full_html_format);
-
-
-
- $default_theme = 'basis';
- config_set('system.core', 'theme_default', $default_theme);
- theme_enable(array($default_theme));
- theme_disable(array('stark'));
-
-
- config_set('system.core', 'site_frontpage', 'home');
- backdrop_flush_all_caches();
-
-
-
-
- $types = array(
- array(
- 'type' => 'page',
- 'name' => st('Page'),
- 'description' => st("Add a page with static content, like the 'About' page."),
- 'settings' => array(
- 'status_default' => NODE_PUBLISHED,
- 'promote_enabled' => FALSE,
- 'node_preview' => TRUE,
- 'promote_default' => FALSE,
- 'sticky_enabled' => FALSE,
- 'sticky_default' => FALSE,
- 'revision_enabled' => TRUE,
- 'revision_default' => FALSE,
- 'node_submitted' => FALSE,
- 'node_user_picture' => FALSE,
- 'comment_default' => COMMENT_NODE_CLOSED,
- 'menu_default' => TRUE,
- 'menu_options' => array('main-menu'),
- ),
- 'is_new' => TRUE,
- ),
- array(
- 'type' => 'post',
- 'name' => st('Post'),
- 'description' => st('Add a blog post, news article, or press release.'),
- 'settings' => array(
- 'status_default' => NODE_PUBLISHED,
- 'node_preview' => TRUE,
- 'promote_enabled' => TRUE,
- 'promote_default' => TRUE,
- 'sticky_enabled' => TRUE,
- 'sticky_default' => FALSE,
- 'revision_enabled' => TRUE,
- 'revision_default' => FALSE,
- 'show_submitted_info' => TRUE,
- 'comment_default' => COMMENT_NODE_OPEN,
- 'node_submitted' => TRUE,
- 'node_user_picture' => TRUE,
- ),
- 'is_new' => TRUE,
- ),
- array(
- 'type' => 'card',
- 'name' => st('Card'),
- 'description' => st('Add a card for use on an existing page. Display as a block or in a view.'),
- 'settings' => array(
- 'status_default' => NODE_PUBLISHED,
- 'node_preview' => TRUE,
- 'promote_enabled' => TRUE,
- 'promote_default' => FALSE,
- 'sticky_enabled' => FALSE,
- 'sticky_default' => FALSE,
- 'revision_enabled' => TRUE,
- 'revision_default' => FALSE,
- 'scheduling_enabled' => FALSE,
- 'show_submitted_info' => FALSE,
- 'comment_default' => COMMENT_NODE_CLOSED,
- 'node_submitted' => FALSE,
- 'node_user_picture' => FALSE,
- 'hidden_path' => TRUE,
- ),
- 'is_new' => TRUE,
- ),
- );
-
- foreach ($types as $type) {
- $type = node_type_set_defaults($type);
- node_type_save($type);
- node_add_body_field($type);
- }
-
-
- config('path.settings')
- ->set('node_page_pattern', '[node:title]')
- ->set('node_post_pattern', 'posts/[node:title]')
- ->set('node_card_pattern', 'node/[node:nid]')
- ->save();
-
- cache_clear_all();
-
-
-
- $description = st('Use tags to group posts on similar topics into categories.');
- $vocabulary = new TaxonomyVocabulary(array(
- 'name' => st('Tags'),
- 'description' => $description,
- 'machine_name' => 'tags',
- ));
- taxonomy_vocabulary_save($vocabulary);
-
- $field = array(
- 'field_name' => 'field_' . $vocabulary->machine_name,
- 'type' => 'taxonomy_term_reference',
-
- 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
- 'settings' => array(
- 'allowed_values' => array(
- array(
- 'vocabulary' => $vocabulary->machine_name,
- 'parent' => 0,
- ),
- ),
- ),
- );
- field_create_field($field);
-
- $help = st('Enter a comma-separated list of words to describe your content.');
- $instance = array(
- 'field_name' => 'field_' . $vocabulary->machine_name,
- 'entity_type' => 'node',
- 'label' => 'Tags',
- 'bundle' => 'post',
- 'description' => $help,
- 'widget' => array(
- 'type' => 'taxonomy_autocomplete',
- 'weight' => -4,
- ),
- 'display' => array(
- 'default' => array(
- 'type' => 'taxonomy_term_reference_link',
- 'weight' => 10,
- ),
- 'teaser' => array(
- 'type' => 'taxonomy_term_reference_link',
- 'weight' => 10,
- ),
- ),
- );
- field_create_instance($instance);
-
-
-
-
-
-
-
- $field = array(
- 'field_name' => 'field_image',
- 'type' => 'image',
- 'cardinality' => 1,
- '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);
-
-
-
-
-
- $instance = array(
- 'field_name' => 'field_image',
- 'entity_type' => 'node',
- 'label' => 'Image',
- 'bundle' => 'post',
- 'description' => st('Upload an image to go with this post.'),
- 'required' => FALSE,
-
- 'settings' => array(
- 'file_directory' => 'field/image',
- 'file_extensions' => implode(' ', image_get_supported_extensions()),
- '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(
- 'default' => array(
- 'label' => 'hidden',
- 'type' => 'image',
- 'settings' => array('image_style' => 'large', 'image_link' => ''),
- 'weight' => -1,
- ),
- 'teaser' => array(
- 'label' => 'hidden',
- 'type' => 'image',
- 'settings' => array(
- 'image_style' => 'medium',
- 'image_link' => 'content',
- 'image_float' => 'right',
- ),
- 'weight' => -1,
- ),
- ),
- );
- field_create_instance($instance);
-
- $instance = array(
- 'field_name' => 'field_image',
- 'entity_type' => 'node',
- 'label' => 'Image',
- 'bundle' => 'card',
- 'description' => st('Upload an image to go with this card.'),
- 'required' => FALSE,
-
- 'settings' => array(
- 'file_directory' => 'field/image',
- 'file_extensions' => implode(' ', image_get_supported_extensions()),
- '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(
- 'default' => array(
- 'label' => 'hidden',
- 'type' => 'image',
- 'settings' => array('image_style' => 'large', 'image_link' => ''),
- 'weight' => 0,
- ),
- 'teaser' => array(
- 'label' => 'hidden',
- 'type' => 'image',
- 'settings' => array(
- 'image_style' => 'medium',
- 'image_link' => '',
- 'image_float' => '',
- ),
- 'weight' => -1,
- ),
- ),
- );
- field_create_instance($instance);
-
-
- $post = new Node(
- array(
- 'title' => st('Your first post!'),
- 'body' => array(
- LANGUAGE_NONE => array(
- array(
- 'value' => '<p>' . st('This is your first post! You may edit or delete it.') . '</p>',
- 'format' => 'filtered_html',
- ),
- ),
- ),
- 'uid' => 1,
- 'status' => 1,
- 'promote' => 1,
- 'type' => 'post',
- )
- );
- $post->save();
-
-
- $page = new Node(
- array(
- 'title' => st('About'),
- 'body' => array(
- LANGUAGE_NONE => array(
- array(
- 'value' => '<p>' . st('This is a page with static content. You may edit or delete it.') . '</p>',
- 'format' => 'filtered_html',
- ),
- ),
- ),
- 'uid' => 1,
- 'status' => 1,
- 'promote' => 0,
- 'type' => 'page',
- )
- );
- $page->save();
-
-
- $item = array(
- 'link_path' => 'node/' . $page->nid,
- 'link_title' => 'About',
- 'weight' => 1,
- );
- menu_link_save($item);
-
-
-
- $field_image_dir = 'public://field/image';
- file_prepare_directory($field_image_dir, FILE_CREATE_DIRECTORY);
-
- $cards = array(
- 'card1-layout.png' => array(
- 'title' => st('The Home page layout'),
- 'body' => st('<p>Use the home page layout to specifically customize this page. These Cards only appear on this layout.</p><p><a href="https://docs.backdropcms.org/documentation/the-home-page">Learn more about the Home page</a></p>'),
- ),
- 'card2-card.png' => array(
- 'title' => st('What is a Card?'),
- 'body' => st('<p>A Card can only be seen as part of another page. Place them individually as "Existing content" Blocks, or grouped as in a View.</p><p><a href="https://docs.backdropcms.org/documentation/creating-and-editing-content">Learn more about Cards</a></p>'),
- ),
- 'card3-organize.png' => array(
- 'title' => st('Organize your content'),
- 'body' => st('<p>Backdrop CMS includes three pre-defined types of content: Pages, Posts, and Cards. Custom content types can also be added.</p><p><a href="https://docs.backdropcms.org/documentation/content-types">Learn more about content types</a></p>'),
- ),
- );
-
- foreach ($cards as $image_filename => $info) {
- $image_url = BACKDROP_ROOT . '/' . backdrop_get_path('profile', 'standard') . '/images/' . $image_filename;
- $moved_file = file_unmanaged_copy($image_url, $field_image_dir);
-
- $file = entity_create('file', array(
- 'filename' => $image_filename,
- 'uri' => $moved_file,
- 'uid' => 1,
- ));
-
- $file->save();
- $card = new Node(
- array(
- 'title' => $info['title'],
- 'body' => array(
- LANGUAGE_NONE => array(
- array(
- 'value' => $info['body'],
- 'format' => 'filtered_html',
- ),
- ),
- ),
- 'field_image' => array(
- LANGUAGE_NONE => array(
- array(
- 'fid' => $file->fid,
- 'filename' => $image_filename,
- 'uri' => 'public://field/image/' . $image_filename,
- 'filemime' => 'image/jpeg',
- 'status' => 0,
- ),
- ),
- ),
- 'uid' => 1,
- 'status' => 1,
- 'promote' => 1,
- 'type' => 'card',
- )
- );
-
- $card->save();
- }
-
-
- $promoted_view = views_get_view('promoted');
- $promoted_view->display['default']->display_options['filters']['type'] = array(
- 'id' => 'type',
- 'table' => 'node',
- 'field' => 'type',
- 'operator' => 'not in',
- 'value' => array('card' => 'card'),
- );
- $promoted_view->save();
-
-
- $filtered_html_permission = filter_permission_name($filtered_html_format);
- $anonymous_permissions = array(
- 'access content',
- 'access comments',
- $filtered_html_permission,
- );
- $authenticated_permissions = array(
- 'access content',
- 'access comments',
- 'post comments',
- 'skip comment approval',
- 'upload editor images',
- $filtered_html_permission,
- );
- user_role_grant_permissions(BACKDROP_ANONYMOUS_ROLE, $anonymous_permissions);
- user_role_grant_permissions(BACKDROP_AUTHENTICATED_ROLE, $authenticated_permissions);
-
-
-
- $editor_role = new stdClass();
- $editor_role->name = 'editor';
- $editor_role->label = 'Editor';
- $editor_role->description = 'Can edit most content on the site, but cannot modify site configuration settings.';
- $editor_role->weight = 2;
- user_role_save($editor_role);
-
- $editor_permissions = array(
- 'view own unpublished content',
- 'view any unpublished content',
- 'view revisions',
- 'revert revisions',
- 'delete revisions',
- 'create page content',
- 'edit own page content',
- 'edit any page content',
- 'delete own page content',
- 'create post content',
- 'edit own post content',
- 'edit any post content',
- 'delete own post content',
- 'create card content',
- 'edit own card content',
- 'edit any card content',
- 'delete own card content',
- 'view hidden paths',
- 'access dashboard',
- 'view the administration theme',
- 'access administration bar',
- 'access content overview',
- 'access administration pages',
- 'access site in maintenance mode',
- 'flush caches',
- 'edit terms in tags',
- 'delete terms in tags',
- 'administer taxonomy',
- 'administer nodes',
- 'search content',
- 'use advanced search',
- 'access file overview',
- 'create files',
- 'view own private files',
- 'view own files',
- 'view files',
- $filtered_html_permission,
- );
- user_role_grant_permissions('editor', $editor_permissions);
-
-
-
- $admin_role = new stdClass();
- $admin_role->name = 'administrator';
- $admin_role->label = 'Administrator';
- $admin_role->description = 'Can manage content and configuration, including the ability to assign roles.';
- $admin_role->weight = 3;
- $admin_role->permissions = array_keys(module_invoke_all('permission'));
- user_role_save($admin_role);
-
- config_set('system.core', 'user_admin_role', $admin_role->name);
-
-
-
- $admin_user = user_load(1);
- $admin_user->roles[] = $admin_role->name;
- $admin_user->path['auto'] = TRUE;
- user_save($admin_user);
-
-
- $item = array(
- 'link_title' => st('Home'),
- 'link_path' => '<front>',
- 'menu_name' => 'main-menu',
- 'weight' => -1,
- );
- menu_link_save($item);
-
-
- $item = array(
- 'link_title' => st('Login'),
- 'link_path' => 'user/login',
- 'menu_name' => 'user-menu',
- 'weight' => -1,
- );
- menu_link_save($item);
-
-
- menu_rebuild();
-
-
- db_update('system')
- ->fields(array('status' => 1))
- ->condition('type', 'theme')
- ->condition('name', 'seven')
- ->execute();
- config_set('system.core', 'admin_theme', 'seven');
- config_set('system.core', 'node_admin_theme', '1');
-
-
- config_set('system.core', 'preprocess_css', '1');
- config_set('system.core', 'preprocess_js', '1');
- config_set('system.core', 'cache', '1');
- }