1 node.install | node_update_1023() |
Create the view replacement for recent content block.
Related topics
File
- core/
modules/ node/ node.install, line 2039 - Install, update and uninstall functions for the node module.
Code
function node_update_1023() {
$data = array(
'name' => 'recent_content',
'description' => 'A list of recently published content.',
'module' => 'node',
'storage' => 2,
'tag' => '',
'disabled' => FALSE,
'base_table' => 'node',
'human_name' => 'Recent content',
'core' => '1.0',
'display' => array(
'default' => array(
'display_title' => 'Default',
'display_plugin' => 'default',
'display_options' => array(
'query' => array(
'type' => 'views_query',
'options' => array(
),
),
'access' => array(
'type' => 'perm',
),
'cache' => array(
'type' => 'none',
),
'exposed_form' => array(
'type' => 'basic',
),
'pager' => array(
'type' => 'some',
'options' => array(
'items_per_page' => '10',
'offset' => '0',
),
),
'style_plugin' => 'table',
'row_plugin' => 'fields',
'fields' => array(
'timestamp' => array(
'id' => 'timestamp',
'table' => 'history',
'field' => 'timestamp',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 1,
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => 0,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => 'div',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'link_to_node' => 0,
'comments' => 0,
),
'path' => array(
'id' => 'path',
'table' => 'node',
'field' => 'path',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 1,
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => 0,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'absolute' => 0,
),
'title' => array(
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 0,
'alter' => array(
'alter_text' => 1,
'text' => '<div class="node-title"><a href="[path]">[title]</a> [timestamp]</div>',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => 0,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 0,
'ellipsis' => 0,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => '',
'element_class' => 'title-author',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'link_to_node' => 0,
),
'created' => array(
'id' => 'created',
'table' => 'node',
'field' => 'created',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 1,
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => 0,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => 'div',
'element_class' => 'node-author',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'date_format' => 'medium',
'custom_date_format' => '',
'timezone' => '',
),
'name' => array(
'id' => 'name',
'table' => 'users',
'field' => 'name',
'relationship' => 'uid',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 0,
'alter' => array(
'alter_text' => 1,
'text' => '<div class="node-author">[created] by [name]</div>',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => 0,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'link_to_user' => 1,
'overwrite_anonymous' => 0,
'anonymous_text' => '',
'format_username' => 1,
),
'edit_node' => array(
'id' => 'edit_node',
'table' => 'views_entity_node',
'field' => 'edit_node',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 1,
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => FALSE,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'text' => '',
),
'delete_node' => array(
'id' => 'delete_node',
'table' => 'views_entity_node',
'field' => 'delete_node',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 1,
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'external' => FALSE,
'replace_spaces' => 0,
'path_case' => 'none',
'trim_whitespace' => 0,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'more_link' => 0,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => 0,
'trim' => 0,
'preserve_tags' => '',
'html' => 0,
),
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 1,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'text' => '',
),
'dropbutton' => array(
'id' => 'dropbutton',
'table' => 'views',
'field' => 'dropbutton',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'exclude' => 0,
'alter' => array(
'alter_text' => FALSE,
'text' => '',
'make_link' => FALSE,
'path' => '',
'absolute' => FALSE,
'external' => FALSE,
'replace_spaces' => FALSE,
'path_case' => 'none',
'trim_whitespace' => FALSE,
'alt' => '',
'rel' => '',
'link_class' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'nl2br' => FALSE,
'max_length' => '',
'word_boundary' => TRUE,
'ellipsis' => TRUE,
'more_link' => FALSE,
'more_link_text' => '',
'more_link_path' => '',
'strip_tags' => FALSE,
'trim' => FALSE,
'preserve_tags' => '',
'html' => FALSE,
),
'element_type' => '',
'element_class' => '',
'element_label_type' => '',
'element_label_class' => '',
'element_label_colon' => FALSE,
'element_wrapper_type' => '',
'element_wrapper_class' => '',
'element_default_classes' => 0,
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'hide_alter_empty' => 1,
'fields' => array(
'edit_node' => 'edit_node',
'delete_node' => 'delete_node',
'title' => 0,
'timestamp' => 0,
'name' => 0,
),
'destination' => 1,
),
),
'filters' => array(
'status_extra' => array(
'id' => 'status_extra',
'table' => 'node',
'field' => 'status_extra',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'operator' => '=',
'value' => '',
'group' => '1',
'exposed' => FALSE,
'expose' => array(
'operator_id' => FALSE,
'label' => '',
'description' => '',
'use_operator' => FALSE,
'operator' => '',
'identifier' => '',
'required' => FALSE,
'remember' => FALSE,
'multiple' => FALSE,
'remember_roles' => array(
2 => 2,
),
),
'is_grouped' => FALSE,
'group_info' => array(
'label' => '',
'description' => '',
'identifier' => '',
'optional' => TRUE,
'widget' => 'select',
'multiple' => FALSE,
'remember' => 0,
'default_group' => 'All',
'default_group_multiple' => array(
),
'group_items' => array(
),
),
),
'type' => array(
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'operator' => 'in',
'value' => array(
),
'group' => '1',
'exposed' => TRUE,
'expose' => array(
'operator_id' => 'type_op',
'label' => 'Content types',
'description' => '',
'use_operator' => 0,
'operator' => 'type_op',
'identifier' => 'type',
'required' => 0,
'remember' => 0,
'multiple' => 1,
'remember_roles' => array(
'authenticated' => 'authenticated',
'anonymous' => 0,
),
'reduce' => 0,
),
'is_grouped' => FALSE,
'group_info' => array(
'label' => '',
'description' => '',
'identifier' => '',
'optional' => TRUE,
'widget' => 'select',
'multiple' => FALSE,
'remember' => 0,
'default_group' => 'All',
'default_group_multiple' => array(
),
'group_items' => array(
),
),
),
),
'sorts' => array(
'changed' => array(
'id' => 'changed',
'table' => 'node',
'field' => 'changed',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'order' => 'DESC',
'exposed' => FALSE,
'expose' => array(
'label' => '',
),
'granularity' => 'minute',
),
),
'title' => 'Recent content',
'relationships' => array(
'uid' => array(
'id' => 'uid',
'table' => 'node',
'field' => 'uid',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => 'author',
'required' => 0,
),
),
'empty' => array(
'area_text_custom' => array(
'id' => 'area_text_custom',
'table' => 'views',
'field' => 'area_text_custom',
'relationship' => 'none',
'group_type' => 'group',
'ui_name' => '',
'label' => '',
'empty' => TRUE,
'content' => 'No content available.',
'tokenize' => 0,
),
),
'use_more' => 1,
'use_more_always' => TRUE,
'use_more_text' => 'More',
'style_options' => array(
'grouping' => array(
),
'row_class' => '',
'default_row_class' => 1,
'row_class_special' => 1,
'override' => 1,
'sticky' => 0,
'caption' => '',
'summary' => '',
'columns' => array(
'title' => 'title',
'timestamp' => 'title',
'name' => 'title',
'edit_node' => 'edit_node',
'delete_node' => 'delete_node',
'dropbutton' => 'dropbutton',
),
'info' => array(
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => 'views-align-left',
'separator' => '',
'empty_column' => 0,
),
'timestamp' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'name' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'edit_node' => array(
'align' => '',
'separator' => '',
'empty_column' => 1,
),
'delete_node' => array(
'align' => '',
'separator' => '',
'empty_column' => 1,
),
'dropbutton' => array(
'align' => '',
'separator' => '',
'empty_column' => 1,
),
),
'default' => '-1',
'empty_table' => 0,
),
'link_display' => 'custom_url',
),
),
'block' => array(
'display_title' => 'Block',
'display_plugin' => 'block',
'display_options' => array(
'query' => array(
'type' => 'views_query',
'options' => array(
),
),
'allow' => array(
'items_per_page' => 'items_per_page',
'exposed_form' => 'exposed_form',
'use_pager' => 0,
'offset' => 0,
'link_to_view' => 0,
'more_link' => 'more_link',
'path_override' => 0,
'fields_override' => 0,
),
'link_url' => 'admin/content',
),
),
),
);
$config = config('views.view.recent_content');
if ($config->isNew()) {
$config->setData($data);
$config->save();
}
// Upgrade recent content block to views.
$layouts = config_get_names_with_prefix('layout.layout.');
foreach ($layouts as $layout_name) {
$config = config($layout_name);
$configs = $config->get();
if (isset($configs['content'])) {
foreach ($configs['content'] as $uuid => $block) {
if ($block['data']['delta'] == 'recent' && $block['data']['module'] == 'node') {
$config->set('content.' . $uuid . '.plugin', 'views:recent_content-block');
$config->set('content.' . $uuid . '.data.module', 'views');
$config->set('content.' . $uuid . '.data.delta', 'recent_content-block');
// Carry over the node_count setting to items_per_page.
if (isset($block['data']['settings']['block_settings']['node_count'])) {
$node_count = $block['data']['settings']['block_settings']['node_count'];
$config->set('content.' . $uuid . '.data.settings.items_per_page', $node_count);
$config->clear('content.' . $uuid . '.data.settings.block_settings');
}
// Add "block-node-recent" class for styling consistency.
$existing_class = isset($block['data']['style']['data']['settings']['classes']) ? $block['data']['style']['data']['settings']['classes'] : '';
$new_class = trim($existing_class . ' block-node-recent');
$config->set('content.' . $uuid . '.data.style.plugin', 'default');
$config->set('content.' . $uuid . '.data.style.data.settings.classes', $new_class);
}
}
}
$config->save();
}
}