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', 'settings callback' => '_textile_settings', 'default settings' => array( 'textile_tags' => FALSE, ), 'tips callback' => '_textile_filter_tips', ); return $filters; } /** * Implements hook_help(). */ function textile_help($path, $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.') . '

'; } } /** * Filter tips callback for the Textile filter. */ 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.'); } } /** * Textile filter. Provides filtering of Textile tags into XHTML. */ function _textile_process($text, $filter, $format, $langcode, $cache, $cache_id) { if ($filter->settings['textile_tags']) { return preg_replace_callback('{\[textile\](.*?)(\[/textile\]|$)}is', '_textile_process_match', $text); } else { return _textile_process_match(array(NULL, $text)); } } /** * Helper function for preg_replace_callback(). */ function _textile_process_match($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]); } /** * Settings callback for the Textile filter. */ function _textile_settings($form, &$form_state, $filter, $format, $defaults, $filters) { $settings = array(); $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; }