Source for file exportcodes.php

Documentation is available at exportcodes.php

  1. <?php
  2. /**
  3. * Numeric codes for defining data export types and formats
  4. *
  5. * Export types include TAB and Comma delimited, formats include the number of decimal places to use.
  6. * The numeric codes for report sections aren't designed to be bitshifted (they
  7. * are mutually exclusive options) so they are not powers of 2.
  8. * Formatting options may be use with bitwise addition etc.
  9. *
  10. @author    Stuart Prescott
  11. @copyright  Copyright Stuart Prescott
  12. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  13. @version    $Id$
  14. @package    Bumblebee
  15. @subpackage Export
  16. */
  17.  
  18. /** Load ancillary functions */
  19. require_once 'inc/typeinfo.php';
  20.  
  21. /** use a user-defined function to create report */
  22. define('EXPORT_FORMAT_CUSTOM',         1);
  23. /** output format is a delimited format like CSV */
  24. define('EXPORT_FORMAT_DELIMITED',      2);
  25. /** comma separated variable format */
  26. define('EXPORT_FORMAT_CSV',            EXPORT_FORMAT_DELIMITED|4);
  27. /** tab separated variable format */
  28. define('EXPORT_FORMAT_TAB',            EXPORT_FORMAT_DELIMITED|8);
  29. /** delimited output bitmask */
  30. define('EXPORT_FORMAT_DELIMITED_MASK'EXPORT_FORMAT_CSV|EXPORT_FORMAT_TAB);
  31.  
  32. /** create a complex data array using {@link ArrayExport } */
  33. define('EXPORT_FORMAT_USEARRAY',  64);
  34. /** create an HTML representation of the report using {@link HTMLExport } */
  35. define('EXPORT_FORMAT_USEHTML',   128);
  36. /** Open the HTML in a new window */
  37. define('EXPORT_FORMAT_VIEWOPEN',  EXPORT_FORMAT_USEARRAY|EXPORT_FORMAT_USEHTML|256);
  38. /** Open the HTML in the existing window */
  39. define('EXPORT_FORMAT_VIEW',      EXPORT_FORMAT_USEARRAY|EXPORT_FORMAT_USEHTML|512);
  40. /** Export using a PDF */
  41. define('EXPORT_FORMAT_PDF',       EXPORT_FORMAT_USEARRAY|1024);
  42. /** bitmask for all exports using {@link ArrayExport } */
  43. define('EXPORT_FORMAT_USEARRAY_MASK'EXPORT_FORMAT_VIEWOPEN|EXPORT_FORMAT_PDF|EXPORT_FORMAT_VIEW);
  44. /** bitmask for all exports using {@link HTMLExport } */
  45. define('EXPORT_FORMAT_USEHTML_MASK',  EXPORT_FORMAT_VIEWOPEN|EXPORT_FORMAT_VIEW);
  46.  
  47. /** bitmask for all export formats */
  48. define('EXPORT_FORMAT_MASK',      EXPORT_FORMAT_USEARRAY_MASK|EXPORT_FORMAT_DELIMITED_MASK
  49.                                             |EXPORT_FORMAT_CUSTOM);
  50.  
  51. /** Start of the report (HTML and PDF reports) */
  52. define('EXPORT_REPORT_START',              1);
  53. /** End of the report (HTML and PDF reports) */
  54. define('EXPORT_REPORT_END',                2);
  55. /** Data for the report page header area */
  56. define('EXPORT_REPORT_HEADER',             3);
  57. /** Start of the section header for this part of the report */
  58. define('EXPORT_REPORT_SECTION_HEADER',     4);
  59. /** Start a data table in the report (HTML and PDF reports) */
  60. define('EXPORT_REPORT_TABLE_START',        5);
  61. /** Header row for the data table (HTML and PDF reports) */
  62. define('EXPORT_REPORT_TABLE_HEADER',       6);
  63. /** Data row in a data table (HTML and PDF reports) */
  64. define('EXPORT_REPORT_TABLE_ROW',          7);
  65. /** Totals row in a data table (HTML and PDF reports) */
  66. define('EXPORT_REPORT_TABLE_TOTAL',        8);
  67. /** Footer row in a data table (HTML and PDF reports)
  68. @todo //TODO: EXPORT_REPORT_TABLE_FOOTER not implemented in styling */
  69. define('EXPORT_REPORT_TABLE_FOOTER',       9);
  70. /** End of data table (HTML and PDF reports) */
  71. define('EXPORT_REPORT_TABLE_END',         10);
  72.  
  73.  
  74. /** Formatting code: alignment descriptions */
  75. define('EXPORT_HTML_ALIGN',      1);
  76. /** Formatting code: centre output */
  77. define('EXPORT_HTML_CENTRE',     EXPORT_HTML_ALIGN|2);
  78. /** Formatting code: right align output */
  79. define('EXPORT_HTML_RIGHT',      EXPORT_HTML_ALIGN|4);
  80. /** Formatting code: left-align output */
  81. define('EXPORT_HTML_LEFT',       EXPORT_HTML_ALIGN|8);
  82. /** Formatting code: alignment bitmask */
  83. define('EXPORT_HTML_ALIGN_MASK'EXPORT_HTML_CENTRE|EXPORT_HTML_RIGHT|EXPORT_HTML_LEFT);
  84.  
  85. /** Formatting code: format as a number */
  86. define('EXPORT_HTML_NUMBER',       32);
  87. /** Formatting code: format as money (use defined currency symbol and 2 decimal places) */
  88. define('EXPORT_HTML_MONEY',        EXPORT_HTML_NUMBER|64);
  89. /** Formatting code: format to 1 decimal place, rounding appropriately */
  90. define('EXPORT_HTML_INTEGER',      EXPORT_HTML_NUMBER|128);  // round to integer
  91. /** Formatting code: format to 1 decimal place, rounding appropriately */
  92. define('EXPORT_HTML_DECIMAL_1',    EXPORT_HTML_NUMBER|256);  // round to 1 sig figs
  93. /** Formatting code: format to 2 decimal places, rounding appropriately */
  94. define('EXPORT_HTML_DECIMAL_2',    EXPORT_HTML_NUMBER|512);  // round to 2 sig figs
  95. /** Formatting code: format to x decimal places  bitmask */
  96. define('EXPORT_HTML_DECIMAL_MASK'EXPORT_HTML_INTEGER|EXPORT_HTML_DECIMAL_1|EXPORT_HTML_DECIMAL_2);
  97. /** Formatting code: format as a number bitmask */
  98. define('EXPORT_HTML_NUMBER_MASK',  EXPORT_HTML_MONEY|EXPORT_HTML_DECIMAL_MASK);
  99.  
  100. /** Formatting code: create an automatic total of the data for this column in the table */
  101. define('EXPORT_CALC_TOTAL',        2048);
  102.  
  103. /** Formatting code: format value as date-time according to locale settings */
  104. define('EXPORT_HTML_DATETIME',     4096);
  105. /** Formatting code: format value as date according to locale settings */
  106. define('EXPORT_HTML_DATE',         8192);
  107. /** Formatting code: format value as time according to locale settings */
  108. define('EXPORT_HTML_TIME',         16384);
  109.  
  110. /**
  111. * convert a string name for an export into the defined numeric code
  112. *
  113. @param string $export_name  name of the exported variable
  114. @return integer numeric code for the export name
  115. */
  116. function exportStringToCode($export_name{
  117.   switch ($export_name{
  118.     case 'EXPORT_FORMAT_CUSTOM':
  119.       return EXPORT_FORMAT_CUSTOM;
  120.     case 'EXPORT_FORMAT_VIEW':
  121.       return EXPORT_FORMAT_VIEW;
  122.     case 'EXPORT_FORMAT_VIEWOPEN':
  123.       return EXPORT_FORMAT_VIEWOPEN;
  124.     case 'EXPORT_FORMAT_CSV':
  125.       return EXPORT_FORMAT_CSV;
  126.     case 'EXPORT_FORMAT_TAB':
  127.       return EXPORT_FORMAT_TAB;
  128.     case 'EXPORT_FORMAT_PDF':
  129.       return EXPORT_FORMAT_PDF;
  130.   }
  131. }
  132.  
  133. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:26 +0000 by phpDocumentor 1.3.0