diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index c0fd3eb..e2003f7 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -89,7 +89,7 @@ public function tips($long = FALSE) { if (!($allowed_html = $this->settings['allowed_html'])) { return; } - $output = $this->t('Allowed HTML tags: @tags', array('@tags' => $allowed_html)); + $output = $this->t('Allowed HTML tags: @tags', ['@tags' => $allowed_html]); if (!$long) { return $output; } @@ -100,120 +100,116 @@ public function tips($long = FALSE) { } $output .= '

' . $this->t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '

'; - $output .= '

' . $this->t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '

'; - $tips = array( - 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''), - 'br' => array($this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with
line break')), - 'p' => array($this->t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '

' . $this->t('Paragraph one.') . '

' . $this->t('Paragraph two.') . '

'), - 'strong' => array($this->t('Strong', array(), array('context' => 'Font weight')), '' . $this->t('Strong', array(), array('context' => 'Font weight')) . ''), - 'em' => array($this->t('Emphasized'), '' . $this->t('Emphasized') . ''), - 'cite' => array($this->t('Cited'), '' . $this->t('Cited') . ''), - 'code' => array($this->t('Coded text used to show programming source code'), '' . $this->t('Coded') . ''), - 'b' => array($this->t('Bolded'), '' . $this->t('Bolded') . ''), - 'u' => array($this->t('Underlined'), '' . $this->t('Underlined') . ''), - 'i' => array($this->t('Italicized'), '' . $this->t('Italicized') . ''), - 'sup' => array($this->t('Superscripted'), $this->t('Superscripted')), - 'sub' => array($this->t('Subscripted'), $this->t('Subscripted')), - 'pre' => array($this->t('Preformatted'), '
' . $this->t('Preformatted') . '
'), - 'abbr' => array($this->t('Abbreviation'), $this->t('Abbrev.')), - 'acronym' => array($this->t('Acronym'), $this->t('TLA')), - 'blockquote' => array($this->t('Block quoted'), '
' . $this->t('Block quoted') . '
'), - 'q' => array($this->t('Quoted inline'), '' . $this->t('Quoted inline') . ''), + $output .= '

' . $this->t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', ['@html-specifications' => 'http://www.w3.org/TR/html/']) . '

'; + $tips = [ + 'a' => [$this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''], + 'br' => [$this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with
line break')], + 'p' => [$this->t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '

' . $this->t('Paragraph one.') . '

' . $this->t('Paragraph two.') . '

'], + 'strong' => [$this->t('Strong', [], ['context' => 'Font weight']), '' . $this->t('Strong', [], ['context' => 'Font weight']) . ''], + 'em' => [$this->t('Emphasized'), '' . $this->t('Emphasized') . ''], + 'cite' => [$this->t('Cited'), '' . $this->t('Cited') . ''], + 'code' => [$this->t('Coded text used to show programming source code'), '' . $this->t('Coded') . ''], + 'b' => [$this->t('Bolded'), '' . $this->t('Bolded') . ''], + 'u' => [$this->t('Underlined'), '' . $this->t('Underlined') . ''], + 'i' => [$this->t('Italicized'), '' . $this->t('Italicized') . ''], + 'sup' => [$this->t('Superscripted'), $this->t('Superscripted')], + 'sub' => [$this->t('Subscripted'), $this->t('Subscripted')], + 'pre' => [$this->t('Preformatted'), '
' . $this->t('Preformatted') . '
'], + 'abbr' => [$this->t('Abbreviation'), $this->t('Abbrev.')], + 'acronym' => [$this->t('Acronym'), $this->t('TLA')], + 'blockquote' => [$this->t('Block quoted'), '
' . $this->t('Block quoted') . '
'], + 'q' => [$this->t('Quoted inline'), '' . $this->t('Quoted inline') . ''], // Assumes and describes tr, td, th. - 'table' => array($this->t('Table'), '
' . $this->t('Table header') . '
' . $this->t('Table cell') . '
'), + 'table' => [$this->t('Table'), '
' . $this->t('Table header') . '
' . $this->t('Table cell') . '
'], 'tr' => NULL, 'td' => NULL, 'th' => NULL, - 'del' => array($this->t('Deleted'), '' . $this->t('Deleted') . ''), - 'ins' => array($this->t('Inserted'), '' . $this->t('Inserted') . ''), + 'del' => [$this->t('Deleted'), '' . $this->t('Deleted') . ''], + 'ins' => [$this->t('Inserted'), '' . $this->t('Inserted') . ''], // Assumes and describes li. - 'ol' => array($this->t('Ordered list - use the <li> to begin each list item'), '
  1. ' . $this->t('First item') . '
  2. ' . $this->t('Second item') . '
'), - 'ul' => array($this->t('Unordered list - use the <li> to begin each list item'), ''), + 'ol' => [$this->t('Ordered list - use the <li> to begin each list item'), '
  1. ' . $this->t('First item') . '
  2. ' . $this->t('Second item') . '
