t('Code filter')); case 'description': return t('Allows users to post code verbatim using <code> and <?php ?> tags.'); case 'prepare': // Note: we use the bytes 0xFE and 0xFF to replace < > during the // filtering process. These bytes are not valid in UTF-8 data and thus // least likely to cause problems. $text = preg_replace('@(.+?)@se', "'\xFEcode\xFF' . codefilter_escape('\\1') . '\xFE/code\xFF'", $text); $text = preg_replace('@<(\?(php)?|%)(.+?)(\?|%)>@se', "'\xFEphp\xFF' . codefilter_escape('\\3') . '\xFE/php\xFF'", $text); return $text; case "process": $text = preg_replace('@\xFEcode\xFF(.+?)\xFE/code\xFF@se', "codefilter_process_code('$1')", $text); $text = preg_replace('@\xFEphp\xFF(.+?)\xFE/php\xFF@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". */