Skip to content
Snippets Groups Projects
Commit 2dd0b6ff authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #548308 by dropcube: remove hook_filter_tips() as part of the hook_filter() refactoring.

parent 173f0249
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -166,17 +166,14 @@ function filter_cron() {
}
/**
* Implement hook_filter_tips().
* @name Tips callbacks for filters.
* @{
* Filters implemented by the filter.module.
*/
function filter_filter_tips($delta, $format, $long = FALSE) {
function _filter_html_tips($format, $long = FALSE) {
global $base_url;
switch ($delta) {
case 0:
if ($allowed_html = variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>')) {
switch ($long) {
case 0:
return t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
case 1:
if ($long) {
$output = '<p>' . t('Allowed HTML tags: @tags', array('@tags' => $allowed_html)) . '</p>';
if (!variable_get("filter_html_help_$format", 1)) {
return $output;
......@@ -262,29 +259,33 @@ function filter_filter_tips($delta, $format, $long = FALSE) {
$output .= theme('table', $header, $rows);
return $output;
}
else {
return t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
}
}
}
break;
case 1:
switch ($long) {
case 0:
return t('Lines and paragraphs break automatically.');
case 1:
function _filter_autop_tips($format, $long = FALSE) {
if ($long) {
return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
}
break;
else {
return t('Lines and paragraphs break automatically.');
}
}
case 2:
function _filter_url_tips() {
return t('Web page addresses and e-mail addresses turn into links automatically.');
break;
}
case 4:
function _filter_html_escape_tips() {
return t('No HTML tags allowed.');
break;
}
}
/**
* @} End of "Tips callback for filters".
*/
/**
* Retrieve a list of text formats.
*/
......@@ -571,7 +572,9 @@ function _filter_tips($format, $long = FALSE) {
$tips[$format->name] = array();
foreach ($filters as $id => $filter) {
if ($tip = module_invoke($filter->module, 'filter_tips', $filter->delta, $format->format, $long)) {
$filter_info = module_invoke($filter->module, 'filter_info');
if (isset($filter_info[$filter->delta]['tips callback']) && drupal_function_exists($filter_info[$filter->delta]['tips callback'])) {
$tip = call_user_func($filter_info[$filter->delta]['tips callback'],$format->format, $long);
$tips[$format->name][] = array('tip' => $tip, 'id' => $id);
}
}
......
......@@ -78,15 +78,11 @@ function php_eval($code) {
}
/**
* Implement hook_filter_tips().
* Tips callback for php filter.
*/
function php_filter_tips($delta, $format, $long = FALSE) {
function _php_filter_tips($format, $long = FALSE) {
global $base_url;
if ($delta == 0) {
switch ($long) {
case 0:
return t('You may post PHP code. You should include &lt;?php ?&gt; tags.');
case 1:
if ($long) {
$output = '<h4>' . t('Using custom PHP code') . '</h4>';
$output .= '<p>' . t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') . '</p>';
$output .= '<p>' . t('If you are unfamiliar with PHP, SQL, or Drupal, avoid using custom PHP code within posts. Experimenting with PHP may corrupt your database, render your site inoperable, or significantly compromise security.') . '</p>';
......@@ -117,6 +113,8 @@ function php_filter_tips($delta, $format, $long = FALSE) {
$output .= '<p>' . t('<a href="@drupal">Drupal.org</a> offers <a href="@php-snippets">some example PHP snippets</a>, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) . '</p>';
return $output;
}
else {
return t('You may post PHP code. You should include &lt;?php ?&gt; tags.');
}
}
......@@ -133,7 +131,8 @@ function php_filter_info() {
'name' => t('PHP evaluator'),
'description' => t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!'),
'cache' => FALSE,
'process callback' => 'php_eval'
'process callback' => 'php_eval',
'tips callback' => '_php_filter_tips'
)
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment