help.inc 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @file
  4. * Help module integration.
  5. */
  6. /**
  7. * Implements hook_help().
  8. */
  9. function custom_formatters_help($path, $arg) {
  10. switch ($path) {
  11. case 'admin/help#custom_formatters':
  12. $output = '<h3>' . t('Table of Contents') . "</h3>\n"
  13. . '<a href="#about">' . t('About') . '</a> | <a href="#create">' . t('Creating a Formatter') . '</a> | <a href="#test">' . t('Testing a Formatter') . '</a> | <a href="#use">' . t('Using a Formatter') . '</a> | <a href="#cfcom">' . t('CustomFormatters.com') . "</a>\n"
  14. . "<p>&nbsp;</p>\n"
  15. . '<h3><a name="about"></a>' . t('About') . "</h3>\n"
  16. . "<p>\n"
  17. . ' ' . t('The Custom Formatters module is a utility to simplify the creation of Field Formatters, which can be used to theme the output of a Field via the Field UI, Views, Display Suite, Wysiwyg Fields and many other modules.') . "\n"
  18. . "</p>\n"
  19. . "<p>\n"
  20. . ' ' . t('Field Formatters created within the Custom Formatters interface can be used as is or exported as either a standard Drupal API Field Formatter or as a Custom Formatters CTools Exportable.')
  21. . "</p>\n"
  22. . "<p>&nbsp;</p>\n"
  23. . '<h3><a name="create"></a>' . t('Creating a Formatter') . "</h3>\n"
  24. . "<p>\n"
  25. . ' ' . t('Formatters can be created via the Formatters interface (!cfui) by clicking the !add button.', array('!cfui' => l(t('Administration &raquo; Structure &raquo; Formatters'), 'admin/structure/formatters', array('html' => TRUE)), '!add' => l(t('Add'), 'admin/structure/formatters/add'))) . "<br />\n"
  26. . "</p>\n"
  27. . "<p>\n"
  28. . ' ' . t('The Formatter add/edit form may vary based on the Format you choose, but in general all Formatters should consist of the following:') . "\n"
  29. . "</p>\n"
  30. . "<dl>\n"
  31. . ' <dt><strong>' . t('Formatter name / Machine name') . "</strong></dt>\n"
  32. . ' <dd>' . t('The Formatter name and the Machine name, in general generated via the same field, are the Human readable name and the unique identifier for the Formatter.') . "</dd>\n"
  33. . ' <dt><strong>' . t('Description') . "</strong></dt>\n"
  34. . ' <dd>' . t('Used purely for administration purposes, displays as a tooltip on the Formatters UI and in the Formatter add/edit form only.') . "</dd>\n"
  35. . ' <dt><strong>' . t('Format') . "</strong></dt>\n"
  36. . " <dd>\n"
  37. . ' ' . t('The format that the Formatter is to be created in, may change the Formatters add/edit form.') . "<br />\n"
  38. . ' ' . t('Two format engines are supplied out of the box, <strong>PHP</strong> and <strong>HTML + Tokens</strong>.') . "\n"
  39. . " </dd>\n"
  40. . ' <dt><strong>' . t('Field type(s)') . "</strong></dt>\n"
  41. . " <dd>\n"
  42. . ' ' . t('Which field type(s) the Formatter will apply to (file, image, text, etc).') . "<br />\n"
  43. . ' ' . t('The value of this field should be the machine name of the field type, not the name of a field you have created on a Content type, available values will be auto-completed as you type.') . "\n"
  44. . " </dd>\n"
  45. . ' <dt><strong>' . t('Formatter') . "</strong></dt>\n"
  46. . " <dd>\n"
  47. . ' ' . t('The actual value of the Formatter, style depending on the chosen Format:') . "<br /><br />\n";
  48. $items = array();
  49. $engines = module_invoke_all('custom_formatters_engine_info');
  50. foreach ($engines as $engine) {
  51. if (isset($engine['file']) && file_exists($engine['file'])) {
  52. require_once $engine['file'];
  53. }
  54. if (isset($engine['callbacks']['help']) && function_exists($engine['callbacks']['help'])) {
  55. $items[] = ' <strong>' . $engine['label'] . "</strong><br />\n"
  56. . ' ' . $engine['callbacks']['help']()
  57. . "<br /><br />\n";
  58. }
  59. }
  60. if (count($items) > 0) {
  61. $output .= theme('item_list', array('items' => $items));
  62. }
  63. $output .= " </dd>\n"
  64. . ' <dt><strong>' . t('Formatter Settings') . "</strong></dt>\n"
  65. . " <dd>\n"
  66. . " <p>\n"
  67. . ' ' . t('As of Custom Formatters 7.x-2.1, the PHP format now supports Formatter Settings, which allow you PHP formatters to be configured on each instance of use (Display settings per content type, etc).') . "\n"
  68. . " </p>\n"
  69. . " <p>\n"
  70. . ' ' . t('To enable the Formatter Settings functionality uou need to download and enable the <a href="http://drupal.org/project/form_builder">Form Builder</a> module, once enabled, you will be able to drag and drop fields to create your settings form, and then access the settings inside of your Formatter.') . "\n"
  71. . " </p>\n"
  72. . " <p>\n"
  73. . ' ' . t('The <a href="!url">Example: Image (PHP)</a> Formatter demonstrates how Formatter Settings can be used.', array('!url' => url('admin/structure/formatters/list/example_php_image/edit'))) . "\n"
  74. . " </p>\n"
  75. . " </dd>\n"
  76. . "</dl>\n"
  77. . "<p>&nbsp;</p>\n"
  78. . '<h3><a name="test"></a>' . t('Testing a Formatter') . "</h3>\n"
  79. . "<p>\n"
  80. . ' ' . t('The Formatter add/edit form includes a Preview tool allowing quick testing of the Formatter on live content.') . "\n"
  81. . "</p>\n"
  82. . "<p>\n"
  83. . ' ' . t('To do so all you need to do is expand the Preview fieldset and select a populated Entity type (Node, Comment, etc), Bundle (Article, Basic page, etc) and Field (Image, Tags, etc) combination, select the desired Entity for testing and hit the <strong>Preview</strong> button.') . "\n"
  84. . "</p>\n"
  85. . "<p>\n"
  86. . ' ' . t('Enabling the <a href="http://drupal.org/project/devel">Devel</a> and Devel Generate module (packaged with the Devel module) adds additional debugging information into your Formatter preview.') . "\n"
  87. . "</p>\n"
  88. . "<p>&nbsp;</p>\n"
  89. . '<h3><a name="use"></a>' . t('Using a Formatter') . "</h3>\n"
  90. . "<p>\n"
  91. . ' ' . t('Formatters can be used on a variety of different modules, including, but not limited to, Drupal Core Field UI, Views, Display Suite and Insert modules.') . "\n"
  92. . "</p>\n"
  93. . "<p>\n"
  94. . ' ' . t('Instructions on how to apply Formatters to Fields varies from module to module, but in general there will be a Format or Formatter field with the Field configuton within said module.') . "\n"
  95. . "</p>\n"
  96. . "<p>&nbsp;</p>\n"
  97. . '<h3><a name="cfcom"></a>' . t('<a href="http://customformatters.com">CustomFormatters.com</a>') . "</h3>\n"
  98. . "<p>\n"
  99. . ' ' . t('<a href="http://customformatters.com">CustomFormatters.com</a> is a Custom Formatters repository, containing a every growing list of reusable Custom Formatters available as raw code snippets, exportables and as Drupal API field formatters, it\'s a useful resouce to see examples of how to create Formatters.') . "\n"
  100. . "</p>\n"
  101. . "<p>&nbsp;</p>\n"
  102. . "<p>&nbsp;</p>\n";
  103. return $output;
  104. }
  105. }