--- modules/filter/filter.module 2009-03-20 11:11:24.000000000 -0400 +++ modules/filter/fix.filter.module 2009-03-20 11:11:14.000000000 -0400 @@ -171,6 +171,17 @@ function filter_cron() { function filter_filter_tips($delta, $format, $long = FALSE) { global $base_url; switch ($delta) { + case -1: + $output = t('All HTML tags are allowed.'); + switch ($long) { + case 0: + return $output; + case 1: + $output .= _filter_filter_tips_tags(); + return $output; + } + break; + case 0: if ($allowed_html = variable_get("allowed_html_$format", '
    1. ')) { switch ($long) { @@ -181,85 +192,7 @@ function filter_filter_tips($delta, $for if (!variable_get("filter_html_help_$format", 1)) { return $output; } - - $output .= '

      ' . 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 .= '

      ' . 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( t('Anchors are used to make links to other pages.'), '' . variable_get('site_name', 'Drupal') . ''), - 'br' => array( 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'), t('Text with
      line break')), - 'p' => array( t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '

      ' . t('Paragraph one.') . '

      ' . t('Paragraph two.') . '

      '), - 'strong' => array( t('Strong'), '' . t('Strong') . ''), - 'em' => array( t('Emphasized'), '' . t('Emphasized') . ''), - 'cite' => array( t('Cited'), '' . t('Cited') . ''), - 'code' => array( t('Coded text used to show programming source code'), '' . t('Coded') . ''), - 'b' => array( t('Bolded'), '' . t('Bolded') . ''), - 'u' => array( t('Underlined'), '' . t('Underlined') . ''), - 'i' => array( t('Italicized'), '' . t('Italicized') . ''), - 'sup' => array( t('Superscripted'), t('Superscripted')), - 'sub' => array( t('Subscripted'), t('Subscripted')), - 'pre' => array( t('Preformatted'), '
      ' . t('Preformatted') . '
      '), - 'abbr' => array( t('Abbreviation'), t('Abbrev.')), - 'acronym' => array( t('Acronym'), t('TLA')), - 'blockquote' => array( t('Block quoted'), '
      ' . t('Block quoted') . '
      '), - 'q' => array( t('Quoted inline'), '' . t('Quoted inline') . ''), - // Assumes and describes tr, td, th. - 'table' => array( t('Table'), '
      ' . t('Table header') . '
      ' . t('Table cell') . '
      '), - 'tr' => NULL, 'td' => NULL, 'th' => NULL, - 'del' => array( t('Deleted'), '' . t('Deleted') . ''), - 'ins' => array( t('Inserted'), '' . t('Inserted') . ''), - // Assumes and describes li. - 'ol' => array( t('Ordered list - use the <li> to begin each list item'), '
      1. ' . t('First item') . '
      2. ' . t('Second item') . '
      '), - 'ul' => array( t('Unordered list - use the <li> to begin each list item'), '
      • ' . t('First item') . '
      • ' . t('Second item') . '
      '), - 'li' => NULL, - // Assumes and describes dt and dd. - 'dl' => array( 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.'), '
      ' . t('First term') . '
      ' . t('First definition') . '
      ' . t('Second term') . '
      ' . t('Second definition') . '
      '), - 'dt' => NULL, 'dd' => NULL, - 'h1' => array( t('Heading'), '

      ' . t('Title') . '

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

      ' . t('Subtitle') . '

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

      ' . t('Subtitle three') . '

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

      ' . t('Subtitle four') . '

      '), - 'h5' => array( t('Heading'), '
      ' . t('Subtitle five') . '
      '), - 'h6' => array( t('Heading'), '
      ' . t('Subtitle six') . '
      ') - ); - $header = array(t('Tag Description'), t('You Type'), t('You Get')); - preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out); - foreach ($out[1] as $tag) { - if (array_key_exists($tag, $tips)) { - if ($tips[$tag]) { - $rows[] = array( - array('data' => $tips[$tag][0], 'class' => 'description'), - array('data' => '' . check_plain($tips[$tag][1]) . '', 'class' => 'type'), - array('data' => $tips[$tag][1], 'class' => 'get') - ); - } - } - else { - $rows[] = array( - array('data' => t('No help provided for tag %tag.', array('%tag' => $tag)), 'class' => 'description', 'colspan' => 3), - ); - } - } - $output .= theme('table', $header, $rows); - - $output .= '

      ' . t('Most unusual characters can be directly entered without any problems.') . '

      '; - $output .= '

      ' . 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')) . '

      '; - - $entities = array( - array( t('Ampersand'), '&'), - array( t('Greater than'), '>'), - array( t('Less than'), '<'), - array( t('Quotation mark'), '"'), - ); - $header = array(t('Character Description'), t('You Type'), t('You Get')); - unset($rows); - foreach ($entities as $entity) { - $rows[] = array( - array('data' => $entity[0], 'class' => 'description'), - array('data' => '' . check_plain($entity[1]) . '', 'class' => 'type'), - array('data' => $entity[1], 'class' => 'get') - ); - } - $output .= theme('table', $header, $rows); + $output .= _filter_filter_tips_tags($allowed_html); return $output; } } @@ -287,6 +220,106 @@ function filter_filter_tips($delta, $for } /** + * Helper function for generating a table of tag descriptions. + */ +function _filter_filter_tips_tags($allowed_html = array()) { + global $base_url; + $output = '

      ' . 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 .= '

      ' . 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( t('Anchors are used to make links to other pages.'), '' . variable_get('site_name', 'Drupal') . ''), + 'br' => array( 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'), t('Text with
      line break')), + 'p' => array( t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '

      ' . t('Paragraph one.') . '

      ' . t('Paragraph two.') . '

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

      ' . t('Title') . '

      '), + 'h2' => array( t('Heading'), '

      ' . t('Subtitle') . '

      '), + 'h3' => array( t('Heading'), '

      ' . t('Subtitle three') . '

      '), + 'h4' => array( t('Heading'), '

      ' . t('Subtitle four') . '

      '), + 'h5' => array( t('Heading'), '
      ' . t('Subtitle five') . '
      '), + 'h6' => array( t('Heading'), '
      ' . t('Subtitle six') . '
      '), + ); + $header = array(t('Tag Description'), t('You Type'), t('You Get')); + + if (empty($allowed_html)) { + foreach ($tips as $tag) { + $rows[] = array( + array('data' => $tag[0], 'class' => 'description'), + array('data' => '' . check_plain($tag[1]) . '', 'class' => 'type'), + array('data' => $tag[1], 'class' => 'get'), + ); + } + } + else { + preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out); + foreach ($out[1] as $tag) { + if (array_key_exists($tag, $tips)) { + if ($tips[$tag]) { + $rows[] = array( + array('data' => $tips[$tag][0], 'class' => 'description'), + array('data' => '' . check_plain($tips[$tag][1]) . '', 'class' => 'type'), + array('data' => $tips[$tag][1], 'class' => 'get'), + ); + } + } + else { + $rows[] = array( + array('data' => t('No help provided for tag %tag.', array('%tag' => $tag)), 'class' => 'description', 'colspan' => 3), + ); + } + } + } + $output .= theme('table', $header, $rows); + + $output .= '

      ' . t('Most unusual characters can be directly entered without any problems.') . '

      '; + $output .= '

      ' . 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')) . '

      '; + + $entities = array( + array( t('Ampersand'), '&'), + array( t('Greater than'), '>'), + array( t('Less than'), '<'), + array( t('Quotation mark'), '"'), + ); + $header = array(t('Character Description'), t('You Type'), t('You Get')); + unset($rows); + foreach ($entities as $entity) { + $rows[] = array( + array('data' => $entity[0], 'class' => 'description'), + array('data' => '' . check_plain($entity[1]) . '', 'class' => 'type'), + array('data' => $entity[1], 'class' => 'get') + ); + } + $output .= theme('table', $header, $rows); + return $output; +} + + + +/** * Retrieve a list of text formats. */ function filter_formats($index = NULL) { @@ -311,7 +344,7 @@ function filter_formats($index = NULL) { if (!$all) { $or = db_or()->condition('format', variable_get('filter_default_format', 1)); foreach ($user->roles as $rid => $role) { - $or->condition('roles', '%'. (int)$rid .'%', 'LIKE'); + $or->condition('roles', '%' . (int)$rid . '%', 'LIKE'); } $query->condition($or); } @@ -485,15 +518,15 @@ function check_markup($text, $format = F function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) { $value = filter_resolve_format($value); $formats = filter_formats(); - + $form = array( '#type' => 'fieldset', '#weight' => $weight, '#attributes' => array('class' => 'filter-wrapper'), ); - + $element_id = form_clean_id('edit-' . implode('-', $parents)); - + if (count($formats) > 1) { foreach ($formats as $format) { $options[$format->format] = $format->name; @@ -558,6 +591,11 @@ function _filter_tips($format, $long = F $filters = filter_list_format($format->format); $tips[$format->name] = array(); + if (array_key_exists('filter/0', $filters) == FALSE && array_key_exists('filter/4', $filters) == FALSE) { + if ($tip = module_invoke('filter', 'filter_tips', -1, $format->format, $long)) { + $tips[$format->name][] = array('tip' => $tip, 'id' => 'filter-all-html'); + } + } foreach ($filters as $id => $filter) { if ($tip = module_invoke($filter->module, 'filter_tips', $filter->delta, $format->format, $long)) { $tips[$format->name][] = array('tip' => $tip, 'id' => $id);