diff --git a/core/includes/common.inc b/core/includes/common.inc index 3f0fd1d..fe03efb 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2503,6 +2503,46 @@ function drupal_attach_tabledrag(&$element, array $options) { } /** + * Process a text element. + */ +function drupal_pre_render_text($elements) { + $text = $elements['#text']; + if ($elements['#localize']) { + $function = isset($elements['#localize_function']) ? $elements['#localize_function'] : get_t(); + $text = call_user_func($function, $text, $elements['#variables'], $elements['#options']); + } + elseif ($elements['#replace'] && !empty($elements['#variables'])) { + $text = format_string($text, $elements['#variables']); + } + $elements['#children'] = $text; + return $elements; +} + +/** + * Build a structured text element to be rendered later. + * @param $name + * Unique text name + * @param $text + * HTML text + * @param array $variables + * Optional variables for text replacement + * @param array $options + * Optional options for text replacement + * + * @return array + * Text array + */ +function text($name, $text, $variables = array(), $options = array()) { + return array( + '#type' => 'text', + '#name' => $name, + '#text' => $text, + '#variables' => $variables, + '#options' => $options, + ); +} + +/** * Deletes old cached JavaScript files and variables. */ function drupal_clear_js_cache() { diff --git a/core/includes/theme.inc b/core/includes/theme.inc index ed27b9c..8c89a3a 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2311,6 +2311,13 @@ function template_preprocess_install_page(&$variables) { } /** + * Returns HTML for a text element + */ +function theme_text($variables) { + $element = $variables['element']; +} + +/** * Prepares variables for region templates. * * Default template: region.html.twig. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 6174a13..9944a77 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -107,8 +107,63 @@ function node_help($route_name, Request $request) { switch ($route_name) { case 'help.page.node': - $output = ''; - $output .= '

' . t('About') . '

'; + $build['about'] = text('node.help.admin.about', + '

About

' . + '

The Node module manages the creation, editing, deletion, settings, and display of the ' . + 'main site content. Content items managed by the Node module are typically displayed as ' . + 'pages on your site, and include a title, some meta-data (author, creation time, content ' . + 'type, etc.), and optional fields containing text or other data (fields are managed by the ' . + 'Field module). For more information, see the online handbook entry for ' . + 'Node module

', + array( + '@node' => 'http://drupal.org/handbook/modules/node', + '@field' => url('admin/help/field'), + ) + ); + $build['uses'] = text('node.help.admin.uses', + '

Uses

' . + '
' . + '
Creating content
' . + '
' . + 'When new content is created, the Node module records basic information about the ' . + 'content, including the author, date of creation, and the Content ' . + 'type. It also manages the publishing options, which define whether or not ' . + 'the content is published, promoted to the front page of the site, and/or sticky at the ' . + 'top of content lists. Default settings can be configured for each ' . + 'type of content on your site.' . + '
' . + '
Creating custom content types
' . + '
' . + 'The Node module gives users with the Administer content types permission the ability ' . + 'to create new content types in addition to the default ones already ' . + 'configured. Creating custom content types allows you the flexibility to add ' . + 'fields and configure default settings that suit the differing needs of various site content.' . + '
' . + '
Administering content
' . + '
' . + 'The Content administration page allows you to review and bulk manage ' . + 'your site content.' . + '
' . + '
Creating revisions
' . + '
' . + 'The Node module also enables you to create multiple versions of any content, and revert ' . + 'to older versions using the Revision information settings.' . + '
' . + '
User permissions
' . + '
' . + 'The Node module makes a number of permissions available for each content type, which can ' . + 'be set by role on the permissions page.' . + '
' . + '
', + array( + '@content' => url('admin/content'), + '@content-type' => url('admin/structure/types'), + '@content-new' => url('admin/structure/types/add'), + '@field' => url('admin/help/field'), + '@permissions' => url('admin/people/permissions', array('fragment' => 'module-node')), + ) + ); + return $build; $output .= '

' . t('The Node module manages the creation, editing, deletion, settings, and display of the main site content. Content items managed by the Node module are typically displayed as pages on your site, and include a title, some meta-data (author, creation time, content type, etc.), and optional fields containing text or other data (fields are managed by the Field module). For more information, see the online documentation for the Node module.', array('!node' => 'https://drupal.org/documentation/modules/node', '!field' => \Drupal::url('help.page', array('name' => 'field')))) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; @@ -126,7 +181,9 @@ function node_help($route_name, Request $request) { return $output; case 'node.type_add': - return '

' . t('Individual content types can have different fields, behaviors, and permissions assigned to them.') . '

'; + return text('node.types.add', + '

Individual content types can have different fields, behaviors, and permissions assigned to them.

' + ); case 'field_ui.form_display_overview_node': case 'field_ui.form_display_overview_form_mode_node': @@ -136,11 +193,21 @@ function node_help($route_name, Request $request) { case 'field_ui.display_overview_node': case 'field_ui.display_overview_view_mode_node': $type = $request->attributes->get('node_type'); - return '

' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. Teaser is a short format that is typically used in lists of multiple content items. Full content is typically used when the content is displayed on its own page.') . '

' . + return text('node.types.manage.display', + '

Content items can be displayed using different view modes: Teaser, Full content, Print, ' . + 'RSS, etc. Teaser is a short format that is typically used in lists of multiple content ' . + 'items. Full content is typically used when the content is displayed on its own page.

' . + '

Here, you can define which fields are shown and hidden when %type content is displayed in each ' . + 'view mode, and define how the fields are displayed in each view mode.

', + array('%type' => node_type_get_name($arg[4])) + ); '

' . t('Here, you can define which fields are shown and hidden when %type content is displayed in each view mode, and define how the fields are displayed in each view mode.', array('%type' => $type->label())) . '

'; case 'node.revision_overview': - return '

' . t('Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.') . '

'; + return text('node.revisions', + '

Revisions allow you to track differences between multiple versions of your content, and revert ' . + 'back to older versions.

' + ); case 'node.page_edit': $node = $request->attributes->get('node'); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 7fbfd99..fad8bb0 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -323,7 +323,13 @@ function system_element_info() { '#items' => array(), '#pre_render' => array('drupal_pre_render_scripts'), ); - + $types['text'] = array( + '#localize' => TRUE, + '#localize_function' => NULL, + '#replace' => TRUE, + '#options' => array(), + '#pre_render' => array('drupal_pre_render_text'), + ); // Input elements. $types['submit'] = array( '#input' => TRUE,