t('Textile'), 'description' => t('Allows content to be submitted using Textile, a simple, plain text syntax that is filtered into valid XHTML.'), 'process callback' => 'textile_process_filter', 'settings callback' => 'textile_settings', 'default settings' => array( 'textile_tags' => FALSE, ), 'tips callback' => 'textile_filter_tips', ); return $filters; } /** * Textile filter settings * @param $form * The prepopulated form array, which will usually have no use here. * @param $form_state * The form state of the (entire) configuration form. * @param $filter * The filter object containing settings for the given format. * @param $format * The format object being configured. * @param $defaults * The default settings for the filter, as defined in 'default settings' in hook_filter_info(). * @param $filters * Complete list of filter objects that are enabled for the given format. */ function textile_settings($form, &$form_state, $filter, $format, $defaults, $filters) { $settings['textile_tags'] = array( '#type' => 'checkbox', '#title' => t('Use tags'), '#default_value' => isset($filter->settings['textile_tags']) ? $filter->settings['textile_tags'] : $defaults['textile_tags'], '#description' => t('If enabled, only text between [textile] and optional [/textile] tags will be processed; otherwise, all text will be processed as Textile markup.') ); return $settings; } function textile_process_filter($text, $filter, $format, $langcode, $cache, $cache_id) { if($filter->settings['textile_tags']) { return preg_replace_callback('{\[textile\](.*?)(\[/textile\]|$)}is', '_textile_process', $text); } else { return _textile_process(array(NULL, $text)); } } /** * Implements hook_filter_tips(). */ function textile_filter_tips($filter, $format, $long) { if ($long) { module_load_include('inc', 'textile', 'textile.tips'); return _textile_filter_long_tips(); } elseif (isset($filter->settings['textile_tags']) && $filter->settings['textile_tags']) { return t('You can use Textile markup to format text between the [textile] and (optional) [/textile] tags.'); } else { return t('You can use Textile markup to format text.'); } } /** * Implements hook_help(). */ function textile_help($path = 'admin/help#textile', $arg) { switch ($path) { case 'admin/help#textile': return t('

The Textile module allows users to enter content using Textile, a simple, plain text syntax that is filtered into valid XHTML. The filter tips page provides syntax descriptions and examples.

'); } } /** * Performs the appropriate Textile filtering on the provided text. * * @param $matches * The array specifying the text to be filtered at index 1. * * @return * A string containing the filtered text. */ function _textile_process($matches) { static $textile = NULL; if (empty($textile)) { module_load_include('php', 'textile', 'classTextile'); $textile = new Textile(); //$textile->hu is the string that preceeds all relative URLs. $textile->hu = url(NULL); } return $textile->TextileThis($matches[1]); }