'], + 'ul' => [$this->t('Unordered list - use the <li> to begin each list item'), ''], 'li' => NULL, // Assumes and describes dt and dd. - 'dl' => array($this->t('Definition lists are similar to other HTML lists. <dl> begins the definition list, <dt> begins the definition term and <dd> begins the definition description.'), '
' . $this->t('First term') . '
' . $this->t('First definition') . '
' . $this->t('Second term') . '
' . $this->t('Second definition') . '
'), + 'dl' => [$this->t('Definition lists are similar to other HTML lists. <dl> begins the definition list, <dt> begins the definition term and <dd> begins the definition description.'), '
' . $this->t('First term') . '
' . $this->t('First definition') . '
' . $this->t('Second term') . '
' . $this->t('Second definition') . '
'], 'dt' => NULL, 'dd' => NULL, - 'h1' => array($this->t('Heading'), '

' . $this->t('Title') . '

'), - 'h2' => array($this->t('Heading'), '

' . $this->t('Subtitle') . '

'), - 'h3' => array($this->t('Heading'), '

' . $this->t('Subtitle three') . '

'), - 'h4' => array($this->t('Heading'), '

' . $this->t('Subtitle four') . '

'), - 'h5' => array($this->t('Heading'), '
' . $this->t('Subtitle five') . '
'), - 'h6' => array($this->t('Heading'), '
' . $this->t('Subtitle six') . '
') - ); - $header = array($this->t('Tag Description'), $this->t('You Type'), $this->t('You Get')); + 'h1' => [$this->t('Heading'), '

' . $this->t('Title') . '

'], + 'h2' => [$this->t('Heading'), '

' . $this->t('Subtitle') . '

'], + 'h3' => [$this->t('Heading'), '

' . $this->t('Subtitle three') . '

'], + 'h4' => [$this->t('Heading'), '

' . $this->t('Subtitle four') . '

'], + 'h5' => [$this->t('Heading'), '
' . $this->t('Subtitle five') . '
'], + 'h6' => [$this->t('Heading'), '
' . $this->t('Subtitle six') . '
'], + ]; + $header = [$this->t('Tag Description'), $this->t('You Type'), $this->t('You Get')]; preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out); foreach ($out[1] as $tag) { if (!empty($tips[$tag])) { - $rows[] = array( - array('data' => $tips[$tag][0], 'class' => array('description')), - array( - 'data' => array( + $rows[] = [ + ['data' => $tips[$tag][0], 'class' => ['description']], + [ + 'data' => [ '#type' => 'inline_template', '#template' => '{{ tip }}', - '#context' => array( - 'tip' => $tips[$tag][1], - ), - ), - 'class' => array('type'), - ), - array( - 'data' => array( - '#type' => 'inline_template', - '#template' => $tips[$tag][1], - ), - 'class' => array('get'), - ), - ); + '#context' => ['tip' => $tips[$tag][1]], + ], + 'class' => ['type'], + ], + [ + 'data' => ['#type' => 'inline_template', '#template' => $tips[$tag][1]], + 'class' => ['get'], + ], + ]; } else { - $rows[] = array( - array('data' => $this->t('No help provided for tag %tag.', array('%tag' => $tag)), 'class' => array('description'), 'colspan' => 3), - ); + $rows[] = [ + [ + 'data' => $this->t('No help provided for tag %tag.', ['%tag' => $tag]), + 'class' => ['description'], 'colspan' => 3 + ], + ]; } } - $table = array( + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, - ); + ]; $output .= \Drupal::service('renderer')->render($table); $output .= '

' . $this->t('Most unusual characters can be directly entered without any problems.') . '

'; - $output .= '

' . $this->t('If you do encounter problems, try using HTML character entities. A common example looks like &amp; for an ampersand & character. For a full list of entities see HTML\'s entities page. Some of the available characters include:', array('@html-entities' => 'http://www.w3.org/TR/html4/sgml/entities.html')) . '

'; + $output .= '

' . $this->t('If you do encounter problems, try using HTML character entities. A common example looks like &amp; for an ampersand & character. For a full list of entities see HTML\'s entities page. Some of the available characters include:', ['@html-entities' => 'http://www.w3.org/TR/html4/sgml/entities.html']) . '

'; - $entities = array( - array($this->t('Ampersand'), '&'), - array($this->t('Greater than'), '>'), - array($this->t('Less than'), '<'), - array($this->t('Quotation mark'), '"'), - ); - $header = array($this->t('Character Description'), $this->t('You Type'), $this->t('You Get')); + $entities = [ + [$this->t('Ampersand'), '&'], + [$this->t('Greater than'), '>'], + [$this->t('Less than'), '<'], + [$this->t('Quotation mark'), '"'], + ]; + $header = [$this->t('Character Description'), $this->t('You Type'), $this->t('You Get')]; unset($rows); foreach ($entities as $entity) { - $rows[] = array( - array('data' => $entity[0], 'class' => array('description')), - array( - 'data' => array( + $rows[] = [ + ['data' => $entity[0], 'class' => ['description']], + [ + 'data' => [ '#type' => 'inline_template', '#template' => '{{ tip }}', - '#context' => array( - 'tip' => $entity[1], - ), - ), - 'class' => array('type'), - ), - array( - 'data' => array( + '#context' => ['tip' => $entity[1]], + ], + 'class' => ['type'], + ], + [ + 'data' => [ '#type' => 'inline_template', '#template' => $entity[1], - ), - 'class' => array('get'), - ), - ); + ], + 'class' => ['get'], + ], + ]; } - $table = array( + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, - ); + ]; $output .= \Drupal::service('renderer')->render($table); return $output; }