| 1 |
<?php |
<?php |
| 2 |
// $Id: marksmarty.module,v 1.16 2006/07/15 20:17:14 teradome Exp $ |
// $Id: marksmarty.module,v 1.17 2006/07/15 20:35:19 teradome Exp $ |
|
|
|
|
ini_set('include_path', ini_get('include_path') . ':' . getcwd() . '/modules/marksmarty/'); |
|
| 3 |
|
|
| 4 |
/******************************************************************** |
/******************************************************************** |
| 5 |
* Drupal Hooks |
* Drupal Hooks |
| 35 |
</ul>For complete details on the Markdown syntax, see the <a href="http://daringfireball.net/projects/markdown/syntax">Markdown documentation</a>.'); |
</ul>For complete details on the Markdown syntax, see the <a href="http://daringfireball.net/projects/markdown/syntax">Markdown documentation</a>.'); |
| 36 |
} |
} |
| 37 |
else { |
else { |
| 38 |
$the_output = t('You can use %link to format and style the text.', array('%link' => l(t('Markdown syntax'), 'filter/tips'))); |
$the_output = t('You can use !link to format and style the text.', array('!link' => l(t('Markdown syntax'), 'filter/tips'))); |
| 39 |
} |
} |
| 40 |
|
|
| 41 |
return $the_output; |
return $the_output; |
| 43 |
|
|
| 44 |
function marksmarty_help($in_section = 'admin/help#marksmarty') { |
function marksmarty_help($in_section = 'admin/help#marksmarty') { |
| 45 |
switch ($in_section) { |
switch ($in_section) { |
| 46 |
case 'admin/modules#description': |
case 'admin/settings/modules#description': |
| 47 |
$the_output = t('Allows content to be submitted using Markdown, a simple plain-text syntax that is filtered into valid XHTML, and converts plain ASCII characters to Unicode entities using SmartyPants.'); |
$the_output = t('Allows content to be submitted using Markdown, a simple plain-text syntax that is transformed into valid XHTML, and/or using SmartyPants, a filter for auto-translating plain ASCII characters to Unicode characters.'); |
| 48 |
break; |
break; |
| 49 |
|
|
| 50 |
case 'admin/help#marksmarty': |
case 'admin/help#marksmarty': |
| 51 |
$the_output = t('<p>The Markdown with SmartyPants module allows you to enter content using <a href="http://daringfireball.net/projects/markdown">Markdown</a>, a simple plain-text syntax that is filtered into valid XHTML, and will automatically convert plain ASCII characters to their proper Unicode entities in context ("curly quotes," et al.) using <a href="http://daringfireball.net/projects/smartypants">SmartyPants</a>.</p>'); |
$the_output = t('<p>The Markdown with SmartyPants module allows you to enter content using <a href="http://daringfireball.net/projects/markdown">Markdown</a>, a simple plain-text syntax that is transformed into valid XHTML, and will automatically convert plain ASCII characters to their proper Unicode entities in context ("curly quotes," et al.) using <a href="http://daringfireball.net/projects/smartypants">SmartyPants</a>.</p>'); |
| 52 |
break; |
break; |
| 53 |
} |
} |
| 54 |
|
|
| 62 |
function _marksmarty_process($text, $format) { |
function _marksmarty_process($text, $format) { |
| 63 |
require_once(dirname(__FILE__) . '/markdown.php'); |
require_once(dirname(__FILE__) . '/markdown.php'); |
| 64 |
require_once(dirname(__FILE__) . '/smartypants.php'); |
require_once(dirname(__FILE__) . '/smartypants.php'); |
| 65 |
|
if (variable_get("marksmarty_is_markdown_on_$format", 1) == 1) { |
| 66 |
|
$text = Markdown($text); |
| 67 |
|
} |
| 68 |
if (variable_get("marksmarty_is_smarty_on_$format", 1) == 1) { |
if (variable_get("marksmarty_is_smarty_on_$format", 1) == 1) { |
| 69 |
global $smartypants_attr; |
global $smartypants_attr; |
| 70 |
$smartypants_attr = variable_get("marksmarty_smarty_hyphens_$format", 0) + 1; |
$smartypants_attr = variable_get("marksmarty_smarty_hyphens_$format", 0) + 1; |
| 71 |
$text = SmartyPants($text); |
$text = SmartyPants($text); |
| 72 |
} |
} |
|
if (variable_get("marksmarty_is_markdown_on_$format", 1) == 1) { |
|
|
$text = Markdown($text); |
|
|
} |
|
| 73 |
return $text; |
return $text; |
| 74 |
} |
} |
| 75 |
|
|
| 76 |
function _marksmarty_settings($format) { |
function _marksmarty_settings($format) { |
| 77 |
|
require_once(dirname(__FILE__) . '/markdown.php'); |
| 78 |
|
require_once(dirname(__FILE__) . '/smartypants.php'); |
| 79 |
$form['markdown_settings'] = array( |
$form['markdown_settings'] = array( |
| 80 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 81 |
'#title' => t('Markdown with SmartyPants'), |
'#title' => t('Markdown with SmartyPants'), |