t('Code filter')); case 'description': return t('Allows users to post code verbatim using <code> and <?php ?> tags.'); case 'prepare': // Note: we use [ and ] to replace < > during the filtering process. // For more information, see "Temporary placeholders and // delimiters" at http://drupal.org/node/209715. $text = preg_replace('@(.+?)@se', "'[codefilter-code]' . codefilter_escape('\\1') . '[/codefilter-code]'", $text); $text = preg_replace('@<(\?(php)?|%)(.+?)(\?|%)>@se', "'[codefilter-php]' . codefilter_escape('\\3') . '[/codefilter-php]'", $text); return $text; case "process": $text = preg_replace('@[codefilter-code](.+?)[/codefilter-code]@se', "codefilter_process_code('$1')", $text); $text = preg_replace('@[codefilter-php](.+?)[/codefilter-php]@se', "codefilter_process_php('$1')", $text); return $text; default: return $text; } } /** * Provide tips for using filters. * * A module's tips should be informative and to the point. Short tips are * preferably one-liners. * * @param $delta * Which of this module's filters to use. Modules which only implement one * filter can ignore this parameter. * @param $format * Which format we are providing tips for. * @param $long * If set to true, long tips are requested, otherwise short tips are needed. * @return * The text of the filter tip. * * */ function hook_filter_tips($delta, $format, $long = FALSE) { if ($long) { return t('To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.'); } else { return t('You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.'); } } /** * @} End of "addtogroup hooks". */