CreateTableContents.inc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. /**
  3. * Create table of contents
  4. *
  5. * @category Phpdocx
  6. * @package elements
  7. * @copyright Copyright (c) 2009-2011 Narcea Producciones Multimedia S.L.
  8. * (http://www.2mdc.com)
  9. * @license LGPL
  10. * @version 1.0
  11. * @link http://www.phpdocx.com
  12. * @since File available since Release 1.0
  13. */
  14. include_once dirname(__FILE__) . '/CreateElement.inc';
  15. /**
  16. * Create table of contents
  17. *
  18. * @category Phpdocx
  19. * @package elements
  20. * @copyright Copyright (c) 2009-2011 Narcea Producciones Multimedia S.L.
  21. * (http://www.2mdc.com)
  22. * @license http://www.phpdocx.com/wp-content/themes/lightword/pro_license.php
  23. * @version 1.0
  24. * @link http://www.phpdocx.com
  25. * @since Class available since Release 1.0
  26. */
  27. class CreateTableContents extends CreateElement
  28. {
  29. /**
  30. *
  31. * @var string
  32. * @access protected
  33. */
  34. protected $_xml;
  35. /**
  36. *
  37. * @var CreateTableContents
  38. * @access protected
  39. * @static
  40. */
  41. private static $_instance = NULL;
  42. /**
  43. * Construct
  44. *
  45. * @access public
  46. */
  47. public function __construct()
  48. {
  49. }
  50. /**
  51. * Destruct
  52. *
  53. * @access public
  54. */
  55. public function __destruct()
  56. {
  57. }
  58. /**
  59. * Magic method, returns current XML
  60. *
  61. * @access public
  62. * @return string Return current XML
  63. */
  64. public function __toString()
  65. {
  66. return $this->_xml;
  67. }
  68. /**
  69. *
  70. * @return CreateTableContents
  71. * @access public
  72. * @static
  73. */
  74. public static function getInstance()
  75. {
  76. if (self::$_instance == NULL) {
  77. self::$_instance = new CreateTableContents();
  78. }
  79. return self::$_instance;
  80. }
  81. /**
  82. * Create table of contents
  83. *
  84. * @param string $font
  85. * @access public
  86. */
  87. public function createTableContents($font)
  88. {
  89. $this->generateP();
  90. $this->generateFLDSIMPLE();
  91. $this->generateR();
  92. $this->generateRPR();
  93. $this->generateRFONTS($font);
  94. $this->generateB();
  95. $this->generateBCS();
  96. $this->generateNOPROOF();
  97. $this->generateT('Press F9 to update table of contents.');
  98. $this->cleanTemplate();
  99. }
  100. /**
  101. * Generate w:fldsimple
  102. *
  103. * @param string $instr. Optional, 'TOC \o &quot;1-4&quot; \h \z \u'
  104. * as default
  105. * @access protected
  106. */
  107. protected function generateFLDSIMPLE($instr = 'TOC \o &quot;1-4&quot;
  108. \h \z \u')
  109. {
  110. $xml = '<' . CreateElement::NAMESPACEWORD .
  111. ':fldSimple ' . CreateElement::NAMESPACEWORD .
  112. ':instr="' . $instr .
  113. '">__GENERATEP__</' . CreateElement::NAMESPACEWORD .
  114. ':fldSimple>';
  115. $this->_xml = str_replace('__GENERATEP__', $xml, $this->_xml);
  116. }
  117. }